From 9a50ed7506a303a9f1ac71d024ed61691521b1ae Mon Sep 17 00:00:00 2001 From: Steve Goering Date: Fri, 14 Aug 2015 10:23:17 +0000 Subject: [PATCH] small refactoring of modules to commands, and update readme file --- config.json | 7 +++++-- readme.md | 49 +++++++++++++++++++++++++++++-------------------- webis.py | 8 +++----- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/config.json b/config.json index 1df5aea..ea717ad 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,10 @@ { - "moduls_directory": "tools/", + "commands_directory": "tools/", "allowed_scripts": ["python", "bash"], "ignored_dirs": ["CVS"], "update": "core/update.sh", - "version": "core/version.sh" + "version": "core/version.sh", + "commands_help": { + "core" :"Core functions of webis command.", + } } \ No newline at end of file diff --git a/readme.md b/readme.md index a3063da..4edfa46 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ authors: About ----- -webis is a command wrapping toolkit +"webis" is a command wrapping toolkit Requirements ------------ @@ -16,22 +16,23 @@ python3, pep8 Usage ----- -for first starts run: +For first starts run: > $./webis.py -h Configuration ------------- -see: config.json +See: config.json ``` { - "moduls_directory": "tools/", + "commands_directory": "tools/", "allowed_scripts": ["python", "bash"], - "ignored_dirs": ["CVS"] + "ignored_dirs": ["CVS"], + .... } ``` -Modules directory (tools) +Commands directory (tools) ------------------------- e.g.: ├── core @@ -44,9 +45,8 @@ e.g.: ├── t.oy └── t.txt -core and test are metanames for each toolkit -a call ->$./webis.py core help +"core" and "test" are metanames for each toolkit, a call +>$./webis.py core -h will print a short summary of all tools @@ -54,30 +54,39 @@ will print a short summary of all tools will perform a code style check of the tools directory -Adding a new Module +Adding a new Command ------------------- -first create a new folder in the "moduls_directory" with name FOLDER -add all scrips to this folder, e.g. MYSCRIPT.py - -check if +First create a new folder in the "commandss_directory" with name FOLDER add all scrips to this folder, +e.g. MYSCRIPT.py and check if >$./webis.py FOLDER MYSCRIPT -works +>$./webis.py FOLDER -h +>$./webis.py -h + +works. +Add in config.json the general description of the command in the "commands_help" part. ### Notes for MYSCRIPT -inside a new module directory, every script should have a small description comment -e.g.: +Inside a new command directory, every script should have a small description comment, e.g.: ``` #!/bin/bash # NICE DESCRIPTION ls / ``` -it is important for the './webis.py NAME help' call that this comment is the second line of the script, this approach can be seen as a extension of shebang +It is important for the './webis.py NAME -h' call that this comment is the second line of the script, this approach can be seen as a extension of shebang. + +### General scripts +All scripts must be code style checked with the "webis code checker" command. For python scripts this checks pep8 code style and for bash it checks the google bash style conventions. ### Bash scripts -use bashhelper functions (logError, ...) for output (see install for including) +Use bashhelper functions (logError, ...) for output (see install for including). ### Python scripts -use lib, log, system in "lib" directory for uniform outputs and reducing reinventing the wheel +Use lib, log, system in "lib" directory for uniform outputs and reducing reinventing the wheel. +Organize imports of each python script in the following way: + +1. python standard libraries +2. thirdparty imports +3. own imports Possible problems with new modules ---------------------------------- diff --git a/webis.py b/webis.py index 25a86ef..35b1722 100755 --- a/webis.py +++ b/webis.py @@ -31,12 +31,10 @@ def load_config(): def get_commands(config): """Returns commands mapped to directories containing their subcommands.""" commands = collections.OrderedDict() - # FIXME: Variable names should be English only; also "moduls" has been - # renamed to "command". - for directory in os.listdir(config["moduls_directory"]): - if (os.path.isdir(config["moduls_directory"] + directory) and + for directory in os.listdir(config["commands_directory"]): + if (os.path.isdir(config["commands_directory"] + directory) and directory not in config["ignored_dirs"]): - commands[directory] = config["moduls_directory"] + directory + commands[directory] = config["commands_directory"] + directory return commands -- GitLab