From dc23f7c4b50ef33ad1e847b27fd4118f9fe578cf Mon Sep 17 00:00:00 2001 From: Paul Sherwood Date: Sun, 13 Mar 2016 21:30:55 +0000 Subject: [PATCH] Fix pep8 issues --- ybd/assembly.py | 1 + ybd/cache.py | 2 +- ybd/repos.py | 4 +++- ybd/splitting.py | 11 ++++++----- ybd/utils.py | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ybd/assembly.py b/ybd/assembly.py index 31b37de..c7054b2 100644 --- a/ybd/assembly.py +++ b/ybd/assembly.py @@ -165,6 +165,7 @@ def shuffle(contents): def lockfile(defs, this): return os.path.join(app.config['tmp'], cache_key(defs, this) + '.lock') + @contextlib.contextmanager def claim(defs, this): with open(lockfile(defs, this), 'a') as l: diff --git a/ybd/cache.py b/ybd/cache.py index 77157d2..ffd063d 100644 --- a/ybd/cache.py +++ b/ybd/cache.py @@ -301,7 +301,7 @@ def clear(deleted, artifact_dir): path = os.path.join(artifact_dir, artifact) if os.path.exists(os.path.join(path, artifact + '.unpacked')): path = os.path.join(path, artifact + '.unpacked') - if os.path.exists(path) and not artifact in app.config['keys']: + if os.path.exists(path) and artifact not in app.config['keys']: tmpdir = tempfile.mkdtemp() shutil.move(path, os.path.join(tmpdir, 'to-delete')) app.remove_dir(tmpdir) diff --git a/ybd/repos.py b/ybd/repos.py index ca47289..7abf668 100644 --- a/ybd/repos.py +++ b/ybd/repos.py @@ -51,8 +51,10 @@ def get_repo_name(repo): NOTE: this naming scheme is based on what lorry uses ''' + def transl(x): + return x if x in valid_chars else '_' + valid_chars = string.digits + string.ascii_letters + '%_' - transl = lambda x: x if x in valid_chars else '_' return ''.join([transl(x) for x in get_repo_url(repo)]) diff --git a/ybd/splitting.py b/ybd/splitting.py index 1bd0a3a..72bb1aa 100644 --- a/ybd/splitting.py +++ b/ybd/splitting.py @@ -49,8 +49,8 @@ def install_stratum_artifacts(defs, component, stratum, artifacts): split_stratum_metadata['products'].append(product) if app.config.get('log-verbose'): - app.log(component, 'Installing artifacts: ' + str(artifacts) - + ' components: ' + str(components)) + app.log(component, 'Installing artifacts: ' + str(artifacts) + + ' components: ' + str(components)) baserockpath = os.path.join(component['sandbox'], 'baserock') if not os.path.isdir(baserockpath): @@ -130,9 +130,9 @@ def compile_rules(defs, component): 'chunk')) for rules in split_rules, default_rules: for rule in rules: - regexp = re.compile('^(?:' - + '|'.join(rule.get('include')) - + ')$') + regexp = re.compile('^(?:' + + '|'.join(rule.get('include')) + + ')$') artifact = rule.get('artifact') if artifact.startswith('-'): artifact = component['name'] + artifact @@ -141,6 +141,7 @@ def compile_rules(defs, component): return regexps, splits + def write_chunk_metafile(defs, chunk): '''Writes a chunk .meta file to the baserock dir of the chunk diff --git a/ybd/utils.py b/ybd/utils.py index 9392b80..85617ce 100644 --- a/ybd/utils.py +++ b/ybd/utils.py @@ -291,7 +291,8 @@ def find_extensions(): def sorted_ls(path): - mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime + def mtime(f): + return os.stat(os.path.join(path, f)).st_mtime return list(sorted(os.listdir(path), key=mtime))