2010-12-22, 20:11
Code:
<slides rating="PG" theme="Star Wars">
<slide>
<question format="[0-9]+Q.jpg"/>
<clue format=""/>
<answer format="[0-9]+A.jpg"/>
</slide>
</slides>
Code:
<slides>
<slide rating="PG" theme="Star Wars">
<question format="[0-9]+Q.jpg"/>
<clue format=""/>
<answer format="[0-9]+A.jpg"/>
</slide>
</slides>
Code:
# fetch data
xml = open( os.path.join( path[ "path" ], "slides.xml" ) ).read()
# parse info
mpaa, theme, question_format, clue_format, answer_format = re.search( "<slides?(?:.+?rating=\"([^\"]*)\")?(?:.+?theme=\"([^\"]*)\")?.*?>.+?<question.+?format=\"([^\"]*)\".*?/>.+?<clue.+?format=\"([^\"]*)\".*?/>.+?<answer.+?format=\"([^\"]*)\".*?/>", xml, re.DOTALL | re.IGNORECASE ).groups()
# compile regex's for performance
if ( question_format ):
question_format = re.compile( question_format )
if ( clue_format ):
clue_format = re.compile( clue_format )
if ( answer_format ):
answer_format = re.compile( answer_format )
if ( question_format and question_format.search( os.path.basename( entry ), re.IGNORECASE ) ):
giftie this is what i'm using, it support new slides.xml and old format slides.xml. it now allows user to leave the regex's blank to skip them. makes more sense this way.