fixed the use of moved-to-files check not working if there were non-alphanumerics in the filename

Mon, 24 Jun 2019 01:01:45 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 24 Jun 2019 01:01:45 +0300
changeset 85
4438502fd3e0
parent 84
55d52e25267f
child 86
b25fc6f7eb70

fixed the use of moved-to-files check not working if there were non-alphanumerics in the filename

ldcheck.py file | annotate | diff | comparison | revisions
tests/subfiles.py file | annotate | diff | comparison | revisions
--- a/ldcheck.py	Mon Jun 24 00:54:24 2019 +0300
+++ b/ldcheck.py	Mon Jun 24 01:01:45 2019 +0300
@@ -102,12 +102,16 @@
         help = 'finds a primitive by name and prints out in which '
             'dimensions it is flat in',
     )
+    parser.add_argument('--description',
+        action = 'store_true',
+        help = 'finds a primitive by name and prints out its description',
+    )
     args = parser.parse_args()
     config = load_config('ldcheck.cfg')
     for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
         with ldconfig_ldr_path.open() as ldconfig_ldr:
             load_colours(ldconfig_ldr)
-    if args.flatness:
+    if args.flatness or args.description:
         import filecache
         cache = filecache.SubfileCache(
             ldraw_directories = config['libraries'],
@@ -115,7 +119,7 @@
         subfile = cache.prepare_file(args.filename)
         if not subfile.valid:
             print(subfile.problem)
-        else:
+        elif args.flatness:
             if subfile.flatness:
                 print(str.format(
                     'Flatness: {}',
@@ -123,6 +127,8 @@
                 ))
             else:
                 print('File is not flat in any dimensions')
+        elif args.description:
+            print('Description:', repr(subfile.description))
     else:
         with open(args.filename) as file:
             from os.path import basename
--- a/tests/subfiles.py	Mon Jun 24 00:54:24 2019 +0300
+++ b/tests/subfiles.py	Mon Jun 24 01:01:45 2019 +0300
@@ -131,7 +131,7 @@
 @problem_type('moved-file-used',
     severity = 'hold',
     message = lambda moved_file, new_file:
-        str.format('subfile "{moved_file}" has been moved to "{new_file}"',
+        str.format('subfile "{moved_file}" has been moved to "{new_file}.dat"',
             **locals(),
         ),
 )
@@ -183,7 +183,7 @@
             else:
                 # Test for use of moved-to files
                 import re
-                match = re.search(r'^\~Moved(?: to (\w+))?$', subfile.description)
+                match = re.search(r'^\~Moved(?: to (.+))?$', subfile.description)
                 if match:
                     yield report_problem(
                         'moved-file-used',

mercurial