-
Notifications
You must be signed in to change notification settings - Fork 632
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
Fix pokedex dump -l argument error (#295) #299
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,9 +431,13 @@ 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 langs is None: | ||
# If no lang arguments were passed or the 'all' argument was passed | ||
if langs is None or langs == ['all']: | ||
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 | ||
elif langs == ['none']: | ||
return False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't thing that can be handled in main. EDIT: fixed typos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I missed that detail. You're right that the change i suggested isn't equivalent to the PR's code; however, i don't think that PR's behaviour is correct. The comment in the Edit: there's a bug too. Returning here will abort the entire dump as soon as any translation table is encountered. To get the behaviour you described, i think you would want a |
||
elif any(col.info.get('official') for col in table.columns): | ||
def include_row(row): | ||
return (languages[row.local_language_id].official or | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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="comma-separated list of language codes to load, 'none', or 'all' (default: en)") | ||
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.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old help text seems sufficient to me (other than updating the default). |
||
cmd_dump.add_argument( | ||
'tables', nargs='*', | ||
help="list of database tables to load (default: all)") | ||
|
@@ -209,6 +209,15 @@ def command_dump(parser, args): | |
|
||
if args.langs is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like this: if args.langs == 'none':
langs = []
elif args.langs is None or args.langs == 'all':
langs = None
else:
langs = [l.strip() for l in args.langs.split(',')]
# etc... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do something like this then in load.py I would have to change
to
So I would think that its pretty much the same thing |
||
langs = [l.strip() for l in args.langs.split(',')] | ||
|
||
# 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: | ||
print("\nERROR: The 'all' code should be used by itself.") | ||
return | ||
elif len(langs) > 1 and 'none' in langs: | ||
print("\nERROR: The 'none' code should be used by itself.") | ||
return | ||
else: | ||
langs = None | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
all
andnone
can be handled inmain.py
, similar to howcommand_load
does it:pokedex/pokedex/main.py
Lines 232 to 235 in e5c18c4