Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
UW-Glance
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eva Schiffer
UW-Glance
Commits
91e1289b
Commit
91e1289b
authored
4 years ago
by
Eva Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
moving from imp to importlib for loading our configuration files
parent
80dbb92e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyglance/glance/config_organizer.py
+17
-4
17 additions, 4 deletions
pyglance/glance/config_organizer.py
with
17 additions
and
4 deletions
pyglance/glance/config_organizer.py
+
17
−
4
View file @
91e1289b
...
...
@@ -10,7 +10,7 @@ Created by evas Dec 2012.
Copyright (c) 2012 University of Wisconsin SSEC. All rights reserved.
"""
import
os
,
sys
,
imp
,
logging
,
re
import
os
,
sys
,
imp
ortlib
,
logging
,
re
import
argparse
import
glance.io
as
io
...
...
@@ -311,6 +311,17 @@ def _get_missing_values_if_needed(fileA, fileB,
return
missing_value_A
,
missing_value_B
def
_import_module
(
full_name
,
full_file_path
,)
:
"""
load up a python module from a file on the fly, this should be used when loading configuration files for Glance
"""
spec
=
importlib
.
util
.
spec_from_file_location
(
full_name
,
full_file_path
,)
mod
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
mod
)
return
mod
# TODO, right now this is the top level function that the library functions in
# compare.py call
def
load_config_or_options
(
aPath
,
bPath
,
optionsSet
,
requestedVars
=
[
])
:
...
...
@@ -373,9 +384,11 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) :
# load the file
LOG
.
debug
(
'
loading config file:
'
+
str
(
requestedConfigFile
))
glanceRunConfig
=
imp
.
load_module
(
fileBaseName
,
file
(
requestedConfigFile
,
'
U
'
),
requestedConfigFile
,
(
'
.py
'
,
'
U
'
,
1
))
glanceRunConfig
=
_import_module
(
fileBaseName
,
requestedConfigFile
,)
#import imp
#glanceRunConfig = imp.load_module(fileBaseName, open(requestedConfigFile, 'U'),
# requestedConfigFile, ('.py' , 'U', 1))
# this is an exception, since it is not advertised to the user we don't expect it to be in the file
# (at least not at the moment, it could be added later and if they did happen to put it in the
# config file, it would override this line)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment