diff --git a/.gitignore b/.gitignore index 72364f9..17ef486 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,8 @@ nosetests.xml coverage.xml *,cover .hypothesis/ +.testrepository/ +cover/ # Translations *.mo @@ -87,3 +89,6 @@ ENV/ # Rope project settings .ropeproject + +#vim swap files +.swp diff --git a/pybluedot/cli.py b/pybluedot/cli.py index 4b588ac..3e4a722 100644 --- a/pybluedot/cli.py +++ b/pybluedot/cli.py @@ -1,7 +1,46 @@ -""" -cli.py constructs a cli interface of commands, options, and subcommands in argparse, given data structures from commands.py -""" import argparse -import json -from pybluedot.commands import cmd, subcmd +from pybluedot.commands import cmd_arg +from pybluedot.commands import sub_cmd +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. + + +def cmd_to_args(cmd_arg): + """creates argparse arguments from commands.cmd dict. + return argparse object. + """ + all_args = argparse.ArgumentParser() + for arg in cmd_arg: + for i in sorted(arg.keys()): + # TODO(gamefiend) + pass + return all_args + + +def cmd_to_subs(sub_cmd): + """creates subcommand arguments from commands.subcmd dict. + returns argparse object. + """ + all_subs = argparse.ArgumentParser() + for sub in sub_cmd: + for i in sorted(sub): + # TODO(gamefiend) + pass + return all_subs + + +if __name__ == "__main__": + bdot_args = cmd_to_args(cmd_arg) + bdot_subcmds = cmd_to_subs(sub_cmd) + bdot_args.parse() + bdot_subcmds.parse() diff --git a/pybluedot/commands.py b/pybluedot/commands.py index a9f1466..86f9032 100644 --- a/pybluedot/commands.py +++ b/pybluedot/commands.py @@ -1,41 +1,39 @@ -""" commands.py contains the data structures that cli.py uses to construct the arguments/subcommand structure. -""" +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. # global arguments and flags to the command, like '--verbose' or '--debug' -cmd_arg = [ - { - name: "verbose", - action: "store_const" - }, - { - name: "debug", - action: "store_const" - } -] - -# subcommands used by the program, like 'bdot init' or 'bdot search'. -# Subcommands are tied to functions, so you must specify a function to use with each subcommand. -sub_cmd = [ - { - name: "init", - help: "create a pybluedot configuration file", - options: [ - { - name: "--force", - action: "store_const" - }, - { - name: "--display", - action: "store_const" - } - ], - function: "init" - }, - { - name: "sounds", - help: "just useless boilerplate atm!", - options: [], - function: "sounds" - } -] +cmd_arg = [{ + 'name': 'verbose', + 'action': 'store_const' +}, { + 'name': 'debug', + 'action': 'store_const' +}] +# subcommands used by the program, like 'bdot init' +sub_cmd = [{ + 'name': 'init', + 'help': 'create a pybluedot configuration file', + 'options': [{ + 'name': '--force', + 'action': 'store_const' + }, { + 'name': '--display', + 'action': 'store_const' + }], + 'function': 'init' +}, { + 'name': 'sounds', + 'help': 'just useless boilerplate atm!', + 'options': [], + 'function': 'sounds' +}] diff --git a/pybluedot/tests/base.py b/pybluedot/tests/base.py index 0a299e8..00d0a5c 100644 --- a/pybluedot/tests/base.py +++ b/pybluedot/tests/base.py @@ -1,5 +1,17 @@ import unittest +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. + class DietTestCase(unittest.TestCase): """Same great taste, less filling. diff --git a/pybluedot/tests/unit/test_sample.py b/pybluedot/tests/unit/test_sample.py index fc2aad8..51b7039 100644 --- a/pybluedot/tests/unit/test_sample.py +++ b/pybluedot/tests/unit/test_sample.py @@ -1,5 +1,17 @@ from pybluedot.tests import base +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License 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. + class SampleTestSuite(base.DietTestCase): """This test suite provides some common things relevant to the