Kaydet (Commit) fb278a5e authored tarafından Jack Jansen's avatar Jack Jansen

Added an "optional" directive, that will include a module if it is available

but not complain if it isn't (giving an ImportError when the frozen code is run).
üst c0d2d51d
...@@ -18,6 +18,7 @@ REPROG=re.compile(DIRECTIVE_RE) ...@@ -18,6 +18,7 @@ REPROG=re.compile(DIRECTIVE_RE)
def findfreezedirectives(program): def findfreezedirectives(program):
extra_modules = [] extra_modules = []
exclude_modules = [] exclude_modules = []
optional_modules = []
extra_path = [] extra_path = []
progdir, filename = os.path.split(program) progdir, filename = os.path.split(program)
fp = open(program) fp = open(program)
...@@ -30,10 +31,12 @@ def findfreezedirectives(program): ...@@ -30,10 +31,12 @@ def findfreezedirectives(program):
extra_modules.append(argument) extra_modules.append(argument)
elif directive == 'exclude': elif directive == 'exclude':
exclude_modules.append(argument) exclude_modules.append(argument)
elif directive == 'optional':
optional_modules.append(argument)
elif directive == 'path': elif directive == 'path':
argument = os.path.join(progdir, argument) argument = os.path.join(progdir, argument)
extra_path.append(argument) extra_path.append(argument)
else: else:
print '** Unknown directive', line print '** Unknown directive', line
return extra_modules, exclude_modules, extra_path return extra_modules, exclude_modules, optional_modules, extra_path
...@@ -57,7 +57,7 @@ def process(program, modules=[], module_files = [], debug=0): ...@@ -57,7 +57,7 @@ def process(program, modules=[], module_files = [], debug=0):
# #
# search the main source for directives # search the main source for directives
# #
extra_modules, exclude_modules, extra_path = \ extra_modules, exclude_modules, optional_modules, extra_path = \
directives.findfreezedirectives(program) directives.findfreezedirectives(program)
for m in extra_modules: for m in extra_modules:
if os.sep in m: if os.sep in m:
...@@ -84,7 +84,7 @@ def process(program, modules=[], module_files = [], debug=0): ...@@ -84,7 +84,7 @@ def process(program, modules=[], module_files = [], debug=0):
# #
# Tell the user about missing modules # Tell the user about missing modules
# #
maymiss = exclude_modules + MAC_MAYMISS_MODULES maymiss = exclude_modules + optional_modules + MAC_MAYMISS_MODULES
for m in modfinder.badmodules.keys(): for m in modfinder.badmodules.keys():
if not m in maymiss: if not m in maymiss:
if debug > 0: if debug > 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment