Skip to content

Commit 1fe5fd8

Browse files
committed
changed dependency-related command-line interface
1 parent d409e15 commit 1fe5fd8

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ install:
8181
- pip install -U pip
8282
- pip install -U -r dev_requirements.txt
8383
# Java
84-
- python -m open_fortran_parser --dev-deps
84+
- python -m open_fortran_parser --deps
8585
- export CLASSPATH="${CLASSPATH}:$(pwd)/lib/*"
8686
- ant -Dpython=python
8787
- export CLASSPATH="${CLASSPATH}:$(pwd)/dist/*"

README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ Get dependencies, either manually, or using the provided script:
455455
.. code:: bash
456456
457457
pip3 install -U -r requirements.txt
458-
python3 -m open_fortran_parser --dev-deps
458+
python3 -m open_fortran_parser --deps
459459
export CLASSPATH="${CLASSPATH}:$(pwd)/lib/*"
460460
461461
Build:
@@ -580,7 +580,7 @@ You can make sure that dependencies are configured correctly by running:
580580

581581
.. code:: bash
582582
583-
python3 -m open_fortran_parser --deps
583+
python3 -m open_fortran_parser --check-deps
584584
585585
If the depenencies changed since you first ran the wrapper from the source tree, you can cleanup
586586
outdated dependencies by executing:
@@ -597,7 +597,7 @@ as script
597597
598598
$ python3 -m open_fortran_parser -h
599599
usage: open_fortran_parser [-h] [--version] [-v VERBOSITY]
600-
[--get-dependencies]
600+
[--check-dependencies]
601601
[input] [output]
602602
603603
Python wrapper around XML generator for Open Fortran Parser
@@ -612,8 +612,9 @@ as script
612612
--version show program's version number and exit
613613
-v VERBOSITY, --verbosity VERBOSITY
614614
level of verbosity, from 0 to 100 (default: 100)
615-
--get-dependencies, --deps
616-
download dependencies and exit (default: False)
615+
--check-dependencies, --check-deps
616+
check if all required dependencies are present and
617+
exit (default: False)
617618
618619
Copyright 2017-2019 by the contributors, Apache License 2.0,
619620
https://github.com/mbdevpl/open-fortran-parser-xml

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ install:
8888
- python -m pip install -U pip
8989
- python -m pip install -U -r dev_requirements.txt
9090
# Java
91-
- python -m open_fortran_parser --dev-deps
91+
- python -m open_fortran_parser --deps
9292
- set CLASSPATH=%cd%\\lib\\*;%CLASSPATH%
9393
- ant -Dpython=python
9494
- set CLASSPATH=%cd%\\dist\\*;%CLASSPATH%

open_fortran_parser/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
from ._version import VERSION
88

9-
DEV_DEPENDENCIES_PATH = pathlib.Path(os.getcwd(), 'lib')
9+
DEPENDENCIES_PATH = pathlib.Path(__file__).resolve().parent
10+
11+
DEV_DEPENDENCIES_PATH = DEPENDENCIES_PATH.parent.joinpath('lib')
1012

11-
DEV_DEPENDENCIES = {
13+
COMMON_DEPENDENCIES = {
1214
'ANTLR 3.5.2': (
1315
urllib.parse.urlparse(
1416
'https://github.com/mbdevpl/open-fortran-parser/releases/download/v0.8.5-1/'),
@@ -22,9 +24,9 @@
2224
'https://github.com/mbdevpl/open-fortran-parser-xml/releases/download/v0.1.0/'),
2325
pathlib.Path('commons-cli-1.4.jar'))}
2426

25-
DEPENDENCIES_PATH = pathlib.Path(__file__).resolve().parent
27+
DEV_DEPENDENCIES = COMMON_DEPENDENCIES.copy()
2628

27-
DEPENDENCIES = DEV_DEPENDENCIES.copy()
29+
DEPENDENCIES = COMMON_DEPENDENCIES.copy()
2830

2931
DEPENDENCIES.update({
3032
'Open Fortran Parser XML {}'.format(VERSION): (

open_fortran_parser/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ def main(args=None, namespace=None):
3838
'-v', '--verbosity', type=int, default=100, help='''level of verbosity, from 0 to 100''')
3939
parser.add_argument(
4040
'--get-dependencies', '--deps', action='store_true',
41-
help='''download dependencies and exit''')
41+
help=argparse.SUPPRESS) # download dependencies for development and exit
4242
parser.add_argument(
43-
'--get-development-dependencies', '--dev-deps', action='store_true',
44-
help=argparse.SUPPRESS)
43+
'--check-dependencies', '--check-deps', action='store_true',
44+
help='''check if all required dependencies are present and exit''')
4545
parser.add_argument(
4646
'--cleanup-dependencies', '--cleanup-deps', action='store_true',
47-
help=argparse.SUPPRESS)
47+
help=argparse.SUPPRESS) # delete outdated development dependencies and exit
4848

4949
args = parser.parse_args(args, namespace)
5050

51-
if args.get_development_dependencies:
51+
if args.get_dependencies:
5252
ensure_dependencies(DEV_DEPENDENCIES, DEV_DEPENDENCIES_PATH)
5353
return
5454

55-
if args.get_dependencies:
56-
ensure_dependencies(DEPENDENCIES, DEPENDENCIES_PATH)
55+
if args.check_dependencies:
56+
ensure_dependencies(DEPENDENCIES, DEPENDENCIES_PATH, download=False)
5757
return
5858

5959
if args.cleanup_dependencies:

test/test_script.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ def test_help(self):
3838
self.assertIn('usage', text)
3939
self.assertIn('open_fortran_parser', text)
4040

41-
@unittest.skipUnless(os.environ.get('TEST_DEPENDENCIES'), 'skipping dependency test')
42-
def test_deps_flag(self):
41+
def test_check_deps_flag(self):
4342
sio = io.StringIO()
4443
with contextlib.redirect_stderr(sio):
45-
run_module('open_fortran_parser', '--deps')
44+
run_module('open_fortran_parser', '--check-deps')
4645
self.assertGreater(len(sio.getvalue()), 0)
4746
self.assertGreater(len(os.listdir(str(DEPENDENCIES_PATH))), 0)
4847

49-
run_module('open_fortran_parser', '--dev-deps')
48+
@unittest.skipUnless(os.environ.get('TEST_DEPENDENCIES'), 'skipping dependency test')
49+
def test_development_flags(self):
50+
run_module('open_fortran_parser', '--deps')
51+
run_module('open_fortran_parser', '--cleanup-deps')
5052
self.assertGreater(len(os.listdir(str(DEV_DEPENDENCIES_PATH))), 0)
5153

5254
def test_verbosity_flag(self):

0 commit comments

Comments
 (0)