[med-svn] [Git][med-team/python-prefixed][master] 6 commits: routine-update: New upstream version

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Feb 6 07:12:28 GMT 2023



Andreas Tille pushed to branch master at Debian Med / python-prefixed


Commits:
0205cba3 by Andreas Tille at 2023-02-06T08:02:54+01:00
routine-update: New upstream version

- - - - -
e761e509 by Andreas Tille at 2023-02-06T08:02:55+01:00
New upstream version 0.7.0
- - - - -
62d69ae5 by Andreas Tille at 2023-02-06T08:02:55+01:00
Update upstream source from tag 'upstream/0.7.0'

Update to upstream version '0.7.0'
with Debian dir 553181ebf586b1cd824f218227ab76a538be0fc8
- - - - -
fe4d94fb by Andreas Tille at 2023-02-06T08:02:57+01:00
routine-update: Testsuite: autopkgtest-pkg-python

- - - - -
f7c9f096 by Andreas Tille at 2023-02-06T08:03:02+01:00
Set upstream metadata fields: Bug-Database, Bug-Submit, Contact, Repository-Browse.

Changes-By: lintian-brush
Fixes: lintian: upstream-metadata-file-is-missing
See-also: https://lintian.debian.org/tags/upstream-metadata-file-is-missing.html
Fixes: lintian: upstream-metadata-missing-bug-tracking
See-also: https://lintian.debian.org/tags/upstream-metadata-missing-bug-tracking.html

- - - - -
e234a351 by Andreas Tille at 2023-02-06T08:04:10+01:00
routine-update: Ready to upload to unstable

- - - - -


14 changed files:

- + .github/workflows/tests.yml
- .gitignore
- README.rst
- debian/changelog
- debian/control
- + debian/upstream/metadata
- doc/conf.py
- doc/format_spec.rst
- prefixed/__init__.py
- setup.cfg
- setup_helpers.py
- tests/test_float.py
- tests/test_formatspec.py
- tox.ini


Changes:

=====================================
.github/workflows/tests.yml
=====================================
@@ -0,0 +1,77 @@
+name: Tests
+
+on:
+  push:
+  pull_request:
+  release:
+  schedule:
+    # Every Thursday at 1 AM
+    - cron: '0 1 * * 4'
+
+jobs:
+
+  Tests:
+    runs-on: ${{ matrix.os || 'ubuntu-latest' }}
+    name: ${{ startsWith(matrix.toxenv, 'py') && matrix.python-version || format('{0} ({1})', matrix.toxenv, matrix.python-version) }} ${{ matrix.optional && '[OPTIONAL]' }}
+    continue-on-error: ${{ matrix.optional || false }}
+
+    strategy:
+      fail-fast: false
+
+      matrix:
+        python-version: ['3.10']
+        toxenv: [lint, docs, codecov]
+        include:
+
+          - python-version: 3.11
+            toxenv: py311
+
+          - python-version: 3.9
+            toxenv: py39
+
+          - python-version: 3.8
+            toxenv: py38
+
+          - python-version: 3.7
+            toxenv: py37
+
+          - python-version: 3.6
+            toxenv: py36
+            os: ubuntu-20.04
+
+          - python-version: 3.5
+            toxenv: py35
+            os: ubuntu-20.04
+
+          - python-version: 2.7
+            toxenv: py27
+            os: ubuntu-20.04
+
+          - python-version: pypy-2.7
+            toxenv: pypy27
+
+          - python-version: pypy-3.9
+            toxenv: pypy39
+
+          - python-version: '3.12-dev'
+            optional: true
+            toxenv: py312
+            toxpython: 3.12
+
+    env:
+      TOXENV: ${{ matrix.toxenv }}
+      TOXPYTHON: python${{ matrix.toxpython || matrix.python-version }}
+
+    steps:
+      - uses: actions/checkout at v3
+
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python at v4
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Install tox
+        run: pip install tox
+
+      - name: Run tox
+        run: tox -- --verbose


=====================================
.gitignore
=====================================
@@ -14,6 +14,7 @@ __pycache__
 # Coverage
 htmlcov
 .coverage
+coverage.xml
 
 # Setup
 dist


=====================================
README.rst
=====================================
@@ -7,7 +7,7 @@
     :target: https://prefixed.readthedocs.org
     :alt: Documentation Status
 
-.. |gh_actions| image:: https://img.shields.io/github/workflow/status/Rockhopper-Technologies/prefixed/Tests?event=push&logo=github-actions&style=plastic
+.. |gh_actions| image:: https://img.shields.io/github/actions/workflow/status/Rockhopper-Technologies/prefixed/tests.yml?event=push&logo=github-actions&style=plastic
     :target: https://github.com/Rockhopper-Technologies/prefixed/actions/workflows/tests.yml
     :alt: GitHub Actions Status
 


=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+python-prefixed (0.7.0-1) unstable; urgency=medium
+
+  * New upstream version
+  * Testsuite: autopkgtest-pkg-python (routine-update)
+  * Set upstream metadata fields: Bug-Database, Bug-Submit, Contact,
+    Repository-Browse.
+
+ -- Andreas Tille <tille at debian.org>  Mon, 06 Feb 2023 08:03:16 +0100
+
 python-prefixed (0.5.0-1) unstable; urgency=medium
 
   * Team Upload.


=====================================
debian/control
=====================================
@@ -1,5 +1,6 @@
 Source: python-prefixed
 Section: python
+Testsuite: autopkgtest-pkg-python
 Priority: optional
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
 Uploaders: Andreas Tille <tille at debian.org>


=====================================
debian/upstream/metadata
=====================================
@@ -0,0 +1,5 @@
+---
+Contact: Avram Lubkin <avylove at rockhopper.net>
+Bug-Database: https://github.com/Rockhopper-Technologies/prefixed/issues
+Bug-Submit: https://github.com/Rockhopper-Technologies/prefixed/issues/new
+Repository-Browse: https://github.com/Rockhopper-Technologies/prefixed


=====================================
doc/conf.py
=====================================
@@ -18,7 +18,7 @@ from setup_helpers import get_version  # noqa: E402
 # -- Project information -----------------------------------------------------
 
 project = 'Prefixed'
-copyright = '2022, Avram Lubkin'
+copyright = '2023, Avram Lubkin'
 author = 'Avram Lubkin'
 
 # The full version, including alpha/beta/rc tags
@@ -60,7 +60,8 @@ html_theme = 'sphinx_rtd_theme'
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css"..
-html_static_path = ['_static']
+# html_static_path = ['_static']
+html_static_path = ['']  # Remove static path since we have no files
 htmlhelp_basename = 'prefixed'
 
 intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}


=====================================
doc/format_spec.rst
=====================================
@@ -1,5 +1,5 @@
 ..
-  Copyright 2017 - 2022 Avram Lubkin, All Rights Reserved
+  Copyright 2017 - 2023 Avram Lubkin, All Rights Reserved
 
   This Source Code Form is subject to the terms of the Mozilla Public
   License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,7 +12,7 @@ Format Specification
 
 .. code-block:: abnf
 
