Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wmlxgettext crashes if there is no .cfg file to scan #3719

Closed
sevu opened this issue Nov 13, 2018 · 3 comments
Closed

wmlxgettext crashes if there is no .cfg file to scan #3719

sevu opened this issue Nov 13, 2018 · 3 comments
Labels
Enhancement Issues that are requests for new features or changes to existing ones. Low Priority Issues that will cause no meaningful problems if left unaddressed. Ready for testing Issues for which a potential fix is available but untested. WML Tools Issues involving WML maintenance tools.

Comments

@sevu
Copy link
Member

sevu commented Nov 13, 2018

E.g.

$ ./wmlxgettext --directory=/tmp --recursive --domain=wesnoth -o out.pot
Traceback (most recent call last):
  File "./wmlxgettext", line 269, in <module>
    main()
  File "./wmlxgettext", line 213, in main
    for fileno, fx in enumerate(filelist):
TypeError: 'NoneType' object is not iterable

(happened to me when I was in the translation subdirectory)

@sevu sevu added Enhancement Issues that are requests for new features or changes to existing ones. WML Tools Issues involving WML maintenance tools. Low Priority Issues that will cause no meaningful problems if left unaddressed. labels Nov 13, 2018
@jostephd jostephd added the Ready for testing Issues for which a potential fix is available but untested. label Nov 13, 2018
@jostephd
Copy link
Member

@sevu Try this please

diff --git a/data/tools/pywmlx/autof.py b/data/tools/pywmlx/autof.py
index f064f45d07a..51a87fb7a73 100644
--- a/data/tools/pywmlx/autof.py
+++ b/data/tools/pywmlx/autof.py
@@ -4,7 +4,7 @@ import re
 
 
 def autoscan(pathdir):
-    filelist = None
+    filelist = []
     parentdir = os.path.realpath(os.path.join(pathdir, '..'))
     for root, dirs, files in os.walk(pathdir, topdown=False):
         for name in files:
@@ -17,10 +17,7 @@ def autoscan(pathdir):
                     value = re.sub(r'^\/', '', value)
                 else:
                     value = re.sub(r'^(?:[A-Za-z]\:)?\\', '', value)
-                if filelist is None:
-                    filelist = [ value ]
-                else:
-                    filelist.append(value)
+                filelist.append(value)
                 # end if m
             # end for name
         # end for root
diff --git a/data/tools/wmlxgettext b/data/tools/wmlxgettext
index f5dfbe954ac..072fbb0041b 100755
--- a/data/tools/wmlxgettext
+++ b/data/tools/wmlxgettext
@@ -176,7 +176,6 @@ def main():
         fdebug = open('debug.txt', 'w', encoding='utf-8')
     pywmlx.statemachine.setup(sentlist, args.initdom, args.domain,
                               args.warnall, fdebug)
-    filelist = None
     if args.recursive is False and args.filelist is None:
         pywmlx.wmlerr("bad command line", "FILELIST must not be empty. "
                "Please, run wmlxgettext again and, this time, add some file "

@sevu
Copy link
Member Author

sevu commented Nov 13, 2018

It fixes it! Will you push it or shall I?

@jostephd
Copy link
Member

Go ahead.

sevu pushed a commit that referenced this issue Nov 14, 2018
@sevu sevu closed this as completed in e642223 Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Issues that are requests for new features or changes to existing ones. Low Priority Issues that will cause no meaningful problems if left unaddressed. Ready for testing Issues for which a potential fix is available but untested. WML Tools Issues involving WML maintenance tools.
Projects
None yet
Development

No branches or pull requests

2 participants