Skip to content

Commit ad3bf0c

Browse files
authored
Merge pull request #52 from sundeep-co-in/master
ZNTA-2791: Port Zanata Python client to Python 3
2 parents 1b23b9d + 14d64e9 commit ad3bf0c

27 files changed

+113
-115
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
language: python
2+
dist: xenial
23
python:
3-
- "2.6"
44
- "2.7"
5+
- "3.5"
6+
- "3.6"
7+
- "3.7"
58
# command to install dependencies
69
install: "pip install -r requirements-dev.txt"
710
# command to run tests

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Fri Mar 08 2019 Sundeep Anand <[email protected]> - 1.5.3
2+
- ZNTA-2791 - Port Zanata Python client to Python 3
3+
14
* Mon Apr 16 2018 Sundeep Anand <[email protected]> - 1.5.2
25
- ZNTA-1390 - Python client fuzzies my strings
36
- ZNTA-1382 - Should "--push-trans-only" be deprecated in the python client?

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ clean:
1818
python setup.py clean
1919
rm -f zanataclient/VERSION-FILE
2020

21+
clean-pyc:
22+
find . -name '*.pyc' -exec rm -f {} +
23+
find . -name '*.pyo' -exec rm -f {} +
24+
find . -name '*~' -exec rm -f {} +
25+
2126
run:
2227
python zanata help
2328

@@ -28,7 +33,7 @@ lint-report:
2833
pylint --reports=n zanata zanataclient
2934

3035
flake8:
31-
flake8 --ignore=E501,F403,F841,F401 zanataclient
36+
flake8 --ignore=E402,E501,F403,F841,F401 zanataclient
3237

3338
test:
3439
(cd zanataclient/test; nosetests ${NOSE_FLAGS} test_all.py)

requirements-dev.txt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
-r requirements.txt
2-
coverage==4.0.3
3-
flake8==2.4.1
4-
flake8-import-order==0.6.1
5-
funcsigs==0.4
6-
linecache2==1.0.0
7-
mccabe==0.3.1
8-
MiniMock==1.2.8
9-
mock==1.3.0
10-
nose==1.3.7
11-
pbr==1.8.1
12-
pep8==1.5.7
13-
pyflakes==0.8.1
14-
six==1.10.0
15-
traceback2==1.4.0
16-
unittest2==1.1.0
2+
coverage
3+
flake8<3.8
4+
flake8-import-order
5+
mock
6+
nose
7+
unittest2

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
future
12
httplib2
23
lxml
3-
ordereddict
44
polib

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_client_version():
1818
path = os.path.dirname(os.path.realpath(__file__))
1919
version_file = os.path.join(path, 'zanataclient', 'VERSION-FILE')
2020
try:
21-
version = open(version_file, 'rb')
21+
version = open(version_file, 'r')
2222
client_version = version.read()
2323
version.close()
2424
version_number = client_version.rstrip().strip('version: ')
@@ -65,7 +65,9 @@ def get_client_version():
6565
'License :: OSI Approved :: GNU Lesser General Public License (LGPL)',
6666
'Operating System :: Unix',
6767
'Programming Language :: Python',
68-
'Programming Language :: Python :: 2.6',
6968
'Programming Language :: Python :: 2.7',
69+
'Programming Language :: Python :: 3.5',
70+
'Programming Language :: Python :: 3.6',
71+
'Programming Language :: Python :: 3.7',
7072
],
7173
)

zanataclient/VERSION-FILE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 1.5.2
1+
version: 1.5.3

zanataclient/cmdbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def check_plural_support(self, server_version):
428428

429429
version = str(server_version.split('-')[0])
430430
main_ver = version[:3]
431-
version_number = string.atof(main_ver)
431+
version_number = float(main_ver)
432432

433433
if version_number >= 1.6:
434434
return True

zanataclient/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def handle_program(
323323
path = os.path.dirname(os.path.realpath(__file__))
324324
version_file = os.path.join(path, 'VERSION-FILE')
325325
try:
326-
version = open(version_file, 'rb')
326+
version = open(version_file, 'r')
327327
client_version = version.read()
328328
version.close()
329329
version_number = client_version.rstrip().strip('version: ')

zanataclient/context.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _update_client_version(self):
164164
version_file = os.path.join(path, client_version_file)
165165

166166
try:
167-
version = open(version_file, 'rb')
167+
version = open(version_file, 'r')
168168
client_version = version.read()
169169
version.close()
170170
version_number = client_version.rstrip()[len('version: '):]
@@ -224,7 +224,7 @@ def _update_locale_mapping(self):
224224
locale_map = self.process_locales(locales)
225225
self.remote_config.update({'locale_map': locale_map})
226226

227-
def _update_project_type(self):
227+
def update_project_type(self):
228228
"""
229229
This fetches project_type from server
230230
"""
@@ -271,7 +271,7 @@ def get_remote_configs(self):
271271
"""
272272
context_remote_configs = {
273273
'default': [self._update_server_version, self._update_locale_mapping,
274-
self._update_project_type],
274+
self.update_project_type],
275275
'init': [],
276276
}
277277
return context_remote_configs[self.mode]
@@ -287,14 +287,18 @@ def get_context_data(self):
287287
"""
288288
updates context_data with remote_config, local_config and command_dict
289289
"""
290+
291+
def merge_dicts(i, j):
292+
z = i.copy()
293+
z.update(j)
294+
return z
295+
290296
build_configs = [self.build_local_config,
291297
self.build_remote_config]
292298
[method() for method in build_configs]
293-
# lowest to higest
299+
# lowest to highest
294300
precedence = [self.remote_config, self.local_config, self.command_dict]
295-
context_data = functools.reduce(
296-
lambda option, value: dict(option.items() + value.items()), precedence
297-
)
301+
context_data = functools.reduce(lambda option, value: merge_dicts(option, value), precedence)
298302
return self.filter_context_data(context_data)
299303

300304
def filter_context_data(self, data):

0 commit comments

Comments
 (0)