-    format_spec     ::=  [[fill]align][sign][#][0][!][width][grouping_option][%[-]margin][.precision][type]
+    format_spec     ::=  [[fill]align][sign][#][0][![!]][width][grouping_option][%[-]margin][.precision][type]
     fill            ::=  <any character>
     align           ::=  "<" | ">" | "=" | "^"
     sign            ::=  "+" | "-" | " "
@@ -31,11 +31,13 @@ Prefixed-specific fields
 Flags
 -----
 
-+---------+----------------------------------------------------------+
-| Flag    | Meaning                                                  |
-+=========+==========================================================+
-| ``'!'`` | Add a single space between number and prefix             |
-+---------+----------------------------------------------------------+
++----------+----------------------------------------------------------+
+| Flag     | Meaning                                                  |
++==========+==========================================================+
+| ``'!'``  | Add a single space between number and prefix             |
++----------+----------------------------------------------------------+
+| ``'!!'`` | Same as ``'!'``, but drop space if there is no prefix    |
++----------+----------------------------------------------------------+
 
 Margin
 ------


=====================================
prefixed/__init__.py
=====================================
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2020 - 2022 Avram Lubkin, All Rights Reserved
+# Copyright 2020 - 2023 Avram Lubkin, All Rights Reserved
 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,12 +10,12 @@
 Numbers with support for formatting with SI and IEC prefixes
 """
 
-
+import itertools
 from math import floor, log10
 import re
 import sys
 
-__version__ = '0.5.0'
+__version__ = '0.7.0'
 
 try:
     BASESTRING = basestring
@@ -34,7 +34,7 @@ RE_FORMAT_SPEC = re.compile(
     # 0: same as 0=, Ignored if fill/align is given
     r'(?P<zero>0)?'
     # !: Add space before prefix
-    r'(?P<prefix_space>!)?'
+    r'(?P<prefix_space>!!?)?'
     # width: integer
     r'(?P<width>\d+)?'
     # grouping_option: ,_
@@ -50,31 +50,34 @@ RE_PREFIX = re.compile(
     r'(?P<value>[-+]?\d+\.?(?:\d+)?(?:[eE]?\d)?) ?(?P<prefix>(?:[a-zA-Z\u03bc]|\xce\xbc)i?)$'
 )
 
-SI_PREFIXES = {
-    10**-30: 'q',  # Quecto
-    10**-27: 'r',  # Ronto
-    10**-24: 'y',  # Yocto
-    10**-21: 'z',  # Zepto
-    10**-18: 'a',  # Atto
-    10**-15: 'f',  # Femto
-    10**-12: 'p',  # Pico
-    10**-9: 'n',  # Nano
-    10**-6: 'μ',  # Micro
-    10**-3: 'm',  # Milli
-    10**3: 'k',  # Kilo
-    10**6: 'M',  # Mega
-    10**9: 'G',  # Giga
-    10**12: 'T',  # Tera
-    10**15: 'P',  # Peta
-    10**18: 'E',  # Exa
-    10**21: 'Z',  # Zetta
-    10**24: 'Y',  # Yotta
-    10**27: 'R',  # Ronna
-    10**30: 'Q',  # Quetta
+SI_SMALL = {
+    1e-30: 'q',  # Quecto
+    1e-27: 'r',  # Ronto
+    1e-24: 'y',  # Yocto
+    1e-21: 'z',  # Zepto
+    1e-18: 'a',  # Atto
+    1e-15: 'f',  # Femto
+    1e-12: 'p',  # Pico
+    1e-9: 'n',  # Nano
+    1e-6: 'μ',  # Micro
+    1e-3: 'm',  # Milli
+}
+SI_LARGE = {
+    1e3: 'k',  # Kilo
+    1e6: 'M',  # Mega
+    1e9: 'G',  # Giga
+    1e12: 'T',  # Tera
+    1e15: 'P',  # Peta
+    1e18: 'E',  # Exa
+    1e21: 'Z',  # Zetta
+    1e24: 'Y',  # Yotta
+    1e27: 'R',  # Ronna
+    1e30: 'Q',  # Quetta
 }
-SI_SMALLEST = 10 ** -30
 
-SI_MAGNITUDE = {val: key for key, val in SI_PREFIXES.items()}
+SI_SMALLEST = 1e-30
+
+SI_MAGNITUDE = {val: key for key, val in itertools.chain(SI_SMALL.items(), SI_LARGE.items())}
 
 IEC_PREFIXES = {
     2**10: 'K',  # Kibi
@@ -89,12 +92,15 @@ IEC_PREFIXES = {
 
 IEC_MAGNITUDE = {val: key for key, val in IEC_PREFIXES.items()}
 
-SI_SMALL = range(-30, 0, 3)
-SI_LARGE = range(3, 33, 3)
-IEC_RANGE = range(10, 90, 10)
-
 SPEC_FIELDS = ('fill', 'align', 'sign', 'alt', 'zero', 'width', 'grouping')
 
+# Use OrderedDict for older versions of Python
+if sys.version_info[:2] < (3, 7):  # pragma: no cover
+    from collections import OrderedDict
+    SI_SMALL = OrderedDict(sorted(SI_SMALL.items()))
+    SI_LARGE = OrderedDict(sorted(SI_LARGE.items()))
+    IEC_PREFIXES = OrderedDict(sorted(IEC_PREFIXES.items()))
+
 
 def raise_from_none(exc):  # pragma: no cover
     """
@@ -119,21 +125,18 @@ def _convert(value, spec):
     absolute_value = abs(value)
 
     if spec['type'] in 'hH':
-        base, prefixes = 10, SI_PREFIXES
-        span = SI_LARGE if absolute_value >= 1.0 else SI_SMALL
+        prefixes = SI_LARGE if absolute_value >= 1.0 else SI_SMALL
+
     else:
-        base, prefixes = 2, IEC_PREFIXES
-        span = IEC_RANGE if absolute_value >= 1.0 else tuple()
+        prefixes = IEC_PREFIXES if absolute_value >= 1.0 else {}
 
     margin = 1.0 if spec['margin'] is None else (100.0 + float(spec['margin'])) / 100.0
 
-    if span is SI_SMALL and 0 < absolute_value < SI_SMALLEST * margin:
+    if prefixes is SI_SMALL and 0 < absolute_value < SI_SMALLEST * margin:
         magnitude = SI_SMALLEST
     else:
         magnitude = 0
-        for exp in span:
-            next_mag = base**exp
-            # Use floor division rather than comparison for float variance
+        for next_mag in prefixes:
             if absolute_value // (next_mag * margin):
                 magnitude = next_mag
             else:
@@ -151,7 +154,7 @@ def _convert(value, spec):
                 spec['width'] = str(width - len(prefix))
 
     else:
-        prefix = ''
+        prefix = ' ' if spec['prefix_space'] == '!' else ''
 
     return value, prefix, spec
 


=====================================
setup.cfg
=====================================
@@ -3,7 +3,7 @@ universal=1
 
 [metadata]
 description_file = README.rst
-license_file = LICENSE
+license_files = LICENSE
 
 [flake8]
 builtins = __path__
@@ -28,6 +28,8 @@ source-dir = doc
 build-dir = build/doc
 all_files = True
 fresh-env = True
+warning-is-error = 1
+keep-going = 1
 
 [aliases]
 spelling=build_sphinx --builder spelling


=====================================
setup_helpers.py
=====================================
@@ -1,4 +1,4 @@
-# Copyright 2017 - 2022 Avram Lubkin, All Rights Reserved
+# Copyright 2017 - 2023 Avram Lubkin, All Rights Reserved
 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -68,6 +68,9 @@ def print_all_spelling_errors(path):
     """
 
     rtn = 0
+    if not os.path.isdir(path):
+        return rtn
+
     for filename in os.listdir(path):
         if print_spelling_errors(os.path.join(path, filename)):
             rtn = 1
@@ -108,38 +111,53 @@ def check_rst2html(path):
     return 0
 
 
-def check_copyrights():
+def _get_changed_files():
     """
-    Check files recursively to ensure year of last change is in copyright line
+    Get files in current repository that have been changed
+    Ignore changes to copyright lines
     """
 
-    this_year = str(datetime.date.today().year)
-    changed_now = []
+    changed = []
 
     # Get list of changed files
     process = subprocess.run(
         ('git', 'status', '--porcelain=1'), stdout=subprocess.PIPE, check=True, text=True
     )
     for entry in process.stdout.splitlines():
+
+        # Ignore deleted files
+        if entry[1] == 'D':
+            continue
+
+        # Construct diff command
         filename = entry[3:].strip()
         diff_cmd = ['git', 'diff', filename]
         if entry[0].strip():
             diff_cmd.insert(-1, '--cached')
 
-        # Get changes for file
-        process = subprocess.run(diff_cmd, stdout=subprocess.PIPE, check=True, text=True)
-
         # Find files with changes that aren't only for copyright
+        process = subprocess.run(diff_cmd, stdout=subprocess.PIPE, check=True, text=True)
         for line in process.stdout.splitlines():
-            if line[0] != '+' or line[:3] == '+++':  # Ignore anything but the new contents
+            if line[0] != '+' or line[:3] == '+++':  # Ignore everything but the new contents
                 continue
 
             if re.search(r'copyright.*20\d\d', line, re.IGNORECASE):  # Ignore copyright line
                 continue
 
-            changed_now.append(filename)
+            changed.append(filename)
             break
 
+    return changed
+
+
+def check_copyrights():
+    """
+    Check files recursively to ensure year of last change is in copyright line
+    """
+
+    this_year = str(datetime.date.today().year)
+    changed_now = _get_changed_files()
+
     # Look for copyright lines
     process = subprocess.run(
         ('git', 'grep', '-i', 'copyright'), stdout=subprocess.PIPE, check=True, text=True
@@ -151,11 +169,12 @@ def check_copyrights():
         modified = None
 
         # Get the year in the copyright line
-        match = re.match(r'([^:]+):.*(20\d\d)', entry)
+        filename, text = entry.split(':', 1)
+        match = re.match(r'.*(20\d\d)', text)
         if match:
-            filename, year = match.groups()
+            year = match.group(1)
 
-            # If files is in current changes, use this year
+            # If file is in current changes, use this year
             if filename in changed_now:
                 modified = this_year
 
@@ -193,7 +212,7 @@ def check_copyrights():
             # Compare modified date to copyright year
             if modified and modified != year:
                 rtn = 1
-                print('%s [%s]' % (entry, modified))
+                print('%s: %s [%s]' % (filename, text, modified))
 
     return rtn
 


=====================================
tests/test_float.py
=====================================
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2020 - 2022 Avram Lubkin, All Rights Reserved
+# Copyright 2020 - 2023 Avram Lubkin, All Rights Reserved
 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -426,10 +426,26 @@ class TestFloatFormatting(unittest.TestCase):
         Flag for space before prefix
         """
 
+        # Single flag leaves trailing space
+        self.assertEqual(format(Float(500), '!7.2h'), ' 500.00 ')
+        self.assertEqual(format(Float(500), '!4.2h'), '500.00 ')
+        self.assertEqual(format(Float(500), '!.2h'), '500.00 ')
+
+        # Double flag removes trailing space
+        self.assertEqual(format(Float(500), '!!7.2h'), ' 500.00')
+        self.assertEqual(format(Float(500), '!!4.2h'), '500.00')
+        self.assertEqual(format(Float(500), '!!.2h'), '500.00')
+
+        # Single flag with prefix
         self.assertEqual(format(Float(3000), '!7.2h'), ' 3.00 k')
         self.assertEqual(format(Float(3000), '!4.2h'), '3.00 k')
         self.assertEqual(format(Float(3000), '!.2h'), '3.00 k')
 
+        # Double Flag, no difference since prefix is added
+        self.assertEqual(format(Float(3000), '!!7.2h'), ' 3.00 k')
+        self.assertEqual(format(Float(3000), '!!4.2h'), '3.00 k')
+        self.assertEqual(format(Float(3000), '!!.2h'), '3.00 k')
+
     def test_margin(self):
         """
         Confirm variable margins


=====================================
tests/test_formatspec.py
=====================================
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2020 Avram Lubkin, All Rights Reserved
+# Copyright 2020 - 2023 Avram Lubkin, All Rights Reserved
 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -70,9 +70,11 @@ class FormatSpec(unittest.TestCase):
         """
         Test space before prefix flag
         """
-        spec = RE_FORMAT_SPEC.match('!').groupdict()
-        self.assertEqual(spec.pop('prefix_space'), '!')
-        self.assertTrue(all(field is None for field in spec.values()))
+
+        for example in ('!', '!!'):
+            spec = RE_FORMAT_SPEC.match(example).groupdict()
+            self.assertEqual(spec.pop('prefix_space'), example)
+            self.assertTrue(all(field is None for field in spec.values()))
 
     def test_width(self):
         """


=====================================
tox.ini
=====================================
@@ -24,7 +24,7 @@ deps =
     flake8
 
 commands =
-    {envpython} -m flake8 prefixed setup.py setup_helpers.py tests
+    flake8 prefixed setup.py setup_helpers.py tests
 
 [testenv:pylint]
 skip_install = True
@@ -34,7 +34,7 @@ deps =
     pyenchant
 
 commands =
-    {envpython} -m pylint prefixed setup setup_helpers tests
+    pylint prefixed setup setup_helpers tests
 
 [testenv:specialist]
 basepython = python3.11
@@ -70,18 +70,21 @@ deps =
     coverage
 
 commands =
-    {envpython} -m coverage run -m unittest discover -s {toxinidir}/tests {posargs}
-    {envpython} -m coverage report
+    coverage run -m unittest discover -s {toxinidir}/tests {posargs}
+    coverage report
 
 [testenv:codecov]
-passenv = CI TRAVIS TRAVIS_*
+passenv =
+    CI
+    CODECOV_*
+    GITHUB_*
 deps =
     {[testenv:coverage]deps}
     codecov
 
 commands =
     {[testenv:coverage]commands}
-    {envpython} -m codecov
+    codecov
 
 [testenv:docs]
 deps =
@@ -91,6 +94,6 @@ deps =
 
 commands=
     {envpython} setup_helpers.py spelling-clean
-    {envpython} setup.py spelling
+    sphinx-build -vWEa --keep-going -b spelling doc build/doc
     {envpython} setup_helpers.py spelling
-    {envpython} setup.py html
+    sphinx-build -vWEa --keep-going -b html doc build/doc



View it on GitLab: https://salsa.debian.org/med-team/python-prefixed/-/compare/fc7b742fa6abe9dcf99f507796d8106cce3e7ba3...e234a351e1a03125b5676b302f521f76ee5e10e0

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-prefixed/-/compare/fc7b742fa6abe9dcf99f507796d8106cce3e7ba3...e234a351e1a03125b5676b302f521f76ee5e10e0
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230206/e446eef8/attachment-0001.htm>


More information about the debian-med-commit mailing list