Was machen dise "u" plötzlich in meinem Dictionary??
a.getvalue() liefert:
Code: Alles auswählen
a {
text-decoration: underline;
font-size: 10px;
}
Code: Alles auswählen
a=StringIO.StringIO(cssParse(css))
for line in a:
handleLine(line) #Handles CSS
Code: Alles auswählen
cssDict = {}
filename=""
inner = 0 # true when handling a tag
currtag='' # name of current tag
attrs = '' # list of names within current tag
def handleLine(l):
global inner, currtag , attrs
l = l.split()
if ('{' in l): # from now on "within '{' brackets"
inner=1
currtag = l[0]
attrs = ""
elif ('}' in l): # "leaving the '{}' brackets"
inner=0
addToDict(cssDict,currtag,attrs)
currtag=''
elif (inner==1):
attrs = attrs+" ".join(l)
def addToDict(dict, name, format): #dict=Dictionary, name=CSS Identifier, format=CSS Formatinfo
dict.setdefault(name, format)
Code: Alles auswählen
{u'a': u'text-decoration: underline;font-size: 10px;'}