Skip to content

Commit d014537

Browse files
author
Gabriel Monroy
committed
chore(utils): move encode to api/utils module
1 parent 99f0152 commit d014537

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

controller/api/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ def fingerprint(key):
108108
return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2]))
109109

110110

111+
def encode(obj):
112+
"""Return UTF-8 encoding for string objects."""
113+
if isinstance(obj, basestring):
114+
return obj.encode('utf-8')
115+
else:
116+
return obj
117+
118+
111119
if __name__ == "__main__":
112120
import doctest
113121
doctest.testmod()

controller/registry/private.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import urlparse
77
import uuid
88

9+
from django.conf import settings
910
from docker.utils import utils
1011

11-
from django.conf import settings
12+
from api.utils import encode
1213

1314

1415
def publish_release(source, config, target):
@@ -158,14 +159,6 @@ def _put_tag(image_id, repository_path, tag):
158159

159160
# utility functions
160161

161-
def encode(obj):
162-
"""Return UTF-8 encoding for string objects."""
163-
if isinstance(obj, basestring):
164-
return obj.encode('utf-8')
165-
else:
166-
return obj
167-
168-
169162
def _construct_env(env, config):
170163
"Update current environment with latest config"
171164
new_env = []

0 commit comments

Comments
 (0)