# HG changeset patch # User Paul Boddie # Date 1485455614 -3600 # Node ID e8233d5dad812a6259e114a8c9890e47a427c3e9 # Parent 10c2627ba58a092e49a92ff5bf817d77f5190588 Avoid importing modules to discover their paths, using imp.find_module instead. Ensure a stable ordering of recorded modules. diff -r 10c2627ba58a -r e8233d5dad81 imiptools/handlers/scheduling/manifest.py --- a/imiptools/handlers/scheduling/manifest.py Thu Jan 26 19:21:02 2017 +0100 +++ b/imiptools/handlers/scheduling/manifest.py Thu Jan 26 19:33:34 2017 +0100 @@ -4,7 +4,7 @@ scheduling_functions = {} unlocking_functions = {} -from imiptools.handlers.scheduling.quota import ( +from imiptools.handlers.scheduling.access import ( confirmation_functions as c, locking_functions as l, retraction_functions as r, @@ -30,7 +30,7 @@ scheduling_functions.update(s) unlocking_functions.update(u) -from imiptools.handlers.scheduling.access import ( +from imiptools.handlers.scheduling.quota import ( confirmation_functions as c, locking_functions as l, retraction_functions as r, diff -r 10c2627ba58a -r e8233d5dad81 tools/update_scheduling_modules.py --- a/tools/update_scheduling_modules.py Thu Jan 26 19:21:02 2017 +0100 +++ b/tools/update_scheduling_modules.py Thu Jan 26 19:33:34 2017 +0100 @@ -3,7 +3,7 @@ """ Update the scheduling modules import manifest. -Copyright (C) 2016 Paul Boddie +Copyright (C) 2016, 2017 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -21,20 +21,24 @@ from glob import glob from os.path import join, split, splitext -import imiptools.handlers +import imp reserved = ["__init__.py", "common.py", "manifest.py"] # The main program generating a new version of the manifest module. if __name__ == "__main__": - dirname = join(split(imiptools.handlers.__file__)[0], "scheduling") + _f, dirname, _d = imp.find_module("imiptools/handlers") + dirname = join(dirname, "scheduling") # Get all Python files in the scheduling directory, filtering out the # reserved files that do not provide scheduling functions. filenames = [] - for filename in glob(join(dirname, "*.py")): + found = glob(join(dirname, "*.py")) + found.sort() + + for filename in found: filename = split(filename)[-1] if filename not in reserved: filenames.append(filename) diff -r 10c2627ba58a -r e8233d5dad81 tools/update_storage_modules.py --- a/tools/update_storage_modules.py Thu Jan 26 19:21:02 2017 +0100 +++ b/tools/update_storage_modules.py Thu Jan 26 19:33:34 2017 +0100 @@ -22,22 +22,27 @@ from glob import glob from os import listdir from os.path import commonprefix, isdir, join, split, splitext -import imiptools.stores +import imp reserved = ["__init__.py", "common.py", "manifest.py"] def get_extensions(dirname): filenames = [] - for filename in glob(join(dirname, "*.py")): + found = glob(join(dirname, "*.py")) + found.sort() + + for filename in found: leafname = split(filename)[-1] if leafname not in reserved: filenames.append(filename) + return filenames # The main program generating a new version of the manifest module. if __name__ == "__main__": - dirname = join(split(imiptools.stores.__file__)[0], "") + _f, dirname, _d = imp.find_module("imiptools/stores") + dirname = join(dirname, "") manifest = join(dirname, "manifest.py") # Get all Python files in the stores directory, filtering out the @@ -47,7 +52,10 @@ # Get all extensions from directories in the stores directory. - for filename in listdir(dirname): + found = listdir(dirname) + found.sort() + + for filename in found: filename = join(dirname, filename) if isdir(filename): filenames += get_extensions(filename)