From f7c4e4c89b029205b7a84fc9007cc026ba271a26 Mon Sep 17 00:00:00 2001 From: Florent Date: Sun, 15 Dec 2013 16:23:17 +0100 Subject: [PATCH] pep8 / split very large line --- modules/ovs/backend.py | 31 +++++++++++++++++++++++++++++-- modules/ovs/browser.py | 7 +++---- modules/ovs/ovsparse.py | 8 +++++++- modules/ovs/pages.py | 2 +- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/modules/ovs/backend.py b/modules/ovs/backend.py index 9df95687..aea26520 100644 --- a/modules/ovs/backend.py +++ b/modules/ovs/backend.py @@ -29,7 +29,35 @@ from .browser import OvsBrowser __all__ = ['OvsBackend'] -CITIES = {u'agen': u'Agen', u'ajaccio': u'Ajaccio', u'albi': u'Albi', u'amiens': u'Amiens', u'angers': u'Angers', u'angouleme': u'Angoul\xeame', u'annecy': u'Annecy', u'aurillac': u'Aurillac', u'auxerre': u'Auxerre', u'avignon': u'Avignon', u'bastia': u'Bastia', u'beauvais': u'Beauvais', u'belfort': u'Belfort', u'bergerac': u'Bergerac', u'besancon': u'Besan\xe7on', u'beziers': u'B\xe9ziers', u'biarritz': u'Biarritz', u'blois': u'Blois', u'bordeaux': u'Bordeaux', u'bourg-en-bresse': u'M\xe2con', u'bourges': u'Bourges', u'brest': u'Brest', u'brive-la-gaillarde': u'Brive', u'bruxelles': u'Bruxelles', u'caen': u'Caen', u'calais': u'Boulogne', u'carcassonne': u'Carcassonne', u'chalon-sur-saone': u'Chalon', u'chambery': u'Albertville', u'chantilly': u'Chantilly', u'charleroi': u'Charleroi', u'charleville-mezieres': u'Charleville', u'chartres': u'Chartres', u'chateauroux': u'Ch\xe2teauroux', u'cherbourg': u'Cherbourg', u'cholet': u'Cholet', u'clermont-ferrand': u'Clt-Ferrand', u'compiegne': u'Compi\xe8gne', u'dieppe': u'Dieppe', u'dijon': u'Dijon', u'dunkerque': u'Dunkerque', u'evreux': u'Evreux', u'frejus': u'Fr\xe9jus', u'gap': u'Gap', u'geneve': u'Gen\xe8ve', u'grenoble': u'Grenoble', u'la-roche-sur-yon': u'La Roche/Yon', u'la-rochelle': u'La Rochelle', u'lausanne': u'Lausanne', u'laval': u'Laval', u'le-havre': u'Le Havre', u'le-mans': u'Alen\xe7on', u'liege': u'Li\xe8ge', u'lille': u'Lille', u'limoges': u'Limoges', u'lorient': u'Lorient', u'luxembourg': u'Luxembourg', u'lyon': u'Lyon', u'marseille': u'Aix', u'metz': u'Metz', u'mons': u'Mons', u'mont-de-marsan': u'Mont de Marsan', u'montauban': u'Montauban', u'montlucon': u'Montlu\xe7on', u'montpellier': u'Montpellier', u'mulhouse': u'Colmar', u'namur': u'Namur', u'nancy': u'Nancy', u'nantes': u'Nantes', u'nevers': u'Nevers', u'nice': u'Cannes', u'nimes': u'N\xeemes', u'niort': u'Niort', u'orleans': u'Orl\xe9ans', u'paris': u'PARIS', u'pau': u'Pau', u'perigueux': u'P\xe9rigueux', u'perpignan': u'Perpignan', u'poitiers': u'Poitiers', u'quimper': u'Quimper', u'reims': u'Reims', u'rennes': u'Rennes', u'roanne': u'Roanne', u'rodez': u'Rodez', u'rouen': u'Rouen', u'saint-brieuc': u'St-Brieuc', u'saint-etienne': u'St-Etienne', u'saint-malo': u'St-Malo', u'saint-nazaire': u'St-Nazaire', u'saint-quentin': u'St-Quentin', u'saintes': u'Saintes', u'strasbourg': u'Strasbourg', u'tarbes': u'Tarbes', u'toulon': u'Toulon', u'toulouse': u'Toulouse', u'tours': u'Tours', u'troyes': u'Troyes', u'valence': u'Mont\xe9limar', u'vannes': u'Vannes', u'zurich': u'Zurich'} +CITIES = {u'agen': u'Agen', u'ajaccio': u'Ajaccio', u'albi': u'Albi', u'amiens': u'Amiens', + u'angers': u'Angers', u'angouleme': u'Angoul\xeame', u'annecy': u'Annecy', u'aurillac': u'Aurillac', + u'auxerre': u'Auxerre', u'avignon': u'Avignon', u'bastia': u'Bastia', u'beauvais': u'Beauvais', + u'belfort': u'Belfort', u'bergerac': u'Bergerac', u'besancon': u'Besan\xe7on', + u'beziers': u'B\xe9ziers', u'biarritz': u'Biarritz', u'blois': u'Blois', u'bordeaux': u'Bordeaux', + u'bourg-en-bresse': u'M\xe2con', u'bourges': u'Bourges', u'brest': u'Brest', + u'brive-la-gaillarde': u'Brive', u'bruxelles': u'Bruxelles', u'caen': u'Caen', + u'calais': u'Boulogne', u'carcassonne': u'Carcassonne', u'chalon-sur-saone': u'Chalon', + u'chambery': u'Albertville', u'chantilly': u'Chantilly', u'charleroi': u'Charleroi', + u'charleville-mezieres': u'Charleville', u'chartres': u'Chartres', u'chateauroux': u'Ch\xe2teauroux', + u'cherbourg': u'Cherbourg', u'cholet': u'Cholet', u'clermont-ferrand': u'Clt-Ferrand', + u'compiegne': u'Compi\xe8gne', u'dieppe': u'Dieppe', u'dijon': u'Dijon', + u'dunkerque': u'Dunkerque', u'evreux': u'Evreux', u'frejus': u'Fr\xe9jus', u'gap': u'Gap', + u'geneve': u'Gen\xe8ve', u'grenoble': u'Grenoble', u'la-roche-sur-yon': u'La Roche/Yon', + u'la-rochelle': u'La Rochelle', u'lausanne': u'Lausanne', u'laval': u'Laval', + u'le-havre': u'Le Havre', u'le-mans': u'Alen\xe7on', u'liege': u'Li\xe8ge', u'lille': u'Lille', + u'limoges': u'Limoges', u'lorient': u'Lorient', u'luxembourg': u'Luxembourg', u'lyon': u'Lyon', + u'marseille': u'Aix', u'metz': u'Metz', u'mons': u'Mons', u'mont-de-marsan': u'Mont de Marsan', + u'montauban': u'Montauban', u'montlucon': u'Montlu\xe7on', u'montpellier': u'Montpellier', + u'mulhouse': u'Colmar', u'namur': u'Namur', u'nancy': u'Nancy', u'nantes': u'Nantes', + u'nevers': u'Nevers', u'nice': u'Cannes', u'nimes': u'N\xeemes', u'niort': u'Niort', + u'orleans': u'Orl\xe9ans', u'paris': u'PARIS', u'pau': u'Pau', u'perigueux': u'P\xe9rigueux', + u'perpignan': u'Perpignan', u'poitiers': u'Poitiers', u'quimper': u'Quimper', u'reims': u'Reims', + u'rennes': u'Rennes', u'roanne': u'Roanne', u'rodez': u'Rodez', u'rouen': u'Rouen', + u'saint-brieuc': u'St-Brieuc', u'saint-etienne': u'St-Etienne', u'saint-malo': u'St-Malo', + u'saint-nazaire': u'St-Nazaire', u'saint-quentin': u'St-Quentin', u'saintes': u'Saintes', + u'strasbourg': u'Strasbourg', u'tarbes': u'Tarbes', u'toulon': u'Toulon', u'toulouse': u'Toulouse', + u'tours': u'Tours', u'troyes': u'Troyes', u'valence': u'Mont\xe9limar', u'vannes': u'Vannes', + u'zurich': u'Zurich'} class OvsBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContact): @@ -110,4 +138,3 @@ class OvsBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContact): # TODO support outing comments, forum messages # TODO make an ICapOuting? - diff --git a/modules/ovs/browser.py b/modules/ovs/browser.py index 041e4208..7181af3c 100644 --- a/modules/ovs/browser.py +++ b/modules/ovs/browser.py @@ -95,17 +95,17 @@ class OvsBrowser(BaseBrowser): return (self.is_on_page(DummyPage) or self.page.is_logged()) def post_to_thread(self, thread_id, subject, body): - self.location('/message_read.php?Id=%s' % thread_id.encode(self.ENCODING)) # FIXME + self.location('/message_read.php?Id=%s' % thread_id.encode(self.ENCODING)) # FIXME assert self.is_on_page(PagePrivateThread) self.page.post_to_thread(thread_id, subject, body) def create_thread(self, recipient, subject, body): - self.location('/profil_read.php?%s' % recipient.encode(self.ENCODING)) # FIXME + self.location('/profil_read.php?%s' % recipient.encode(self.ENCODING)) # FIXME assert self.is_on_page(PageUserProfile) self.page.create_thread(recipient, subject, body) def get_contact(self, id): - self.location('/profil_read.php?%s' % id.encode(self.ENCODING)) # FIXME + self.location('/profil_read.php?%s' % id.encode(self.ENCODING)) # FIXME assert self.is_on_page(PageUserProfile) return self.page.get_contact() @@ -118,4 +118,3 @@ class OvsBrowser(BaseBrowser): self.location('http://www.urbeez.com') assert self.is_on_page(PageCityList) return self.page.get_cities('urbeez.com') - diff --git a/modules/ovs/ovsparse.py b/modules/ovs/ovsparse.py index ad65c73a..d64c2a08 100644 --- a/modules/ovs/ovsparse.py +++ b/modules/ovs/ovsparse.py @@ -28,9 +28,11 @@ def nearest_parent(node, expected): node = node.parent return node + def all_text_recursive(node): return ''.join(node.findAll(text=True)) + def all_next_siblings(node): ret = [] while node: @@ -38,6 +40,7 @@ def all_next_siblings(node): node = node.nextSibling return ret + def image_to_text(src): smileys = {'chat/e/grin.gif': ':D', 'chat/e/unsure.gif': ':s', @@ -60,6 +63,7 @@ def image_to_text(src): return smileys.get(src) + def html_message_to_text(nodes): parts = [] @@ -77,6 +81,7 @@ def html_message_to_text(nodes): return ''.join(parts) + def create_unique_id(proposed_id, used_ids): if proposed_id not in used_ids: return proposed_id @@ -90,8 +95,8 @@ def create_unique_id(proposed_id, used_ids): return make_id(proposed_id, index) -# public +# public def private_message_form_fields(document): ret = {} form = document.find('form', attrs={'name': 'envoimail'}) @@ -107,5 +112,6 @@ def private_message_form_fields(document): set_if_present('Titre') return ret + def is_logged(document): return (not document.find('form', attrs={'name': 'connection'})) diff --git a/modules/ovs/pages.py b/modules/ovs/pages.py index c45c0888..1404eb17 100644 --- a/modules/ovs/pages.py +++ b/modules/ovs/pages.py @@ -101,7 +101,7 @@ class PagePrivateThread(OvsPage): first_br = td.find('br') assert first_br.nextSibling.name == 'br' - text_nodes = ovsparse.all_next_siblings(first_br.nextSibling.nextSibling) # TODO + text_nodes = ovsparse.all_next_siblings(first_br.nextSibling.nextSibling) # TODO #~ print text_nodes # date will be used as id