Skip to content

Commit

Permalink
- pep8-ified code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-h committed Nov 11, 2014
1 parent 25646b6 commit 47082ec
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 97 deletions.
10 changes: 5 additions & 5 deletions osc2/build.py
Expand Up @@ -54,7 +54,7 @@ def _create_xml(project, repository, arch, package, **kwargs):
parameters)
"""
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = BinaryList.SCHEMA
f = BinaryList._perform_request(project, repository, arch, package,
**kwargs)
Expand Down Expand Up @@ -166,7 +166,7 @@ def result(self, **kwargs):
arch = kwargs.pop('arch', self.arch)
request = Osc.get_osc().get_reqobj()
path = "/build/%s/_result" % self.project
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = BuildResult.RESULT_SCHEMA
f = request.get(path, package=package, repository=repository,
arch=arch, **kwargs)
Expand All @@ -175,7 +175,7 @@ def result(self, **kwargs):

def _prepare_kwargs(self, kwargs, *required):
for i in required:
if not i in kwargs and getattr(self, i, ''):
if i not in kwargs and getattr(self, i, ''):
kwargs[i] = getattr(self, i)
else:
raise ValueError("missing parameter: %s" % i)
Expand Down Expand Up @@ -224,7 +224,7 @@ def builddepinfo(self, reverse=False, **kwargs):
view = 'pkgnames'
if reverse:
view = 'revpkgnames'
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = BuildResult.BUILDDEPINFO_SCHEMA
f = request.get(path, view=view, **kwargs)
# no custom parser needed atm
Expand Down Expand Up @@ -257,7 +257,7 @@ def __init__(self, project='', package='', repository='', arch='',
"""
if ((project or package or repository or arch) and xml_data
or not (project and repository and arch) and not xml_data):
or not (project and repository and arch) and not xml_data):
msg = 'Either project, package, repository, arch or xml_data'
raise ValueError(msg)
elif not xml_data:
Expand Down
6 changes: 3 additions & 3 deletions osc2/builder.py
Expand Up @@ -83,7 +83,7 @@ def can_build(hostarch, buildarch, cando):
Otherwise False is returned.
"""
if not hostarch in cando.keys():
if hostarch not in cando.keys():
raise ValueError("hostarch \"%s\" is not supported" % hostarch)
return buildarch in cando[hostarch].keys()

Expand Down Expand Up @@ -166,7 +166,7 @@ def set(self, opt, val, append=False):
append -- do not overwrite old value(s) (default: False)
"""
if not opt in self._options:
if opt not in self._options:
self._options[opt] = ListDelegate()
values = self._options[opt]
if val is None:
Expand All @@ -186,7 +186,7 @@ def opts(self):
for opt in sorted(self._options.keys()):
for val in self._options[opt]:
l.append("--%s" % opt.replace('_', '-'))
if val != True:
if val is not True:
# option has a value
l.append(str(val))
return l
Expand Down
6 changes: 3 additions & 3 deletions osc2/cli/cli.py
Expand Up @@ -44,7 +44,7 @@ def _init(apiurl):
password = cp.get(section, 'pass', raw=True)
password = password.decode('base64').decode('bz2')
if (cp.has_option(section, 'keyring')
and cp.getboolean(section, 'keyring')):
and cp.getboolean(section, 'keyring')):
try:
import keyring
host = urlparse.urlparse(apiurl).hostname
Expand Down Expand Up @@ -96,7 +96,7 @@ def parse_illegal_options_doc(doc):
break
return '\n'.join(res)
params = inspect.getargspec(f)[0]
if not 'info' in params:
if 'info' not in params:
return f(*f_args, **f_kwargs)
i = params.index('info')
info = f_kwargs.get('info', f_args[i])
Expand Down Expand Up @@ -148,7 +148,7 @@ def call_func(info):
# skip self and cls - that's just a convention
if arg in ('self', 'cls'):
continue
if not arg in info and arg in required_args:
if arg not in info and arg in required_args:
msg = ("cannot call \"%s\": cannot bind \"%s\" parameter"
% (func.__name__, arg))
raise ValueError(msg)
Expand Down
12 changes: 6 additions & 6 deletions osc2/cli/description.py
Expand Up @@ -41,7 +41,7 @@ def __new__(cls, name, bases, attrs):
real_bases, parent_cmds, ext_alias_cmd = cls._calculate_bases(bases)
# check if we extend or alias an existing command
extends_cmd = False
if ext_alias_cmd and not 'cmd' in attrs:
if ext_alias_cmd and 'cmd' not in attrs:
extends_cmd = True
real_bases = tuple(real_bases)
descr = super(AbstractSubcommandFilterMeta, cls).__new__(cls, name,
Expand Down Expand Up @@ -82,14 +82,14 @@ class which is used for inheritance and not for building a
if issubclass(base, cls.filter_cls)]
# just a small sanity check: it makes no sense to extend multiple
# commands
if len(filter_subs) != 1 and not cls.filter_cls in filter_subs:
if len(filter_subs) != 1 and cls.filter_cls not in filter_subs:
raise ValueError('exactly one cmd can be extended or aliased')
ext_alias_cmd = (len(filter_subs) == 1
and not cls.filter_cls in filter_subs)
and cls.filter_cls not in filter_subs)
for base in bases:
if (base.__name__ == cls.filter_cls.__name__
or ext_alias_cmd
or not issubclass(base, cls.filter_cls)):
or ext_alias_cmd
or not issubclass(base, cls.filter_cls)):
real_bases.append(base)
else:
parent_cmds.append(base)
Expand Down Expand Up @@ -135,7 +135,7 @@ def _append_subcommand(cls, parent_cmds, descr):
for parent_cmd in parent_cmds:
name = parent_cmd.__name__
names = [s.__name__ for s in descr.cls_map().setdefault(name, [])]
if not descr.__name__ in names:
if descr.__name__ not in names:
descr.cls_map()[name].append(descr)


Expand Down
2 changes: 1 addition & 1 deletion osc2/cli/parse.py
Expand Up @@ -41,7 +41,7 @@ def _add_items(self, info):
# add options etc. to info object
for i in self.__dict__.keys():
if (i.startswith('oargs') or i in info or i in self.oargs
or i == 'func_defaults'):
or i == 'func_defaults'):
continue
elif i.startswith('opt_oargs_'):
self._resolve_option(info, i)
Expand Down
2 changes: 1 addition & 1 deletion osc2/cli/render.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, path=None, loader=None, filters=None):
"""
if (path is None and loader is None
or path is not None and loader is not None):
or path is not None and loader is not None):
raise ValueError('Either specify path oder loader')
if path is not None:
loader = FileSystemLoader(path)
Expand Down
8 changes: 4 additions & 4 deletions osc2/cli/review/shell.py
Expand Up @@ -151,10 +151,10 @@ def __init__(self, global_by_kind_filter, *args, **kwargs):
def _augment_info(self, info):
super(ReviewShell, self)._augment_info(info)
if (self._global_by_kind_filter is not None
and 'user' in info and 'group' in info
and 'project' in info and 'package' in info
and info.user is None and info.group is None
and info.project is None and not info.package):
and 'user' in info and 'group' in info
and 'project' in info and 'package' in info
and info.user is None and info.group is None
and info.project is None and not info.package):
# use global_by_kind_filter if no filter was specified
# by the user
info.set(self._global_by_kind_filter[0],
Expand Down
2 changes: 1 addition & 1 deletion osc2/cli/util/shell.py
Expand Up @@ -68,7 +68,7 @@ def _check_input(self, inp):
if i == 0 or i == len(inp) - 1:
continue
if (cnt % 2 == 0 and inp[i + 1] != ' '
or cnt % 2 == 1 and inp[i - 1] != ' '):
or cnt % 2 == 1 and inp[i - 1] != ' '):
msg = "invalid user input: %s (wrong quoting)" % inp
raise ShellSyntaxError(msg)
return cnt % 2 == 0
Expand Down
6 changes: 2 additions & 4 deletions osc2/fetch.py
Expand Up @@ -181,10 +181,8 @@ def __init__(self, root, **prefers):
def _calculate_filename(self, bdep, *args, **kwargs):
if bdep.get('name') in self._prefers.keys():
return self._prefers[bdep.get('name')]
return super(NamePreferCacheManager, self)._calculate_filename(bdep,
*args,
**kwargs
)
return super(NamePreferCacheManager, self)._calculate_filename(
bdep, *args, **kwargs)

def remove(self, bdep, *args, **kwargs):
if bdep.get('name') in self._prefers.keys():
Expand Down
4 changes: 2 additions & 2 deletions osc2/httprequest.py
Expand Up @@ -41,7 +41,7 @@ def build_url(apiurl, path, **query):
quoted_path = '/'.join([urllib.quote_plus(p) for p in path.split('/')])
# rewrite to internal key -> ['val'] representation
query.update([(k, [query[k]]) for k in query.keys()
if not hasattr(query[k], 'pop')])
if not hasattr(query[k], 'pop')])
# sort query keys (to get a reproduceable url)
sorted_keys = sorted(query.keys())
quoted_query = '&'.join([urllib.quote_plus(k) + '=' +
Expand Down Expand Up @@ -297,7 +297,7 @@ def _setup_cookie_processor(self, cookie_filename):
if not cookie_filename:
return None
if (os.path.exists(cookie_filename) and not
os.path.isfile(cookie_filename)):
os.path.isfile(cookie_filename)):
raise ValueError("%s exists but is no file" % cookie_filename)
elif not os.path.exists(cookie_file):
open(cookie_file, 'w').close()
Expand Down
18 changes: 9 additions & 9 deletions osc2/remote.py
Expand Up @@ -215,9 +215,9 @@ def store(self, path, method='PUT', **kwargs):
self.validate()
request = Osc.get_osc().get_reqobj()
http_method = _get_http_method(request, method)
if not 'data' in kwargs:
if 'data' not in kwargs:
kwargs['data'] = self.tostring()
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = self._store_schema
# FIXME: api.o.o does not like this for requests
kwargs['content_type'] = 'application/xml'
Expand Down Expand Up @@ -300,7 +300,7 @@ def __init__(self, name='', **kwargs):
@classmethod
def find(cls, project, **kwargs):
path = RemoteProject.PATH % {'project': project}
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = RemoteProject.SCHEMA
return super(RemoteProject, cls).find(path, **kwargs)

Expand Down Expand Up @@ -334,7 +334,7 @@ def __init__(self, project='', name='', **kwargs):
@classmethod
def find(cls, project, package, **kwargs):
path = RemotePackage.PATH % {'project': project, 'package': package}
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = RemotePackage.SCHEMA
return super(RemotePackage, cls).find(path, **kwargs)

Expand All @@ -361,7 +361,7 @@ def __init__(self, **kwargs):
@classmethod
def find(cls, reqid, **kwargs):
path = Request.GET_PATH % {'reqid': reqid}
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = Request.SCHEMA
return super(Request, cls).find(path, **kwargs)

Expand Down Expand Up @@ -670,7 +670,7 @@ def write_back(self, force=False, **kwargs):
self._init_fobj(read_required=True)
request = Osc.get_osc().get_reqobj()
http_method = _get_http_method(request, self.wb_method)
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = self._schema
data = None
filename = ''
Expand Down Expand Up @@ -732,9 +732,9 @@ class RemotePerson(RemoteModel):
def __init__(self, name='', **kwargs):
store_schema = RemotePerson.PUT_RESPONSE_SCHEMA
super(RemotePerson, self).__init__(tag='person', name=name,
schema=RemotePerson.SCHEMA,
store_schema=store_schema,
**kwargs)
schema=RemotePerson.SCHEMA,
store_schema=store_schema,
**kwargs)

@classmethod
def find(cls, userid, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion osc2/search.py
Expand Up @@ -76,7 +76,7 @@ def find_request(xp, **kwargs):
"""
path = '/search/request'
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = RequestCollection.SCHEMA
tag_class = {'collection': RequestCollection, 'request': RORequest}
return _find(path, xp, tag_class, **kwargs)
8 changes: 4 additions & 4 deletions osc2/source.py
Expand Up @@ -29,7 +29,7 @@ def file(self, **kwargs):
data = {'project': parent.get('project'),
'package': parent.get('name'), 'file': self.get('name')}
# specifying a different rev probably makes no sense...
if not 'rev' in kwargs:
if 'rev' not in kwargs:
kwargs['rev'] = self.getparent().get('srcmd5')
path = path % data
mtime = int(self.get('mtime'))
Expand Down Expand Up @@ -76,7 +76,7 @@ def list(self, **kwargs):
"""
request = Osc.get_osc().get_reqobj()
path = '/source/' + self.name
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = Project.LIST_SCHEMA
f = request.get(path, **kwargs)
entries = fromstring(f.read())
Expand Down Expand Up @@ -116,7 +116,7 @@ def list(self, **kwargs):
"""
request = Osc.get_osc().get_reqobj()
path = "/source/%s/%s" % (self.project, self.name)
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = Package.LIST_SCHEMA
f = request.get(path, **kwargs)
directory = fromstring(f.read(), directory=Directory, entry=File,
Expand All @@ -134,7 +134,7 @@ def log(self, **kwargs):
"""
request = Osc.get_osc().get_reqobj()
path = "/source/%s/%s/_history" % (self.project, self.name)
if not 'schema' in kwargs:
if 'schema' not in kwargs:
kwargs['schema'] = Package.HISTORY_SCHEMA
f = request.get(path, **kwargs)
return fromstring(f.read())
7 changes: 4 additions & 3 deletions osc2/wc/convert.py
Expand Up @@ -5,9 +5,10 @@
from osc2.wc.project import Project
from osc2.wc.package import Package
from osc2.wc.util import (wc_read_files, wc_pkg_data_filename, _storefile,
_write_storefile, _VERSION, wc_read_project,
_read_storefile, wc_read_packages, missing_storepaths,
wc_read_apiurl, wc_pkg_data_mkdir, _storedir)
_write_storefile, _VERSION, wc_read_project,
_read_storefile, wc_read_packages,
missing_storepaths, wc_read_apiurl,
wc_pkg_data_mkdir, _storedir)


def convert_package(path, ext_storedir=None, **kwargs):
Expand Down

0 comments on commit 47082ec

Please sign in to comment.