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.
|
||||
# For non-translation tables, dump all rows.
|
||||
if 'local_language_id' in columns:
|
||||
# If no lang arguments were passed or the 'all' argument was passed
|
||||
if langs is None or langs == ['all']:
|
||||
if langs is None:
|
||||
def include_row(row):
|
||||
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']:
|
||||
return False
|
||||
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")
|
||||
cmd_dump.add_argument(
|
||||
'-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(
|
||||
'tables', nargs='*',
|
||||
help="list of database tables to load (default: all)")
|
||||
|
@ -210,9 +210,13 @@ def command_dump(parser, args):
|
|||
if args.langs is not None:
|
||||
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.
|
||||
# If either code is used, an error message will be displayed and the progrm will close.
|
||||
if len(langs) > 1 and 'all' in langs:
|
||||
# If either code is used, an error message will be displayed and the program will close.
|
||||
elif len(langs) > 1 and 'all' in langs:
|
||||
print("\nERROR: The 'all' code should be used by itself.")
|
||||
return
|
||||
elif len(langs) > 1 and 'none' in langs:
|
||||
|
|
Loading…
Reference in a new issue