[Python-modules-commits] [transifex-client] 02/09: Imported Upstream version 0.12.2

Hans-Christoph Steiner eighthave at moszumanska.debian.org
Thu Dec 22 14:38:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

eighthave pushed a commit to branch master
in repository transifex-client.

commit bf62302ec20854b650eeb20817ff664e7ac7a5d2
Author: Hans-Christoph Steiner <hans at eds.org>
Date:   Tue Sep 13 10:57:12 2016 +0200

    Imported Upstream version 0.12.2
---
 .gitignore                                         |   7 -
 DEVELOPMENT.rst                                    |  21 ---
 PKG-INFO                                           |  86 +++++++++++
 README.rst                                         |  17 +--
 appveyor.yml                                       |  75 ----------
 circle.yml                                         |  17 ---
 contrib/test_build.sh                              |   5 -
 contrib/test_win_build.sh                          |  11 --
 contrib/tx.ico                                     | Bin 24870 -> 0 bytes
 contrib/tx.spec                                    |  29 ----
 contrib/tx_commands.sh                             |  17 ---
 requirements.txt                                   |   1 +
 setup.cfg                                          |   5 +
 tests/test_utils.py                                | 163 +++++++++++++++++++++
 tox.ini                                            |  12 --
 transifex_client.egg-info/PKG-INFO                 |  86 +++++++++++
 transifex_client.egg-info/SOURCES.txt              |  32 ++++
 transifex_client.egg-info/dependency_links.txt     |   1 +
 transifex_client.egg-info/entry_points.txt         |   3 +
 transifex_client.egg-info/not-zip-safe             |   1 +
 .../requires.txt                                   |   1 +
 transifex_client.egg-info/top_level.txt            |   1 +
 txclib/__init__.py                                 |   2 +-
 txclib/cmdline.py                                  |   8 +
 txclib/commands.py                                 |   6 +-
 txclib/config.py                                   |   8 +-
 txclib/exceptions.py                               |  11 ++
 txclib/project.py                                  |  71 +++++----
 txclib/utils.py                                    | 110 +++++++++-----
 29 files changed, 535 insertions(+), 272 deletions(-)

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 508cc21..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-.tx
-*pyc
-*pyo
-*~
-*egg-info*
-/build
-/dist
diff --git a/DEVELOPMENT.rst b/DEVELOPMENT.rst
deleted file mode 100644
index 992e518..0000000
--- a/DEVELOPMENT.rst
+++ /dev/null
@@ -1,21 +0,0 @@
-Releasing
-=========
-
-To create a new release:
-
-1. Update local rep and update the version in ``setup.py``::
-
-    $ hg pull -u
-    $ vim setup.py
-
-2. Test::
-
-    $ python setup.py clean sdist
-    $ cd dist
-    $ tar zxf ...
-    $ cd transifex-client
-    ...test
-
-3. Package and upload on PyPI::
-
-    $ python setup.py clean sdist bdist_egg upload
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..20775a1
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,86 @@
+Metadata-Version: 1.1
+Name: transifex-client
+Version: 0.12.2
+Summary: A command line interface for Transifex
+Home-page: https://www.transifex.com
+Author: Transifex
+Author-email: admin at transifex.com
+License: GPLv2
+Description: .. image:: https://circleci.com/gh/transifex/transifex-client/tree/master.svg?style=shield&circle-token=33aafd984726261eff1b73278a0cf761382c478a
+            :target: https://circleci.com/gh/transifex/transifex-client/tree/master
+        .. image:: https://ci.appveyor.com/api/projects/status/github/transifex/transifex-client?branch=master&svg=true
+            :target: https://ci.appveyor.com/project/transifex/transifex-client/branch/master
+        .. image:: https://codecov.io/gh/transifex/transifex-client/branch/master/graph/badge.svg
+            :target: https://codecov.io/gh/transifex/transifex-client
+        
+        
+        
+        =============================
+         Transifex Command-Line Tool
+        =============================
+        
+        The Transifex Command-line Tool enables you to manage your translations within a project without the need of an elaborate UI system.
+        
+        You can use the command line tool to create new resources, map locale files to translations, and synchronize your Transifex project with your local repository. Translators and localization managers can use it to handle large volumes of translation files. The Transifex Command-line Tool can help to enable continuous integration workflows and can be run from CI servers like Jenkins and Bamboo.
+        
+        Check the full documentation at http://docs.transifex.com/client/
+        
+        Installing
+        ==========
+        
+        You can install the latest version of transifex-client running ``pip
+        install transifex-client`` or ``easy_install transifex-client``.
+        
+        
+        Build transifex-client for Windows
+        ==================================
+        
+        1. Download transifex-client sources via git or github archive.
+        
+           a. ``git clone https://github.com/transifex/transifex-client.git``
+           b. Download and unpack https://github.com/transifex/transifex-client/archive/master.zip
+        
+        2. Download and install Python_.
+        
+           At this step choose right version of python: 2 or 3 and x86 or x86-64 instruction set.
+        
+           Make sure pip marked for installation(default for latest installers).
+        
+        3. Install PyInstaller_.
+        
+           Suppose that Python installed to ``C:\\Program Files\\Python35-32``
+        
+           Make ``python.exe`` accessible via PATH environment variable or cd to directory containing python.exe.
+        
+           ::
+        
+             python -m pip install pyinstaller
+        
+           This command will install ``PyInstaller`` package and its dependencies.
+        
+        4. Build ``transifex-client`` distribution.
+        
+           Change directory to transifex-client folder and run command:
+        
+           ::
+        
+             python -m PyInstaller contrib/tx.spec
+             # or
+             pyinstaller contrib/tx.spec
+        
+        5. ``tx.exe``
+        
+           ``dist/tx.exe`` will be created as the result of build process.
+        
+        
+        .. _Python: https://www.python.org/downloads/windows/
+        .. _PyInstaller: http://www.pyinstaller.org
+        
+Keywords: translation,localization,internationalization
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.5
diff --git a/README.rst b/README.rst
index 60202b1..39188c1 100644
--- a/README.rst
+++ b/README.rst
@@ -2,25 +2,20 @@
     :target: https://circleci.com/gh/transifex/transifex-client/tree/master
 .. image:: https://ci.appveyor.com/api/projects/status/github/transifex/transifex-client?branch=master&svg=true
     :target: https://ci.appveyor.com/project/transifex/transifex-client/branch/master
+.. image:: https://codecov.io/gh/transifex/transifex-client/branch/master/graph/badge.svg
+    :target: https://codecov.io/gh/transifex/transifex-client
+
 
 
 =============================
  Transifex Command-Line Tool
 =============================
 
-The Transifex Command-line Client is a command line tool that enables
-you to easily manage your translations within a project without the need
-of an elaborate UI system.
-
-You can use the command line client to easily create new resources, map
-locale files to translations and synchronize your Transifex project with
-your local repository and vice verca. Translators and localization
-managers can also use it to handle large volumes of translation files
-easily and without much hassle.
+The Transifex Command-line Tool enables you to manage your translations within a project without the need of an elaborate UI system.
 
-Check the full documentation at
-http://docs.transifex.com/client/
+You can use the command line tool to create new resources, map locale files to translations, and synchronize your Transifex project with your local repository. Translators and localization managers can use it to handle large volumes of translation files. The Transifex Command-line Tool can help to enable continuous integration workflows and can be run from CI servers like Jenkins and Bamboo.
 
+Check the full documentation at http://docs.transifex.com/client/
 
 Installing
 ==========
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 1854a81..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-environment:
-  global:
-    # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
-    # /E:ON and /V:ON options are not enabled in the batch script intepreter
-    # See: http://stackoverflow.com/a/13751649/163740
-    CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
-
-  matrix:
-
-    - PYTHON: "C:\\Python27"
-      PYTHON_VERSION: "2.7.x"
-      PYTHON_ARCH: "32"
-
-    - PYTHON: "C:\\Python27-x64"
-      PYTHON_VERSION: "2.7.x"
-      PYTHON_ARCH: "64"
-
-    - PYTHON: "C:\\Python35"
-      PYTHON_VERSION: "3.5.x"
-      PYTHON_ARCH: "32"
-
-    - PYTHON: "C:\\Python35-x64"
-      PYTHON_VERSION: "3.5.x"
-      PYTHON_ARCH: "64"
-
-
-install:
-  - ECHO "Filesystem root:"
-  - ps: "ls \"C:/\""
-
-  # Prepend newly installed Python to the PATH of this build (this cannot be
-  # done from inside the powershell script as it would require to restart
-  # the parent CMD process).
-  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
-
-  # Check that we have the expected version and architecture for Python
-  - "python --version"
-  - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
-
-  # Upgrade to the latest version of pip to avoid it displaying warnings
-  # about it being out of date.
-  - "pip install --disable-pip-version-check --user --upgrade pip"
-  - "pip install pyinstaller"
-
-  # Set up the project in develop mode. If some dependencies contain
-  # compiled extensions and are not provided as pre-built wheel packages,
-  # pip will build them from source using the MSVC compiler matching the
-  # target Python version and architecture
-  - pip install -e .
-
-build_script:
-  # Build the compiled extension
-  #- "%CMD_IN_ENV% python setup.py build"
-  - pyinstaller contrib/tx.spec
-
-test_script:
-  # Run the project tests
-  #- "%CMD_IN_ENV% python setup.py nosetests"
-  - bash contrib/test_win_build.sh
-
-after_test:
-  # If tests are successful, create binary packages for the project.
-  #- "%CMD_IN_ENV% python setup.py bdist_wheel"
-  #- "%CMD_IN_ENV% python setup.py bdist_wininst"
-  #- "%CMD_IN_ENV% python setup.py bdist_msi"
-  - ps: "ls dist"
-
-artifacts:
-  # Archive the generated packages in the ci.appveyor.com build report.
-  - path: dist\*
-
-#on_success:
-#  - TODO: upload the content of dist/*.whl to a public wheelhouse
-#
-
diff --git a/circle.yml b/circle.yml
deleted file mode 100644
index adda24e..0000000
--- a/circle.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-machine:
-  environment:
-    TOX_PY27: '2.7.10'
-    TOX_PY35: '3.5.0'
-
-dependencies:
-  override:
-    - pip -V
-    - pip install -U pip
-    - pip install -U ipdb
-    - pip install -U tox
-    - pip install -U tox-pyenv
-    - pyenv local $TOX_PY27 $TOX_PY35
-
-test:
-  override:
-    - tox -v --recreate
diff --git a/contrib/test_build.sh b/contrib/test_build.sh
deleted file mode 100755
index 930ef33..0000000
--- a/contrib/test_build.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-BRANCH="linux_osx"
-TX=`which tx`
-echo $TX
-source "$DIR/tx_commands.sh"
diff --git a/contrib/test_win_build.sh b/contrib/test_win_build.sh
deleted file mode 100644
index 7520cdc..0000000
--- a/contrib/test_win_build.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-BRANCH="win-${PYTHON//C:\\/}"
-
-# Test the PyInstaller executable:
-TX="$DIR/../dist/tx.exe"
-source "$DIR/tx_commands.sh"
-
-# Test the Setuptools script:
-TX="tx"
-source "$DIR/tx_commands.sh"
-
diff --git a/contrib/tx.ico b/contrib/tx.ico
deleted file mode 100644
index ade1963..0000000
Binary files a/contrib/tx.ico and /dev/null differ
diff --git a/contrib/tx.spec b/contrib/tx.spec
deleted file mode 100644
index b743f1b..0000000
--- a/contrib/tx.spec
+++ /dev/null
@@ -1,29 +0,0 @@
-# -*- mode: python -*-
-
-block_cipher = None
-added_files = [
-    ('../txclib/cacert.pem', 'txclib'),
-]
-
-a = Analysis(['../txclib/cmdline.py'],
-             binaries=None,
-             datas=added_files,
-             hiddenimports=[],
-             hookspath=None,
-             runtime_hooks=None,
-             excludes=None,
-             win_no_prefer_redirects=None,
-             win_private_assemblies=None,
-             cipher=block_cipher)
-pyz = PYZ(a.pure, a.zipped_data,
-             cipher=block_cipher)
-exe = EXE(pyz,
-          a.scripts,
-          a.binaries,
-          a.zipfiles,
-          a.datas,
-          name='tx',
-          debug=False,
-          strip=None,
-          upx=False,
-          console=True , icon='contrib/tx.ico')
diff --git a/contrib/tx_commands.sh b/contrib/tx_commands.sh
deleted file mode 100644
index 0e0e9ce..0000000
--- a/contrib/tx_commands.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-if [[ -z "$TRANSIFEX_USER" ]] ; then
-	echo "NB: Skipping tests of $TX since TRANSIFEX_USER is undefined or empty"
-	exit 0
-fi
-
-# Exit on fail
-set -e
-
-rm -rf txci
-git clone https://github.com/diegobz/txci.git
-cd txci
-rm -rf .tx
-$TX init --host="https://www.transifex.com" --user=$TRANSIFEX_USER --pass=$TRANSIFEX_PASSWORD
-$TX set --auto-local -r txci.$BRANCH -s en 'locale/<lang>/LC_MESSAGES/django.po' -t PO --execute
-$TX --traceback push -s
-$TX --traceback pull -l pt_BR -f
-$TX --traceback delete -f
diff --git a/requirements.txt b/requirements.txt
index a42590b..71aa090 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
 urllib3
+six
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100755
index 0000000..33ad6ab
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,163 @@
+import unittest
+from mock import patch, MagicMock
+from urllib3.exceptions import SSLError
+
+from txclib import utils, exceptions
+
+
+class MakeRequestTestCase(unittest.TestCase):
+
+    @patch('urllib3.PoolManager')
+    def test_makes_request(self, mock_manager):
+        response_mock = MagicMock()
+        response_mock.status = 200
+        response_mock.data = 'test_data'
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_manager.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        utils.make_request(
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+        mock_manager.assert_called_once_with(num_pools=1)
+        mock_connection.request.assert_called_once()
+
+    @patch('urllib3.PoolManager')
+    @patch('txclib.utils.logger')
+    def test_catches_ssl_error(self, mock_logger, mock_manager):
+        mock_connection = MagicMock()
+        mock_connection.request.side_effect = SSLError('Boom!')
+        mock_manager.return_value = mock_connection
+
+        host = 'https://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        self.assertRaises(
+            SSLError,
+            utils.make_request,
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+        mock_logger.error.assert_called_once_with("Invalid SSL certificate")
+
+    @patch('txclib.utils.determine_charset')
+    @patch('urllib3.PoolManager')
+    def test_makes_request_skip_decode(self, mock_conn, mock_determine):
+        response_mock = MagicMock()
+        response_mock.status = 200
+        response_mock.data = 'test_data'
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_conn.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        utils.make_request(
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass',
+            skip_decode=True
+        )
+        mock_conn.assert_called_once_with(num_pools=1)
+        mock_connection.request.assert_called_once()
+        mock_determine.assert_not_called()
+
+    @patch('urllib3.PoolManager')
+    def test_makes_request_404(self, mock_manager):
+        response_mock = MagicMock()
+        response_mock.status = 404
+        response_mock.data = 'test_data'
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_manager.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        self.assertRaises(
+            exceptions.HttpNotFound,
+            utils.make_request,
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+
+    @patch('urllib3.PoolManager')
+    def test_makes_request_403(self, mock_manager):
+        response_mock = MagicMock()
+        response_mock.status = 403
+        response_mock.data = 'test_data'
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_manager.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        self.assertRaises(
+            Exception,
+            utils.make_request,
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+
+    @patch('urllib3.PoolManager')
+    def test_makes_request_401(self, mock_manager):
+        response_mock = MagicMock()
+        response_mock.status = 401
+        response_mock.data = 'test_data'
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_manager.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        self.assertRaises(
+            exceptions.HttpNotAuthorized,
+            utils.make_request,
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+
+    @patch('urllib3.PoolManager')
+    def test_makes_request_None(self, mock_manager):
+        response_mock = MagicMock()
+        response_mock.status = 200
+        response_mock.data = None
+
+        mock_connection = MagicMock()
+        mock_connection.request.return_value = response_mock
+        mock_manager.return_value = mock_connection
+
+        host = 'http://whynotestsforthisstuff.com'
+        url = '/my_test_url/'
+        utils.make_request(
+            'GET',
+            host,
+            url,
+            'a_user',
+            'a_pass'
+        )
+        mock_manager.assert_called_once_with(num_pools=1)
+        mock_connection.request.assert_called_once()
diff --git a/tox.ini b/tox.ini
deleted file mode 100644
index d0ef5f8..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-[tox]
-envlist = py27,py35
-
-[testenv]
-whitelist_externals = source
-                      bash
-install_command = pip install -U {opts} {packages}
-setenv = TOX_ENV_NAME={envname}
-passenv = TOX_* TRANSIFEX_USER TRANSIFEX_PASSWORD CI_* APPVEYOR_*
-commands = python -V
-           python setup.py test
-           bash ./contrib/test_build.sh
diff --git a/transifex_client.egg-info/PKG-INFO b/transifex_client.egg-info/PKG-INFO
new file mode 100644
index 0000000..20775a1
--- /dev/null
+++ b/transifex_client.egg-info/PKG-INFO
@@ -0,0 +1,86 @@
+Metadata-Version: 1.1
+Name: transifex-client
+Version: 0.12.2
+Summary: A command line interface for Transifex
+Home-page: https://www.transifex.com
+Author: Transifex
+Author-email: admin at transifex.com
+License: GPLv2
+Description: .. image:: https://circleci.com/gh/transifex/transifex-client/tree/master.svg?style=shield&circle-token=33aafd984726261eff1b73278a0cf761382c478a
+            :target: https://circleci.com/gh/transifex/transifex-client/tree/master
+        .. image:: https://ci.appveyor.com/api/projects/status/github/transifex/transifex-client?branch=master&svg=true
+            :target: https://ci.appveyor.com/project/transifex/transifex-client/branch/master
+        .. image:: https://codecov.io/gh/transifex/transifex-client/branch/master/graph/badge.svg
+            :target: https://codecov.io/gh/transifex/transifex-client
+        
+        
+        
+        =============================
+         Transifex Command-Line Tool
+        =============================
+        
+        The Transifex Command-line Tool enables you to manage your translations within a project without the need of an elaborate UI system.
+        
+        You can use the command line tool to create new resources, map locale files to translations, and synchronize your Transifex project with your local repository. Translators and localization managers can use it to handle large volumes of translation files. The Transifex Command-line Tool can help to enable continuous integration workflows and can be run from CI servers like Jenkins and Bamboo.
+        
+        Check the full documentation at http://docs.transifex.com/client/
+        
+        Installing
+        ==========
+        
+        You can install the latest version of transifex-client running ``pip
+        install transifex-client`` or ``easy_install transifex-client``.
+        
+        
+        Build transifex-client for Windows
+        ==================================
+        
+        1. Download transifex-client sources via git or github archive.
+        
+           a. ``git clone https://github.com/transifex/transifex-client.git``
+           b. Download and unpack https://github.com/transifex/transifex-client/archive/master.zip
+        
+        2. Download and install Python_.
+        
+           At this step choose right version of python: 2 or 3 and x86 or x86-64 instruction set.
+        
+           Make sure pip marked for installation(default for latest installers).
+        
+        3. Install PyInstaller_.
+        
+           Suppose that Python installed to ``C:\\Program Files\\Python35-32``
+        
+           Make ``python.exe`` accessible via PATH environment variable or cd to directory containing python.exe.
+        
+           ::
+        
+             python -m pip install pyinstaller
+        
+           This command will install ``PyInstaller`` package and its dependencies.
+        
+        4. Build ``transifex-client`` distribution.
+        
+           Change directory to transifex-client folder and run command:
+        
+           ::
+        
+             python -m PyInstaller contrib/tx.spec
+             # or
+             pyinstaller contrib/tx.spec
+        
+        5. ``tx.exe``
+        
+           ``dist/tx.exe`` will be created as the result of build process.
+        
+        
+        .. _Python: https://www.python.org/downloads/windows/
+        .. _PyInstaller: http://www.pyinstaller.org
+        
+Keywords: translation,localization,internationalization
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.5
diff --git a/transifex_client.egg-info/SOURCES.txt b/transifex_client.egg-info/SOURCES.txt
new file mode 100644
index 0000000..fc9876b
--- /dev/null
+++ b/transifex_client.egg-info/SOURCES.txt
@@ -0,0 +1,32 @@
+LICENSE
+MANIFEST.in
+README.rst
+requirements.txt
+setup.py
+tests/__init__.py
+tests/test_paths.py
+tests/test_processors.py
+tests/test_project.py
+tests/test_utils.py
+transifex_client.egg-info/PKG-INFO
+transifex_client.egg-info/SOURCES.txt
+transifex_client.egg-info/dependency_links.txt
+transifex_client.egg-info/entry_points.txt
+transifex_client.egg-info/not-zip-safe
+transifex_client.egg-info/requires.txt
+transifex_client.egg-info/top_level.txt
+txclib/__init__.py
+txclib/__main__.py
+txclib/cacert.pem
+txclib/cmdline.py
+txclib/commands.py
+txclib/config.py
+txclib/exceptions.py
+txclib/log.py
+txclib/parsers.py
+txclib/paths.py
+txclib/processors.py
+txclib/project.py
+txclib/urls.py
+txclib/utils.py
+txclib/web.py
\ No newline at end of file
diff --git a/transifex_client.egg-info/dependency_links.txt b/transifex_client.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/transifex_client.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/transifex_client.egg-info/entry_points.txt b/transifex_client.egg-info/entry_points.txt
new file mode 100644
index 0000000..ddca8fb
--- /dev/null
+++ b/transifex_client.egg-info/entry_points.txt
@@ -0,0 +1,3 @@
+[console_scripts]
+tx = txclib.cmdline:main
+
diff --git a/transifex_client.egg-info/not-zip-safe b/transifex_client.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/transifex_client.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/requirements.txt b/transifex_client.egg-info/requires.txt
similarity index 66%
copy from requirements.txt
copy to transifex_client.egg-info/requires.txt
index a42590b..71aa090 100644
--- a/requirements.txt
+++ b/transifex_client.egg-info/requires.txt
@@ -1 +1,2 @@
 urllib3
+six
diff --git a/transifex_client.egg-info/top_level.txt b/transifex_client.egg-info/top_level.txt
new file mode 100644
index 0000000..5561019
--- /dev/null
+++ b/transifex_client.egg-info/top_level.txt
@@ -0,0 +1 @@
+txclib
diff --git a/txclib/__init__.py b/txclib/__init__.py
index 7926bec..d5a6ece 100644
--- a/txclib/__init__.py
+++ b/txclib/__init__.py
@@ -1,4 +1,4 @@
 # -*- coding: utf-8 -*-
 
 # https://www.python.org/dev/peps/pep-0440/#examples-of-compliant-version-schemes
-__version__ = '0.11'
+__version__ = '0.12.2'
diff --git a/txclib/cmdline.py b/txclib/cmdline.py
index 7eba1b7..71c2d19 100755
--- a/txclib/cmdline.py
+++ b/txclib/cmdline.py
@@ -11,6 +11,14 @@ from txclib import utils
 from txclib.log import set_log_level, logger
 
 
+# use pyOpenSSL if available
+try:
+    import urllib3.contrib.pyopenssl
+    urllib3.contrib.pyopenssl.inject_into_urllib3()
+except ImportError:
+    pass
+
+
 # This block ensures that ^C interrupts are handled quietly.
 try:
     import signal
diff --git a/txclib/commands.py b/txclib/commands.py
index 122ecca..b99928e 100644
--- a/txclib/commands.py
+++ b/txclib/commands.py
@@ -25,7 +25,7 @@ try:
 except ImportError:
     import ConfigParser as configparser
 
-from urllib3.packages.six.moves import input
+from six.moves import input
 
 from txclib import utils, project
 from txclib.utils import parse_json, compile_json, files_in_project
@@ -278,7 +278,7 @@ def _auto_remote(path_to_tx, url):
     prj = project.Project(path_to_tx)
     username, password = prj.getset_host_credentials(vars['hostname'])
 
-    if type == 'project':
+    if type.startswith('project'):
         logger.info("Getting details for project %s" % vars['project'])
         proj_info = utils.get_details(
             'project_details',
@@ -303,7 +303,7 @@ def _auto_remote(path_to_tx, url):
             else:
                 resources.append('.'.join([vars['project'], r['slug']]))
         logger.info("%s resources found. Configuring..." % len(resources))
-    elif type == 'resource':
+    elif type.startswith('resource'):
         logger.info("Getting details for resource %s" % vars['resource'])
         resources = ['.'.join([vars['project'], vars['resource']])]
     else:
diff --git a/txclib/config.py b/txclib/config.py
index f37f0a6..bda8b9d 100644
--- a/txclib/config.py
+++ b/txclib/config.py
@@ -3,7 +3,7 @@ try:
 except ImportError:
     import ConfigParser as configparser
 
-from urllib3.packages import six
+import six
 
 
 class OrderedRawConfigParser(configparser.RawConfigParser):
@@ -118,3 +118,9 @@ class Flipdict(dict):
     def clear(self):
         dict.clear(self)
         dict.clear(self._flip)
+
+
+import os
+import ssl
+
+CERT_REQUIRED = getattr(ssl, os.environ.get('TX_CERT_MODE', 'CERT_REQUIRED'))
diff --git a/txclib/exceptions.py b/txclib/exceptions.py
index 8766a01..375a109 100644
--- a/txclib/exceptions.py
+++ b/txclib/exceptions.py
@@ -11,3 +11,14 @@ class UnInitializedError(Exception):
 
 class UnknownCommandError(Exception):
     """The provided command is not supported."""
+
+
+# HTTP exceptions
+
+
+class HttpNotFound(Exception):
+    pass
+
+
+class HttpNotAuthorized(Exception):
+    pass
diff --git a/txclib/project.py b/txclib/project.py
index 0961abf..c71d1af 100644
--- a/txclib/project.py
+++ b/txclib/project.py
@@ -6,9 +6,9 @@ import re
 import fnmatch
 import datetime
 import time
-import ssl
 import sys
 import urllib3
+import six
 
 try:
     import configparser
@@ -18,14 +18,16 @@ except ImportError:
 from txclib import web
 from txclib import utils
 from urllib3.exceptions import SSLError
-from urllib3.packages import six
+from six.moves import input
 from txclib.urls import API_URLS
-from txclib.config import OrderedRawConfigParser, Flipdict
+from txclib.config import OrderedRawConfigParser, Flipdict, CERT_REQUIRED
 from txclib.log import logger
 from txclib.processors import visit_hostname
 from txclib.paths import posix_path, native_path, posix_sep
 
 
+
+
 class ProjectNotInit(Exception):
     pass
 
@@ -35,6 +37,9 @@ class Project(object):
     remote project instances.
     """
 
+    SKIP_DECODE_I18N_TYPES = ['DOCX', 'XLSX']
+    FILE_FILTER = "translations<sep>%(proj)s.%(res)s<sep><lang>.%(extension)s"
+
     def __init__(self, path_to_tx=None, init=True):
         """Initialize the Project attributes."""
         if init:
@@ -60,7 +65,7 @@ class Project(object):
         if host.lower().startswith('https://'):
             self.conn = urllib3.connection_from_url(
                 host,
-                cert_reqs=ssl.CERT_REQUIRED,
+                cert_reqs=CERT_REQUIRED,
                 ca_certs=web.certs_file()
             )
         else:
@@ -174,9 +179,11 @@ class Project(object):
         return username, passwd
 
     def set_remote_resource(self, resource, source_lang, i18n_type, host,
-                            file_filter="translations<sep>%(proj)s.%(res)s<sep>\
-                            <lang>.%(extension)s"):
+                            file_filter=None):
         """Method to handle the add/conf of a remote resource."""
+        if file_filter is None:
+            file_filter = self.FILE_FILTER
+
         if not self.config.has_section(resource):
             self.config.add_section(resource)
 
@@ -377,6 +384,7 @@ class Project(object):
         """Pull all translations file from transifex server."""
         self.minimum_perc = minimum_perc
         resource_list = self.get_chosen_resources(resources)
+        skip_decode = False
 
         if mode == 'reviewed':
             url = 'pull_reviewed_file'
@@ -411,7 +419,10 @@ class Project(object):
             logger.debug("URL data are: %s" % self.url_info)
 
             stats = self._get_stats_for_resource()
-
+            details_response, _ = self.do_url_request('resource_details')
+            details = utils.parse_json(details_response)
+            if details['i18n_type'] in self.SKIP_DECODE_I18N_TYPES:
+                skip_decode = True
             try:
                 file_filter = self.config.get(resource, 'file_filter')
             except configparser.NoOptionError:
@@ -500,18 +511,16 @@ class Project(object):
                                     local_file)
                 )
                 try:
-                    r, charset = self.do_url_request(url, language=remote_lang)
+                    r, charset = self.do_url_request(
+                        url, language=remote_lang, skip_decode=skip_decode
+                    )
                 except Exception as e:
                     if isinstance(e, SSLError) or not skip:
                         raise
                     else:
                         logger.error(e)
                         continue
-                base_dir = os.path.split(local_file)[0]
-                utils.mkdir_p(base_dir)
-                fd = open(local_file, 'wb')
-                fd.write(r.encode(charset))
-                fd.close()
+                self._save_file(local_file, charset, r)
 
             if new_translations:
                 msg = "Pulling new translations for resource %s (source: %s)"
@@ -552,12 +561,10 @@ class Project(object):
                                         local_file)
                     )
 
-                    r, charset = self.do_url_request(url, language=remote_lang)
-                    base_dir = os.path.split(local_file)[0]
-                    utils.mkdir_p(base_dir)
-                    fd = open(local_file, 'wb')
-                    fd.write(r.encode(charset))
-                    fd.close()
+                    r, charset = self.do_url_request(
+                        url, language=remote_lang, skip_decode=skip_decode
+                    )
... 286 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/transifex-client.git



More information about the Python-modules-commits mailing list