Hello community,

here is the log from the commit of package python-python-slugify for 
openSUSE:Factory checked in at 2020-08-05 20:28:47
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-slugify (Old)
 and      /work/SRC/openSUSE:Factory/.python-python-slugify.new.3592 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-python-slugify"

Wed Aug  5 20:28:47 2020 rev:9 rq:824454 version:4.0.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-python-slugify/python-python-slugify.changes  
    2020-05-26 17:18:36.723883444 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-python-slugify.new.3592/python-python-slugify.changes
    2020-08-05 20:29:01.823087071 +0200
@@ -1,0 +2,6 @@
+Wed Aug  5 08:35:13 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com>
+
+- update to 4.0.1
+  * Add support for Py 3.8
+
+-------------------------------------------------------------------

Old:
----
  python-slugify-4.0.0.tar.gz

New:
----
  python-slugify-4.0.1.tar.gz

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

Other differences:
------------------
++++++ python-python-slugify.spec ++++++
--- /var/tmp/diff_new_pack.I6AD2A/_old  2020-08-05 20:29:03.495087944 +0200
+++ /var/tmp/diff_new_pack.I6AD2A/_new  2020-08-05 20:29:03.495087944 +0200
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-python-slugify
-Version:        4.0.0
+Version:        4.0.1
 Release:        0
 Summary:        Slugify application that handles Unicode
 License:        MIT

++++++ python-slugify-4.0.0.tar.gz -> python-slugify-4.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/CHANGELOG.md 
new/python-slugify-4.0.1/CHANGELOG.md
--- old/python-slugify-4.0.0/CHANGELOG.md       2019-10-20 19:40:08.000000000 
+0200
+++ new/python-slugify-4.0.1/CHANGELOG.md       2020-06-30 05:22:38.000000000 
+0200
@@ -1,3 +1,6 @@
+## 4.0.1
+  - Add support for Py 3.8
+
 ## 4.0.0
   - Drop support from 2.6, & < 3.4.5
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/PKG-INFO 
new/python-slugify-4.0.1/PKG-INFO
--- old/python-slugify-4.0.0/PKG-INFO   2019-10-20 19:40:41.000000000 +0200
+++ new/python-slugify-4.0.1/PKG-INFO   2020-06-30 05:34:51.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: python-slugify
-Version: 4.0.0
+Version: 4.0.1
 Summary: A Python Slugify application that handles Unicode
 Home-page: https://github.com/un33k/python-slugify
 Author: Val Neekman
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/README.md 
new/python-slugify-4.0.1/README.md
--- old/python-slugify-4.0.0/README.md  2019-10-11 00:13:34.000000000 +0200
+++ new/python-slugify-4.0.1/README.md  2020-06-30 05:19:49.000000000 +0200
@@ -137,6 +137,32 @@
 For more examples, have a look at the [test.py](test.py) file.
 
 
+Command Line Options
+====================
+
+With the package, a command line tool called `slugify` is also installed.
+
+It allows convenient command line access to all the features the `slugify` 
function supports. Call it with `-h` for help.
+
+The command can take its input directly on the command line or from STDIN 
(when the `--stdin` flag is passed):
+
+```
+$ echo "Taking input from STDIN" | slugify --stdin
+taking-input-from-stdin
+```
+```
+$ slugify taking input from the command line
+taking-input-from-the-command-line
+```
+
+Please note that when a multi-valued option such as `--stopwords` or 
`--replacements` is passed, you need to use `--` as separator before you start 
with the input:
+
+```
+$ slugify --stopwords the in a hurry -- the quick brown fox jumps over the 
lazy dog in a hurry
+quick-brown-fox-jumps-over-lazy-dog
+```
+
+
 Running the tests
 ====================
 
@@ -145,6 +171,12 @@
     python test.py
 
 
