From a9e1ad10cefd1a2c432abf58f6ad19ccd3b16fed Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Thu, 15 Feb 2007 13:20:02 +0000 Subject: [PATCH] This is thedailywtf material: To write an xml file in tag order, autoxml implementation reads the .py source files, parses them, puts the source code order to a list by looking at the written line orders of the members. This perfect implementation blows reload logic. Seen when a new class (class Obsolete) added. --- pisi/pxml/autoxml.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pisi/pxml/autoxml.py b/pisi/pxml/autoxml.py index 30291fcb..84ae3b65 100644 --- a/pisi/pxml/autoxml.py +++ b/pisi/pxml/autoxml.py @@ -268,16 +268,22 @@ class autoxml(oo.autosuper, oo.autoprop): errorss = [] formatters = [] + # FIXME: What is this? Remove this crap and try to fix autoxml, if can not be fixed then + # really throw whole autoxml to junk. But not this. + # read declaration order from source # code contributed by bahadir kandemir - from inspect import getsourcelines - from itertools import ifilter - import re + try: + from inspect import getsourcelines + from itertools import ifilter + import re - fn = re.compile('\s*([tas]_[a-zA-Z]+).*').findall + fn = re.compile('\s*([tas]_[a-zA-Z]+).*').findall - lines = filter(fn, getsourcelines(cls)[0]) - decl_order = map(lambda x:x.split()[0], lines) + lines = filter(fn, getsourcelines(cls)[0]) + decl_order = map(lambda x:x.split()[0], lines) + except IOError: + decl_order = dict.keys() # there should be at most one str member, and it should be # the first to process