summaryrefslogtreecommitdiff
path: root/gitlab/utils.py
diff options
context:
space:
mode:
authorJoost Evertse <joustie@gmail.com>2019-01-21 13:36:56 +0100
committerGitHub <noreply@github.com>2019-01-21 13:36:56 +0100
commitb51d2969ad34a9aad79e42a69f275caf2a4059cb (patch)
treea4519d935a0b5ae5361cb178318402e09da17d75 /gitlab/utils.py
parent53f7de7bfe0056950a8e7271632da3f89e3ba3b3 (diff)
parent52d76312660109d3669d459b11b448a3a60b9603 (diff)
downloadgitlab-b51d2969ad34a9aad79e42a69f275caf2a4059cb.tar.gz
Merge branch 'master' into master
Diffstat (limited to 'gitlab/utils.py')
-rw-r--r--gitlab/utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gitlab/utils.py b/gitlab/utils.py
index a449f81..49e2c88 100644
--- a/gitlab/utils.py
+++ b/gitlab/utils.py
@@ -15,6 +15,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import six
+
class _StdoutStream(object):
def __call__(self, chunk):
@@ -31,3 +33,21 @@ def response_content(response, streamed, action, chunk_size):
for chunk in response.iter_content(chunk_size=chunk_size):
if chunk:
action(chunk)
+
+
+def copy_dict(dest, src):
+ for k, v in src.items():
+ if isinstance(v, dict):
+ # Transform dict values to new attributes. For example:
+ # custom_attributes: {'foo', 'bar'} =>
+ # "custom_attributes['foo']": "bar"
+ for dict_k, dict_v in v.items():
+ dest['%s[%s]' % (k, dict_k)] = dict_v
+ else:
+ dest[k] = v
+
+
+def sanitized_url(url):
+ parsed = six.moves.urllib.parse.urlparse(url)
+ new_path = parsed.path.replace('.', '%2E')
+ return parsed._replace(path=new_path).geturl()