parent
38359dc8c9
commit
88df613a53
5 changed files with 11 additions and 11 deletions
|
|
@ -37,7 +37,7 @@ class HomePage(BadUTF8Page):
|
||||||
class item(ItemElement):
|
class item(ItemElement):
|
||||||
klass = Subscription
|
klass = Subscription
|
||||||
|
|
||||||
obj_subscriber = CleanText('div[@class="idAbonne pointer"]/p[1]', symbols='-', childs=False)
|
obj_subscriber = CleanText('div[@class="idAbonne pointer"]/p[1]', symbols='-', children=False)
|
||||||
obj_id = CleanText('div[@class="idAbonne pointer"]/p/span')
|
obj_id = CleanText('div[@class="idAbonne pointer"]/p/span')
|
||||||
obj__login = GetID(Attr('.//div[@class="acceuil_btn"]/a', 'href'))
|
obj__login = GetID(Attr('.//div[@class="acceuil_btn"]/a', 'href'))
|
||||||
obj_label = Format(u'%s - %s', Field('id'), CleanText('//div[@class="forfaitChoisi"]'))
|
obj_label = Format(u'%s - %s', Field('id'), CleanText('//div[@class="forfaitChoisi"]'))
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class CitiesPage(JsonPage):
|
||||||
|
|
||||||
class PhonePage(HTMLPage):
|
class PhonePage(HTMLPage):
|
||||||
def get_phone(self):
|
def get_phone(self):
|
||||||
return CleanText('//div[has-class("phone")]', childs=False)(self.doc)
|
return CleanText('//div[has-class("phone")]', children=False)(self.doc)
|
||||||
|
|
||||||
|
|
||||||
class HousingPage(HTMLPage):
|
class HousingPage(HTMLPage):
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ class OkCBrowser(Browser):
|
||||||
# return r['result']['flashs']
|
# return r['result']['flashs']
|
||||||
|
|
||||||
#@check_login
|
#@check_login
|
||||||
#def nb_godchilds(self):
|
#def nb_godchildren(self):
|
||||||
# r = self.api_request('member', 'view', data={'id': self.my_id})
|
# r = self.api_request('member', 'view', data={'id': self.my_id})
|
||||||
# return int(r['result']['member']['popu']['invits'])
|
# return int(r['result']['member']['popu']['invits'])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -317,29 +317,29 @@ class CleanText(Filter):
|
||||||
u'coucou\\ncoucou'
|
u'coucou\\ncoucou'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, selector=None, symbols='', replace=[], childs=True, newlines=True, normalize='NFC', **kwargs):
|
def __init__(self, selector=None, symbols='', replace=[], children=True, newlines=True, normalize='NFC', **kwargs):
|
||||||
super(CleanText, self).__init__(selector, **kwargs)
|
super(CleanText, self).__init__(selector, **kwargs)
|
||||||
self.symbols = symbols
|
self.symbols = symbols
|
||||||
self.toreplace = replace
|
self.toreplace = replace
|
||||||
self.childs = childs
|
self.children = children
|
||||||
self.newlines = newlines
|
self.newlines = newlines
|
||||||
self.normalize = normalize
|
self.normalize = normalize
|
||||||
|
|
||||||
@debug()
|
@debug()
|
||||||
def filter(self, txt):
|
def filter(self, txt):
|
||||||
if isinstance(txt, (tuple, list)):
|
if isinstance(txt, (tuple, list)):
|
||||||
txt = u' '.join([self.clean(item, childs=self.childs) for item in txt])
|
txt = u' '.join([self.clean(item, children=self.children) for item in txt])
|
||||||
|
|
||||||
txt = self.clean(txt, self.childs, self.newlines, self.normalize)
|
txt = self.clean(txt, self.children, self.newlines, self.normalize)
|
||||||
txt = self.remove(txt, self.symbols)
|
txt = self.remove(txt, self.symbols)
|
||||||
txt = self.replace(txt, self.toreplace)
|
txt = self.replace(txt, self.toreplace)
|
||||||
# ensure it didn't become str by mistake
|
# ensure it didn't become str by mistake
|
||||||
return unicode(txt)
|
return unicode(txt)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def clean(cls, txt, childs=True, newlines=True, normalize='NFC'):
|
def clean(cls, txt, children=True, newlines=True, normalize='NFC'):
|
||||||
if not isinstance(txt, basestring):
|
if not isinstance(txt, basestring):
|
||||||
if childs:
|
if children:
|
||||||
txt = [t.strip() for t in txt.itertext()]
|
txt = [t.strip() for t in txt.itertext()]
|
||||||
else:
|
else:
|
||||||
txt = [txt.text.strip()]
|
txt = [txt.text.strip()]
|
||||||
|
|
|
||||||
|
|
@ -464,11 +464,11 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
def path_completer(self, arg):
|
def path_completer(self, arg):
|
||||||
dirname = os.path.dirname(arg)
|
dirname = os.path.dirname(arg)
|
||||||
try:
|
try:
|
||||||
childs = os.listdir(dirname or '.')
|
children = os.listdir(dirname or '.')
|
||||||
except OSError:
|
except OSError:
|
||||||
return ()
|
return ()
|
||||||
l = []
|
l = []
|
||||||
for child in childs:
|
for child in children:
|
||||||
path = os.path.join(dirname, child)
|
path = os.path.join(dirname, child)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
child += '/'
|
child += '/'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue