| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,7 @@ | |||
| 1 | + Version 0.4 | ||
| 2 | + | ||
| 3 | + * Fix strings encoding (Closes #6) | ||
| 4 | + | ||
| 1 | 5 | Version 0.3 | |
| 2 | 6 | ||
| 3 | 7 | * Use PRIVATE-TOKEN header for passing the auth token | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | import json | |
| 20 | 20 | import requests | |
| 21 | + import sys | ||
| 21 | 22 | ||
| 22 | 23 | __title__ = 'python-gitlab' | |
| 23 | 24 | __version__ = '0.3' | |
@@ -298,8 +299,10 @@ def update(self, obj): | |||
| 298 | 299 | # build a dict of data that can really be sent to server | |
| 299 | 300 | d = {} | |
| 300 | 301 | for k, v in obj.__dict__.items(): | |
| 301 | - if type(v) in (int, str, unicode, bool): | ||
| 302 | + if type(v) in (int, str, bool): | ||
| 302 | 303 | d[k] = str(v) | |
| 304 | + elif type(v) == unicode: | ||
| 305 | + d[k] = str(v.encode(sys.stdout.encoding, "replace")) | ||
| 303 | 306 | ||
| 304 | 307 | try: | |
| 305 | 308 | r = requests.put(url, d, headers=self.headers, verify=self.ssl_verify) | |
@@ -520,6 +523,8 @@ def _obj_to_str(obj): | |||
| 520 | 523 | elif isinstance(obj, list): | |
| 521 | 524 | s = ", ".join([GitlabObject._obj_to_str(x) for x in obj]) | |
| 522 | 525 | return "[ %s ]" %s | |
| 526 | + elif isinstance(obj, unicode): | ||
| 527 | + return obj.encode(sys.stdout.encoding, "replace") | ||
| 523 | 528 | else: | |
| 524 | 529 | return str(obj) | |
| 525 | 530 | ||
@@ -530,7 +535,7 @@ def pretty_print(self, depth=0): | |||
| 530 | 535 | if k == self.idAttr: | |
| 531 | 536 | continue | |
| 532 | 537 | v = self.__dict__[k] | |
| 533 | - pretty_k = k.replace('_', '-') | ||
| 538 | + pretty_k = k.replace('_', '-').encode(sys.stdout.encoding, "replace") | ||
| 534 | 539 | if isinstance(v, GitlabObject): | |
| 535 | 540 | if depth == 0: | |
| 536 | 541 | print("%s:" % pretty_k) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments