[Python-modules-commits] [wlc] 02/04: Imported Upstream version 0.5

Michal Cihar nijel at moszumanska.debian.org
Mon Jul 11 09:59:03 UTC 2016


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

nijel pushed a commit to branch master
in repository wlc.

commit 90880fc6d81799d21e64ebfc8a13fec107324b5f
Author: Michal Čihař <michal at cihar.com>
Date:   Mon Jul 11 11:10:15 2016 +0200

    Imported Upstream version 0.5
---
 PKG-INFO                                           |   2 +-
 wlc.egg-info/PKG-INFO                              |   2 +-
 wlc.egg-info/SOURCES.txt                           |   6 +++
 wlc/__init__.py                                    |  23 +++++++-
 wlc/main.py                                        |  58 ++++++++++++++++++++-
 wlc/test_base.py                                   |   1 +
 ...components-hello-weblate-lock--POST--lock=0.swp | Bin 0 -> 12288 bytes
 ...components-hello-weblate-lock--POST--lock=1.swp | Bin 0 -> 12288 bytes
 .../api/.components-hello-weblate-lock.swp         | Bin 0 -> 12288 bytes
 wlc/test_data/api/components-hello-weblate-lock    |   3 ++
 .../components-hello-weblate-lock--POST--lock=0    |   4 ++
 .../components-hello-weblate-lock--POST--lock=1    |   4 ++
 wlc/test_main.py                                   |  15 ++++++
 wlc/test_wlc.py                                    |  21 ++++++++
 14 files changed, 134 insertions(+), 5 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index a79b657..724a126 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: wlc
-Version: 0.4
+Version: 0.5
 Summary: A command line utility for Weblate, translation tool with tight version control integration
 Home-page: https://weblate.org/
 Author: Michal Čihař
diff --git a/wlc.egg-info/PKG-INFO b/wlc.egg-info/PKG-INFO
index a79b657..724a126 100644
--- a/wlc.egg-info/PKG-INFO
+++ b/wlc.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: wlc
-Version: 0.4
+Version: 0.5
 Summary: A command line utility for Weblate, translation tool with tight version control integration
 Home-page: https://weblate.org/
 Author: Michal Čihař
diff --git a/wlc.egg-info/SOURCES.txt b/wlc.egg-info/SOURCES.txt
index bd8c97e..4f50660 100644
--- a/wlc.egg-info/SOURCES.txt
+++ b/wlc.egg-info/SOURCES.txt
@@ -19,9 +19,15 @@ wlc.egg-info/top_level.txt
 wlc/test_data/.weblate
 wlc/test_data/section
 wlc/test_data/wlc
+wlc/test_data/api/.components-hello-weblate-lock--POST--lock=0.swp
+wlc/test_data/api/.components-hello-weblate-lock--POST--lock=1.swp
+wlc/test_data/api/.components-hello-weblate-lock.swp
 wlc/test_data/api/components
 wlc/test_data/api/components-hello-android
 wlc/test_data/api/components-hello-weblate
+wlc/test_data/api/components-hello-weblate-lock
+wlc/test_data/api/components-hello-weblate-lock--POST--lock=0
+wlc/test_data/api/components-hello-weblate-lock--POST--lock=1
 wlc/test_data/api/components-hello-weblate-repository
 wlc/test_data/api/components-hello-weblate-repository--POST--operation=commit
 wlc/test_data/api/components-hello-weblate-repository--POST--operation=pull
diff --git a/wlc/__init__.py b/wlc/__init__.py
index acbcbcb..2f02dd1 100644
--- a/wlc/__init__.py
+++ b/wlc/__init__.py
@@ -24,7 +24,7 @@ from urllib.parse import urlencode
 
 import json
 
-__version__ = '0.4'
+__version__ = '0.5'
 
 URL = 'https://weblate.org/'
 DEVEL_URL = 'https://github.com/WeblateOrg/wlc'
@@ -321,6 +321,27 @@ class Component(LazyObject, RepoObjectMixin):
             self._attribs['statistics_url'], Statistics
         )
 
+    def _get_lock_url(self):
+        self.ensure_loaded('lock_url')
+        return self._attribs['lock_url']
+
+    def lock(self):
+        return self.weblate.post(
+            self._get_lock_url(),
+            lock=1
+        )
+
+    def unlock(self):
+        return self.weblate.post(
+            self._get_lock_url(),
+            lock=0
+        )
+
+    def lock_status(self):
+        return self.weblate.get(
+            self._get_lock_url(),
+        )
+
 
 class Translation(LazyObject, RepoObjectMixin):
     """Translation object"""
diff --git a/wlc/main.py b/wlc/main.py
index 8b30fb9..e569615 100644
--- a/wlc/main.py
+++ b/wlc/main.py
@@ -227,7 +227,7 @@ class Command(object):
 
     def run(self):
         """Main execution of the command."""
-        raise NotImplementedError
+        raise NotImplementedError()
 
 
 class ObjectCommand(Command):
@@ -264,7 +264,7 @@ class ObjectCommand(Command):
 
     def run(self):
         """Main execution of the command."""
-        raise NotImplementedError
+        raise NotImplementedError()
 
 
 @register_command
@@ -469,6 +469,60 @@ class StatsObject(ObjectCommand):
             self.print(obj.statistics())
 
 
+class ComponentCommand(ObjectCommand):
+    """Wrapper to allow only component objects"""
+    def get_object(self):
+        obj = super(ComponentCommand, self).get_object()
+        if not isinstance(obj, wlc.Component):
+            raise CommandError('Not supported')
+        return obj
+
+
+ at register_command
+class LockStatusObject(ComponentCommand):
+    """Shows lock status"""
+
+    name = 'lock-status'
+    description = (
+        "Shows component lock status"
+    )
+
+    def run(self):
+        """Executor"""
+        obj = self.get_object()
+        self.print(obj.lock_status())
+
+
+ at register_command
+class LockObject(ComponentCommand):
+    """Locks component for transaltion"""
+
+    name = 'lock'
+    description = (
+        "Locks componets from translations"
+    )
+
+    def run(self):
+        """Executor"""
+        obj = self.get_object()
+        obj.lock()
+
+
+ at register_command
+class UnlockObject(ComponentCommand):
+    """Unocks component for transaltion"""
+
+    name = 'unlock'
+    description = (
+        "Unlocks componets from translations"
+    )
+
+    def run(self):
+        """Executor"""
+        obj = self.get_object()
+        obj.unlock()
+
+
 def main(settings=None, stdout=None, args=None):
     """Execution entry point."""
     parser = get_parser()
diff --git a/wlc/test_base.py b/wlc/test_base.py
index 5213c77..bb53a05 100644
--- a/wlc/test_base.py
+++ b/wlc/test_base.py
@@ -93,6 +93,7 @@ def register_uris():
         'translations/hello/weblate/cs/statistics',
         'projects/hello/components',
         'components/hello/weblate/translations',
+        'components/hello/weblate/lock',
         'languages',
     )
     for path in paths:
diff --git a/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=0.swp b/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=0.swp
new file mode 100644
index 0000000..2b1c879
Binary files /dev/null and b/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=0.swp differ
diff --git a/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=1.swp b/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=1.swp
new file mode 100644
index 0000000..0990660
Binary files /dev/null and b/wlc/test_data/api/.components-hello-weblate-lock--POST--lock=1.swp differ
diff --git a/wlc/test_data/api/.components-hello-weblate-lock.swp b/wlc/test_data/api/.components-hello-weblate-lock.swp
new file mode 100644
index 0000000..a8af8b8
Binary files /dev/null and b/wlc/test_data/api/.components-hello-weblate-lock.swp differ
diff --git a/wlc/test_data/api/components-hello-weblate-lock b/wlc/test_data/api/components-hello-weblate-lock
new file mode 100644
index 0000000..8f73e5d
--- /dev/null
+++ b/wlc/test_data/api/components-hello-weblate-lock
@@ -0,0 +1,3 @@
+{
+    "locked": false
+}
diff --git a/wlc/test_data/api/components-hello-weblate-lock--POST--lock=0 b/wlc/test_data/api/components-hello-weblate-lock--POST--lock=0
new file mode 100644
index 0000000..1958fa0
--- /dev/null
+++ b/wlc/test_data/api/components-hello-weblate-lock--POST--lock=0
@@ -0,0 +1,4 @@
+{
+    "locked": false
+}
+
diff --git a/wlc/test_data/api/components-hello-weblate-lock--POST--lock=1 b/wlc/test_data/api/components-hello-weblate-lock--POST--lock=1
new file mode 100644
index 0000000..29db817
--- /dev/null
+++ b/wlc/test_data/api/components-hello-weblate-lock--POST--lock=1
@@ -0,0 +1,4 @@
+{
+    "locked": true
+}
+
diff --git a/wlc/test_main.py b/wlc/test_main.py
index 8abbd1b..7a5be8b 100644
--- a/wlc/test_main.py
+++ b/wlc/test_main.py
@@ -289,3 +289,18 @@ class TestCommands(APITest):
 
         output = execute(['stats', 'hello/weblate/cs'])
         self.assertIn('failing_percent', output)
+
+    def test_locks(self):
+        """Project locks."""
+        output = execute(['lock-status', 'hello'], expected=1)
+        self.assertIn('Not supported', output)
+
+        output = execute(['lock-status', 'hello/weblate'])
+        self.assertIn('locked', output)
+        output = execute(['lock', 'hello/weblate'])
+        self.assertEqual('', output)
+        output = execute(['unlock', 'hello/weblate'])
+        self.assertEqual('', output)
+
+        output = execute(['lock-status', 'hello/weblate/cs'], expected=1)
+        self.assertIn('Not supported', output)
diff --git a/wlc/test_wlc.py b/wlc/test_wlc.py
index 9fba17e..b7d2bb3 100644
--- a/wlc/test_wlc.py
+++ b/wlc/test_wlc.py
@@ -199,6 +199,27 @@ class ComponentTest(ObjectTest, APITest):
         obj = self.get()
         self.assertEqual(33, len(list(obj.statistics())))
 
+    def test_lock_status(self):
+        obj = self.get()
+        self.assertEqual(
+            {'locked': False},
+            obj.lock_status()
+        )
+
+    def test_lock(self):
+        obj = self.get()
+        self.assertEqual(
+            {'locked': True},
+            obj.lock()
+        )
+
+    def test_unlock(self):
+        obj = self.get()
+        self.assertEqual(
+            {'locked': False},
+            obj.unlock()
+        )
+
 
 class TranslationTest(ObjectTest, APITest):
     _name = 'hello/weblate/cs'

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



More information about the Python-modules-commits mailing list