-
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
Open
rluzuriaga
wants to merge
3
commits into
veekun:master
Choose a base branch
from
rluzuriaga:dump-langs-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', or 'all' (default: all)") | ||
cmd_dump.add_argument( | ||
'tables', nargs='*', | ||
help="list of database tables to load (default: all)") | ||
|
@@ -209,6 +209,19 @@ 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(',')] | ||
|
||
# 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 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: | ||
print("\nERROR: The 'none' code should be used by itself.") | ||
return | ||
else: | ||
langs = None | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
none
should be handled inmain.py
too.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 don't thing that can be handled in main.
If the user enters
pokedex dump -l none
then the parser has to passnone
as the code to load.py. A code ofnone
is not the same as the parser not getting any code. If the parser doesn't get any code, thenpokedex dump
langs defaults toall
.The load.py file is the one that figures out what to dump to the csv files depending on the langs code(s). So it checks if no codes are passed (
pokedex dump
ORpokedex dump -l all
since they are treated the same) and dumps everything to the csvs. Ifpokedex dump -l none
is entered then thereturn False
from line 440 makes the function only dump the tables that do not contain thelocal_language_id
column identifier.I hope I made this at least somewhat clear, its a bit complicated to explain over plain text.
EDIT: fixed typos
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.
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
dump
function makes it clear that thelangs
argument is only supposed to apply to unofficial translations; official text is always loaded, regardless of language. I think the CLI should preserve that behaviour -dump -l none
should only disable dumping of translations, not all text. That's consistent with howload -l
works too.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
continue
.