Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
code-webis-cmd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
code-generic
code-webis-cmd
Commits
c5a1e0b5
Commit
c5a1e0b5
authored
Jun 19, 2015
by
Steve Goering
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add shortcut way for modules
parent
ea291102
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
tools/core/install.sh
tools/core/install.sh
+1
-0
webis.py
webis.py
+21
-2
No files found.
tools/core/install.sh
View file @
c5a1e0b5
...
...
@@ -51,6 +51,7 @@ main() {
sudo ln
-s
"
$webiscmdrootpath
/webis.py"
"/usr/bin/webis"
}
#
...
...
webis.py
View file @
c5a1e0b5
...
...
@@ -65,6 +65,9 @@ def get_submodule_description(modulepath):
extract submodul description based on modulepath
:return description
"""
if
not
os
.
path
.
isfile
(
modulepath
):
return
os
.
path
.
basename
(
modulepath
)
f
=
open
(
modulepath
)
lines
=
f
.
readlines
()
f
.
close
()
...
...
@@ -96,6 +99,14 @@ def handle_script(submodul, scriptfile, params=[]):
return
return_value
def
get_keys_startswith
(
dictionary
,
searchkey
):
"""
extract keys that have a prefix match
"""
needed_keys
=
[
x
for
x
in
dictionary
.
keys
()
if
x
.
startswith
(
searchkey
)]
return
needed_keys
def
main
(
args
):
lInfo
(
"read config"
)
# read config file
...
...
@@ -119,10 +130,13 @@ def main(args):
parser
.
add_argument
(
'submodul'
,
type
=
str
,
nargs
=
'?'
,
default
=
"help"
,
help
=
'submodul'
)
parser
.
add_argument
(
'parameter'
,
type
=
str
,
nargs
=
'*'
,
help
=
'parameters for submodul command'
)
argsdict
=
vars
(
parser
.
parse_args
(
sys
.
argv
[
1
:
3
]))
# using sys.arv[..] is necessary because of unknown arguments in the parameters for submoduls
if
len
(
args
)
>
0
and
len
(
get_keys_startswith
(
modules
,
args
[
0
]))
==
1
:
args
[
0
]
=
get_keys_startswith
(
modules
,
args
[
0
])[
0
]
argsdict
=
vars
(
parser
.
parse_args
(
args
[
0
:
2
]))
# using args[..] is necessary because of unknown arguments in the parameters for submoduls
# set parameters
argsdict
[
"parameter"
]
=
sys
.
argv
[
3
:]
argsdict
[
"parameter"
]
=
args
[
2
:]
lInfo
(
"available moduls: "
+
str
(
len
(
modules
)))
...
...
@@ -132,6 +146,11 @@ def main(args):
lInfo
(
"selected modul: "
+
argsdict
[
"modul"
])
submodules
=
get_submodules
(
config
,
modules
[
argsdict
[
"modul"
]])
submodules
[
"help"
]
=
"integrated help"
if
len
(
get_keys_startswith
(
submodules
,
argsdict
[
"submodul"
]))
==
1
:
argsdict
[
"submodul"
]
=
get_keys_startswith
(
submodules
,
argsdict
[
"submodul"
])[
0
]
if
argsdict
[
"submodul"
]
==
"help"
:
lHelp
(
"submodules of "
+
argsdict
[
"modul"
])
max_size
=
len
(
max
(
submodules
.
keys
(),
key
=
len
))
...
...
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