> > 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))) > return files > > > > # Now walk the tree and insert data. > for filename in sorted(GetArgs()): > for meeting in pq(filename=filename): > print(filename) > print(meeting) > meetdata = [meeting.get(attr) for attr in meetattrs] > cur.execute("insert into meetings valueme in GetArgs():s (" + > ",".join(["%s"]*len(meetattrs)) + ")", meetdata) > for race in meeting.findall("race"): > race.set("meeting_id", meeting.get("id")) > racedata = [race.get(attr) for attr in raceattrs] > cur.execute("insert into races values (" + > ",".join(["%s"]*len(raceattrs)) + ")", > racedata) > for horse in race.findall("nomination"): > horse.set("race_id", race.get("id")) > horsedata = [horse.get(attr) for attr in horseattrs] > cur.execute("insert into horses values (" + > ",".join(["%s"]*len(horseattrs)) + ")", > horsedata) > > If your actual indentation matches what I see in your post, is your
for filename in sorted(GetArgs()) line within the definition of GetArgs? If yes, it will not be executed. -- https://mail.python.org/mailman/listinfo/python-list