ajout d'une couleur random pour les boites
darcs-hash:20060417100007-f46e9-e8c3cdaf10a7c03ef4a56457dcee55e1d1c03b56.gz
This commit is contained in:
parent
c553d5fda0
commit
1baf6e6a58
2 changed files with 15 additions and 5 deletions
|
@ -18,6 +18,9 @@ from MoinMoin.parser import wiki
|
|||
import os,string,re,StringIO
|
||||
from MoinMoin.action import AttachFile
|
||||
|
||||
color_list = ['orange', 'black', 'red', 'green', 'blue', 'gray']
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Fonctions #
|
||||
#####################################################################
|
||||
|
@ -81,14 +84,22 @@ class Parser:
|
|||
self.settings={'title': u'|'.join([u" ".join(kw.keys()), u" ".join(kw.values())])}
|
||||
self.settings = self.parseArgs(kw["format_args"])
|
||||
|
||||
|
||||
def getRandomColor(self):
|
||||
nb_of_colors = color_list.__len__()
|
||||
from random import randint
|
||||
colorNum = randint(0, nb_of_colors - 1)
|
||||
return color_list[colorNum]
|
||||
|
||||
def parseArgs(self, argsString):
|
||||
argList = argsString.split(u',')
|
||||
settings = {}
|
||||
for anArg in argList:
|
||||
anArg = anArg.strip(u' ')
|
||||
if anArg.find(u'color=')!=-1:
|
||||
settings['color'] = anArg.split(u'=')[1]
|
||||
theColor = anArg.split(u'=')[1]
|
||||
if theColor == 'random':
|
||||
theColor = self.getRandomColor()
|
||||
settings['color'] = theColor
|
||||
else:
|
||||
settings['title'] = anArg
|
||||
return settings
|
||||
|
@ -104,7 +115,6 @@ class Parser:
|
|||
color = self.settings['color']
|
||||
except:
|
||||
color=None
|
||||
boite.make( title,content, color)
|
||||
boite.make(title, content, color)
|
||||
return
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue