rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
logging.error(u'You can configure backends using the "weboob-config add" command:\nweboob-config add <name> [options..]')
weboobcfg.formatter.flush() print '\nYou can configure backends with weboob-config:\n\tweboob-config add <name> [options..]'
def load_backends(self, caps=None, names=None, *args, **kwargs): loaded_backends = BaseApplication.load_backends(self, caps, names, *args, **kwargs) if not loaded_backends: logging.error(u'Cannot start application: no configured backend was found.\nHere is a list of all available backends:') from weboob.applications.we...
logging.error(u'You can configure backends using the "weboob-config-qt" GUI, too.')
print '\nYou can configure backends using the "weboob-config-qt" GUI, too.'
def load_backends(self, caps=None, names=None, *args, **kwargs): loaded_backends = BaseApplication.load_backends(self, caps, names, *args, **kwargs) if not loaded_backends: logging.error(u'Cannot start application: no configured backend was found.\nHere is a list of all available backends:') from weboob.applications.we...
atitle = tr.getchildren()[2].getchildren()[1] title = atitle.text if not title: title = '' for bold in atitle.getchildren(): if bold.text: title += bold.text if bold.tail: title += bold.tail idt = tr.getchildren()[2].getchildren()[0].attrib.get('href','') idt = idt.split('/')[2] size = tr.getchildren()[3].text u = size...
if tr.attrib.has_key('onmouseout'): atitle = tr.getchildren()[2].getchildren()[1] title = atitle.text if not title: title = '' for bold in atitle.getchildren(): if bold.text: title += bold.text if bold.tail: title += bold.tail idt = tr.getchildren()[2].getchildren()[0].attrib.get('href','') idt = idt.split('/')[2] size...
def iter_torrents(self): for tr in self.document.getiterator('tr'): if tr.attrib.get('class', '') == 'hlRow': # TODO à corriger atitle = tr.getchildren()[2].getchildren()[1] title = atitle.text if not title: title = '' for bold in atitle.getchildren(): if bold.text: title += bold.text if bold.tail: title += bold.tail i...
p2 = Popen([player_name, args], stdin=p1.stdout, stderr=PIPE)
Popen([player_name, args], stdin=p1.stdout, stderr=PIPE)
def _play_rtmp(self, video): """ Download data with rtmpdump and pipe them to a video player.
for backend, error, backtrace in self.errors)))
for backend, error, backtrace in errors)))
def __init__(self, errors): Exception.__init__(self, u'These errors have been raised in backend threads:\n%s' % ( u'\n'.join((u' * %s: %s%s' % (backend, error, backtrace + '\n' if logging.root.level == logging.DEBUG else '')) for backend, error, backtrace in self.errors))) self.errors = copy(errors)
os.spawnlp(os.P_NOWAIT, player_name, video.url)
os.spawnlp(os.P_NOWAIT, player_name, player_name, video.url)
def _play_default(self, video): """ Play video.url with the video player. """ player_name = self.get_player_name() print 'Invoking "%s %s".' % (player_name, video.url) os.spawnlp(os.P_NOWAIT, player_name, video.url)
div = self.document.getroot().cssselect('div[id=watch-description-body]') if not div: return div = div[0] v.author = div.find('a').find('strong').text
v.author = self.document.getroot().cssselect('a.watch-description-username strong')[0].text
def set_details(self, v): div = self.document.getroot().cssselect('div[id=watch-description-body]') if not div: return
def do_post(self):
def do_post(self, line):
def do_post(self): """ post
def do_run(self):
def do_run(self, line):
def do_run(self): """ run
def onecmd(self, _cmd):
def onecmd(self, line):
def onecmd(self, _cmd): """ This REPL method is overrided to catch some particular exceptions. """ cmd_name = _cmd.split()[0] if cmd_name in self.commands_formatters: self.set_formatter(self.commands_formatters[cmd_name]) else: self.set_formatter(self.DEFAULT_FORMATTER) try: return super(ReplApplication, self).onecmd(_...
cmd_name = _cmd.split()[0] if cmd_name in self.commands_formatters: self.set_formatter(self.commands_formatters[cmd_name])
cmd, arg, ignored = self.parseline(line) if cmd in self.commands_formatters: self.set_formatter(self.commands_formatters[cmd])
def onecmd(self, _cmd): """ This REPL method is overrided to catch some particular exceptions. """ cmd_name = _cmd.split()[0] if cmd_name in self.commands_formatters: self.set_formatter(self.commands_formatters[cmd_name]) else: self.set_formatter(self.DEFAULT_FORMATTER) try: return super(ReplApplication, self).onecmd(_...
try: return super(ReplApplication, self).onecmd(_cmd)
try: return super(ReplApplication, self).onecmd(line)
def onecmd(self, _cmd): """ This REPL method is overrided to catch some particular exceptions. """ cmd_name = _cmd.split()[0] if cmd_name in self.commands_formatters: self.set_formatter(self.commands_formatters[cmd_name]) else: self.set_formatter(self.DEFAULT_FORMATTER) try: return super(ReplApplication, self).onecmd(_...
if only_new and not self.browser.nb_new_mails():
if not only_new or self.browser.nb_new_mails():
def _iter_messages(self, thread, only_new): try: if only_new and not self.browser.nb_new_mails(): my_name = self.browser.get_my_name() contacts = self.browser.get_contact_list() contacts.reverse()
self.url = url
self.url = url.replace(' ', '%20')
def __init__(self, url): self.url = url self.data = None
title = div.text
title = div.text.strip()
def get_torrent(self, id): for div in self.document.getiterator('div'): if div.attrib.get('id','') == 'title': title = div.text elif div.attrib.get('class','') == 'download': url = div.getchildren()[0].attrib.get('href','') elif div.attrib.get('id','') == 'details': size = float(div.getchildren()[0].getchildren()[5].te...
seed = div.getchildren()[1].getchildren()[7].text leech = div.getchildren()[1].getchildren()[9].text
if len(div.getchildren()) > 1 \ and div.getchildren()[1].attrib.get('class','') == 'col2' : seed = div.getchildren()[1].getchildren()[7].text leech = div.getchildren()[1].getchildren()[9].text else: seed = div.getchildren()[0].getchildren()[24].text leech = div.getchildren()[0].getchildren()[26].text
def get_torrent(self, id): for div in self.document.getiterator('div'): if div.attrib.get('id','') == 'title': title = div.text elif div.attrib.get('class','') == 'download': url = div.getchildren()[0].attrib.get('href','') elif div.attrib.get('id','') == 'details': size = float(div.getchildren()[0].getchildren()[5].te...
res = getattr(backend, function)(*args, **kwargs)
if callable(function): res = function(backend, *args, **kwargs) else: res = getattr(backend, function)(*args, **kwargs)
def complete(self, backend, count, selected_fields, function, *args, **kwargs): assert count is None or count > 0 res = getattr(backend, function)(*args, **kwargs)
def __init__(self, login, pwd):
def __init__(self, login, pwd, **kwargs):
def __init__(self, login, pwd):
self.assertTrue(len(l) > 0)
self.assertTrue(len(forecasts) > 0)
def test_meteofrance(self): l = list(self.backend.iter_city_search('paris')) self.assertTrue(len(l) > 0)
self.ui.nsfwCheckBox.setChecked(bool(self.config.get('settings', 'nsfw')))
self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw')))
def __init__(self, config, weboob, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self)
debug('[%s] Opening URL %s' % (self.username, args[0]))
def location(self, *args, **kwargs): """ Change location of browser on an URL.
error(e)
error('Error opening URL "%s": %s' % (args[0], e))
def location(self, *args, **kwargs): """ Change location of browser on an URL.
photo_regex = re.compile('(?P<base_url>http://.+\.adopteunmec\.com/.+/)image(?P<id>.+)\.jpg') photo_max_id = max(int(photo_regex.match(photo['url']).groupdict()['id']) for photo in self.photos) base_url = photo_regex.match(self.photos[0]['url']).groupdict()['base_url'] for id in xrange(1, photo_max_id + 1): url = '%sim...
def on_loaded(self): self.name = u'' self.description = u'' self.table = deepcopy(self.empty_table) self.id = 0 self.photos = [] self.status = '' self.stats = OrderedDict(( ('score', 0), ('visits', 0), ('charms', 0), ('baskets', 0), ('mails', 0), ))
for backend, in self.weboob.iter_backends():
for backend in self.weboob.iter_backends():
def command_search(self, pattern): print ".--------------------------------.---------------------------------------------." print '| ID | Name |' print '+--------------------------------+---------------------------------------------+' count = 0 for back...
for backend, in self.weboob.iter_backends():
for backend in self.weboob.iter_backends():
def command_current(self, city): print ".-------------.----------------------------------------------------------------." print '| Temperature | Text |' print '+-------------+----------------------------------------------------------------+' found = 0 for backen...
m = re.match(r'((\d+)min)?(\d+)s', duration)
m = re.match(r'((\d+)h)?((\d+)min)?(\d+)s', duration)
def iter_videos(self): ul = select(self.document.getroot(), 'div.container-videos ul', 1) for li in ul.findall('li'): id = re.sub(r'/video/(.+)\.html', r'\1', li.find('a').attrib['href'])
duration = datetime.timedelta(minutes=int(m.group(2) or 0), seconds=int(m.group(3)))
duration = datetime.timedelta(hours=int(m.group(2) or 0), minutes=int(m.group(4) or 0), seconds=int(m.group(5)))
def iter_videos(self): ul = select(self.document.getroot(), 'div.container-videos ul', 1) for li in ul.findall('li'): id = re.sub(r'/video/(.+)\.html', r'\1', li.find('a').attrib['href'])
self.values = {} self.config = SafeConfigParser()
self.values = OrderedDict() self.config = RawConfigParser()
def __init__(self, path): self.path = path self.values = {} self.config = SafeConfigParser()
def load_section(section): sections = section.split(':') if len(sections) > 1: result = {} for s in sections: result[s] = load_section(s) return result else: return {section: dict(self.config.items(section))} self.values = default.copy()
self.values = OrderedDict(default)
def load_section(section): sections = section.split(':') if len(sections) > 1: result = {} for s in sections: result[s] = load_section(s) return result else: return {section: dict(self.config.items(section))}
self.values = load_section(section) self.values.update(self.config.items('DEFAULT'))
args = section.split(':') if args[0] == 'ROOT': args.pop(0) for key, value in self.config.items(section): self.set(*(args + [key, value])) if len(self.config.sections()) == 0: first = True for key, value in self.config.items('DEFAULT'): if first: logging.warning('The configuration file "%s" uses an old-style' % self.p...
def load_section(section): sections = section.split(':') if len(sections) > 1: result = {} for s in sections: result[s] = load_section(s) return result else: return {section: dict(self.config.items(section))}
def save_section(values, root_section=None):
def save_section(values, root_section='ROOT'):
def save_section(values, root_section=None): for k, v in values.iteritems(): if isinstance(v, (int, float, basestring)): if root_section is not None and not self.config.has_section(root_section): self.config.add_section(root_section) self.config.set(root_section, k, unicode(v)) elif isinstance(v, dict): new_section = '...
if root_section is not None and not self.config.has_section(root_section):
if not self.config.has_section(root_section):
def save_section(values, root_section=None): for k, v in values.iteritems(): if isinstance(v, (int, float, basestring)): if root_section is not None and not self.config.has_section(root_section): self.config.add_section(root_section) self.config.set(root_section, k, unicode(v)) elif isinstance(v, dict): new_section = '...
new_section = ':'.join((root_section, k)) if root_section else k
new_section = ':'.join((root_section, k)) if (root_section != 'ROOT' or k == 'ROOT') else k
def save_section(values, root_section=None): for k, v in values.iteritems(): if isinstance(v, (int, float, basestring)): if root_section is not None and not self.config.has_section(root_section): self.config.add_section(root_section) self.config.set(root_section, k, unicode(v)) elif isinstance(v, dict): new_section = '...
v[k] = {}
v[k] = OrderedDict()
def set(self, *args): v = self.values for k in args[:-2]: if k not in v: v[k] = {} v = v[k] v[args[-2]] = args[-1]
if _backends: backends = [self.backend_instances[_backends]]
if len(_backends) > 0: try: backends = [self.backend_instances[_backends]] except (ValueError,KeyError): backends = []
def do(self, function, *args, **kwargs): """ Do calls on loaded backends with specified arguments, in separated threads.
account.balance = ''.join( compte.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() )
account.balance = float(''.join( compte.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ))
def get_accounts_list(self):
account.balance = ''.join( epargne.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() )
account.balance = float(''.join( epargne.xpath("./td/span")[0].text.replace('.','').replace(',','.').split() ) )
def get_accounts_list(self):
self.response_event.set()
def _caller(self, backend, function, args, kwargs): debug('%s: Thread created successfully' % backend) with backend: try: # Call method on backend try: debug('%s: Calling function %s' % (backend, function)) if callable(function): result = function(backend, *args, **kwargs) else: result = getattr(backend, function)(*arg...
IFormatter.__init__(self, display_keys, return_only)
IFormatter.__init__(self, display_keys=display_keys, return_only=return_only)
def __init__(self, display_keys=True, return_only=False, result_funcname='get_string'): IFormatter.__init__(self, display_keys, return_only) self.result_funcname = result_funcname
e = self.queue[count] self.logger.debug('function "%s" will be called in %s seconds' % (function.__name__, e.interval))
try: e = self.queue[count] except KeyError: return else: self.logger.debug('function "%s" will be called in %s seconds' % (function.__name__, e.interval))
def _repeat_callback(self, count, interval, function, args): function(*args) with self.mutex: e = self.queue[count] self.logger.debug('function "%s" will be called in %s seconds' % (function.__name__, e.interval))
HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder(api, ElementTree))
implementation = self.defaults.get(api, None) HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder(api, implementation))
def __init__(self, api='etree'): HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder(api, ElementTree))
print "s"+s+"::"+operation.label+"::"
def get_history(self): index = 0 for tr in self.document.getiterator('tr'): first_td = tr.getchildren()[0] if first_td.attrib.get('class', '') == 'i g' or first_td.attrib.get('class', '') == 'p g': operation = Operation(index) index += 1 operation.date = first_td.text operation.label = tr.getchildren()[2].text.replace(...
if len(args) < nb_min_args or len(args) > nb_max_args and not varargs:
if len(args) > nb_max_args and not varargs: sys.stderr.write("Command '%s' takes at most %d arguments.\n" % (command, nb_max_args)) return elif len(args) < nb_min_args:
def f(x): return x.startswith('command_' + command)
return local2utc(datetime.strptime(unicode(date_s.strip()), u'le %d/%m/%Y à %H:%M.'))
return local2utc(datetime.strptime(date_s.strip().encode('utf-8'), u'le %d/%m/%Y \xe0 %H:%M.'.encode('utf-8')))
def parse_date(self, date_s): return local2utc(datetime.strptime(unicode(date_s.strip()), u'le %d/%m/%Y à %H:%M.'))
return '%s\n%s' % (Exception.__str__(self), self.original_backtrace)
s = Exception.__str__(self) if logging.root.level == logging.DEBUG: s += '\n' + self.original_backtrace return s
def __str__(self): return '%s\n%s' % (Exception.__str__(self), self.original_backtrace)
self.PAGES = {'https://%s/' % website: pages.LoginPage, 'https://%s/.*\.c.*' % website: pages.AccountsList,
self.PAGES = {'https://%s/' % website: pages.LoginPage, 'https://%s/.*\.c.*' % website: pages.AccountsList, 'https://%s/login/process' % website: pages.AccountsList,
def __init__(self, website, *args, **kwargs): self.DOMAIN = website self.PAGES = {'https://%s/' % website: pages.LoginPage, 'https://%s/.*\.c.*' % website: pages.AccountsList, } Browser.__init__(self, *args, **kwargs)
self.location('https://%s/' % self.DOMAIN)
self.location('https://%s/login/process' % self.DOMAIN)
def home(self): self.location('https://%s/' % self.DOMAIN)
return not self.is_on_page(pages.LoginPage) or self.is_logging
return not self.is_on_page(pages.LoginPage) or self.page.is_logged()
def is_logged(self): return not self.is_on_page(pages.LoginPage) or self.is_logging
return u"<Account id='%s' label='%s'>" % (self.id, self.label)
return u"<Account id=%r label=%r>" % (self.id, self.label)
def __repr__(self): return u"<Account id='%s' label='%s'>" % (self.id, self.label)
warning('python-html is not present. HTML pages will not be converted into text.')
warning('python-html2text is not present. HTML pages will not be converted into text.')
def utc2local(d): d = d.replace(tzinfo=tz.tzutc()) d = d.astimezone(tz.tzlocal()) return d
self.check_cron = self.sched.repeat(self.config['interval'], self.check_godchilds) self.activity_cron = self.sched.repeat(300, self.activity_fakes)
self.check_cron = self.sched.repeat(int(self.config['interval']), self.check_godchilds) self.activity_cron = self.sched.repeat(600, self.activity_fakes)
def start(self): if self.config is None: return False
if isinstance(field.default, bool):
if isinstance(field.default, bool) and not isinstance(value, bool):
def __init__(self, weboob, name, config, storage): self.weboob = weboob self.name = name self.config = {} for name, field in self.CONFIG.iteritems(): value = config.get(name, field.default)
elif isinstance(field.default, int):
elif isinstance(field.default, int) and not isinstance(value, int):
def __init__(self, weboob, name, config, storage): self.weboob = weboob self.name = name self.config = {} for name, field in self.CONFIG.iteritems(): value = config.get(name, field.default)
elif isinstance(field.default, float):
elif isinstance(field.default, float) and not isinstance(value, float):
def __init__(self, weboob, name, config, storage): self.weboob = weboob self.name = name self.config = {} for name, field in self.CONFIG.iteritems(): value = config.get(name, field.default)
values = load_section(s)
result[s] = load_section(s) return result
def load_section(section): sections = section.split(':') if len(sections) > 1: for s in sections: values = load_section(s) else: return {section: dict(self.config.items(section))}
self.location('/NS_AVEET?ch4=%s' % account.link_id)
self.location('/NS_AVEDT?ch4=%s' % account.link_id)
def get_coming_operations(self, account): if not self.is_on_page(pages.AccountComing) or self.page.account.id != account.id: self.location('/NS_AVEET?ch4=%s' % account.link_id) return self.page.get_operations()
if 'photos' in fields:
if 'photos' in fields and contact.photos:
def fill_contact(self, contact, fields): if 'profile' in fields: contact = self.get_contact(contact) if 'photos' in fields: for name, photo in contact.photos.iteritems(): with self.browser: if photo.url: data = self.browser.openurl(photo.url).read() contact.set_photo(name, data=data) if photo.thumbnail_url: data = self...
text = to_unicode(p.text).strip()
try: text = p.text except UnicodeDecodeError, error: text = error.object.strip()
def get_transfer_id(self): p = self.document.xpath("//form/div/p")[0] text = to_unicode(p.text).strip()
def post_mesage(self, message):
def post_message(self, message): if not message.parent: raise CantSendMessage('Posting news and telegrams on DLFP is not supported yet') assert message.thread
def post_mesage(self, message): with self.browser: return self.browser.post_reply(message.thread.id, message.parent.id, message.title, message.content)
missing_godchilds = self.config['minimal'] - nb_godchilds
missing_godchilds = int(self.config['minimal']) - nb_godchilds
def check_godchilds(self): with self.browser: try: my_id = self.browser.get_my_id() nb_godchilds = self.browser.nb_godchilds() except AdopteWait: nb_godchilds = 0 except BrowserUnavailable: # We'll check later return
birthday_y= random.randint(1970, 1990),
birthday_y= random.randint(1975, 1990),
def check_godchilds(self): with self.browser: try: my_id = self.browser.get_my_id() nb_godchilds = self.browser.nb_godchilds() except AdopteWait: nb_godchilds = 0 except BrowserUnavailable: # We'll check later return
fakes = self.storage.get('priority_connection', 'fakes', default={}) while 1: name = random.choice(fakes.keys()) fake = fakes[name] try: browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy) except (AdopteBanned,BrowserIncorrectPassword), e: self.warning('Fake %s can\'t login: %s' % (name, ...
try: fakes = self.storage.get('priority_connection', 'fakes', default={}) if len(fakes) == 0: return while 1: name = random.choice(fakes.keys()) fake = fakes[name] try: browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy) except (AdopteBanned,BrowserIncorrectPassword), e: self.warning('Fak...
def activity_fakes(self): fakes = self.storage.get('priority_connection', 'fakes', default={}) while 1: name = random.choice(fakes.keys()) fake = fakes[name] try: browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy) except (AdopteBanned,BrowserIncorrectPassword), e: self.warning('Fake %s c...
id = profiles.pop() profile = browser.get_profile(id) for i in xrange(4): browser.rate(profile.get_id(), i, 0.6) browser.deblock(profile.get_id()) return
id = profiles.pop() profile = browser.get_profile(id) for i in xrange(4): browser.rate(profile.get_id(), i, 0.6) browser.deblock(profile.get_id()) return except BrowserUnavailable: pass
def activity_fakes(self): fakes = self.storage.get('priority_connection', 'fakes', default={}) while 1: name = random.choice(fakes.keys()) fake = fakes[name] try: browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy) except (AdopteBanned,BrowserIncorrectPassword), e: self.warning('Fake %s c...
def label_set(self, value):
def label(self, value):
def label_set(self, value): self._label = str(value)
def amount_set(self, value):
def amount(self, value):
def amount_set(self, value): self._amount = float(value)
while not self.finish_event.isSet():
while not self.finish_event.isSet() or self.response_event.isSet():
def _callback_thread_run(self, callback, errback): responses = [] while not self.finish_event.isSet(): self.response_event.wait() with self.mutex: responses = self.responses self.responses = []
while not self.finish_event.isSet():
while not self.finish_event.isSet() or self.response_event.isSet():
def __iter__(self): # Don't know how to factorize with _callback_thread_run responses = [] while not self.finish_event.isSet(): self.response_event.wait() with self.mutex: responses = self.responses self.responses = []
if mail.sender != my_name:
if mail.sender == my_name:
def get_thread(self, id, profiles=None): """ Get a thread and its messages.
try: with self.browser: if isinstance(contact, Contact): _id = contact.id elif isinstance(contact, (int,long,str,unicode)): _id = contact else: raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact) profile = self.browser.get_profile(_id) if profile.is_online(): s = Contac...
with self.browser: if isinstance(contact, Contact): _id = contact.id elif isinstance(contact, (int,long,str,unicode)): _id = contact else: raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact) profile = self.browser.get_profile(_id) if profile.is_online(): s = Contact.STA...
def get_contact(self, contact): try: with self.browser: if isinstance(contact, Contact): _id = contact.id elif isinstance(contact, (int,long,str,unicode)): _id = contact else: raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact)
debug('Import error for weboob.tools.config.yamlconfig: %s' % e)
error('Import error for weboob.tools.config.yamlconfig: %s' % e)
def get(self, backend, *args, **kwargs): raise NotImplementedError()
print >>sys.stderr, 'Use --debug option to print backtraces.'
if self.interactive: print >>sys.stderr, 'Use "logging debug" option to print backtraces.' else: print >>sys.stderr, 'Use --debug option to print backtraces.'
def onecmd(self, line): """ This REPL method is overrided to catch some particular exceptions. """ cmd, arg, ignored = self.parseline(line)
logging.root.setLevel(levels[args[0]])
level = levels[args[0]]
def do_logging(self, line): """ logging [LEVEL]
m = re.match('.*<(.*)@(.*)>', s)
m = re.match('.*<([^@]*)@(.*)>', s)
def get_email_address_ident(self, msg, header): s = msg.get(header) m = re.match('.*<(.*)@(.*)>', s) if m: return m.group(1) else: try: return s.split('@')[0] except IndexError: return s
if not self.is_on_page(pages.AccountsList):
if not self.is_on_page(pages.AccountsList) or self.page.is_account_page():
def get_accounts_list(self): if not self.is_on_page(pages.AccountsList): self.home() return self.page.get_list()
html5lib.HTMLParser.__init__(tree=treebuilders.getTreeBuilder("dom"))
html5lib.HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder("dom"))
def __init__(self): html5lib.HTMLParser.__init__(tree=treebuilders.getTreeBuilder("dom"))
self.__changeLocation(mechanize.Browser.submit(self, *args, **kwargs))
self.__change_location(mechanize.Browser.submit(self, *args, **kwargs))
def submit(self, *args, **kwargs): try: self.__changeLocation(mechanize.Browser.submit(self, *args, **kwargs)) except (mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError), e: error(e) self.page = None raise BrowserUnavailable() except (mechanize.BrowserStateError,BrowserRetry): self.home() raise Brows...
self.__changeLocation(mechanize.Browser.follow_link(self, *args, **kwargs))
self.__change_location(mechanize.Browser.follow_link(self, *args, **kwargs))
def follow_link(self, *args, **kwargs): try: self.__changeLocation(mechanize.Browser.follow_link(self, *args, **kwargs)) except (mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError), e: error(e) self.page = None raise BrowserUnavailable() except (mechanize.BrowserStateError,BrowserRetry): self.home() r...
self.__changeLocation(mechanize.Browser.open(self, *args, **kwargs))
self.__change_location(mechanize.Browser.open(self, *args, **kwargs))
def location(self, *args, **kwargs): keep_args = copy(args) keep_kwargs = kwargs.copy()
document = self.__parser.parse()
document = self.__parser.parse(result)
def __change_location(self, result): # Find page from url pageCls = None for key, value in self.PAGES.items(): regexp = re.compile('^%s$' % key) m = regexp.match(result.geturl()) if m: pageCls = value break
def get_thread(self, id):
def get_thread(self, id, profiles=None): """ Get a thread and its messages. The 'profiles' parameter is only used for internal calls. """
def get_thread(self, id): thread = None if isinstance(id, Thread): thread = id id = thread.id
thread = self.get_thread(contact.get_id())
thread = self.get_thread(contact.get_id(), profiles)
def iter_unread_messages(self, thread=None): try: with self.browser: contacts = self.browser.get_threads_list() for contact in contacts: slut = self._get_slut(contact.get_id()) if contact.get_lastmsg_date() > slut['lastmsg']: thread = self.get_thread(contact.get_id()) for m in thread.iter_all_messages(): if m.flags & m...
raise Exception('command_result type not expected: %s' % type(command_result))
try: print unicode(command_result) except ValueError: raise Exception('command_result type not expected: %s' % type(command_result))
def f(x): return x.startswith('command_' + command)
args.append("[*%s]" % varargs)
args.append("[%s..]" % varargs)
def getArguments(func, skip=0): """ Get arguments of a function as a string. skip is the number of skipped arguments. """ skip += 1 args, varargs, varkw, defaults = getargspec(func) cut = len(args) if defaults: cut -= len(defaults) args = ["<%s>" % a for a in args[skip:cut]] + \ ["[%s]" % a for a in args[cut:]] if vara...
args.append("[**%s]" % varkw)
args.append("{WTF}" % varkw)
def getArguments(func, skip=0): """ Get arguments of a function as a string. skip is the number of skipped arguments. """ skip += 1 args, varargs, varkw, defaults = getargspec(func) cut = len(args) if defaults: cut -= len(defaults) args = ["<%s>" % a for a in args[skip:cut]] + \ ["[%s]" % a for a in args[cut:]] if vara...
el = self.document.getroot().cssselect('.bloc-video-edito h3')[0]
el = self.document.getroot().cssselect('div.bloc-produit-haut p.date')[0]
def get_date_and_duration(self): duration_regexp = re.compile('(.+) - (.+)min(.+)s') el = self.document.getroot().cssselect('.bloc-video-edito h3')[0] if el is not None: m = duration_regexp.match(el.text.strip()) if m: day, month, year = [int(s) for s in m.group(1).split('/')] date = datetime.datetime(year, month, day)...
el = self.document.getroot().cssselect('.bloc-video-edito h2')[0]
el = self.document.getroot().cssselect('div.bloc-produit-haut h1')[0]
def get_title(self): el = self.document.getroot().cssselect('.bloc-video-edito h2')[0] if el is not None: return unicode(el.text.strip()) else: return None
return (v is NotLoaded or isinstance(value, CapBaseObject) and not value.__iscomplete__())
return (v is NotLoaded or isinstance(v, CapBaseObject) and not v.__iscomplete__())
def not_loaded(v): return (v is NotLoaded or isinstance(value, CapBaseObject) and not value.__iscomplete__())
('Configuration', ', '.join('%s=%s' % (key, ('*****' if backend.config[key].is_masked else value)) for key, value in params.iteritems())),
('Configuration', ', '.join('%s=%s' % (key, ('*****' if key in backend.config and backend.config[key].is_masked else value)) for key, value in params.iteritems())),
def command_listconfigured(self): self.set_default_formatter('table') for instance_name, name, params in sorted(self.weboob.backends_config.iter_backends()): backend = self.weboob.modules_loader.get_or_load_module(name) row = OrderedDict([('Instance name', instance_name), ('Backend name', name), ('Configuration', ', '....
backends = self.backend_instances[kwargs.pop('backends')]
backends = [self.backend_instances[kwargs.pop('backends')]]
def do(self, function, *args, **kwargs): """ Do calls on loaded backends with specified arguments, in separated threads.
yield selected_field, d[selected_field]
yield selected_field, v
def iter_select_and_decorate(d): if hasattr(obj, '__id__'): id_attr = getattr(obj, '__id__') if not isinstance(id_attr, (set, list, tuple)): id_attr = (id_attr,) id_fields = id_attr else: id_fields = ('id',) if selected_fields is None or '*' in selected_fields: for k, v in d: if k in id_fields and backend_name is not N...
i = len(tds) - 7
i = len(tds) - 1 while i >= 0 and tds[i].find('a') is None: i -= 1
def iter_torrents(self): table = self.document.getroot().cssselect('table.torrent_table') if not table: table = self.document.getroot().cssselect('table#browse_torrent_table') if table: table = table[0] current_group = None for tr in table.findall('tr'): if tr.attrib.get('class', '') == 'group': tds = tr.findall('td') ...
seeders = int(tds[i+5].text) leechers = int(tds[i+6].text)
seeders = int(tds[-2].text) leechers = int(tds[-1].text)
def iter_torrents(self): table = self.document.getroot().cssselect('table.torrent_table') if not table: table = self.document.getroot().cssselect('table#browse_torrent_table') if table: table = table[0] current_group = None for tr in table.findall('tr'): if tr.attrib.get('class', '') == 'group': tds = tr.findall('td') ...
print tr.attrib
debug('unknown attrib: %s' % tr.attrib)
def iter_torrents(self): table = self.document.getroot().cssselect('table.torrent_table') if not table: table = self.document.getroot().cssselect('table#browse_torrent_table') if table: table = table[0] current_group = None for tr in table.findall('tr'): if tr.attrib.get('class', '') == 'group': tds = tr.findall('td') ...
path = weboob.applications.__path__[0] applications = [] regexp = re.compile('^%s/([\w\d_]+)$' % path) for root, dirs, files in os.walk(path): m = regexp.match(root) if m and '__init__.py' in files: applications.append(m.group(1)) print ' '.join(applications)
for path in weboob.applications.__path__: regexp = re.compile('^%s/([\w\d_]+)$' % path) for root, dirs, files in os.walk(path): m = regexp.match(root) if m and '__init__.py' in files: applications.add(m.group(1)) print ' '.join(sorted(applications)).encode('utf-8')
def command_applications(self, *caps): import weboob.applications path = weboob.applications.__path__[0] applications = [] regexp = re.compile('^%s/([\w\d_]+)$' % path) for root, dirs, files in os.walk(path): m = regexp.match(root) if m and '__init__.py' in files: applications.append(m.group(1))
self.signature = u'Profile link: %s' % self.profile_link
self.signature = u'Profile: http://www.adopteunmec.com%s' % self.profile_link
def parse_profile_link(self): tables = self.tr.getElementsByTagName('div')
ul = select(self.document.getroot(), 'div.container-videos ul', 1)
try: ul = select(self.document.getroot(), 'div.container-videos ul', 1) except SelectElementException: return
def iter_videos(self): ul = select(self.document.getroot(), 'div.container-videos ul', 1) for li in ul.findall('li'): id = re.sub(r'/video/(.+)\.html', r'\1', li.find('a').attrib['href'])
Show available backends
Show available backends.
def do_backends(self, line): """ backends [CAPS ...]
caps = line.split(' ')
caps = line.split()
def do_backends(self, line): """ backends [CAPS ...]
el = self.document.getroot().cssselect('h1')
el = self.document.getroot().cssselect('
def get_title(self): el = self.document.getroot().cssselect('h1') if el: return unicode(el[0].getchildren()[0].tail).strip()
if p.find('br'):
if p.find('br') is not None:
def get_transfer_id(self): p = self.document.xpath("//form/div/p")[0] text = to_unicode(p.text).strip()