+Contribution
+====================
+
+Please read the 
([wiki](https://github.com/un33k/python-slugify/wiki/Python-Slugify-Wiki)) page 
prior to raising any PRs. 
+
+
 License
 ====================
 
@@ -159,8 +191,8 @@
     `MINOR` version -- when you add functionality in a backwards-compatible 
manner, and
     `PATCH` version -- when you make backwards-compatible bug fixes.
 
-[status-image]: 
https://secure.travis-ci.org/un33k/python-slugify.png?branch=master
-[status-link]: http://travis-ci.org/un33k/python-slugify?branch=master
+[status-image]: https://travis-ci.org/un33k/python-slugify.svg?branch=master
+[status-link]: https://travis-ci.org/un33k/python-slugify
 
 [version-image]: https://img.shields.io/pypi/v/python-slugify.svg
 [version-link]: https://pypi.python.org/pypi/python-slugify
@@ -175,4 +207,4 @@
 Sponsors
 ====================
 
-[Surge](https://github.com/surgeforward)
+[Neekware Inc.](http://neekware.com)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-slugify-4.0.0/python_slugify.egg-info/PKG-INFO 
new/python-slugify-4.0.1/python_slugify.egg-info/PKG-INFO
--- old/python-slugify-4.0.0/python_slugify.egg-info/PKG-INFO   2019-10-20 
19:40:41.000000000 +0200
+++ new/python-slugify-4.0.1/python_slugify.egg-info/PKG-INFO   2020-06-30 
05:34:51.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: python-slugify
-Version: 4.0.0
+Version: 4.0.1
 Summary: A Python Slugify application that handles Unicode
 Home-page: https://github.com/un33k/python-slugify
 Author: Val Neekman
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-slugify-4.0.0/python_slugify.egg-info/SOURCES.txt 
new/python-slugify-4.0.1/python_slugify.egg-info/SOURCES.txt
--- old/python-slugify-4.0.0/python_slugify.egg-info/SOURCES.txt        
2019-10-20 19:40:41.000000000 +0200
+++ new/python-slugify-4.0.1/python_slugify.egg-info/SOURCES.txt        
2020-06-30 05:34:51.000000000 +0200
@@ -12,5 +12,6 @@
 python_slugify.egg-info/requires.txt
 python_slugify.egg-info/top_level.txt
 slugify/__init__.py
+slugify/__main__.py
 slugify/slugify.py
 slugify/special.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-slugify-4.0.0/python_slugify.egg-info/entry_points.txt 
new/python-slugify-4.0.1/python_slugify.egg-info/entry_points.txt
--- old/python-slugify-4.0.0/python_slugify.egg-info/entry_points.txt   
2019-10-20 19:40:41.000000000 +0200
+++ new/python-slugify-4.0.1/python_slugify.egg-info/entry_points.txt   
2020-06-30 05:34:51.000000000 +0200
@@ -1,3 +1,3 @@
 [console_scripts]
-slugify = slugify.slugify:main
+slugify = slugify.__main__:main
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/setup.py 
new/python-slugify-4.0.1/setup.py
--- old/python-slugify-4.0.0/setup.py   2019-10-20 19:40:08.000000000 +0200
+++ new/python-slugify-4.0.1/setup.py   2020-06-30 05:19:11.000000000 +0200
@@ -67,5 +67,5 @@
     extras_require=extras_require,
     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
     classifiers=classifiers,
-    entry_points={'console_scripts': ['slugify=slugify.slugify:main']},
+    entry_points={'console_scripts': ['slugify=slugify.__main__:main']},
 )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/slugify/__init__.py 
new/python-slugify-4.0.1/slugify/__init__.py
--- old/python-slugify-4.0.0/slugify/__init__.py        2019-10-20 
19:40:08.000000000 +0200
+++ new/python-slugify-4.0.1/slugify/__init__.py        2020-06-30 
05:22:38.000000000 +0200
@@ -4,4 +4,4 @@
 
 __author__ = 'Val Neekman @ Neekware Inc. [@vneekman]'
 __description__ = 'A Python slugify application that also handles Unicode'
-__version__ = '4.0.0'
+__version__ = '4.0.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/slugify/__main__.py 
new/python-slugify-4.0.1/slugify/__main__.py
--- old/python-slugify-4.0.0/slugify/__main__.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/python-slugify-4.0.1/slugify/__main__.py        2020-06-30 
05:19:11.000000000 +0200
@@ -0,0 +1,93 @@
+from __future__ import print_function, absolute_import
+import argparse
+import sys
+
+from .slugify import slugify, DEFAULT_SEPARATOR
+
+
+def parse_args(argv):
+    parser = argparse.ArgumentParser(description="Sluggify string")
+
+    input_group = parser.add_argument_group(description="Input")
+    input_group.add_argument("input_string", nargs='*',
+                             help='Text to slugify')
+    input_group.add_argument("--stdin", action='store_true',
+                             help="Take the text from STDIN")
+
+    parser.add_argument("--no-entities", action='store_false', 
dest='entities', default=True,
+                        help="Do not convert HTML entities to unicode")
+    parser.add_argument("--no-decimal", action='store_false', dest='decimal', 
default=True,
+                        help="Do not convert HTML decimal to unicode")
+    parser.add_argument("--no-hexadecimal", action='store_false', 
dest='hexadecimal', default=True,
+                        help="Do not convert HTML hexadecimal to unicode")
+    parser.add_argument("--max-length", type=int, default=0,
+                        help="Output string length, 0 for no limit")
+    parser.add_argument("--word-boundary", action='store_true', default=False,
+                        help="Truncate to complete word even if length ends up 
shorter than --max_length")
+    parser.add_argument("--save-order", action='store_true', default=False,
+                        help="When set and --max_length > 0 return whole words 
in the initial order")
+    parser.add_argument("--separator", type=str, default=DEFAULT_SEPARATOR,
+                        help="Separator between words. By default " + 
DEFAULT_SEPARATOR)
+    parser.add_argument("--stopwords", nargs='+',
+                        help="Words to discount")
+    parser.add_argument("--regex-pattern",
+                        help="Python regex pattern for allowed characters")
+    parser.add_argument("--no-lowercase", action='store_false', 
dest='lowercase', default=True,
+                        help="Activate case sensitivity")
+    parser.add_argument("--replacements", nargs='+',
+                        help="""Additional replacement rules e.g. "|->or", 
"%%->percent".""")
+
+    args = parser.parse_args(argv[1:])
+
+    if args.input_string and args.stdin:
+        parser.error("Input strings and --stdin cannot work together")
+
+    if args.replacements:
+        def split_check(repl):
+            SEP = '->'
+            if SEP not in repl:
+                parser.error("Replacements must be of the form: 
ORIGINAL{SEP}REPLACED".format(SEP=SEP))
+            return repl.split(SEP, 1)
+        args.replacements = [split_check(repl) for repl in args.replacements]
+
+    if args.input_string:
+        args.input_string = " ".join(args.input_string)
+    elif args.stdin:
+        args.input_string = sys.stdin.read()
+
+    if not args.input_string:
+        args.input_string = ''
+
+    return args
+
+
+def slugify_params(args):
+    return dict(
+        text=args.input_string,
+        entities=args.entities,
+        decimal=args.decimal,
+        hexadecimal=args.hexadecimal,
+        max_length=args.max_length,
+        word_boundary=args.word_boundary,
+        save_order=args.save_order,
+        separator=args.separator,
+        stopwords=args.stopwords,
+        lowercase=args.lowercase,
+        replacements=args.replacements
+    )
+
+
+def main(argv=None): # pragma: no cover
+    """ Run this program """
+    if argv is None:
+        argv = sys.argv
+    args = parse_args(argv)
+    params = slugify_params(args)
+    try:
+        print(slugify(**params))
+    except KeyboardInterrupt:
+        sys.exit(-1)
+
+
+if __name__ == '__main__': # pragma: no cover
+    main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/slugify/slugify.py 
new/python-slugify-4.0.1/slugify/slugify.py
--- old/python-slugify-4.0.0/slugify/slugify.py 2019-10-20 19:40:08.000000000 
+0200
+++ new/python-slugify-4.0.1/slugify/slugify.py 2020-06-30 05:19:11.000000000 
+0200
@@ -178,11 +178,3 @@
         text = text.replace(DEFAULT_SEPARATOR, separator)
 
     return text
-
-
-def main(): # pragma: no cover
-    if len(sys.argv) < 2:
-        print("Usage %s TEXT TO SLUGIFY" % sys.argv[0])
-    else:
-        text = ' '.join(sys.argv[1:])
-        print(slugify(text))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-slugify-4.0.0/test.py 
new/python-slugify-4.0.1/test.py
--- old/python-slugify-4.0.0/test.py    2019-10-20 19:40:08.000000000 +0200
+++ new/python-slugify-4.0.1/test.py    2020-06-30 05:19:11.000000000 +0200
@@ -1,8 +1,13 @@
 # -*- coding: utf-8 -*-
-
+import io
+import os
+import sys
 import unittest
+from contextlib import contextmanager
+
 from slugify import slugify
 from slugify import smart_truncate
+from slugify.__main__ import slugify_params, parse_args
 
 
 class TestSlugification(unittest.TestCase):
@@ -242,5 +247,117 @@
         self.assertEqual(r, txt)
 
 
+PY3 = sys.version_info.major == 3
+
+
+@contextmanager
+def captured_stderr():
+    backup = sys.stderr
+    sys.stderr = io.StringIO() if PY3 else io.BytesIO()
+    try:
+        yield sys.stderr
+    finally:
+        sys.stderr = backup
+
+
+@contextmanager
+def loaded_stdin(contents):
+    backup = sys.stdin
+    sys.stdin = io.StringIO(contents) if PY3 else io.BytesIO(contents)
+    try:
+        yield sys.stdin
+    finally:
+        sys.stdin = backup
+
+
+class TestCommandParams(unittest.TestCase):
+    DEFAULTS = {
+        'entities': True,
+        'decimal': True,
+        'hexadecimal': True,
+        'max_length': 0,
+        'word_boundary': False,
+        'save_order': False,
+        'separator': '-',
+        'stopwords': None,
+        'lowercase': True,
+        'replacements': None
+    }
+
+    def get_params_from_cli(self, *argv):
+        args = parse_args([None] + list(argv))
+        return slugify_params(args)
+
+    def make_params(self, **values):
+        return dict(self.DEFAULTS, **values)
+
+    def assertParamsMatch(self, expected, checked):
+        reduced_checked = {}
+        for key in expected.keys():
+            reduced_checked[key] = checked[key]
+        self.assertEqual(expected, reduced_checked)
+
+    def test_defaults(self):
+        params = self.get_params_from_cli()
+        self.assertParamsMatch(self.DEFAULTS, params)
+
+    def test_negative_flags(self):
+        params = self.get_params_from_cli('--no-entities', '--no-decimal', 
'--no-hexadecimal', '--no-lowercase')
+        expected = self.make_params(entities=False, decimal=False, 
hexadecimal=False, lowercase=False)
+        self.assertFalse(expected['lowercase'])
+        self.assertFalse(expected['word_boundary'])
+        self.assertParamsMatch(expected, params)
+
+    def test_affirmative_flags(self):
+        params = self.get_params_from_cli('--word-boundary', '--save-order')
+        expected = self.make_params(word_boundary=True, save_order=True)
+        self.assertParamsMatch(expected, params)
+
+    def test_valued_arguments(self):
+        params = self.get_params_from_cli('--stopwords', 'abba', 'beatles', 
'--max-length', '98', '--separator', '+')
+        expected = self.make_params(stopwords=['abba', 'beatles'], 
max_length=98, separator='+')
+        self.assertParamsMatch(expected, params)
+
+    def test_replacements_right(self):
+        params = self.get_params_from_cli('--replacements', 'A->B', 'C->D')
+        expected = self.make_params(replacements=[['A', 'B'], ['C', 'D']])
+        self.assertParamsMatch(expected, params)
+
+    def test_replacements_wrong(self):
+        with self.assertRaises(SystemExit) as err, captured_stderr() as cse:
+            self.get_params_from_cli('--replacements', 'A--B')
+        self.assertEqual(err.exception.code, 2)
+        self.assertIn("Replacements must be of the form: ORIGINAL->REPLACED", 
cse.getvalue())
+
+    def test_text_in_cli(self):
+        params = self.get_params_from_cli('Cool Text')
+        expected = self.make_params(text='Cool Text')
+        self.assertParamsMatch(expected, params)
+
+    def test_text_in_cli_multi(self):
+        params = self.get_params_from_cli('Cool', 'Text')
+        expected = self.make_params(text='Cool Text')
+        self.assertParamsMatch(expected, params)
+
+    def test_text_in_stdin(self):
+        with loaded_stdin("Cool Stdin"):
+            params = self.get_params_from_cli('--stdin')
+        expected = self.make_params(text='Cool Stdin')
+        self.assertParamsMatch(expected, params)
+
+    def test_two_text_sources_fails(self):
+        with self.assertRaises(SystemExit) as err, captured_stderr() as cse:
+            self.get_params_from_cli('--stdin', 'Text')
+        self.assertEqual(err.exception.code, 2)
+        self.assertIn("Input strings and --stdin cannot work together", 
cse.getvalue())
+
+    def test_multivalued_options_with_text(self):
+        text = "the quick brown fox jumps over the lazy dog in a hurry"
+        cli_args = "--stopwords the in a hurry -- {}".format(text).split()
+        params = self.get_params_from_cli(*cli_args)
+        self.assertEqual(params['text'], text)
+        self.assertEqual(params['stopwords'], ['the', 'in', 'a', 'hurry'])
+
+
 if __name__ == '__main__':
     unittest.main()


Reply via email to