Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
68f711d5
Commit
68f711d5
authored
Apr 28, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teach plugin loader to find modules in subdirectories
parent
391fb98e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
lib/ansible/utils/plugins.py
+19
-6
No files found.
lib/ansible/utils/plugins.py
View file @
68f711d5
...
...
@@ -71,16 +71,20 @@ class PluginLoader(object):
ret
.
append
(
i
)
return
os
.
pathsep
.
join
(
ret
)
def
_get_package_path
(
self
):
def
_get_package_path
s
(
self
):
''' Gets the path of a Python package '''
paths
=
[]
if
not
self
.
package
:
return
[]
if
not
hasattr
(
self
,
'package_path'
):
m
=
__import__
(
self
.
package
)
parts
=
self
.
package
.
split
(
'.'
)[
1
:]
self
.
package_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
m
.
__file__
),
*
parts
)
return
[
self
.
package_path
]
paths
.
append
(
self
.
package_path
)
return
paths
else
:
return
[
self
.
package_path
]
def
_get_paths
(
self
):
''' Return a list of paths to search for plugins in '''
...
...
@@ -95,14 +99,23 @@ class PluginLoader(object):
if
os
.
path
.
isdir
(
fullpath
):
files
=
glob
.
glob
(
"
%
s/*"
%
fullpath
)
for
file
in
files
:
if
os
.
path
.
isdir
(
file
):
if
os
.
path
.
isdir
(
file
)
and
file
not
in
ret
:
ret
.
append
(
file
)
else
:
if
fullpath
not
in
ret
:
ret
.
append
(
fullpath
)
ret
+=
self
.
config
.
split
(
os
.
pathsep
)
ret
+=
self
.
_get_package_path
()
# look in any configured plugin paths, allow one level deep for subcategories
configured_paths
=
self
.
config
.
split
(
os
.
pathsep
)
for
path
in
configured_paths
:
ret
.
append
(
path
)
contents
=
glob
.
glob
(
"
%
s/*"
%
path
)
for
c
in
contents
:
if
os
.
path
.
isdir
(
c
):
ret
.
append
(
c
)
# look for any plugins installed in the package subtree
ret
.
extend
(
self
.
_get_package_paths
())
self
.
_paths
=
ret
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment