|
29 | 29 |
|
30 | 30 |
|
31 | 31 | from __future__ importprint_function |
32 | | -importimp |
33 | 32 | importlogging |
34 | 33 | importoptparse |
35 | 34 | importos |
|
45 | 44 | importerrno |
46 | 45 | importcopy |
47 | 46 |
|
| 47 | + |
| 48 | +ifsys.version_info>= (3, 5): |
| 49 | +fromimportlibimportmachinery, util |
| 50 | +defget_module(name, path): |
| 51 | +loader_details= (machinery.SourceFileLoader, machinery.SOURCE_SUFFIXES) |
| 52 | +spec=machinery.FileFinder(path, loader_details).find_spec(name) |
| 53 | +module=util.module_from_spec(spec) |
| 54 | +spec.loader.exec_module(module) |
| 55 | +returnmodule |
| 56 | +else: |
| 57 | +importimp |
| 58 | +defget_module(name, path): |
| 59 | +file=None |
| 60 | +try: |
| 61 | + (file, pathname, description) =imp.find_module(name, [path]) |
| 62 | +returnimp.load_module(name, file, pathname, description) |
| 63 | +finally: |
| 64 | +iffile: |
| 65 | +file.close() |
| 66 | + |
| 67 | + |
48 | 68 | fromioimportopen |
49 | 69 | fromos.pathimportjoin, dirname, abspath, basename, isdir, exists |
50 | 70 | fromdatetimeimportdatetime |
@@ -786,18 +806,13 @@ def GetConfiguration(self, context): |
786 | 806 | ifself.is_loaded: |
787 | 807 | returnself.config |
788 | 808 | self.is_loaded=True |
789 | | -file=None |
790 | | -try: |
791 | | - (file, pathname, description) =imp.find_module('testcfg', [ self.path ]) |
792 | | -module=imp.load_module('testcfg', file, pathname, description) |
793 | | -self.config=module.GetConfiguration(context, self.path) |
794 | | -ifhasattr(self.config, 'additional_flags'): |
795 | | -self.config.additional_flags+=context.node_args |
796 | | -else: |
797 | | -self.config.additional_flags=context.node_args |
798 | | -finally: |
799 | | -iffile: |
800 | | -file.close() |
| 809 | + |
| 810 | +module=get_module('testcfg', self.path) |
| 811 | +self.config=module.GetConfiguration(context, self.path) |
| 812 | +ifhasattr(self.config, 'additional_flags'): |
| 813 | +self.config.additional_flags+=context.node_args |
| 814 | +else: |
| 815 | +self.config.additional_flags=context.node_args |
801 | 816 | returnself.config |
802 | 817 |
|
803 | 818 | defGetBuildRequirements(self, path, context): |
|
0 commit comments