Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
"editor.insertSpaces": true,
"editor.rulers": [ 51, 61, 76 ],
"editor.tabSize": 4,
},
"editor.insertSpaces": false,
"editor.renderWhitespace": "all",
"editor.tabSize": 2,
"files.trimTrailingWhitespace": true,
}
22 changes: 22 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
# **CLASP.Python** Changes


## 0.8.8 - 24th August 2020

* ~ fixing defect in option default value processing


## 0.8.7 - 24th August 2020

* ~ fixing defect in option value processing


## 0.8.6 - 17th August 2020

* ~ ``show_usage()`` now issues a warning message to stderr for duplicate aliases (consistent with behaviour of (CLASP.Ruby)[https://github.com/synesissoftware/CLASP.Ruby])


## 0.8.5 - 13th August 2020

* ~ fixing compatibility with Python 3's removal of ``long``


## 0.8.4 - 12th August 2020

* allows ``OptionSpecification``'s ``value_type`` to be ``bool``
* added ``InvalidBooleanException`` exception class


## 0.8.3 - 12th August 2020

* allows ``OptionSpecification``'s ``value_type`` to be ``long``


## 0.8.2 - 12th August 2020

* allows ``OptionSpecification``'s ``value_type`` to be ``str``


## 0.8.1 - 11th August 2020

* can now compare equal ``Flag`` instances with ``FlagSpecification`` instances and ``Option`` instances with ``OptionSpecification`` instances
* significantly expanded unit-tests


## 0.8.0 - 6th August 2020

* added ``on_multiple`` keyword argument to ``OptionSpecification``
Expand All @@ -42,55 +51,68 @@
* added ``ParsingException`` exception class
* added examples/multiple_options.py (and examples/multiple_options.md)


## 0.7.1 - 4th August 2020

* ~ various tidyings



## 0.7.0 - 22nd August 2019

* + added sections, via ``clasp.section()``
* + added examples/sections.py (and examples/section.md)


## 0.6.1 - 22nd August 2019

* ~ fixed defect in ``get_first_unused_flag_or_option()`` introduced in 0.6.0


## 0.6.0 - 19th August 2019

* ~ ``get_first_unused_flag()``, ``get_first_unused_option()``, ``get_first_unused_flag_or_option()`` all now take an optional ``id`` parameter, which may be a flag/option or a string, that constrains the search


## 0.5.3 - 16th July 2019

* ~ increased flexibility of dealing with ``flags_and_options`` and ``values_string``


## 0.5.2 - 16th July 2019

* ~ fixed ``lookup_flag()``/``lookup_option()`` such that can now be passed specifications as well as strings for id
* ~ compatibility for StringIO for Python 2/3
* ~ updated examples to use non-deprecated constructs


## 0.5.1 - 12th June 2019

* ~ improving flexibility of handling of options to ``show_usage()``


## 0.5.0 - 25th April 2019

* + added ``OptionArgument.given_value`` attribute, which is always the string that is given during parsing
* + now supports 'value_type' named parameter in option specifications, whose value can be ``None`` (default), ``float``, or ``int``. For ``float`` and ``int`` a successful parse of the option value means that the ``OptionArgument.value`` attribute will be a ``float`` or ``int`` converted from the given value


## 0.4.2 - 25th April 2019

* ~ ensuring that all flag/option arguments receive the correct (underlying) flag/option specifications


## 0.4.1 - 25th April 2019

* ~ fixed type in exception message in ``option()``


## 0.4.0 - 17th April 2019

* ~ changed *Alias classes to *Specification
* ~ clasp.Arguments aliases attribute is now changed to specifications, and a [DEPRECATED] #aliases added


## 0.3.1 - 17th April 2019

* ~ fixed defect whereby sys.argv[0] was not used correctly to determine program name
Expand Down
8 changes: 4 additions & 4 deletions examples/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

args = clasp.parse(sys.argv, specifications)

print '*' * 50 + "\n"
print "usage:\n"
print('*' * 50 + "\n")
print("usage:\n")
clasp.show_usage(args, version = [ 1, 2, 3 ], stream = sys.stdout, program_name = 'myprog', version_prefix = 'v', info_lines=INFO_LINES)

print '*' * 50 + "\n"
print "version:\n"
print('*' * 50 + "\n")
print("version:\n")
clasp.show_version(args, version = [ 1, 2, 3 ], stream = sys.stdout, program_name = 'myprog', version_prefix = 'v')

print
Expand Down
2 changes: 1 addition & 1 deletion examples/typed_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if args.flag_is_specified('--version'):
opt_length = args.lookup_option('--length')
if opt_length:

print("You specified length with the value: %d (of type %s). The string that was passed is available in the 'given_value' attribute, which is '%s' (of type %s)\n" % (opt_length.value, type(opt_length.value), opt_length.given_value, type(opt_length.given_value)))
print("You specified length with the value: %d (of type `%s`). The string that was passed is available in the `given_value` attribute, which is '%s' (of type `%s`)\n" % (opt_length.value, type(opt_length.value), opt_length.given_value, type(opt_length.given_value)))
else:

sys.stderr.write("try specifying the '--length' option; use --help for usage\n")
Expand Down
2 changes: 1 addition & 1 deletion examples/typed_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
opt_length = args.lookup_option('--length')
if opt_length:

print("You specified length with the value: %d (of type %s). The string that was passed is available in the 'given_value' attribute, which is '%s' (of type %s)\n" % (opt_length.value, type(opt_length.value), opt_length.given_value, type(opt_length.given_value)))
print("You specified length with the value: %d (of type `%s`). The string that was passed is available in the `given_value` attribute, which is '%s' (of type `%s`)\n" % (opt_length.value, type(opt_length.value), opt_length.given_value, type(opt_length.given_value)))
else:

sys.stderr.write("try specifying the '--length' option; use --help for usage\n")
Expand Down
8 changes: 6 additions & 2 deletions pyclasp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import sys

def parse(argv = None, specifications = None):
"""Obtains an instance of clasp.Arguments, representing all the command-line arguments present in argv (or sys.argv)"""
"""
Obtains an instance of `clasp.Arguments`, representing all the command-line arguments present in `argv` (or `sys.argv`)
"""

if argv is None:

Expand All @@ -37,7 +39,9 @@ def parse(argv = None, specifications = None):
return Arguments(argv, specifications)

def get_program_name(argv = None):
"""Obtains/infers the program name from the given array, or from sys.argv"""
"""
Obtains/infers the program name from the given array, or from `sys.argv`
"""

return Arguments.get_program_name(argv)

Loading