def handle_starttag(self, tag, attrs):

        if not self._in_table:
            if tag == 'tbody':
                self._in_table = True
        else:
            if tag == 'tr':
                key, value = get_attribute(attrs, 'class')
                if key:
                    if value == 'negative':
                        self._in_secteur = True
                        self._secteurs.append(Secteur())
                    elif value == 'positive':
                        self._in_massif = True
                        self._current_secteur.append(Massif())
                else:
                    self._in_circuit = True
                    self._current_massif.append(Circuit())
            else:
                if self._in_circuit:
                    if tag == 'td':
                        self._target = self._current_circuit.next_target()
                    elif tag == 'a':
                        key, value = get_attribute(attrs, 'href')
                        if key:
                            self._current_circuit.url = value
                elif self._in_secteur and tag == 'h1':
                    self._in_secteur_name = True
                    self._target = self._current_secteur.name
                elif self._in_massif:
                    if tag == 'a':
                        self._in_massif_name = True
                        self._target = self._current_massif.name
                        key, value = get_attribute(attrs, 'href')
                        if key:
                            self._current_massif.url = value
                    elif tag == 'div':
                        key, value = get_attribute(attrs, 'class')
                        if key:
                            if value == 'descriptif':
                                self._target = self._current_massif.descriptif
                            else:
                                self._target = self._current_massif.note
Exemplo n.º 2
0
    def handle_starttag(self, tag, attrs):

        if self._in_bloc and tag == 'a':
            self._target = self._current_bloc.numero
        elif tag == 'h2' and not self.circuit.name:
            self._target = self.circuit.name
        elif tag == 'div' and self.circuit.name:
            key, value = get_attribute(attrs, 'class')
            if key and value == 'texte surlignable':
                if self.circuit.numero:
                    self._target = self.circuit.descriptif
                elif self.circuit.date:
                    self._target = self.circuit.numero
        elif tag == 'li' and self.circuit.name:
            self._in_bloc = True
            self.circuit.append(Bloc())