compare instance to basestring instead of (str, unicode)
This commit is contained in:
parent
3ced2bee38
commit
8afff42465
9 changed files with 13 additions and 13 deletions
|
|
@ -242,7 +242,7 @@ class AuMBrowser(BaseBrowser):
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def get_profile(self, link):
|
def get_profile(self, link):
|
||||||
if isinstance(link, (str,unicode)) and link.startswith('/'):
|
if isinstance(link, basestring) and link.startswith('/'):
|
||||||
link = link[1:]
|
link = link[1:]
|
||||||
self.location('/%s' % link)
|
self.location('/%s' % link)
|
||||||
return self.page
|
return self.page
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ class BNPorc(BaseBrowser):
|
||||||
return not self.is_on_page(pages.LoginPage) or self.is_logging
|
return not self.is_on_page(pages.LoginPage) or self.is_logging
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
assert isinstance(self.username, (str,unicode))
|
assert isinstance(self.username, basestring)
|
||||||
assert isinstance(self.password, (str,unicode))
|
assert isinstance(self.password, basestring)
|
||||||
assert self.password.isdigit()
|
assert self.password.isdigit()
|
||||||
|
|
||||||
if not self.is_on_page(pages.LoginPage):
|
if not self.is_on_page(pages.LoginPage):
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ class Cragr(BaseBrowser):
|
||||||
return self.page and self.page.is_logged() or self.is_logging
|
return self.page and self.page.is_logged() or self.is_logging
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
assert isinstance(self.username, (str,unicode))
|
assert isinstance(self.username, basestring)
|
||||||
assert isinstance(self.password, (str,unicode))
|
assert isinstance(self.password, basestring)
|
||||||
|
|
||||||
self.is_logging = True
|
self.is_logging = True
|
||||||
if not self.is_on_page(pages.LoginPage):
|
if not self.is_on_page(pages.LoginPage):
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class Backend(object):
|
||||||
|
|
||||||
def has_caps(self, *caps):
|
def has_caps(self, *caps):
|
||||||
for c in caps:
|
for c in caps:
|
||||||
if (isinstance(c, (unicode,str)) and c in [cap.__name__ for cap in self.iter_caps()]) or \
|
if (isinstance(c, basestring) and c in [cap.__name__ for cap in self.iter_caps()]) or \
|
||||||
(type(c) == type and issubclass(self.klass, c)):
|
(type(c) == type and issubclass(self.klass, c)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class BackendsCall(object):
|
||||||
else:
|
else:
|
||||||
debug('%s: Called function %s returned: %r' % (backend, function, result))
|
debug('%s: Called function %s returned: %r' % (backend, function, result))
|
||||||
|
|
||||||
if hasattr(result, '__iter__') and not isinstance(result, (str,unicode)):
|
if hasattr(result, '__iter__') and not isinstance(result, basestring):
|
||||||
# Loop on iterator
|
# Loop on iterator
|
||||||
try:
|
try:
|
||||||
for subresult in result:
|
for subresult in result:
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ class Weboob(object):
|
||||||
return loaded
|
return loaded
|
||||||
|
|
||||||
def unload_backends(self, names=None):
|
def unload_backends(self, names=None):
|
||||||
if isinstance(names, (str,unicode)):
|
if isinstance(names, basestring):
|
||||||
names = [names]
|
names = [names]
|
||||||
elif names is None:
|
elif names is None:
|
||||||
names = self.backend_instances.keys()
|
names = self.backend_instances.keys()
|
||||||
|
|
@ -159,12 +159,12 @@ class Weboob(object):
|
||||||
if _backends:
|
if _backends:
|
||||||
if isinstance(_backends, BaseBackend):
|
if isinstance(_backends, BaseBackend):
|
||||||
backends = [_backends]
|
backends = [_backends]
|
||||||
elif isinstance(_backends, (str,unicode)) and _backends:
|
elif isinstance(_backends, basestring) and _backends:
|
||||||
backends = [self.backend_instances[_backends]]
|
backends = [self.backend_instances[_backends]]
|
||||||
elif isinstance(_backends, (list,tuple)):
|
elif isinstance(_backends, (list,tuple)):
|
||||||
backends = []
|
backends = []
|
||||||
for backend in _backends:
|
for backend in _backends:
|
||||||
if isinstance(backend, (str,unicode)):
|
if isinstance(backend, basestring):
|
||||||
try:
|
try:
|
||||||
backends.append(self.backend_instances[backend])
|
backends.append(self.backend_instances[backend])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ class ConsoleApplication(BaseApplication):
|
||||||
if caps is not None:
|
if caps is not None:
|
||||||
if not isinstance(caps, (list, tuple, set)):
|
if not isinstance(caps, (list, tuple, set)):
|
||||||
caps = (caps,)
|
caps = (caps,)
|
||||||
caps = [(cap if isinstance(cap, (str,unicode)) else cap.__name__) for cap in caps]
|
caps = [(cap if isinstance(cap, basestring) else cap.__name__) for cap in caps]
|
||||||
weboobcfg.command_backends(*caps)
|
weboobcfg.command_backends(*caps)
|
||||||
logging.error(u'You can configure backends using the "weboob-config add" command:\nweboob-config add <name> [options..]')
|
logging.error(u'You can configure backends using the "weboob-config add" command:\nweboob-config add <name> [options..]')
|
||||||
with open('/dev/null', 'w') as devnull:
|
with open('/dev/null', 'w') as devnull:
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ class BaseBackend(object):
|
||||||
|
|
||||||
def has_caps(self, *caps):
|
def has_caps(self, *caps):
|
||||||
for c in caps:
|
for c in caps:
|
||||||
if (isinstance(c, (unicode,str)) and c in [cap.__name__ for cap in self.iter_caps()]) or \
|
if (isinstance(c, basestring) and c in [cap.__name__ for cap in self.iter_caps()]) or \
|
||||||
isinstance(self, c):
|
isinstance(self, c):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
|
|
||||||
def check_location(func):
|
def check_location(func):
|
||||||
def inner(self, *args, **kwargs):
|
def inner(self, *args, **kwargs):
|
||||||
if args and isinstance(args[0], (str,unicode)) and args[0][0] == '/' and \
|
if args and isinstance(args[0], basestring) and args[0][0] == '/' and \
|
||||||
(not self.request or self.request.host != self.DOMAIN):
|
(not self.request or self.request.host != self.DOMAIN):
|
||||||
args = ('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, args[0]),) + args[1:]
|
args = ('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, args[0]),) + args[1:]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue