Hello community,

here is the log from the commit of package python-clikit for openSUSE:Factory 
checked in at 2019-12-02 11:27:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-clikit (Old)
 and      /work/SRC/openSUSE:Factory/.python-clikit.new.4691 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-clikit"

Mon Dec  2 11:27:19 2019 rev:3 rq:751628 version:0.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-clikit/python-clikit.changes      
2019-10-10 11:53:12.403359222 +0200
+++ /work/SRC/openSUSE:Factory/.python-clikit.new.4691/python-clikit.changes    
2019-12-02 11:28:48.562630428 +0100
@@ -1,0 +2,7 @@
+Thu Nov 28 15:05:12 CET 2019 - Matej Cepl <[email protected]>
+
+- Update to 0.4.0:
+  - Changed the way event names are stored and exposed.
+  - Fixed parsing of options after a -- token.
+
+-------------------------------------------------------------------

Old:
----
  clikit-0.3.2.tar.gz

New:
----
  clikit-0.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-clikit.spec ++++++
--- /var/tmp/diff_new_pack.SpjwMX/_old  2019-12-02 11:28:50.018629754 +0100
+++ /var/tmp/diff_new_pack.SpjwMX/_new  2019-12-02 11:28:50.018629754 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-clikit
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-clikit
-Version:        0.3.2
+Version:        0.4.0
 Release:        0
 Summary:        Helper to build testable command line interfaces
 License:        MIT

++++++ clikit-0.3.2.tar.gz -> clikit-0.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/.github/workflows/push.yml 
new/clikit-0.4.0/.github/workflows/push.yml
--- old/clikit-0.3.2/.github/workflows/push.yml 2019-09-20 15:59:56.000000000 
+0200
+++ new/clikit-0.4.0/.github/workflows/push.yml 2019-10-25 14:22:57.000000000 
+0200
@@ -1,4 +1,4 @@
-name: Push
+name: Tests
 
 on: [push, pull_request]
 
@@ -82,16 +82,15 @@
       with:
         python-version: ${{ matrix.python-version }}
     - name: Install Poetry
-      shell: pwsh
       run: |
         Invoke-WebRequest 
https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -O 
get-poetry.py
         python get-poetry.py --preview -y
         $env:Path += ";$env:Userprofile\.poetry\bin"
     - name: Install dependencies
       run: |
-        SET PATH=%USERPROFILE%\\.poetry\\bin;%PATH%
+        $env:Path += ";$env:Userprofile\.poetry\bin"
         poetry install
     - name: Test
       run: |
-        SET PATH=%USERPROFILE%\\.poetry\\bin;%PATH%
+        $env:Path += ";$env:Userprofile\.poetry\bin"
         poetry run pytest -q tests
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/.gitignore new/clikit-0.4.0/.gitignore
--- old/clikit-0.3.2/.gitignore 2019-09-20 15:59:56.000000000 +0200
+++ new/clikit-0.4.0/.gitignore 2019-10-25 14:22:57.000000000 +0200
@@ -23,3 +23,5 @@
 /test
 poetry.lock
 .pytest_cache
+pip-wheel-metadata
+setup.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/CHANGELOG.md 
new/clikit-0.4.0/CHANGELOG.md
--- old/clikit-0.3.2/CHANGELOG.md       2019-09-20 15:59:56.000000000 +0200
+++ new/clikit-0.4.0/CHANGELOG.md       2019-10-25 14:22:57.000000000 +0200
@@ -1,5 +1,17 @@
 # Change Log
 
+## [0.4.0] - 2019-10-25
+
+### Changed
+
+- Changed the way event names are stored and exposed.
+
+
+### Fixed
+
+- Fixed parsing of options after a `--` token.
+
+
 ## [0.3.2] - 2019-09-20
 
 ### Fixed
@@ -74,7 +86,8 @@
 - Fixed the progress indicator component.
 
 
-[Unreleased]: https://github.com/sdispater/tomlkit/compare/0.3.2...master
+[Unreleased]: https://github.com/sdispater/tomlkit/compare/0.4.0...master
+[0.4.0]: https://github.com/sdispater/tomlkit/releases/tag/0.4.0
 [0.3.2]: https://github.com/sdispater/tomlkit/releases/tag/0.3.2
 [0.3.1]: https://github.com/sdispater/tomlkit/releases/tag/0.3.1
 [0.3.0]: https://github.com/sdispater/tomlkit/releases/tag/0.3.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/pyproject.toml 
new/clikit-0.4.0/pyproject.toml
--- old/clikit-0.3.2/pyproject.toml     2019-09-20 15:59:56.000000000 +0200
+++ new/clikit-0.4.0/pyproject.toml     2019-10-25 14:22:57.000000000 +0200
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "clikit"
-version = "0.3.2"
+version = "0.4.0"
 description = "CliKit is a group of utilities to build beautiful and testable 
command line interfaces."
 authors = ["Sébastien Eustace <[email protected]>"]
 license = "MIT"
@@ -33,5 +33,5 @@
 pre-commit = "^1.12"
 
 [build-system]
-requires = ["poetry>=0.12"]
+requires = ["poetry>=1.0.0b2"]
 build-backend = "poetry.masonry.api"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/__init__.py 
new/clikit-0.4.0/src/clikit/__init__.py
--- old/clikit-0.3.2/src/clikit/__init__.py     2019-09-20 15:59:56.000000000 
+0200
+++ new/clikit-0.4.0/src/clikit/__init__.py     2019-10-25 14:22:57.000000000 
+0200
@@ -3,4 +3,4 @@
 from .config.default_application_config import DefaultApplicationConfig
 
 
-__version__ = "0.3.2"
+__version__ = "0.4.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/api/args/raw_args.py 
new/clikit-0.4.0/src/clikit/api/args/raw_args.py
--- old/clikit-0.3.2/src/clikit/api/args/raw_args.py    2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/api/args/raw_args.py    2019-10-25 
14:22:57.000000000 +0200
@@ -20,3 +20,11 @@
 
     def to_string(self, script_name=True):  # type: (bool) -> str
         raise NotImplementedError()
+
+    @property
+    def option_tokens(self):  # type: () -> List[str]
+        raise NotImplementedError()
+        return list(itertools.takewhile(lambda arg: arg != "--", self.tokens))
+
+    def has_option_token(self, token):  # type: (str) -> bool
+        raise NotImplementedError()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/api/command/command.py 
new/clikit-0.4.0/src/clikit/api/command/command.py
--- old/clikit-0.3.2/src/clikit/api/command/command.py  2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/api/command/command.py  2019-10-25 
14:22:57.000000000 +0200
@@ -5,7 +5,7 @@
 from clikit.api.args.raw_args import RawArgs
 from clikit.api.args.format.args_format import ArgsFormat
 from clikit.api.config.command_config import CommandConfig
-from clikit.api.event import ConsoleEvents
+from clikit.api.event import PRE_HANDLE
 from clikit.api.event import PreHandleEvent
 from clikit.api.io import IO
 
@@ -158,11 +158,9 @@
             self._named_sub_commands.add(command)
 
     def _do_handle(self, args, io):  # type: (Args, IO) -> Optional[int]
-        if self._dispatcher and self._dispatcher.has_listeners(
-            ConsoleEvents.PRE_HANDLE.value
-        ):
+        if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
             event = PreHandleEvent(args, io, self)
-            self._dispatcher.dispatch(ConsoleEvents.PRE_HANDLE.value, event)
+            self._dispatcher.dispatch(PRE_HANDLE, event)
 
             if event.is_handled():
                 return event.status_code
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/api/event/__init__.py 
new/clikit-0.4.0/src/clikit/api/event/__init__.py
--- old/clikit-0.3.2/src/clikit/api/event/__init__.py   2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/api/event/__init__.py   2019-10-25 
14:22:57.000000000 +0200
@@ -1,5 +1,7 @@
 from .config_event import ConfigEvent
-from .console_events import ConsoleEvents
+from .console_events import CONFIG
+from .console_events import PRE_HANDLE
+from .console_events import PRE_RESOLVE
 from .event import Event
 from .event_dispatcher import EventDispatcher
 from .pre_handle_event import PreHandleEvent
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/api/event/console_events.py 
new/clikit-0.4.0/src/clikit/api/event/console_events.py
--- old/clikit-0.3.2/src/clikit/api/event/console_events.py     2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/api/event/console_events.py     2019-10-25 
14:22:57.000000000 +0200
@@ -1,10 +1,5 @@
-from enum import Enum
+PRE_RESOLVE = "pre-resolve"
 
+PRE_HANDLE = "pre-handle"
 
-class ConsoleEvents(Enum):
-
-    PRE_RESOLVE = "pre-resolve"
-
-    PRE_HANDLE = "pre-handle"
-
-    CONFIG = "config"
+CONFIG = "config"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/args/argv_args.py 
new/clikit-0.4.0/src/clikit/args/argv_args.py
--- old/clikit-0.3.2/src/clikit/args/argv_args.py       2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/args/argv_args.py       2019-10-25 
14:22:57.000000000 +0200
@@ -1,3 +1,4 @@
+import itertools
 import sys
 
 from typing import List
@@ -19,6 +20,9 @@
         argv = argv[:]
         self._script_name = argv.pop(0)
         self._tokens = argv
+        self._option_tokens = list(
+            itertools.takewhile(lambda arg: arg != "--", self.tokens)
+        )
 
     @property
     def script_name(self):  # type: () -> str
@@ -28,9 +32,16 @@
     def tokens(self):  # type: () -> List[str]
         return self._tokens
 
+    @property
+    def option_tokens(self):  # type: () -> List[str]
+        return self._option_tokens
+
     def has_token(self, token):  # type: (str) -> bool
         return token in self._tokens
 
+    def has_option_token(self, token):  # type: (str) -> bool
+        return token in self._option_tokens
+
     def to_string(self, script_name=True):  # type: (bool) -> str
         string = " ".join(self._tokens)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/args/string_args.py 
new/clikit-0.4.0/src/clikit/args/string_args.py
--- old/clikit-0.3.2/src/clikit/args/string_args.py     2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/args/string_args.py     2019-10-25 
14:22:57.000000000 +0200
@@ -1,3 +1,5 @@
+import itertools
+
 from typing import List
 from typing import Optional
 
@@ -16,6 +18,9 @@
         parser = TokenParser()
 
         self._tokens = parser.parse(string)
+        self._option_tokens = list(
+            itertools.takewhile(lambda arg: arg != "--", self.tokens)
+        )
 
     @property
     def script_name(self):  # type: () -> Optional[str]
@@ -25,8 +30,15 @@
     def tokens(self):  # type: () -> List[str]
         return self._tokens
 
+    @property
+    def option_tokens(self):  # type: () -> List[str]
+        return self._option_tokens
+
     def has_token(self, token):  # type: (str) -> bool
         return token in self._tokens
 
+    def has_option_token(self, token):  # type: (str) -> bool
+        return token in self._option_tokens
+
     def to_string(self, script_name=True):  # type: (bool) -> str
         return " ".join(self._tokens)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/clikit-0.3.2/src/clikit/config/default_application_config.py 
new/clikit-0.4.0/src/clikit/config/default_application_config.py
--- old/clikit-0.3.2/src/clikit/config/default_application_config.py    
2019-09-20 15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/config/default_application_config.py    
2019-10-25 14:22:57.000000000 +0200
@@ -2,7 +2,8 @@
 from clikit.api.args.raw_args import RawArgs
 from clikit.api.args.format.argument import Argument
 from clikit.api.args.format.option import Option
-from clikit.api.event import ConsoleEvents
+from clikit.api.event import PRE_HANDLE
+from clikit.api.event import PRE_RESOLVE
 from clikit.api.event import EventDispatcher
 from clikit.api.event import PreHandleEvent
 from clikit.api.event import PreResolveEvent
@@ -35,10 +36,8 @@
 
     def configure(self):
         self.set_io_factory(self.create_io)
-        self.add_event_listener(
-            ConsoleEvents.PRE_RESOLVE.value, self.resolve_help_command
-        )
-        self.add_event_listener(ConsoleEvents.PRE_HANDLE.value, 
self.print_version)
+        self.add_event_listener(PRE_RESOLVE, self.resolve_help_command)
+        self.add_event_listener(PRE_HANDLE, self.print_version)
 
         self.add_option("help", "h", Option.NO_VALUE, "Display this help 
message")
         self.add_option("quiet", "q", Option.NO_VALUE, "Do not output any 
message")
@@ -90,9 +89,9 @@
 
         style_set = application.config.style_set
 
-        if args.has_token("--no-ansi"):
+        if args.has_option_token("--no-ansi"):
             output_formatter = error_formatter = PlainFormatter(style_set)
-        elif args.has_token("--ansi"):
+        elif args.has_option_token("--ansi"):
             output_formatter = error_formatter = AnsiFormatter(style_set, True)
         else:
             if output_stream.supports_ansi():
@@ -111,17 +110,17 @@
             Output(error_stream, error_formatter),
         )
 
-        if args.has_token("-vvv") or self.is_debug():
+        if args.has_option_token("-vvv") or self.is_debug():
             io.set_verbosity(DEBUG)
-        elif args.has_token("-vv"):
+        elif args.has_option_token("-vv"):
             io.set_verbosity(VERY_VERBOSE)
-        elif args.has_token("-v"):
+        elif args.has_option_token("-v"):
             io.set_verbosity(VERBOSE)
 
-        if args.has_token("--quiet") or args.has_token("-q"):
+        if args.has_option_token("--quiet") or args.has_option_token("-q"):
             io.set_quiet(True)
 
-        if args.has_token("--no-interaction") or args.has_token("-n"):
+        if args.has_option_token("--no-interaction") or 
args.has_option_token("-n"):
             io.set_interactive(False)
 
         return io
@@ -144,7 +143,7 @@
         args = event.raw_args
         application = event.application
 
-        if args.has_token("-h") or args.has_token("--help"):
+        if args.has_option_token("-h") or args.has_option_token("--help"):
             command = application.get_command("help")
 
             # Enable lenient parsing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/src/clikit/console_application.py 
new/clikit-0.4.0/src/clikit/console_application.py
--- old/clikit-0.3.2/src/clikit/console_application.py  2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/src/clikit/console_application.py  2019-10-25 
14:22:57.000000000 +0200
@@ -8,8 +8,9 @@
 from .api.command.exceptions import CannotAddCommandException
 from .api.config.application_config import ApplicationConfig
 from .api.config.command_config import CommandConfig
+from .api.event import CONFIG
+from .api.event import PRE_RESOLVE
 from .api.event import ConfigEvent
-from .api.event import ConsoleEvents
 from .api.event import PreResolveEvent
 from .api.exceptions import CliKitException
 from .api.io import IO
@@ -37,8 +38,8 @@
 
         try:
             dispatcher = config.dispatcher
-            if dispatcher and 
dispatcher.has_listeners(ConsoleEvents.CONFIG.value):
-                dispatcher.dispatch(ConsoleEvents.CONFIG.value, 
ConfigEvent(config))
+            if dispatcher and dispatcher.has_listeners(CONFIG):
+                dispatcher.dispatch(CONFIG, ConfigEvent(config))
 
             self._config = config
             self._dispatcher = config.dispatcher
@@ -98,11 +99,9 @@
         return not self._default_commands.is_empty()
 
     def resolve_command(self, args):  # type: (RawArgs) -> ResolvedCommand
-        if self._dispatcher and self._dispatcher.has_listeners(
-            ConsoleEvents.PRE_RESOLVE.value
-        ):
+        if self._dispatcher and self._dispatcher.has_listeners(PRE_RESOLVE):
             event = PreResolveEvent(args, self)
-            self._dispatcher.dispatch(ConsoleEvents.PRE_RESOLVE.value, event)
+            self._dispatcher.dispatch(PRE_RESOLVE, event)
 
             resolved_command = event.resolved_command
             if resolved_command:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/tests/args/test_argv_args.py 
new/clikit-0.4.0/tests/args/test_argv_args.py
--- old/clikit-0.3.2/tests/args/test_argv_args.py       2019-09-20 
15:59:56.000000000 +0200
+++ new/clikit-0.4.0/tests/args/test_argv_args.py       2019-10-25 
14:22:57.000000000 +0200
@@ -42,6 +42,33 @@
     assert not args.has_token("foo")
 
 
+def test_has_option_token():
+    args = ArgvArgs(
+        [
+            "console",
+            "server",
+            "add",
+            "--port",
+            "80",
+            "localhost",
+            "--",
+            "-h",
+            "--test",
+            "remainder",
+        ]
+    )
+
+    assert args.has_option_token("server")
+    assert args.has_option_token("add")
+    assert args.has_option_token("--port")
+    assert args.has_option_token("80")
+    assert args.has_option_token("localhost")
+    assert not args.has_option_token("console")
+    assert not args.has_option_token("-h")
+    assert not args.has_option_token("--test")
+    assert not args.has_option_token("remainder")
+
+
 def test_to_string():
     args = ArgvArgs(["console", "server", "add", "--port", "80", "localhost"])
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/clikit-0.3.2/tests/handler/help/test_help_option.py 
new/clikit-0.4.0/tests/handler/help/test_help_option.py
--- old/clikit-0.3.2/tests/handler/help/test_help_option.py     1970-01-01 
01:00:00.000000000 +0100
+++ new/clikit-0.4.0/tests/handler/help/test_help_option.py     2019-10-25 
14:22:57.000000000 +0200
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from contextlib import contextmanager
+
+import pytest
+
+from clikit.api.args import Args
+from clikit.api.args.format import Argument
+from clikit.args.string_args import StringArgs
+from clikit.config.default_application_config import DefaultApplicationConfig
+from clikit.console_application import ConsoleApplication
+from clikit.io.output_stream import BufferedOutputStream
+
+
[email protected]()
+def app():
+    config = DefaultApplicationConfig()
+    config.set_catch_exceptions(True)
+    config.set_terminate_after_run(False)
+    config.set_display_name("The Application")
+    config.set_version("1.2.3")
+
+    with config.command("command") as c:
+        with c.sub_command("run") as sc:
+            sc.set_description('Description of "run"')
+            sc.add_argument("args", Argument.MULTI_VALUED, 'Description of 
"argument"')
+
+    application = ConsoleApplication(config)
+
+    return application
+
+
+def func_spy():
+    def decorator(func):
+        def wrapper(*args, **kwargs):
+            decorator.called = True
+            return func(*args, **kwargs)
+
+        return wrapper
+
+    decorator.called = False
+    return decorator
+
+
+@contextmanager
+def help_spy(help_command):
+    spy = func_spy()
+    original = help_command.config.handler.handle
+    try:
+        help_command.config.handler.handle = spy(original)
+        yield spy
+    finally:
+        help_command.config.handler.handle = original
+
+
[email protected](
+    "args",
+    [
+        "command run --help",
+        "command run --help --another",
+        "command run --help -- whatever",
+        "command run -h",
+        "command run -h --another",
+        "command run -h -- whatever",
+    ],
+)
+def test_help_option(app, args):
+    help_command = app.get_command("help")
+    with help_spy(help_command) as spy:
+        app.run(StringArgs(args))
+        assert spy.called, "help command not called"
+
+
[email protected](
+    "args",
+    [
+        "command run -- whatever --help",
+        "command run -- whatever -h",
+        "command run -- --help",
+    ],
+)
+def test_help_option_ignored(app, args):
+    help_command = app.get_command("help")
+    with help_spy(help_command) as spy:
+        app.run(StringArgs(args))
+        assert not spy.called, "help command called"


Reply via email to