TODO : Remplacer liste des gares par un assesseur
TODO : Remplacer get_liste_train par un assesseur
TODO : Remplacer get_liste_horaire par un assesseur
+ TODO : Remplacer get_list_ligne_horaire par un assesseur
TODO : Trier les gares par ordre alphabetique
TODO : Intercepter les entrées vides
TODO : ajouter les argument à l'url avec httplib
TODO : corriger les noms des variables
TODO : corriger la taille des lignes
TODO : Fusionner liste horaire et liste train
+ TODO : etre ok sur pylint
+ TODO : faire des try sur les import
+ TODO : documenter les classes
+
DONE 0.1.1 : Modélisation Objet
DONE 0.1.2 : Corriger l'indentation
+ DONE 0.1.3 : Faire un objet ListeHoraire
+
app_version = '1.0' # the version number of your app
initial_mode = FremantleRotation.AUTOMATIC
+class LigneHoraire(object):
+ def __init__(self, code_mission, heure_de_passage):
+ self.code_mission = code_mission
+ self.heure_de_passage = heure_de_passage
+
+ def add_to_treestore(self, treestore):
+ print treestore
+ treestore.append(None, [self.code_mission, self.heure_de_passage])
+
+
class tableParser(HTMLParser.HTMLParser):
def __init__(self):
self.heure_de_passage = False
self.liste_train = []
self.liste_horaire = []
+ self.list_ligne_horaire = []
def handle_starttag(self, tag, attrs):
if (tag == 'table' and (dict(attrs)['class'] == 'horaires3')):
def handle_endtag(self,tag):
self.a_code_de_mission ^= (self.a_code_de_mission and tag == 'a')
self.heure_de_passage ^= (self.heure_de_passage and tag == 'td')
+
+ def get_list_ligne_horaire(self):
+ print 'get_list_ligne_horaire'
+ z = 0
+ print self.liste_train
+ for i in self.liste_train:
+ self.list_ligne_horaire.append(LigneHoraire(code_mission=i, heure_de_passage=self.liste_horaire[z]))
+ z += 1
+ return self.list_ligne_horaire
+
+
class Trajet(object):
def __init__(self, gare_source, gare_dest):
self.parse()
def get_liste_train(self):
return self.p.liste_train
- def get_liste_horaire(self):
+ def get_liste_horaire(self):
return self.p.liste_horaire
def parse(self):
self.p = tableParser()
- print "URL:"
- print 'http://www.transilien.com/web/ITProchainsTrainsAvecDest.do?codeTr3aDepart='+self.gare_source.shortname+'&codeTr3aDest='+self.gare_dest.shortname+'&urlModule=/site/pid/184&gareAcc=true'
- self.p.feed(urllib2.urlopen('http://www.transilien.com/web/ITProchainsTrainsAvecDest.do?codeTr3aDepart='+self.gare_source.shortname+'&codeTr3aDest='+self.gare_dest.shortname+'&urlModule=/site/pid/184&gareAcc=true').read())
+ #print "URL:"
+ #print 'http://www.transilien.com/web/ITProchainsTrainsAvecDest.do?codeTr3aDepart='+self.gare_source.shortname+'&codeTr3aDest='+self.gare_dest.shortname+'&urlModule=/site/pid/184&gareAcc=true'
+ rsrc = urllib2.urlopen('http://www.transilien.com/web/ITProchainsTrainsAvecDest.do?codeTr3aDepart='+self.gare_source.shortname+'&codeTr3aDest='+self.gare_dest.shortname+'&urlModule=/site/pid/184&gareAcc=true')
+ self.p.feed(rsrc.read())
+ print "parsing ok"
+
+ def refresh_treestore(self, treestore):
+ print 'refresh'
+ print treestore
+
+ treestore.clear()
+ liste_ligne_horaire = self.p.get_list_ligne_horaire()
+ print liste_ligne_horaire
+ for i in liste_ligne_horaire:
+ print i
+ i.add_to_treestore(treestore)
class ConfFile(object):
def __init__(self, fichier):
gtk.main_quit()
def on_refreshButton_clicked(self, widget):
- self.treestore.clear()
- trajet = Trajet(LongNameGare(self.combo_source.get_current_text()).get_gare(ConfFile('example.cfg')), LongNameGare(self.combo_dest.get_current_text()).get_gare(ConfFile('example.cfg')))
- z=0
- for i in trajet.get_liste_train():
- liste_horaire = trajet.get_liste_horaire()
- self.treestore.append(None, [i, liste_horaire[z]])
- z += 1
-
+ gare_source = LongNameGare(self.combo_source.get_current_text()).get_gare(ConfFile('example.cfg'))
+ gare_dest = LongNameGare(self.combo_dest.get_current_text()).get_gare(ConfFile('example.cfg'))
+ trajet = Trajet(gare_source , gare_dest)
+ print trajet
+ print self.treestore
+ trajet.refresh_treestore(self.treestore)
if __name__ == "__main__":