| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fc407bb commit 68e4b5a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,6 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 31 | from __future__ import print_function | |
| 32 | - import imp | ||
| 33 | 32 | import logging | |
| 34 | 33 | import optparse | |
| 35 | 34 | import os | |
@@ -45,6 +44,27 @@ | |||
| 45 | 44 | import errno | |
| 46 | 45 | import copy | |
| 47 | 46 | ||
| 47 | + | ||
| 48 | + if sys.version_info >= (3, 5): | ||
| 49 | + from importlib import machinery, util | ||
| 50 | + def get_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 | + return module | ||
| 56 | + else: | ||
| 57 | + import imp | ||
| 58 | + def get_module(name, path): | ||
| 59 | + file = None | ||
| 60 | + try: | ||
| 61 | + (file, pathname, description) = imp.find_module(name, [path]) | ||
| 62 | + return imp.load_module(name, file, pathname, description) | ||
| 63 | + finally: | ||
| 64 | + if file: | ||
| 65 | + file.close() | ||
| 66 | + | ||
| 67 | + | ||
| 48 | 68 | from io import open | |
| 49 | 69 | from os.path import join, dirname, abspath, basename, isdir, exists | |
| 50 | 70 | from datetime import datetime | |
@@ -791,18 +811,13 @@ def GetConfiguration(self, context): | |||
| 791 | 811 | if self.is_loaded: | |
| 792 | 812 | return self.config | |
| 793 | 813 | self.is_loaded = True | |
| 794 | - file = None | ||
| 795 | - try: | ||
| 796 | - (file, pathname, description) = imp.find_module('testcfg', [ self.path ]) | ||
| 797 | - module = imp.load_module('testcfg', file, pathname, description) | ||
| 798 | - self.config = module.GetConfiguration(context, self.path) | ||
| 799 | - if hasattr(self.config, 'additional_flags'): | ||
| 800 | - self.config.additional_flags += context.node_args | ||
| 801 | - else: | ||
| 802 | - self.config.additional_flags = context.node_args | ||
| 803 | - finally: | ||
| 804 | - if file: | ||
| 805 | - file.close() | ||
| 814 | + | ||
| 815 | + module = get_module('testcfg', self.path) | ||
| 816 | + self.config = module.GetConfiguration(context, self.path) | ||
| 817 | + if hasattr(self.config, 'additional_flags'): | ||
| 818 | + self.config.additional_flags += context.node_args | ||
| 819 | + else: | ||
| 820 | + self.config.additional_flags = context.node_args | ||
| 806 | 821 | return self.config | |
| 807 | 822 | ||
| 808 | 823 | def GetBuildRequirements(self, path, context): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments