Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-organize passes invalid type to configparser #53

Closed
IrishPrime opened this issue Aug 26, 2017 · 1 comment
Closed

--no-organize passes invalid type to configparser #53

IrishPrime opened this issue Aug 26, 2017 · 1 comment
Assignees
Labels

Comments

@IrishPrime
Copy link
Owner

Using the --no-organize option raises an error.

Traceback (most recent call last):
  File "/home/irish/.local/bin/nielsen", line 11, in <module>
    load_entry_point('Nielsen==1.0.1', 'console_scripts', 'nielsen')()
  File "/home/irish/.local/lib/python3.6/site-packages/Nielsen-1.0.1-py3.6.egg/nielsen/api.py", line 230, in main
  File "/usr/lib/python3.6/configparser.py", line 1192, in set
    self._validate_value_types(option=option, value=value)
  File "/usr/lib/python3.6/configparser.py", line 1177, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings
@IrishPrime IrishPrime added the bug label Aug 26, 2017
@IrishPrime IrishPrime self-assigned this Aug 26, 2017
@IrishPrime
Copy link
Owner Author

IrishPrime commented Aug 26, 2017

Nielsen/nielsen/api.py

Lines 195 to 207 in 40d9acc

PARSER.add_argument("-o", "--organize", dest="organize", action="store_true",
help="Organize files")
PARSER.add_argument("--no-organize", dest="organize", action="store_false",
help="Do not organize files")
PARSER.set_defaults(organize=None)
PARSER.add_argument("-f", "--fetch", dest="fetch", action="store_true",
help="Fetch titles from the web")
PARSER.add_argument("--no-fetch", dest="fetch", action="store_false",
help="Do not fetch titles from the web")
PARSER.set_defaults(fetch=None)
PARSER.add_argument("-n", "--dry-run", dest="dry_run", action="store_true",
help="Do not rename files, just list the renaming actions.")
PARSER.set_defaults(dry_run=False)

This affects all boolean style option flags.

The --organize and --no-organize options both store the boolean types for True and False, while the configparser object needs a string. Either the type stored must be changed, or the value should be cast as a string upon retrieval.

IrishPrime added a commit that referenced this issue Aug 26, 2017
- Store the string values `'True'` and `'False'` for option flag type
  command line arguments rather than actual boolean values. These values
  are passed to the `configparser`, which only accepts strings. This
  affects `--[no-]organize`, `--[no-]fetch`, and `--dry-run`.
- Create mutually exclusive option groups for the option flag type
  command line arguments so users cannot pass, for example,
  `--fetch --no-fetch`.
- Add comments to help break up the wall of `argparse` code.
- List Python 3.6 as a valid version in `setup.py`.
- Resolves #53.
IrishPrime added a commit that referenced this issue Aug 26, 2017
* Improve handling of boolean command line options

- Store the string values `'True'` and `'False'` for option flag type
  command line arguments rather than actual boolean values. These values
  are passed to the `configparser`, which only accepts strings. This
  affects `--[no-]organize`, `--[no-]fetch`, and `--dry-run`.
- Create mutually exclusive option groups for the option flag type
  command line arguments so users cannot pass, for example,
  `--fetch --no-fetch`.
- Add comments to help break up the wall of `argparse` code.
- List Python 3.6 as a valid version in `setup.py`.
- Add Python 3.6 to Travis-CI config
- Resolves #53.
IrishPrime added a commit that referenced this issue Feb 23, 2019
* Improve handling of boolean command line options

- Store the string values `'True'` and `'False'` for option flag type
  command line arguments rather than actual boolean values. These values
  are passed to the `configparser`, which only accepts strings. This
  affects `--[no-]organize`, `--[no-]fetch`, and `--dry-run`.
- Create mutually exclusive option groups for the option flag type
  command line arguments so users cannot pass, for example,
  `--fetch --no-fetch`.
- Add comments to help break up the wall of `argparse` code.
- List Python 3.6 as a valid version in `setup.py`.
- Add Python 3.6 to Travis-CI config
- Resolves #53.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant