FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
aws-cli/awscli/plugin.py at develop · GAUTAM67/aws-cli · GitHub
GAUTAM67
/
aws-cli
Public
forked from
aws/aws-cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
aws-cli
/
awscli
/
plugin.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (51 loc) · 2.21 KB
Breadcrumbs
aws-cli
/
awscli
/
plugin.py
Copy path
File metadata and controls
63 lines (51 loc) · 2.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import
logging
from
botocore
.
hooks
import
HierarchicalEmitter
log
=
logging
.
getLogger
(
'awscli.plugin'
)
BUILTIN_PLUGINS
=
{
'__builtin__'
:
'awscli.handlers'
}
def
load_plugins
(
plugin_mapping
,
event_hooks
=
None
,
include_builtins
=
True
):
"""
:type plugin_mapping: dict
:param plugin_mapping: A dict of plugin name to import path,
e.g. ``{"plugingName": "package.modulefoo"}``.
:type event_hooks: ``EventHooks``
:param event_hooks: Event hook emitter. If one if not provided,
an emitter will be created and returned. Otherwise, the
passed in ``event_hooks`` will be used to initialize plugins.
:type include_builtins: bool
:param include_builtins: If True, the builtin awscli plugins (specified in
``BUILTIN_PLUGINS``) will be included in the list of plugins to load.
:rtype: HierarchicalEmitter
:return: An event emitter object.
"""
if
include_builtins
:
plugin_mapping
.
update
(
BUILTIN_PLUGINS
)
modules
=
_import_plugins
(
plugin_mapping
)
if
event_hooks
is
None
:
event_hooks
=
HierarchicalEmitter
()
for
name
,
plugin
in
zip
(
plugin_mapping
.
keys
(),
modules
):
log
.
debug
(
"Initializing plugin %s: %s"
,
name
,
plugin
)
plugin
.
awscli_initialize
(
event_hooks
)
return
event_hooks
def
_import_plugins
(
plugin_names
):
plugins
=
[]
for
name
,
path
in
plugin_names
.
items
():
log
.
debug
(
"Importing plugin %s: %s"
,
name
,
path
)
if
'.'
not
in
path
:
plugins
.
append
(
__import__
(
path
))
else
:
package
,
module
=
path
.
rsplit
(
'.'
,
1
)
module
=
__import__
(
path
,
fromlist
=
[
module
])
plugins
.
append
(
module
)
return
plugins
Back
|
FazBrowse Home
|
New Git URL