From 621e401afd8b5aeb5cd98c06d3d813aceaa069f8 Mon Sep 17 00:00:00 2001 From: Li Jinjing Date: Mon, 22 Dec 2014 18:38:13 +0800 Subject: [PATCH] Fix bad indentation from pylint checking Fix Conflicts: gitbuildsys/cmd_build.py Change-Id: If2fd77167e37d029de392b88c755878c285e3b0d Signed-off-by: Li Jinjing Signed-off-by: Dai Lang --- gitbuildsys/cmd_build.py | 43 ++++++++++++----------- gitbuildsys/cmd_changelog.py | 4 +-- gitbuildsys/cmd_devel.py | 4 +-- gitbuildsys/cmd_export.py | 24 ++++++------- gitbuildsys/cmd_import.py | 2 +- gitbuildsys/cmd_remotebuild.py | 30 ++++++++-------- gitbuildsys/cmd_submit.py | 16 ++++----- gitbuildsys/conf.py | 62 +++++++++++++++++----------------- gitbuildsys/log.py | 4 +-- gitbuildsys/oscapi.py | 9 ++--- gitbuildsys/utils.py | 18 +++++----- tests/test_changelog.py | 2 +- tests/test_config.py | 2 +- tests/test_help.py | 4 +-- tests/test_passwdx.py | 2 +- 15 files changed, 114 insertions(+), 112 deletions(-) diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index 767a30f..b6ed9c8 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -39,26 +39,26 @@ from gbp.errors import GbpError CHANGE_PERSONALITY = { - 'ia32': 'linux32', - 'i686': 'linux32', - 'i586': 'linux32', - 'i386': 'linux32', - 'ppc': 'powerpc32', - 's390': 's390', - 'sparc': 'linux32', - 'sparcv8': 'linux32', - } + 'ia32': 'linux32', + 'i686': 'linux32', + 'i586': 'linux32', + 'i386': 'linux32', + 'ppc': 'powerpc32', + 's390': 's390', + 'sparc': 'linux32', + 'sparcv8': 'linux32', + } SUPPORTEDARCHS = [ - 'x86_64', - 'i586', - 'armv6l', - 'armv7hl', - 'armv7l', - 'aarch64', - 'mips', - 'mipsel', - ] + 'x86_64', + 'i586', + 'armv6l', + 'armv7hl', + 'armv7l', + 'aarch64', + 'mips', + 'mipsel', + ] USERID = pwd.getpwuid(os.getuid())[0] TMPDIR = None @@ -89,7 +89,7 @@ def get_binary_name_from_git(args, package_dirs): for package_dir in package_dirs: main_spec, rest_specs = guess_spec(package_dir, packaging_dir, - None, commit) + None, commit) rest_specs.append(main_spec) for spec in rest_specs: if args.include_all: @@ -98,7 +98,7 @@ def get_binary_name_from_git(args, package_dirs): content = show_file_from_rev(package_dir, spec, commit) if content is None: raise GbsError('failed to checkout %s from commit: %s' % - (spec, commit)) + (spec, commit)) tmp_spec = Temp(content=content) spec_to_parse = tmp_spec.path @@ -115,7 +115,7 @@ def prepare_repos_and_build_conf(args, arch, profile): cmd_opts = [] cache = Temp(prefix=os.path.join(TMPDIR, 'gbscache'), - directory=True) + directory=True) cachedir = cache.path if not os.path.exists(cachedir): os.makedirs(cachedir) @@ -261,7 +261,6 @@ def get_profile(args): profile = configmgr.get_current_profile() return profile - def main(args): """gbs build entry point.""" diff --git a/gitbuildsys/cmd_changelog.py b/gitbuildsys/cmd_changelog.py index ab8f80f..0aae547 100644 --- a/gitbuildsys/cmd_changelog.py +++ b/gitbuildsys/cmd_changelog.py @@ -47,7 +47,7 @@ def main(args): fn_changes = changes_file_list[0] if len(changes_file_list) > 1: log.warning("Found more than one changes files, %s is taken " - % (changes_file_list[0])) + % (changes_file_list[0])) else: fn_changes = 'CHANGES' @@ -61,7 +61,7 @@ def main(args): '--spec-file=%s' % specfile, '--changelog-file=%s' % fn_changes, '--editor-cmd=%s' % get_editor_cmd(), - ] + ] if args.since: gbp_args.append('--since=%s' % args.since) if args.all: diff --git a/gitbuildsys/cmd_devel.py b/gitbuildsys/cmd_devel.py index db5c5d7..ba63e67 100644 --- a/gitbuildsys/cmd_devel.py +++ b/gitbuildsys/cmd_devel.py @@ -87,7 +87,7 @@ def main(args): raise GbsError(str(err)) tmp = Temp(prefix='gbp_', dirn=configmgr.get('tmpdir', 'general'), - directory=True) + directory=True) packaging_dir = get_packaging_dir(args) # Guess spec from correct branch @@ -121,7 +121,7 @@ def main(args): ret = gbp_pq_rpm(gbp_args + ['convert']) if not ret: log.info("You can now create the development branch with " - "'gbs devel start'") + "'gbs devel start'") if ret: raise GbsError('Action failed!') diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 5e4f478..c4b866b 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -178,9 +178,9 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args, argv.extend(["--git-patch-export", "--git-patch-export-compress=100k", "--git-patch-export-squash-until=%s" % - squash_patches_until, + squash_patches_until, "--git-patch-export-ignore-path=^(%s/.*|.gbs.conf)" % - packaging_dir, + packaging_dir, ]) if orphan_packaging: @@ -202,7 +202,7 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args, '--git-rpmbuild-srpmdir=.', '--git-rpmbuild-buildrootdir=.', '--short-circuit', '-bs', - ]) + ]) else: argv.extend(["--git-builder=osc", "--git-export-only"]) @@ -213,7 +213,7 @@ def export_sources(repo, commit, export_dir, spec, args, create_tarball=True): Export packaging files using git-buildpackage """ tmp = utils.Temp(prefix='gbp_', dirn=configmgr.get('tmpdir', 'general'), - directory=True) + directory=True) gbp_args = create_gbp_export_args(repo, commit, export_dir, tmp.path, spec, args, force_native=False, @@ -292,7 +292,7 @@ def main(args): mkdir_p(outdir) tmpdir = configmgr.get('tmpdir', 'general') - tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), \ + tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), directory=True) export_dir = tempd.path @@ -304,14 +304,14 @@ def main(args): if rest_specs: # backup updated spec file specbakd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), - directory=True) - shutil.copy(os.path.join(export_dir, - os.path.basename(main_spec)), specbakd.path) + directory=True) + shutil.copy(os.path.join(export_dir, os.path.basename(main_spec)), + specbakd.path) for spec in rest_specs: export_sources(repo, commit, export_dir, spec, args, create_tarball=False) - shutil.copy(os.path.join(export_dir, - os.path.basename(spec)), specbakd.path) + shutil.copy(os.path.join(export_dir, os.path.basename(spec)), + specbakd.path) # restore updated spec files for spec in glob.glob(os.path.join(specbakd.path, "*.spec")): shutil.copy(spec, export_dir) @@ -338,7 +338,7 @@ def main(args): shutil.move(export_dir, outdir) if args.source_rpm: - log.info('source rpm generated to:\n %s/%s.src.rpm' % \ - (outdir, os.path.basename(outdir))) + log.info('source rpm generated to:\n %s/%s.src.rpm' % + (outdir, os.path.basename(outdir))) log.info('package files have been exported to:\n %s' % outdir) diff --git a/gitbuildsys/cmd_import.py b/gitbuildsys/cmd_import.py index 6bf19b4..6bfcb2d 100644 --- a/gitbuildsys/cmd_import.py +++ b/gitbuildsys/cmd_import.py @@ -55,7 +55,7 @@ def main(args): "--upstream-branch=%s" % upstream_branch, path, "--upstream-tag=%s" % upstream_tag, "--tmp-dir=%s" % tmp.path, - ] + ] if args.debug: params.append("--verbose") if not args.no_pristine_tar and os.path.exists("/usr/bin/pristine-tar"): diff --git a/gitbuildsys/cmd_remotebuild.py b/gitbuildsys/cmd_remotebuild.py index 61e8e68..0d612e1 100644 --- a/gitbuildsys/cmd_remotebuild.py +++ b/gitbuildsys/cmd_remotebuild.py @@ -61,12 +61,12 @@ def main(args): apiurl = obsconf.url if not apiurl.user: - raise GbsError('empty user is not allowed for remotebuild, please '\ + raise GbsError('empty user is not allowed for remotebuild, please ' 'add user/passwd to gbs conf, and try again') if args.commit and args.include_all: raise Usage('--commit can\'t be specified together with ' - '--include-all') + '--include-all') obs_repo = args.repository obs_arch = args.arch @@ -106,7 +106,7 @@ def main(args): content = utils.show_file_from_rev(workdir, relative_spec, commit) if content is None: raise GbsError('failed to checkout %s from commit: %s' % - (relative_spec, commit)) + (relative_spec, commit)) tmp_spec = utils.Temp(content=content) spec_to_parse = tmp_spec.path @@ -139,13 +139,12 @@ def main(args): api_passwd = apiurl.passwd if apiurl.passwd else '' # Create temporary oscrc - oscrc = OSCRC_TEMPLATE % { - "http_debug": 1 if log.level == DEBUG else 0, - "debug": 1 if log.level == DEBUG else 0, - "apiurl": apiurl, - "user": apiurl.user, - "passwdx": encode_passwd(api_passwd), - } + oscrc = OSCRC_TEMPLATE % {"http_debug": 1 if log.level == DEBUG else 0, + "debug": 1 if log.level == DEBUG else 0, + "apiurl": apiurl, + "user": apiurl.user, + "passwdx": encode_passwd(api_passwd), + } tmpdir = configmgr.get('tmpdir', 'general') tmpd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_remotebuild_'), @@ -175,7 +174,7 @@ def main(args): 'no build log.' % (package, obs_repo, obs_arch, status[obs_repo][obs_arch])) log.info('build log for %s/%s/%s/%s' % (target_prj, package, - obs_repo, obs_arch)) + obs_repo, obs_arch)) print api.get_buildlog(target_prj, package, obs_repo, obs_arch) return 0 @@ -236,7 +235,7 @@ def main(args): api.rebuild(target_prj, package, obs_arch) else: log.warning("no local changes found. can't trigger rebuild " - "as no available build repos found") + "as no available build repos found") return 0 else: log.info('commit packaging files to build server ...') @@ -245,10 +244,11 @@ def main(args): api.commit_files(target_prj, package, commit_files, commit_msg) except ObsError as exc: raise GbsError('commit packages fail: %s, please check the ' - 'permission of target project:%s' % (exc, target_prj)) + 'permission of target project:%s' % + (exc, target_prj)) log.info('local changes submitted to build server successfully') log.info('follow the link to monitor the build progress:\n' - ' %s/package/show?package=%s&project=%s' \ - % (apiurl.replace('api', 'build'), package, target_prj)) + '%s/package/show?package=%s&project=%s' + % (apiurl.replace('api', 'build'), package, target_prj)) diff --git a/gitbuildsys/cmd_submit.py b/gitbuildsys/cmd_submit.py index 75940e1..7e27424 100644 --- a/gitbuildsys/cmd_submit.py +++ b/gitbuildsys/cmd_submit.py @@ -35,11 +35,10 @@ def _lookup_submit_template(): user and system settings location """ - lookup_paths = ( - '.gbs/templates/submit_message', - '~/.gbs/templates/submit_message', - '/etc/gbs/templates/submit_message') - + lookup_paths = ('.gbs/templates/submit_message', + '~/.gbs/templates/submit_message', + '/etc/gbs/templates/submit_message', + ) for path in lookup_paths: abs_path = os.path.abspath(os.path.expanduser(path)) @@ -78,8 +77,9 @@ def main(args): orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel') if orphan_packaging and args.commit == 'HEAD': log.error("You seem to be submitting a development branch of an " - "(orphan) packaging branch. Please export your changes to the " - "packaging branch with 'gbs devel export' and submit from there.") + "(orphan) packaging branch. Please export your changes to" + "the packaging branch with 'gbs devel export' and submit" + "from there.") raise GbsError("Refusing to submit from devel branch") message = args.msg @@ -106,7 +106,7 @@ def main(args): args.remote = upstream.split('/')[0] else: log.info("no upstream set for the current branch, using " - "'origin' as the remote server") + "'origin' as the remote server") args.remote = 'origin' diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index a63fce6..c790597 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -164,7 +164,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) @@ -172,23 +172,20 @@ class ConfigMgr(object): '''Support multi-levels of gbs.conf. Use this class to get and set item value without caring about concrete ini format''' - DEFAULTS = { - 'general': { - 'tmpdir': '/var/tmp', - 'editor': '', - 'packaging_branch': 'master', - 'upstream_branch': 'upstream', - 'upstream_tag': 'upstream/${upstreamversion}', - 'squash_patches_until': '', - 'buildroot': '~/GBS-ROOT/', - 'packaging_dir': 'packaging', - 'work_dir': '.', - 'fallback_to_native': '', - }, - 'orphan-devel': { - 'packaging_branch': '', - }, - } + DEFAULTS = {'general': {'tmpdir': '/var/tmp', + 'editor': '', + 'packaging_branch': 'master', + 'upstream_branch': 'upstream', + 'upstream_tag': 'upstream/${upstreamversion}', + 'squash_patches_until': '', + 'buildroot': '~/GBS-ROOT/', + 'packaging_dir': 'packaging', + 'work_dir': '.', + 'fallback_to_native': '', + }, + 'orphan-devel': {'packaging_branch': '', + }, + } DEFAULT_CONF_TEMPLATE = '''[general] #Current profile name which should match a profile section name @@ -366,9 +363,9 @@ url = http://download.tizen.org/releases/daily/trunk/ivi/latest/ # empty string password is acceptable here continue cfgparser.set_into_file(sec, - key + 'x', - encode_passwd(plainpass), - key) + key + 'x', + encode_passwd(plainpass), + key) dirty.add(cfgparser) if dirty: @@ -590,8 +587,8 @@ class BizConfigManager(ConfigMgr): raise errors.ConfigError(err) log.warning('subcommand oriented style of config is deprecated. ' - 'Please check %s, a new profile oriented style of config which' - ' was converted from your current settings.' % fname) + 'Please check %s, a new profile oriented style of config ' + ' which was converted from your current settings.' % fname) def get_optional_item(self, section, option, default=None): '''return default if section.option does not exist''' @@ -610,8 +607,9 @@ class BizConfigManager(ConfigMgr): def build_profile_by_name(self, name): '''return profile object by a given section''' if not name.startswith('profile.'): - raise errors.ConfigError('section name specified by general.profile' - ' must start with string "profile.": %s' % name) + raise errors.ConfigError('section name specified by ' + ' general.profile must start with string' + ' "profile.": %s' % name) if not self.has_section(name): raise errors.ConfigError('no such section: %s' % name) @@ -648,13 +646,12 @@ class BizConfigManager(ConfigMgr): profile.buildroot = self.get_optional_item(name, 'buildroot') if self.get_optional_item(name, 'buildconf'): profile.buildconf = os.path.expanduser(self._interpolate( - self.get_optional_item(name, - 'buildconf'))) + self.get_optional_item(name, 'buildconf'))) if self.get_optional_item(name, 'exclude_packages'): exclude_val = self.get_optional_item(name, 'exclude_packages') for pkg in exclude_val.split(','): if pkg.strip(): - profile.exclude_packages.append(pkg.strip()); + profile.exclude_packages.append(pkg.strip()) return profile @@ -705,9 +702,12 @@ class BizConfigManager(ConfigMgr): password = self.get_optional_item(sec, 'passwd') url = URL(addr, user, password) - obsconf = SectionConf(profile, 'obs.%s' % sec, url, - self.get_optional_item('remotebuild', 'base_prj'), - self.get_optional_item('remotebuild', 'target_prj')) + obsconf = SectionConf(profile, + 'obs.%s' % sec, url, + self.get_optional_item('remotebuild', + 'base_prj'), + self.get_optional_item('remotebuild', + 'target_prj')) profile.set_obs(obsconf) repos = self._parse_build_repos() diff --git a/gitbuildsys/log.py b/gitbuildsys/log.py index 3332b16..8d683be 100644 --- a/gitbuildsys/log.py +++ b/gitbuildsys/log.py @@ -63,8 +63,8 @@ def setup(verbose, debug=False): # Change logging level names to lower case for level in (DEBUG, INFO, WARNING, ERROR): - gbp.log.logging.addLevelName(level, - gbp.log.logging.getLevelName(level).lower()) + gbp.log.logging.addLevelName(level, \ + gbp.log.logging.getLevelName(level).lower()) # Set verbosity verbose = verbose or debug if verbose: diff --git a/gitbuildsys/oscapi.py b/gitbuildsys/oscapi.py index 41cd6b1..0342717 100644 --- a/gitbuildsys/oscapi.py +++ b/gitbuildsys/oscapi.py @@ -152,9 +152,10 @@ class OSC(object): meta += "\n" else: logger.warning('no project repos in target project, please add ' - 'repos from OBS webUI manually, or specify base project ' - 'with -B , then gbs can help to set repos ' - 'using the settings of the specified base project.') + 'repos from OBS webUI manually, or specify base ' + 'project with -B , then gbs can help to ' + 'set repos using the settings of the specified ' + 'base project.') meta += "\n" try: @@ -325,7 +326,7 @@ class OSC(object): # This regular expression is created for parsing the # results of of core.get_results() stat_re = re.compile(r'^(?P\S+)\s+(?P\S+)\s+' - '(?P\S*)$') + '(?P\S*)$') for res in build_status: match = stat_re.match(res) if match: diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index 3814038..262293a 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -67,8 +67,8 @@ def guess_spec(git_path, packaging_dir, given_spec, 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( - git_path, fname)) - glob_ = lambda pattern: [name.replace(git_path+'/', '') + git_path, fname)) + 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: @@ -83,8 +83,10 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): 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, - fname, commit_id, dir_only=dir_only) + 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 @@ -251,7 +253,7 @@ class URLGrabber(object): 'NO_PROXY', 'no_proxy']: 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, + "proxy settings, please check. %s" % (curl.url, \ '\n '.join(proxies))) elif errcode == pycurl.E_ABORTED_BY_CALLBACK: raise KeyboardInterrupt(err) @@ -389,7 +391,7 @@ class RepoParser(object): 'buildconf' not in meta or \ not meta['buildconf']: log.warning("No build.conf in build.xml " - "of repo: %s" % latest_repo_url) + "of repo: %s" % latest_repo_url) return buildconf_url = latest_repo_url.pathjoin('builddata/%s' % @@ -577,10 +579,10 @@ def git_status_checker(git, opts): if not is_clean and opts.include_all: if untracked_files: log.info('the following untracked files would be included' - ':\n %s' % '\n '.join(untracked_files)) + ':\n %s' % '\n '.join(untracked_files)) if uncommitted_files: log.info('the following uncommitted changes would be included' - ':\n %s' % '\n '.join(uncommitted_files)) + ':\n %s' % '\n '.join(uncommitted_files)) def hexdigest(fhandle, block_size=4096): """Calculate hexdigest of file content.""" diff --git a/tests/test_changelog.py b/tests/test_changelog.py index 51922bb..ea97063 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -35,7 +35,7 @@ from gitbuildsys.errors import GbsError GBS = imp.load_source("gbs", "./tools/gbs").main ENV = {} -TEST_SPEC_CONTENT=""" +TEST_SPEC_CONTENT = """ Name: test Version: 1.0 Release: 0 diff --git a/tests/test_config.py b/tests/test_config.py index 701717e..f897ce7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -43,7 +43,7 @@ class Fixture(object): self.fake_files = {self.ETC: etc, self.HOME: home, self.PROJECT: project, - } + } self.real_exists = os.path.exists self.real_abspath = os.path.abspath diff --git a/tests/test_help.py b/tests/test_help.py index f6c2a3f..1d53b22 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -32,8 +32,8 @@ class TestHelp(unittest.TestCase): def test_subcommand_help(): """Test running gbs help with all possible subcommands.""" for sub in ["build", "lb", "remotebuild", "rb", "changelog", "ch", - "submit", "sr", "export", "ex", "import", "im", - "chroot", "chr"]: + "submit", "sr", "export", "ex", "import", "im", + "chroot", "chr"]: try: print '>>>sub', sub diff --git a/tests/test_passwdx.py b/tests/test_passwdx.py index 152f864..42d4cd4 100644 --- a/tests/test_passwdx.py +++ b/tests/test_passwdx.py @@ -170,4 +170,4 @@ class AutoGenerateTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() -- 2.34.1