lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.18-27-gb8ee830

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

python-stdnum branch master updated. 1.18-27-gb8ee830



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  b8ee83071e63501f2410b9085f53d28c48696025 (commit)
       via  ef49f496aff717658cbea10e23a37ccf7d991893 (commit)
      from  38483183f47b0b12d80e76dd6d37df8f8af06da2 (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=b8ee83071e63501f2410b9085f53d28c48696025

commit b8ee83071e63501f2410b9085f53d28c48696025
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Aug 6 15:51:42 2023 +0200

    Extend license check to file header check
    
    This also checks that the file name referenced in the file header is
    correct.

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 24af22e..90412d8 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -60,7 +60,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        tox_job: [docs, flake8, license]
+        tox_job: [docs, flake8, headers]
     steps:
       - uses: actions/checkout@v3
       - name: Set up Python
diff --git a/scripts/check_license_headers.py b/scripts/check_headers.py
similarity index 72%
rename from scripts/check_license_headers.py
rename to scripts/check_headers.py
index 366fb79..41ab395 100755
--- a/scripts/check_license_headers.py
+++ b/scripts/check_headers.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-# check_license_headers - check that all source files have licensing 
information
+# check_headers.py - check that all source files have licensing information
 #
 # Copyright (C) 2023 Arthur de Jong
 #
@@ -22,11 +22,19 @@
 """This script checks that all source files have licensing information."""
 
 import glob
+import os
 import re
 import sys
 import textwrap
 
 
+# Regext to match the first line
+identification_re = re.compile(
+    r'^(#!/usr/bin/env python3?\s+|/\*\s+)?'
+    r'(# coding: utf-8\s+)?'
+    r'(\s?#\s+)?'
+    r'(?P<filename>[^ :]+) - ', re.MULTILINE)
+
 # Regex to match standard license blurb
 license_re = re.compile(textwrap.dedent(r'''
     [# ]*This library is free software; you can redistribute it and/or
@@ -46,13 +54,12 @@ license_re = re.compile(textwrap.dedent(r'''
     ''').strip(), re.MULTILINE)
 
 
-def file_has_correct_license(filename):
-    """Check that the file contains a valid license header."""
+def get_file_header(filename):
+    """Read the file header from the file."""
     with open(filename, 'rt') as f:
         # Only read the first 2048 bytes to avoid loading too much and the
         # license information should be in the first part anyway.
-        contents = f.read(2048)
-        return bool(license_re.search(contents))
+        return f.read(2048)
 
 
 if __name__ == '__main__':
@@ -66,8 +73,17 @@ if __name__ == '__main__':
         glob.glob('online_check/check.js', recursive=True)
     )
 
-    incorrect_files = [f for f in files_to_check if not 
file_has_correct_license(f)]
-    if incorrect_files:
-        print('Files with incorrect license information:')
-        print('\n'.join(incorrect_files))
+    # Look for files with incorrect first lines or license
+    fail = False
+    for filename in sorted(files_to_check):
+        contents = get_file_header(filename)
+        m = identification_re.match(contents)
+        if not bool(m) or m.group('filename') not in (filename, 
os.path.basename(filename)):
+            print('%s: Incorrect file identification' % filename)
+            fail = True
+        if not bool(license_re.search(contents)):
+            print('%s: Incorrect license text' % filename)
+            fail = True
+
+    if fail:
         sys.exit(1)
diff --git a/tox.ini b/tox.ini
index 81c352b..36eda87 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py{27,35,36,37,38,39,310,311,py,py3},flake8,docs,license
+envlist = py{27,35,36,37,38,39,310,311,py,py3},flake8,docs,headers
 skip_missing_interpreters = true
 
 [testenv]
@@ -35,7 +35,7 @@ use_develop = true
 deps = Sphinx
 commands = sphinx-build -N -b html docs {envtmpdir}/sphinx -W
 
-[testenv:license]
+[testenv:headers]
 skip_install = true
 deps =
-commands = python scripts/check_license_headers.py
+commands = python scripts/check_headers.py

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

commit ef49f496aff717658cbea10e23a37ccf7d991893
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Aug 6 15:07:18 2023 +0200

    Fix file headers
    
    This improves consistency across files and fixes some files that had an
    incorrect file name reference.

diff --git a/stdnum/be/bis.py b/stdnum/be/bis.py
index 467f3b7..77876fe 100644
--- a/stdnum/be/bis.py
+++ b/stdnum/be/bis.py
@@ -1,5 +1,5 @@
-# coding=utf-8
 # bis.py - functions for handling Belgian BIS numbers
+# coding: utf-8
 #
 # Copyright (C) 2023 Jeff Horemans
 #
diff --git a/stdnum/be/nn.py b/stdnum/be/nn.py
index 1de122a..6dea86b 100644
--- a/stdnum/be/nn.py
+++ b/stdnum/be/nn.py
@@ -1,5 +1,5 @@
-# coding=utf-8
 # nn.py - function for handling Belgian national numbers
+# coding: utf-8
 #
 # Copyright (C) 2021-2022 C├ędric Krier
 # Copyright (C) 2023 Jeff Horemans
diff --git a/stdnum/de/stnr.py b/stdnum/de/stnr.py
index 7838977..6c511f3 100644
--- a/stdnum/de/stnr.py
+++ b/stdnum/de/stnr.py
@@ -1,4 +1,4 @@
-# steuernummer.py - functions for handling German tax numbers
+# stnr.py - functions for handling German tax numbers
 # coding: utf-8
 #
 # Copyright (C) 2017 Holvi Payment Services
diff --git a/stdnum/dz/nif.py b/stdnum/dz/nif.py
index 68a1f09..48a16fd 100644
--- a/stdnum/dz/nif.py
+++ b/stdnum/dz/nif.py
@@ -1,4 +1,4 @@
-# pin.py - functions for handling Algeria NIF numbers
+# nif.py - functions for handling Algeria NIF numbers
 # coding: utf-8
 #
 # Copyright (C) 2022 Leandro Regueiro
diff --git a/stdnum/fi/alv.py b/stdnum/fi/alv.py
index 6e3515c..ca90bad 100644
--- a/stdnum/fi/alv.py
+++ b/stdnum/fi/alv.py
@@ -1,4 +1,4 @@
-# vat.py - functions for handling Finnish VAT numbers
+# alv.py - functions for handling Finnish VAT numbers
 # coding: utf-8
 #
 # Copyright (C) 2012-2015 Arthur de Jong
diff --git a/stdnum/gb/utr.py b/stdnum/gb/utr.py
index 958c723..1c4ee70 100644
--- a/stdnum/gb/utr.py
+++ b/stdnum/gb/utr.py
@@ -1,4 +1,4 @@
-# upn.py - functions for handling English UTRs
+# utr.py - functions for handling English UTRs
 #
 # Copyright (C) 2020 Holvi Payment Services
 # Copyright (C) 2020 Arthur de Jong
diff --git a/stdnum/hr/oib.py b/stdnum/hr/oib.py
index 092c58c..72801a4 100644
--- a/stdnum/hr/oib.py
+++ b/stdnum/hr/oib.py
@@ -1,4 +1,4 @@
-# cnp.py - functions for handling Croatian OIB numbers
+# oib.py - functions for handling Croatian OIB numbers
 # coding: utf-8
 #
 # Copyright (C) 2012, 2013 Arthur de Jong
diff --git a/stdnum/md/idno.py b/stdnum/md/idno.py
index 4ba8063..5673d7f 100644
--- a/stdnum/md/idno.py
+++ b/stdnum/md/idno.py
@@ -1,4 +1,4 @@
-# rnc.py - functions for handling Moldavian company identification numbers
+# idno.py - functions for handling Moldavian company identification numbers
 # coding: utf-8
 #
 # Copyright (C) 2019 Arthur de Jong
diff --git a/stdnum/pl/regon.py b/stdnum/pl/regon.py
index 42f3f6a..e738ca7 100644
--- a/stdnum/pl/regon.py
+++ b/stdnum/pl/regon.py
@@ -1,4 +1,4 @@
-# pesel.py - functions for handling REGON numbers
+# regon.py - functions for handling REGON numbers
 # coding: utf-8
 #
 # Copyright (C) 2015 Dariusz Choruzy
diff --git a/stdnum/py/ruc.py b/stdnum/py/ruc.py
index 0870b66..0630d96 100644
--- a/stdnum/py/ruc.py
+++ b/stdnum/py/ruc.py
@@ -1,4 +1,4 @@
-# rut.py - functions for handling Paraguay RUC numbers
+# ruc.py - functions for handling Paraguay RUC numbers
 # coding: utf-8
 #
 # Copyright (C) 2019 Leandro Regueiro
diff --git a/stdnum/sk/dph.py b/stdnum/sk/dph.py
index c8cab28..c76f526 100644
--- a/stdnum/sk/dph.py
+++ b/stdnum/sk/dph.py
@@ -1,4 +1,4 @@
-# vat.py - functions for handling Slovak VAT numbers
+# dph.py - functions for handling Slovak VAT numbers
 # coding: utf-8
 #
 # Copyright (C) 2012, 2013 Arthur de Jong
diff --git a/stdnum/tn/mf.py b/stdnum/tn/mf.py
index 4ea2414..90cb3cf 100644
--- a/stdnum/tn/mf.py
+++ b/stdnum/tn/mf.py
@@ -1,4 +1,4 @@
-# pin.py - functions for handling Tunisia MF numbers
+# mf.py - functions for handling Tunisia MF numbers
 # coding: utf-8
 #
 # Copyright (C) 2022 Leandro Regueiro
diff --git a/stdnum/ua/edrpou.py b/stdnum/ua/edrpou.py
index 4ecb8eb..b7d3f9f 100644
--- a/stdnum/ua/edrpou.py
+++ b/stdnum/ua/edrpou.py
@@ -1,4 +1,4 @@
-# ubn.py - functions for handling Ukrainian EDRPOU numbers
+# edrpou.py - functions for handling Ukrainian EDRPOU numbers
 # coding: utf-8
 #
 # Copyright (C) 2020 Leandro Regueiro
diff --git a/stdnum/ua/rntrc.py b/stdnum/ua/rntrc.py
index 301daa2..07b64de 100644
--- a/stdnum/ua/rntrc.py
+++ b/stdnum/ua/rntrc.py
@@ -1,4 +1,4 @@
-# ubn.py - functions for handling Ukrainian RNTRC numbers
+# rntrc.py - functions for handling Ukrainian RNTRC numbers
 # coding: utf-8
 #
 # Copyright (C) 2020 Leandro Regueiro
diff --git a/stdnum/vn/mst.py b/stdnum/vn/mst.py
index 55d5575..7e372cf 100644
--- a/stdnum/vn/mst.py
+++ b/stdnum/vn/mst.py
@@ -1,4 +1,4 @@
-# nit.py - functions for handling Vietnam MST numbers
+# mst.py - functions for handling Vietnam MST numbers
 # coding: utf-8
 #
 # Copyright (C) 2020 Leandro Regueiro
diff --git a/stdnum/za/idnr.py b/stdnum/za/idnr.py
index c4cae18..beb53ef 100644
--- a/stdnum/za/idnr.py
+++ b/stdnum/za/idnr.py
@@ -1,4 +1,4 @@
-# tin.py - functions for handling South Africa ID number
+# idnr.py - functions for handling South Africa ID number
 # coding: utf-8
 #
 # Copyright (C) 2020 Arthur de Jong
diff --git a/tests/test_al_nipt.doctest b/tests/test_al_nipt.doctest
index 0c90fb7..19cad11 100644
--- a/tests/test_al_nipt.doctest
+++ b/tests/test_al_nipt.doctest
@@ -1,4 +1,4 @@
-test_al_nitp.doctest - more detailed doctests stdnum.al.nipt
+test_al_nipt.doctest - more detailed doctests stdnum.al.nipt
 
 Copyright (C) 2015-2023 Arthur de Jong
 
diff --git a/tests/test_gb_sedol.doctest b/tests/test_gb_sedol.doctest
index 407d295..c617dbf 100644
--- a/tests/test_gb_sedol.doctest
+++ b/tests/test_gb_sedol.doctest
@@ -1,4 +1,4 @@
-test_sedol.doctest - more detailed doctests for the stdnum.gb.sedol module
+test_gb_sedol.doctest - more detailed doctests for the stdnum.gb.sedol module
 
 Copyright (C) 2015 Arthur de Jong
 
diff --git a/tests/test_iso6346.doctest b/tests/test_iso6346.doctest
index a6b2f49..a6234ff 100644
--- a/tests/test_iso6346.doctest
+++ b/tests/test_iso6346.doctest
@@ -1,4 +1,4 @@
-test_doctest - more detailed doctests for the stdnum.iso6346 package
+test_iso6346.doctest - more detailed doctests for the stdnum.iso6346 package
 
 Copyright (C) 2014 Openlabs Technologies & Consulting (P) Limited
 
diff --git a/tests/test_iso7064.doctest b/tests/test_iso7064.doctest
index 0195013..12b5743 100644
--- a/tests/test_iso7064.doctest
+++ b/tests/test_iso7064.doctest
@@ -1,4 +1,4 @@
-test_doctest - more detailed doctests for the stdnum.iso7064 package
+test_iso7064.doctest - more detailed doctests for the stdnum.iso7064 package
 
 Copyright (C) 2010-2022 Arthur de Jong
 
diff --git a/tests/test_th_moa.doctest b/tests/test_th_moa.doctest
index 47c0f08..fbe1258 100644
--- a/tests/test_th_moa.doctest
+++ b/tests/test_th_moa.doctest
@@ -1,4 +1,4 @@
-test_th_mod.doctest - more detailed doctests for stdnum.th.moa module
+test_th_moa.doctest - more detailed doctests for stdnum.th.moa module
 
 Copyright (C) 2021 Piruin Panichphol
 
diff --git a/tests/test_tn_mf.doctest b/tests/test_tn_mf.doctest
index 743105a..a45623b 100644
--- a/tests/test_tn_mf.doctest
+++ b/tests/test_tn_mf.doctest
@@ -1,4 +1,4 @@
-test_gt_nit.doctest - more detailed doctests for stdnum.tn.mf module
+test_tn_mf.doctest - more detailed doctests for stdnum.tn.mf module
 
 Copyright (C) 2022 Leandro Regueiro
 
diff --git a/tests/test_ve_rif.doctest b/tests/test_ve_rif.doctest
index ce4eec3..825cfbc 100644
--- a/tests/test_ve_rif.doctest
+++ b/tests/test_ve_rif.doctest
@@ -1,4 +1,4 @@
-test_ve_nitp.doctest - more detailed doctests stdnum.ve.rif
+test_ve_rif.doctest - more detailed doctests stdnum.ve.rif
 
 Copyright (C) 2015-2017 Arthur de Jong
 

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

Summary of changes:
 .github/workflows/test.yml                         |  2 +-
 .../{check_license_headers.py => check_headers.py} | 34 ++++++++++++++++------
 stdnum/be/bis.py                                   |  2 +-
 stdnum/be/nn.py                                    |  2 +-
 stdnum/de/stnr.py                                  |  2 +-
 stdnum/dz/nif.py                                   |  2 +-
 stdnum/fi/alv.py                                   |  2 +-
 stdnum/gb/utr.py                                   |  2 +-
 stdnum/hr/oib.py                                   |  2 +-
 stdnum/md/idno.py                                  |  2 +-
 stdnum/pl/regon.py                                 |  2 +-
 stdnum/py/ruc.py                                   |  2 +-
 stdnum/sk/dph.py                                   |  2 +-
 stdnum/tn/mf.py                                    |  2 +-
 stdnum/ua/edrpou.py                                |  2 +-
 stdnum/ua/rntrc.py                                 |  2 +-
 stdnum/vn/mst.py                                   |  2 +-
 stdnum/za/idnr.py                                  |  2 +-
 tests/test_al_nipt.doctest                         |  2 +-
 tests/test_gb_sedol.doctest                        |  2 +-
 tests/test_iso6346.doctest                         |  2 +-
 tests/test_iso7064.doctest                         |  2 +-
 tests/test_th_moa.doctest                          |  2 +-
 tests/test_tn_mf.doctest                           |  2 +-
 tests/test_ve_rif.doctest                          |  2 +-
 tox.ini                                            |  6 ++--
 26 files changed, 52 insertions(+), 36 deletions(-)
 rename scripts/{check_license_headers.py => check_headers.py} (72%)


hooks/post-receive
-- 
python-stdnum