Skip to content

Commit

Permalink
Fix pep8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurmudgeon committed Mar 13, 2016
1 parent 6c56563 commit dc23f7c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions ybd/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ybd/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion ybd/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])


Expand Down
11 changes: 6 additions & 5 deletions ybd/splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ybd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down

0 comments on commit dc23f7c

Please sign in to comment.