mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Fix pokedex dump -l argument error - PR Changes
All changes requested in PR 17f36243bc
### pokedex/main.py -
#### create_parser() -
- Change to langs argument reverting the help message to the original
one but changing the default to 'all'.
#### command_dump() -
- Add check for 'all' langs code instead of in the load.py file.
- Add/fix comments.
---
### pokedex/db/load.py -
#### dump() -
- Remove unneeded check for 'all' langs code since not it is checked in
the main.py file.
- Reword comment of what happens when the 'none' code is passed.
This commit is contained in:
parent
17f36243bc
commit
8ad6443a6c
2 changed files with 10 additions and 6 deletions
|
@ -431,11 +431,11 @@ def dump(session, tables=[], directory=None, verbose=False, langs=None):
|
||||||
# if specified, or for official languages by default.
|
# if specified, or for official languages by default.
|
||||||
# For non-translation tables, dump all rows.
|
# For non-translation tables, dump all rows.
|
||||||
if 'local_language_id' in columns:
|
if 'local_language_id' in columns:
|
||||||
# If no lang arguments were passed or the 'all' argument was passed
|
if langs is None:
|
||||||
if langs is None or langs == ['all']:
|
|
||||||
def include_row(row):
|
def include_row(row):
|
||||||
return languages[row.local_language_id].official
|
return languages[row.local_language_id].official
|
||||||
# If the none argument is passed then nothing should be changed from the csv files
|
# If the none code is passed, then all the csv files with the local_language_id
|
||||||
|
# column are not updated. In other words they are left blank.
|
||||||
elif langs == ['none']:
|
elif langs == ['none']:
|
||||||
return False
|
return False
|
||||||
elif any(col.info.get('official') for col in table.columns):
|
elif any(col.info.get('official') for col in table.columns):
|
||||||
|
|
|
@ -114,7 +114,7 @@ def create_parser():
|
||||||
help="directory to place the dumped CSV files")
|
help="directory to place the dumped CSV files")
|
||||||
cmd_dump.add_argument(
|
cmd_dump.add_argument(
|
||||||
'-l', '--langs', dest='langs', default=None,
|
'-l', '--langs', dest='langs', default=None,
|
||||||
help=u"comma-separated list of language codes to load, 'none', 'all', or other languages like 'en,es' (default: all). The 'all' and 'none' codes cannot be used with other codes.")
|
help=u"comma-separated list of language codes to load, 'none', or 'all' (default: all)")
|
||||||
cmd_dump.add_argument(
|
cmd_dump.add_argument(
|
||||||
'tables', nargs='*',
|
'tables', nargs='*',
|
||||||
help="list of database tables to load (default: all)")
|
help="list of database tables to load (default: all)")
|
||||||
|
@ -210,9 +210,13 @@ def command_dump(parser, args):
|
||||||
if args.langs is not None:
|
if args.langs is not None:
|
||||||
langs = [l.strip() for l in args.langs.split(',')]
|
langs = [l.strip() for l in args.langs.split(',')]
|
||||||
|
|
||||||
|
# If the langs code is only 'all' then langs is None so that all the tables get dumped.
|
||||||
|
if len(langs) == 1 and langs[0] == 'all':
|
||||||
|
langs = None
|
||||||
|
|
||||||
# Check if either 'all' or 'none' codes are used along side other codes.
|
# Check if either 'all' or 'none' codes are used along side other codes.
|
||||||
# If either code is used, an error message will be displayed and the progrm will close.
|
# If either code is used, an error message will be displayed and the program will close.
|
||||||
if len(langs) > 1 and 'all' in langs:
|
elif len(langs) > 1 and 'all' in langs:
|
||||||
print("\nERROR: The 'all' code should be used by itself.")
|
print("\nERROR: The 'all' code should be used by itself.")
|
||||||
return
|
return
|
||||||
elif len(langs) > 1 and 'none' in langs:
|
elif len(langs) > 1 and 'none' in langs:
|
||||||
|
|
Loading…
Reference in a new issue