Skip to content

Commit

Permalink
restore py2.7 alongwith py3
Browse files Browse the repository at this point in the history
  • Loading branch information
sdp5 committed Mar 7, 2019
1 parent 0aecec9 commit 14ec45a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,5 +1,6 @@
language: python
python:
- "2.7"
- "3.5"
- "3.6"
# command to install dependencies
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -18,6 +18,11 @@ clean:
python setup.py clean
rm -f zanataclient/VERSION-FILE

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

run:
python zanata help

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
@@ -1,3 +1,4 @@
future
httplib2
lxml
polib
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -65,6 +65,7 @@ def get_client_version():
'License :: OSI Approved :: GNU Lesser General Public License (LGPL)',
'Operating System :: Unix',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
Expand Down
12 changes: 9 additions & 3 deletions zanataclient/context.py
Expand Up @@ -224,7 +224,7 @@ def _update_locale_mapping(self):
locale_map = self.process_locales(locales)
self.remote_config.update({'locale_map': locale_map})

def _update_project_type(self):
def update_project_type(self):
"""
This fetches project_type from server
"""
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_remote_configs(self):
"""
context_remote_configs = {
'default': [self._update_server_version, self._update_locale_mapping,
self._update_project_type],
self.update_project_type],
'init': [],
}
return context_remote_configs[self.mode]
Expand All @@ -287,12 +287,18 @@ def get_context_data(self):
"""
updates context_data with remote_config, local_config and command_dict
"""

def merge_dicts(i, j):
z = i.copy()
z.update(j)
return z

build_configs = [self.build_local_config,
self.build_remote_config]
[method() for method in build_configs]
# lowest to highest
precedence = [self.remote_config, self.local_config, self.command_dict]
context_data = functools.reduce(lambda option, value: {**option, **value}, precedence)
context_data = functools.reduce(lambda option, value: merge_dicts(option, value), precedence)
return self.filter_context_data(context_data)

def filter_context_data(self, data):
Expand Down
22 changes: 11 additions & 11 deletions zanataclient/initcmd.py
Expand Up @@ -23,19 +23,19 @@
import fnmatch
import os
import sys
from datetime import datetime

from .cmdbase import CommandsBase, CommandsInit
from .context import ContextBase
from .parseconfig import ZanataConfig
from .zanatalib.logger import Logger, TextColour
from .zanatalib.projectutils import ToolBox


try:
from collections import OrderedDict
from builtins import input
except ImportError:
from ordereddict import OrderedDict
from __builtin__ import input
from collections import OrderedDict
from datetime import datetime

from zanataclient.cmdbase import CommandsBase, CommandsInit
from zanataclient.context import ContextBase
from zanataclient.parseconfig import ZanataConfig
from zanataclient.zanatalib.logger import Logger, TextColour
from zanataclient.zanatalib.projectutils import ToolBox


log = Logger()
Expand Down Expand Up @@ -64,7 +64,7 @@ def get_init_stages(self):
self._update_user_config, self._update_http_headers,
self._update_client_version, self.check_config_exists,
self.set_zanata_command, self.project_options,
self.version_options, self._update_project_type,
self.version_options, self.update_project_type,
self.post_project_version, self.source_target_dirs,
self.dump_project_config, self.whats_next]
}
Expand Down
2 changes: 1 addition & 1 deletion zanataclient/zanatalib/rest/config.py
Expand Up @@ -27,7 +27,7 @@
http_methods = ('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH', 'OPTIONS')
media_types = ('application/json', 'application/vnd.zanata.projects+json', 'application/vnd.zanata.Version+json',
'application/vnd.zanata.project.iteration+json', 'application/vnd.zanata.glossary+json',
'application/vnd.zanata.project.locales+json', 'application/xml')
'application/vnd.zanata.project.locales+json', 'application/xml', 'application/json;charset=ISO-8859-1')

# based on https://zanata.ci.cloudbees.com/job/zanata-api-site/site/zanata-common-api/rest-api-docs/index.html
# please add, modify resource details here, and make entry in service-to-resource mappings and in zpc_services
Expand Down
2 changes: 2 additions & 0 deletions zanataclient/zanatalib/service.py
Expand Up @@ -73,6 +73,8 @@ def messages(self, res, content, extra_msg=None):
sys.exit(1)
else:
print("Exception while decoding: %s" % e)
if isinstance(content, str):
print(content)
return rst
elif res['status'] == '201':
return True
Expand Down

0 comments on commit 14ec45a

Please sign in to comment.