From fb3c7ae61f05d9d466b5f29965dd07d489a1b953 Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Tue, 11 Mar 2014 11:27:15 +0800 Subject: [PATCH] Fix Pylint Error C0301: Line too long C0326: No space allowed around keyword argument assignment C0326: Exactly one space allowed before assignment Change-Id: Ie40818628a51c0d52ec6b9bd3ad062c0caee9209 --- gitbuildsys/cmd_build.py | 22 +++++++++++----------- gitbuildsys/cmd_changelog.py | 2 +- gitbuildsys/cmd_createimage.py | 2 +- gitbuildsys/cmd_export.py | 4 ++-- gitbuildsys/cmd_remotebuild.py | 4 ++-- gitbuildsys/cmd_submit.py | 2 +- gitbuildsys/conf.py | 2 +- gitbuildsys/oscapi.py | 10 +++++----- gitbuildsys/parsing.py | 2 +- gitbuildsys/utils.py | 32 ++++++++++++++++---------------- setup.py | 2 +- tests/test_config.py | 3 ++- tests/test_help.py | 2 +- 13 files changed, 45 insertions(+), 44 deletions(-) diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index 853c95a..60ba061 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -73,7 +73,7 @@ def formalize_build_conf(profile): # '-' is not allowed, so replace with '_' return profile.replace('-', '_') -def get_binary_name_from_git (args, package_dirs): +def get_binary_name_from_git(args, package_dirs): ''' get binary rpm name from specified git package''' binary_list = [] @@ -114,7 +114,7 @@ def prepare_repos_and_build_conf(args, arch, profile): cmd_opts = [] cache = Temp(prefix=os.path.join(TMPDIR, 'gbscache'), directory=True) - cachedir = cache.path + cachedir = cache.path if not os.path.exists(cachedir): os.makedirs(cachedir) log.info('generate repositories ...') @@ -125,17 +125,17 @@ def prepare_repos_and_build_conf(args, arch, profile): repos = [i.url for i in profile.repos] if args.repositories: - for r in args.repositories: + for repo in args.repositories: try: - if not urlparse.urlsplit(r).scheme: - if os.path.exists(r): - r = os.path.abspath(os.path.expanduser(r)) + if not urlparse.urlsplit(repo).scheme: + if os.path.exists(repo): + repo = os.path.abspath(os.path.expanduser(repo)) else: - log.warning('local repo: %s does not exist' % r) + log.warning('local repo: %s does not exist' % repo) continue - opt_repo = SafeURL(r) + opt_repo = SafeURL(repo) except ValueError, err: - log.warning('Invalid repo %s: %s' % (r, str(err))) + log.warning('Invalid repo %s: %s' % (repo, str(err))) else: repos.append(opt_repo) @@ -226,7 +226,7 @@ def prepare_depanneur_opts(args): binary_list = get_binary_name_from_git(args, pkglist) args.binary_list += ',' + ','.join(binary_list) if args.binary_list: - blist = [ i.strip() for i in args.binary_list.split(',') ] + blist = [i.strip() for i in args.binary_list.split(',')] cmd_opts += ['--binary-list=%s' % ','.join(blist)] if args.binary_from_file: if not os.path.exists(args.binary_from_file): @@ -333,7 +333,7 @@ def main(args): cmd += ['--extra-packs=%s' % args.extra_packs] if hostarch != buildarch and buildarch in CHANGE_PERSONALITY: - cmd = [ CHANGE_PERSONALITY[buildarch] ] + cmd + cmd = [CHANGE_PERSONALITY[buildarch]] + cmd # Extra depanneur special command options cmd += prepare_depanneur_opts(args) diff --git a/gitbuildsys/cmd_changelog.py b/gitbuildsys/cmd_changelog.py index bb28de3..a1f17fd 100644 --- a/gitbuildsys/cmd_changelog.py +++ b/gitbuildsys/cmd_changelog.py @@ -74,7 +74,7 @@ def make_log_entries(commits, git_repo): author.name, author.email, get_version(git_repo, commits[0]))) for commit in commits: - commit_info = git_repo.get_commit_info(commit) + commit_info = git_repo.get_commit_info(commit) entries.append("- %s" % commit_info["subject"]) return entries diff --git a/gitbuildsys/cmd_createimage.py b/gitbuildsys/cmd_createimage.py index 64cdb4e..47c3d99 100644 --- a/gitbuildsys/cmd_createimage.py +++ b/gitbuildsys/cmd_createimage.py @@ -39,7 +39,7 @@ def createimage(args, ks_file): def main(args): '''main entrance for createimage''' try: - import mic + import mic except ImportError: raise GbsError('please install mic manually first') diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 12a29ab..71c046a 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -76,7 +76,7 @@ def track_export_branches(repo, args): # track upstream/pristine-tar branch for branch in [upstream_branch, 'pristine-tar']: - if not repo.has_branch(branch ) and branch in remote_branches: + if not repo.has_branch(branch) and branch in remote_branches: log.info('tracking branch: %s -> %s' % (remote_branches[branch], branch)) repo.create_branch(branch, remote_branches[branch]) @@ -244,7 +244,7 @@ def main(args): else: mkdir_p(outdir) - tmpdir = configmgr.get('tmpdir', 'general') + tmpdir = configmgr.get('tmpdir', 'general') tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), \ directory=True) export_dir = tempd.path diff --git a/gitbuildsys/cmd_remotebuild.py b/gitbuildsys/cmd_remotebuild.py index d21d414..61e8e68 100644 --- a/gitbuildsys/cmd_remotebuild.py +++ b/gitbuildsys/cmd_remotebuild.py @@ -105,7 +105,7 @@ def main(args): else: content = utils.show_file_from_rev(workdir, relative_spec, commit) if content is None: - raise GbsError('failed to checkout %s from commit: %s' % + raise GbsError('failed to checkout %s from commit: %s' % (relative_spec, commit)) tmp_spec = utils.Temp(content=content) @@ -147,7 +147,7 @@ def main(args): "passwdx": encode_passwd(api_passwd), } - tmpdir = configmgr.get('tmpdir', 'general') + tmpdir = configmgr.get('tmpdir', 'general') tmpd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_remotebuild_'), directory=True) exportdir = tmpd.path diff --git a/gitbuildsys/cmd_submit.py b/gitbuildsys/cmd_submit.py index 89ab530..aed1124 100644 --- a/gitbuildsys/cmd_submit.py +++ b/gitbuildsys/cmd_submit.py @@ -65,7 +65,7 @@ def get_message(): prompt = submit_template raw = edit(prompt) - useful = [i for i in raw.splitlines() if not i.startswith('#') ] + useful = [i for i in raw.splitlines() if not i.startswith('#')] return os.linesep.join(useful).strip() diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index 43d1ee8..9095441 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -161,7 +161,7 @@ class BrainConfigParser(SafeConfigParser): return with open(self._fpname, 'w') as fptr: - buf = ''.join([ line for line in self._flines if line is not None ]) + buf = ''.join([line for line in self._flines if line is not None ]) fptr.write(buf) diff --git a/gitbuildsys/oscapi.py b/gitbuildsys/oscapi.py index 8755423..41cd6b1 100644 --- a/gitbuildsys/oscapi.py +++ b/gitbuildsys/oscapi.py @@ -52,7 +52,7 @@ class OSC(object): def __init__(self, apiurl=None, oscrc=None): if oscrc: try: - conf.get_config(override_conffile = oscrc) + conf.get_config(override_conffile=oscrc) except OSError, err: if err.errno == 1: # permission problem, should be the chmod(0600) issue @@ -202,8 +202,8 @@ class OSC(object): metatype, path_args = self.get_path(prj, pkg) err = None try: - core.meta_exists(metatype = metatype, path_args = path_args, - create_new = False, apiurl = self.apiurl) + core.meta_exists(metatype=metatype, path_args=path_args, + create_new=False, apiurl=self.apiurl) except urllib2.HTTPError, err: if err.code == 404: return False @@ -346,8 +346,8 @@ class OSC(object): except OSCError, err: raise ObsError("can't get %s/%s build log: %s" % (prj, pkg, err)) - return log.translate(None, "".join([chr(i) \ - for i in range(10) + range(11,32)])) + return log.translate(None, "".join([chr(i) for i in \ + range(10) + range(11, 32)])) @staticmethod def get_path(prj, pkg=None): diff --git a/gitbuildsys/parsing.py b/gitbuildsys/parsing.py index 776d44c..e62829e 100644 --- a/gitbuildsys/parsing.py +++ b/gitbuildsys/parsing.py @@ -58,7 +58,7 @@ class GbsHelpFormatter(RawDescriptionHelpFormatter): if subcomm: match = re.match("[ ]+([^ ]+)[ ]+(.+)", line) if match: - name, help_text = match.group(1), match.group(2) + name, help_text = match.group(1), match.group(2) alias = self._aliases.get(name) or '' if alias: alias = "(%s)" % alias diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index b7857c3..e19c951 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -66,24 +66,24 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): if commit_id == 'WC.UNTRACKED': if os.path.islink(packaging_dir): packaging_dir = os.readlink(packaging_dir) - check = lambda fname, dir_only = False: os.path.exists(os.path.join( + check = lambda fname, dir_only=False: os.path.exists(os.path.join( git_path, fname)) - glob_ = lambda pattern: [ name.replace(git_path+'/', '') - for name in reversed(glob.glob(os.path.join(git_path, pattern))) ] + glob_ = lambda pattern: [name.replace(git_path+'/', '') + for name in reversed(glob.glob(os.path.join(git_path, pattern)))] msg = 'No such spec file %s' else: git_object = commit_id + ':' + packaging_dir cmd = ['git', 'show', git_object] try: with Workdir(git_path): - p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + outp = subprocess.Popen(cmd, stdout=subprocess.PIPE) except (subprocess.CalledProcessError, OSError): raise GbsError("failed to run %s in %s" % (' '.join(cmd), git_path)) - output = p.communicate()[0] + output = outp.communicate()[0] if not output.startswith('tree %s' % git_object): # packaging_dir is a symlink packaging_dir = output - check = lambda fname, dir_only = False : file_exists_in_rev(git_path, + check = lambda fname, dir_only=False : file_exists_in_rev(git_path, fname, commit_id, dir_only=dir_only) glob_ = lambda pattern: glob_in_rev(git_path, pattern, commit_id) msg = "No such spec file %%s in %s" % commit_id @@ -99,7 +99,7 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): raise GbsError("can't find any spec file under packaging dir: " "%s" % packaging_dir) - project_name = os.path.basename(git_path) + project_name = os.path.basename(git_path) if not spec: spec = os.path.join(packaging_dir, '%s.spec' % project_name) spec = spec if spec in specs else specs[0] @@ -245,11 +245,11 @@ class URLGrabber(object): if errcode == pycurl.E_OPERATION_TIMEOUTED or http_code == 503: proxies = ['Detected proxies set in system environment:'] - ENV = os.environ + env = os.environ for key in ['HTTPS_PROXY', 'HTTP_PROXY', 'FTP_PROXY', 'https_proxy', 'http_proxy', 'ftp_proxy', 'NO_PROXY', 'no_proxy']: - proxies.append('%s=%s' % (key, ENV.get(key, ''))) + proxies.append('%s=%s' % (key, env.get(key, ''))) raise UrlError("connect timeout to %s, maybe it's caused by " "proxy settings, please check. %s" % (curl.url, '\n '.join(proxies))) @@ -285,7 +285,7 @@ class RepoParser(object): def __init__(self, repos, cachedir): self.cachedir = cachedir - self.repourls = defaultdict(list) + self.repourls = defaultdict(list) self.buildconf = None self.standardrepos = [] self.urlgrabber = URLGrabber() @@ -328,13 +328,13 @@ class RepoParser(object): repo_items = root.find('repos') if repo_items is not None: - meta['repos'] = [ repo.text.strip() - for repo in repo_items.findall('repo') ] + meta['repos'] = [repo.text.strip() + for repo in repo_items.findall('repo')] arch_items = root.find('archs') if arch_items is not None: - meta['archs'] = [ arch.text.strip() - for arch in arch_items.findall('arch') ] + meta['archs'] = [arch.text.strip() + for arch in arch_items.findall('arch')] id_item = root.find('id') if id_item is not None: meta['id'] = id_item.text.strip() @@ -397,7 +397,7 @@ class RepoParser(object): fname = self.fetch(buildconf_url) if fname: release, _buildid = meta['id'].split('_') - release = release.replace('-','') + release = release.replace('-', '') target_conf = os.path.join(os.path.dirname(fname), '%s.conf' % release) os.rename(fname, target_conf) @@ -539,7 +539,7 @@ class SearchConfAction(argparse.Action): try: repo = RpmGitRepository(value) workdir = repo.path - except GitRepositoryError, err: + except GitRepositoryError: pass read_localconf(workdir) diff --git a/setup.py b/setup.py index 7ca23f6..669282a 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup(name='gbs', author_email='jian-feng.ding@intel.com, huaxu.wan@intel.com', url='https://git.tizen.org/', scripts=['tools/gbs'], - data_files = [('/etc/bash_completion.d/', ['data/gbs.sh']), + data_files=[('/etc/bash_completion.d/', ['data/gbs.sh']), ('/etc/zsh_completion.d/', ['data/_gbs'])], packages=[MOD_NAME], ) diff --git a/tests/test_config.py b/tests/test_config.py index 6e3aedc..701717e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -151,7 +151,8 @@ class ConfigGettingTest(unittest.TestCase): @Fixture(home='home1.ini') def test_addconf(self): '''value can be inherit from two levels''' - self.add_conf(os.path.join(FILE_DIRNAME, 'testdata', 'ini', 'project1.ini')) + self.add_conf(os.path.join(FILE_DIRNAME, 'testdata', 'ini',\ + 'project1.ini')) self.assertEqual('homev2', self.get('section', 'home_only_key')) diff --git a/tests/test_help.py b/tests/test_help.py index 8a94645..f6c2a3f 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -31,7 +31,7 @@ class TestHelp(unittest.TestCase): @staticmethod def test_subcommand_help(): """Test running gbs help with all possible subcommands.""" - for sub in [ "build", "lb", "remotebuild", "rb", "changelog", "ch", + for sub in ["build", "lb", "remotebuild", "rb", "changelog", "ch", "submit", "sr", "export", "ex", "import", "im", "chroot", "chr"]: -- 2.34.1