summaryrefslogtreecommitdiff
path: root/morphlib/util.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-09-23 18:14:08 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-09-24 11:24:36 +0000
commita751e4fc1ab7b00ae70f12f498d2050a5fb71445 (patch)
tree94bd038495f06a46ade459f72face80bf5ff7392 /morphlib/util.py
parentf9c02205608356b4c57611509b574e3874d243a9 (diff)
downloadmorph-a751e4fc1ab7b00ae70f12f498d2050a5fb71445.tar.gz
Allow Morph code to be run with Python 2.7 and Python 3.4sam/python3
PRETTY BROKEN! Change-Id: I92545c821103eea1316383086e77e6b654f2321c
Diffstat (limited to 'morphlib/util.py')
-rw-r--r--morphlib/util.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index 284fe305..bdc39c68 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -60,8 +60,6 @@ def indent(string, spaces=4):
'''
- if type(string) == unicode: # pragma: no cover
- string = string.decode('utf-8')
lines = string.splitlines()
lines = ['%*s%s' % (spaces, '', line) for line in lines]
return '\n'.join(lines)
@@ -203,7 +201,7 @@ def combine_aliases(app): # pragma: no cover
'Invalid repo-alias: %s' % repo_alias)
- return alias_map.values()
+ return list(alias_map.values())
def new_repo_caches(app): # pragma: no cover
'''Create new objects for local, remote git repository caches.'''
@@ -230,11 +228,11 @@ def env_variable_is_password(key): # pragma: no cover
@contextlib.contextmanager
def hide_password_environment_variables(env): # pragma: no cover
is_password = env_variable_is_password
- password_env = { k:v for k,v in env.iteritems() if is_password(k) }
+ password_env = { k:v for k,v in env.items() if is_password(k) }
for k in password_env:
env[k] = '(value hidden)'
yield
- for k, v in password_env.iteritems():
+ for k, v in password_env.items():
env[k] = v
def log_environment_changes(app, current_env, previous_env): # pragma: no cover
@@ -670,7 +668,7 @@ def write_from_dict(filepath, d, validate=lambda x, y: True): #pragma: no cover
# Sort items asciibetically
# the output of the deployment should not depend
# on the locale of the machine running the deployment
- items = sorted(d.iteritems(), key=lambda (k, v): [ord(c) for c in v])
+ items = sorted(d.items(), key=lambda k_v: [ord(c) for c in k_v[1]])
for (k, v) in items:
validate(k, v)
@@ -680,7 +678,7 @@ def write_from_dict(filepath, d, validate=lambda x, y: True): #pragma: no cover
f.write('%s\n' % v)
os.fchown(f.fileno(), 0, 0)
- os.fchmod(f.fileno(), 0644)
+ os.fchmod(f.fileno(), 0o644)
def word_join_list(l): # pragma: no cover