[Git][debian-gis-team/proj-data][master] 2 commits: Group files by copyright & license.

Bas Couwenberg gitlab at salsa.debian.org
Wed Feb 26 09:34:08 GMT 2020



Bas Couwenberg pushed to branch master at Debian GIS Project / proj-data


Commits:
32c557fe by Bas Couwenberg at 2020-02-26T10:32:08+01:00
Group files by copyright & license.

- - - - -
19eb9cbb by Bas Couwenberg at 2020-02-26T10:34:01+01:00
Strip trailing whitespace.

- - - - -


3 changed files:

- debian/changelog
- debian/copyright
- debian/csv2dep5.py


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+proj-data (1.0~rc2-1~exp2) UNRELEASED; urgency=medium
+
+  * Group files by copyright & license.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Wed, 26 Feb 2020 10:13:45 +0100
+
 proj-data (1.0~rc2-1~exp1) experimental; urgency=medium
 
   * New upstream release candidate.


=====================================
debian/copyright
=====================================
@@ -57,10 +57,7 @@ Files: ca_nrc_ABCSRSV4.tif
  ca_nrc_ON76CSv1.tif
  ca_nrc_ON83CSv1.tif
  ca_nrc_PE7783V2.tif
-Copyright: Her Majesty the Queen in right of Canada as represented by the Canadian Geodetic Survey, Natural Resources Canada
-License: OGL-Canada-2.0
-
-Files: ca_nrc_SK27-98.tif
+ ca_nrc_SK27-98.tif
  ca_nrc_SK83-98.tif
  ca_nrc_TO27CSv1.tif
 Copyright: Her Majesty the Queen in right of Canada as represented by the Canadian Geodetic Survey, Natural Resources Canada
@@ -112,6 +109,7 @@ Files: DK
  dk_sdfe_fvr09.tif
  dk_sdfe_gvr2000.tif
  dk_sdfe_gvr2016.tif
+ FO
 Copyright: Agency for Data Supply and Efficiency (SDFE)
 License: CC-BY-4.0
 
@@ -120,13 +118,10 @@ Copyright: Institut Cartogràfic i Geològic de Catalunya (ICGC)
 License: CC-BY-4.0
 
 Files: eur_nkg_nkgrf03vel_realigned.tif
+ NKG
 Copyright: Nordic Geodetic Commission
 License: CC-BY-4.0
 
-Files: FO
-Copyright: Agency for Data Supply and Efficiency (SDFE)
-License: CC-BY-4.0
-
 Files: fr_ign_CGVD2013RGSPM06.tif
  fr_ign_gg10_sbv2.tif
  fr_ign_gg10_smv2.tif
@@ -186,10 +181,6 @@ Files: ISL
 Copyright: Copyright 2017-2019, National Land Survey of Iceland
 License: CC-BY-4.0
 
-Files: NKG
-Copyright: Nordic Geodetic Commission
-License: CC-BY-4.0
-
 Files: nl_nsgi_naptrans2018.tif
  nl_nsgi_nlgeo2018.tif
  nl_nsgi_rdcorr2018.tif
@@ -210,10 +201,7 @@ Files: nz_linz_auckht1946-nzvd2016.tif
  nz_linz_nzgeoid2009.tif
  nz_linz_nzgeoid2016.tif
  nz_linz_ontpht1964-nzvd2016.tif
-Copyright: Land Information New Zealand
-License: CC-BY-4.0
-
-Files: nz_linz_stisht1977-nzvd2016.tif
+ nz_linz_stisht1977-nzvd2016.tif
  nz_linz_taraht1970-nzvd2016.tif
  nz_linz_wellht1953-nzvd2016.tif
 Copyright: Land Information New Zealand


=====================================
debian/csv2dep5.py
=====================================
@@ -23,7 +23,7 @@ def csv2dep5():
 
         for row in reader:
             if args.debug:
-                print("Row: %s" % row)    
+                print("Row: %s" % row)
 
             rows.append(row)
 
@@ -47,7 +47,16 @@ def csv2dep5():
         'The 2-Clause BSD License':           'BSD-2-Clause',
     }
 
+    file_copyright = {}
+    copyright_group = {}
+
     for row in rows:
+        if(
+            row['filename'].endswith('_README.txt') or
+            row['filename'] == 'README.DATA'
+          ):
+            continue
+
         filename = row['filename']
         copyright = row['copyright']
         if 'license' in row:
@@ -65,21 +74,39 @@ def csv2dep5():
         else:
             license = "FIXME: %s" % license
 
-        if(
-            len(sections) > 0 and
-            sections[-1]['copyright'] == copyright and
-            sections[-1]['license'] == license
-          ):
-            sections[-1]['files'].append(filename)
-        else:
+        file_copyright[filename] = {
+                                     'copyright': copyright,
+                                     'license':   license,
+                                   }
+
+        if copyright not in copyright_group:
+            copyright_group[copyright] = {}
+
+        if license not in copyright_group[copyright]:
+            copyright_group[copyright][license] = []
+
+        copyright_group[copyright][license].append(filename)
+
+    seen = {}
+
+    for filename in file_copyright:
+        copyright = file_copyright[filename]['copyright']
+        license = file_copyright[filename]['license']
+
+        if copyright not in seen or license not in seen[copyright]:
             section = {
-                        'files':     [ filename ],
+                        'files':     copyright_group[copyright][license],
                         'copyright': copyright,
                         'license':   license
                       }
 
             sections.append(section)
 
+            if copyright not in seen:
+                seen[copyright] = {}
+
+            seen[copyright][license] = True
+
     output = ''
 
     i = 0
@@ -120,23 +147,23 @@ def main():
                          ),
                          default=default['input-file'],
                        )
-    parser.add_argument( 
+    parser.add_argument(
                          '-d', '--debug',
-                         action='store_true', 
+                         action='store_true',
                          help='Enable debug output',
-                       ) 
-    parser.add_argument( 
+                       )
+    parser.add_argument(
                          '-v', '--verbose',
-                         action='store_true', 
+                         action='store_true',
                          help='Enable verbose output',
-                       ) 
-                       
+                       )
+
     args = parser.parse_args()
 
     if not args.input_file:
         print("Error: No input file specified!")
         sys.exit(1)
-                         
+
     csv2dep5()
 
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/proj-data/-/compare/9c3cd7b9ee5e19e5aeb12eaf68bbe5a564385b74...19eb9cbb90a7d92d54932e0913e091b5178347bf

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/proj-data/-/compare/9c3cd7b9ee5e19e5aeb12eaf68bbe5a564385b74...19eb9cbb90a7d92d54932e0913e091b5178347bf
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/pkg-grass-devel/attachments/20200226/2f812b57/attachment-0001.html>


More information about the Pkg-grass-devel mailing list