lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.18-7-gcf22705

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.18-7-gcf22705



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  cf22705e9fb1a7900174c5040d403cc767b866d0 (commit)
      from  6d366e3312f4eafa61f617bc6ba4f35cf63fa251 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=cf22705e9fb1a7900174c5040d403cc767b866d0

commit cf22705e9fb1a7900174c5040d403cc767b866d0
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Mon Jan 2 23:01:46 2023 +0100

    Extend number properties to show in online check
    
    This also ensures that flake8 is run on the WSGI script.

diff --git a/online_check/stdnum.wsgi b/online_check/stdnum.wsgi
index 74da5b4..f65c959 100755
--- a/online_check/stdnum.wsgi
+++ b/online_check/stdnum.wsgi
@@ -1,6 +1,6 @@
 # stdnum.wsgi - simple WSGI application to check numbers
 #
-# Copyright (C) 2017-2020 Arthur de Jong.
+# Copyright (C) 2017-2023 Arthur de Jong
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -19,6 +19,7 @@
 
 """Simple WSGI application to check numbers."""
 
+import datetime
 import html
 import inspect
 import json
@@ -31,7 +32,7 @@ import urllib.parse
 sys.stdout = sys.stderr
 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'python-stdnum'))
 
-from stdnum.util import (
+from stdnum.util import (  # noqa: E402,I001 (import after changes to sys.path)
     get_module_description, get_module_name, get_number_modules, to_unicode)
 
 
@@ -41,16 +42,19 @@ _template = None
 def get_conversions(module, number):
     """Return the possible conversions for the number."""
     for name, func in inspect.getmembers(module, inspect.isfunction):
-        if name.startswith('to_'):
+        if name.startswith('to_') or name.startswith('get_'):
             args, varargs, varkw, defaults = inspect.getargspec(func)
             if defaults:
                 args = args[:-len(defaults)]
             if args == ['number'] and not name.endswith('binary'):
                 try:
+                    prop = name.split('_', 1)[1].replace('_', ' ')
                     conversion = func(number)
-                    if conversion != number:
-                        yield (name[3:], to_unicode(conversion))
-                except Exception:
+                    if isinstance(conversion, datetime.date):
+                        yield (prop, conversion.strftime('%Y-%m-%d'))
+                    elif conversion != number:
+                        yield (prop, to_unicode(conversion))
+                except Exception:  # noqa: B902 (catch anything that goes 
wrong)
                     pass
 
 
diff --git a/tox.ini b/tox.ini
index 3120136..ba29878 100644
--- a/tox.ini
+++ b/tox.ini
@@ -28,7 +28,7 @@ deps = flake8<6.0
        flake8-tidy-imports
        flake8-tuple
        pep8-naming
-commands = flake8 stdnum tests update setup.py
+commands = flake8 stdnum tests update setup.py online_check/stdnum.wsgi
 
 [testenv:docs]
 use_develop = true

-----------------------------------------------------------------------

Summary of changes:
 online_check/stdnum.wsgi | 16 ++++++++++------
 tox.ini                  |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
python-stdnum