pep8 / split very large line
This commit is contained in:
parent
e3d440d359
commit
f7c4e4c89b
4 changed files with 40 additions and 8 deletions
|
|
@ -29,7 +29,35 @@ from .browser import OvsBrowser
|
||||||
__all__ = ['OvsBackend']
|
__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):
|
class OvsBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContact):
|
||||||
|
|
@ -110,4 +138,3 @@ class OvsBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContact):
|
||||||
|
|
||||||
# TODO support outing comments, forum messages
|
# TODO support outing comments, forum messages
|
||||||
# TODO make an ICapOuting?
|
# TODO make an ICapOuting?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,17 +95,17 @@ class OvsBrowser(BaseBrowser):
|
||||||
return (self.is_on_page(DummyPage) or self.page.is_logged())
|
return (self.is_on_page(DummyPage) or self.page.is_logged())
|
||||||
|
|
||||||
def post_to_thread(self, thread_id, subject, body):
|
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)
|
assert self.is_on_page(PagePrivateThread)
|
||||||
self.page.post_to_thread(thread_id, subject, body)
|
self.page.post_to_thread(thread_id, subject, body)
|
||||||
|
|
||||||
def create_thread(self, recipient, 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)
|
assert self.is_on_page(PageUserProfile)
|
||||||
self.page.create_thread(recipient, subject, body)
|
self.page.create_thread(recipient, subject, body)
|
||||||
|
|
||||||
def get_contact(self, id):
|
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)
|
assert self.is_on_page(PageUserProfile)
|
||||||
return self.page.get_contact()
|
return self.page.get_contact()
|
||||||
|
|
||||||
|
|
@ -118,4 +118,3 @@ class OvsBrowser(BaseBrowser):
|
||||||
self.location('http://www.urbeez.com')
|
self.location('http://www.urbeez.com')
|
||||||
assert self.is_on_page(PageCityList)
|
assert self.is_on_page(PageCityList)
|
||||||
return self.page.get_cities('urbeez.com')
|
return self.page.get_cities('urbeez.com')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,11 @@ def nearest_parent(node, expected):
|
||||||
node = node.parent
|
node = node.parent
|
||||||
return node
|
return node
|
||||||
|
|
||||||
|
|
||||||
def all_text_recursive(node):
|
def all_text_recursive(node):
|
||||||
return ''.join(node.findAll(text=True))
|
return ''.join(node.findAll(text=True))
|
||||||
|
|
||||||
|
|
||||||
def all_next_siblings(node):
|
def all_next_siblings(node):
|
||||||
ret = []
|
ret = []
|
||||||
while node:
|
while node:
|
||||||
|
|
@ -38,6 +40,7 @@ def all_next_siblings(node):
|
||||||
node = node.nextSibling
|
node = node.nextSibling
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def image_to_text(src):
|
def image_to_text(src):
|
||||||
smileys = {'chat/e/grin.gif': ':D',
|
smileys = {'chat/e/grin.gif': ':D',
|
||||||
'chat/e/unsure.gif': ':s',
|
'chat/e/unsure.gif': ':s',
|
||||||
|
|
@ -60,6 +63,7 @@ def image_to_text(src):
|
||||||
|
|
||||||
return smileys.get(src)
|
return smileys.get(src)
|
||||||
|
|
||||||
|
|
||||||
def html_message_to_text(nodes):
|
def html_message_to_text(nodes):
|
||||||
parts = []
|
parts = []
|
||||||
|
|
||||||
|
|
@ -77,6 +81,7 @@ def html_message_to_text(nodes):
|
||||||
|
|
||||||
return ''.join(parts)
|
return ''.join(parts)
|
||||||
|
|
||||||
|
|
||||||
def create_unique_id(proposed_id, used_ids):
|
def create_unique_id(proposed_id, used_ids):
|
||||||
if proposed_id not in used_ids:
|
if proposed_id not in used_ids:
|
||||||
return proposed_id
|
return proposed_id
|
||||||
|
|
@ -90,8 +95,8 @@ def create_unique_id(proposed_id, used_ids):
|
||||||
|
|
||||||
return make_id(proposed_id, index)
|
return make_id(proposed_id, index)
|
||||||
|
|
||||||
# public
|
|
||||||
|
|
||||||
|
# public
|
||||||
def private_message_form_fields(document):
|
def private_message_form_fields(document):
|
||||||
ret = {}
|
ret = {}
|
||||||
form = document.find('form', attrs={'name': 'envoimail'})
|
form = document.find('form', attrs={'name': 'envoimail'})
|
||||||
|
|
@ -107,5 +112,6 @@ def private_message_form_fields(document):
|
||||||
set_if_present('Titre')
|
set_if_present('Titre')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def is_logged(document):
|
def is_logged(document):
|
||||||
return (not document.find('form', attrs={'name': 'connection'}))
|
return (not document.find('form', attrs={'name': 'connection'}))
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class PagePrivateThread(OvsPage):
|
||||||
|
|
||||||
first_br = td.find('br')
|
first_br = td.find('br')
|
||||||
assert first_br.nextSibling.name == '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
|
#~ print text_nodes
|
||||||
|
|
||||||
# date will be used as id
|
# date will be used as id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue