Menu

#8 small suggestions

open
nobody
None
5
2005-11-15
2005-11-15
KomitlaK
No

1. in ogame.py / def LevaPuntoDaRisorsa it could be:

def LevaPuntoDaRisorsa(string):
return "".join( string.split(".") )

2. in ogame.py / class Pianeta / def AggiornaRisorse a
clearer result is returned if:

re_risorse = re.compile( r"(?:<td
align=['|\"]?center['|\"]?
width=['|\"]?85['|\"]?>)(?:<font
color=['|\"]?#ff0000['|\"]?>)?(?:<font
color=['|\"]?#ffffff['|\"]?>)?(?P<risorsa>[.0-9]+)(?:</font>)?(?:</td>),
re.M)

instead ie of this result:
[("<font color='#ff0000'>", '', '211.040', '0',
'</font>'), ('', '', '43.796', '6', ''), ('', '',
'1.670', '0', '')]

you'll get more clear result:
['211.040', '43.796', '1.670']

same goes for:
re_energia_combinata = re.compile( r"(?:<td
align=['|\"]?center['|\"]?
width=['|\"]?85['|\"]?>)(?:<font
color=['|\"]?#ff0000['|\"]?>)?(?P<disponibile>-?[.0-9]+)(?:</font>)?/(?P<totale>[.0-9]+)(?:</td>)",
re.M)

instead ie of this rezult:
[('25', '5', '897', '7')] you'll get [('25', '897')]

Discussion


Log in to post a comment.

MongoDB Logo MongoDB