Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hammonds
dm-docs
Commits
0a5840bc
Commit
0a5840bc
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
object instance creation method can now use provided import path
parent
b6ab24cf
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/dm/common/utility/objectUtility.py
+9
-1
9 additions, 1 deletion
src/python/dm/common/utility/objectUtility.py
with
9 additions
and
1 deletion
src/python/dm/common/utility/objectUtility.py
+
9
−
1
View file @
0a5840bc
...
...
@@ -5,12 +5,20 @@ from dm.common.utility.loggingManager import LoggingManager
class
ObjectUtility
:
@classmethod
def
createObjectInstance
(
cls
,
moduleName
,
className
,
constructor
):
def
createObjectInstance
(
cls
,
moduleName
,
className
,
constructor
,
importPath
=
None
):
logger
=
LoggingManager
.
getInstance
().
getLogger
(
cls
.
__name__
)
logger
.
debug
(
'
Creating object: %s, %s, %s
'
%
(
moduleName
,
className
,
constructor
))
if
importPath
is
not
None
:
# Add import path if it was provided
sys
.
path
.
append
[
importPath
]
cmd
=
'
from %s import %s
'
%
(
moduleName
,
className
)
exec
cmd
cmd
=
'
objectInstance = %s
'
%
(
constructor
)
exec
cmd
if
importPath
is
not
None
:
# Remove import path that was added
del
sys
.
path
[
-
1
]
return
objectInstance
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