Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Weblate
gajim
Commits
162dd1eb
Commit
162dd1eb
authored
14 years ago
by
Alexander Cherniuk
Browse files
Options
Downloads
Patches
Plain Diff
Minor fixes for the command system dispatching
parent
09e1742b
No related branches found
Branches containing commit
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/command_system/dispatching.py
+27
-27
27 additions, 27 deletions
src/command_system/dispatching.py
with
27 additions
and
27 deletions
src/command_system/dispatching.py
+
27
−
27
View file @
162dd1eb
...
...
@@ -28,63 +28,63 @@ class Dispatcher(type):
commands
=
{}
@classmethod
def
register_host
(
klas
s
,
host
):
klas
s
.
containers
[
host
]
=
[]
def
register_host
(
cl
s
,
host
):
cl
s
.
containers
[
host
]
=
[]
@classmethod
def
register_container
(
klas
s
,
container
):
def
register_container
(
cl
s
,
container
):
for
host
in
container
.
HOSTS
:
klas
s
.
containers
[
host
].
append
(
container
)
cl
s
.
containers
[
host
].
append
(
container
)
@classmethod
def
register_commands
(
klas
s
,
container
):
klas
s
.
commands
[
container
]
=
{}
for
command
in
klas
s
.
traverse_commands
(
container
):
def
register_commands
(
cl
s
,
container
):
cl
s
.
commands
[
container
]
=
{}
for
command
in
cl
s
.
traverse_commands
(
container
):
for
name
in
command
.
names
:
klas
s
.
commands
[
container
][
name
]
=
command
cl
s
.
commands
[
container
][
name
]
=
command
@classmethod
def
get_command
(
klas
s
,
host
,
name
):
for
container
in
klas
s
.
containers
[
host
]:
command
=
klas
s
.
commands
[
container
].
get
(
name
)
def
get_command
(
cl
s
,
host
,
name
):
for
container
in
cl
s
.
containers
[
host
]:
command
=
cl
s
.
commands
[
container
].
get
(
name
)
if
command
:
return
command
@classmethod
def
list_commands
(
klas
s
,
host
):
for
container
in
klas
s
.
containers
[
host
]:
commands
=
klas
s
.
commands
[
container
]
def
list_commands
(
cl
s
,
host
):
for
container
in
cl
s
.
containers
[
host
]:
commands
=
cl
s
.
commands
[
container
]
for
name
,
command
in
commands
.
iteritems
():
yield
name
,
command
@classmethod
def
traverse_commands
(
klas
s
,
container
):
def
traverse_commands
(
cl
s
,
container
):
for
name
in
dir
(
container
):
attribute
=
getattr
(
container
,
name
)
if
klas
s
.
is_command
(
attribute
):
if
cl
s
.
is_command
(
attribute
):
yield
attribute
@staticmethod
def
is_root
(
ns
):
meta
=
ns
.
get
(
'
__metaclass__
'
,
NoneType
)
return
issubclass
(
meta
,
Dispatcher
)
meta
class
=
ns
.
get
(
'
__metaclass__
'
,
NoneType
)
return
issubclass
(
meta
class
,
Dispatcher
)
@staticmethod
def
is_command
(
attribute
):
name
=
attribute
.
__class__
.
__name__
return
name
==
'
Command
'
from
framework
import
Command
return
isinstance
(
attribute
,
Command
)
class
HostDispatcher
(
Dispatcher
):
def
__init__
(
klass
,
name
,
bases
,
ns
):
def
__init__
(
self
,
name
,
bases
,
ns
):
if
not
Dispatcher
.
is_root
(
ns
):
HostDispatcher
.
register_host
(
klass
)
super
(
HostDispatcher
,
klass
).
__init__
(
name
,
bases
,
ns
)
HostDispatcher
.
register_host
(
self
)
super
(
HostDispatcher
,
self
).
__init__
(
name
,
bases
,
ns
)
class
ContainerDispatcher
(
Dispatcher
):
def
__init__
(
klass
,
name
,
bases
,
ns
):
def
__init__
(
self
,
name
,
bases
,
ns
):
if
not
Dispatcher
.
is_root
(
ns
):
ContainerDispatcher
.
register_container
(
klass
)
ContainerDispatcher
.
register_commands
(
klass
)
super
(
ContainerDispatcher
,
klass
).
__init__
(
name
,
bases
,
ns
)
ContainerDispatcher
.
register_container
(
self
)
ContainerDispatcher
.
register_commands
(
self
)
super
(
ContainerDispatcher
,
self
).
__init__
(
name
,
bases
,
ns
)
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