On 27May2016 21:02, Sayth Renshaw <flebber.c...@gmail.com> wrote:
On Saturday, 28 May 2016 13:06:59 UTC+10, Michael Torrie  wrote:
Add more print() calls. Offhand I'd say that pq(filename=filename) is
returning an empty list so that for loop is not doing anything.  Hence
your debugging print() calls never happen.

Add sanity print()'s earlier in your program, and make sure everything
you are iterating over is what you expect.

Ok after printing a few things i have found an error.

def GetArgs():
   '''parse XML from command line'''
   parser = argparse.ArgumentParser()

   parser.add_argument("path", nargs="+")
   parser.add_argument('-e', '--extension', default='',
                       help='File extension to filter by.')
   args = parser.parse_args()

   files = set()
   name_pattern = "*" + args.extension
   for path in args.path:
       files.update(glob.glob(os.path.join(path, name_pattern)))

   print(files)
   return files

a = GetArgs()
print(a)

so printing the files or the call to the function returns set() not the actual 
files.

Since you're constructing a set of filenames, this means it is probably returning the right kind of thing, but it is empty. That points to the glob not doing what you want or the for-loop not doing anything.

[sayth@localhost pyXML]$ python3 racemeeting.py data/*.xml
set()
set()
set()

So...  Add more prints!

Specificly, print(args) right after it is set, and put a print() _inside_ the loop before the call to files.update, probably printing "path", eg print("path =", path).

Then see what you learn.

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to