-
Notifications
You must be signed in to change notification settings - Fork 145
Fix check for python version on sc2json script #179
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
Changes from all commits
09a00cc
99e1071
d5f6c5d
c313b2b
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import sc2reader | ||
from sc2reader.factories.plugins.replay import toJSON | ||
import sys | ||
|
||
|
||
def main(): | ||
|
@@ -15,28 +16,31 @@ def main(): | |
default=None, | ||
help="The per-line indent to use when printing a human readable json string", | ||
) | ||
parser.add_argument( | ||
"--encoding", | ||
"-e", | ||
type=str, | ||
default="UTF-8", | ||
help="The character encoding use..", | ||
) | ||
parser.add_argument( | ||
"path", | ||
metavar="path", | ||
type=str, | ||
nargs=1, | ||
help="Path to the replay to serialize.", | ||
) | ||
if sys.version_info.major < 3: | ||
parser.add_argument( | ||
"--encoding", | ||
"-e", | ||
type=str, | ||
default="UTF-8", | ||
help="The character encoding use..", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
factory = sc2reader.factories.SC2Factory() | ||
try: | ||
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. This change above is good. 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 would leave the original try/except it would throw an AttributeError before the TypeError though if args.encoding doesn't exist |
||
|
||
if sys.version_info.major < 3: | ||
factory.register_plugin( | ||
"Replay", toJSON(encoding=args.encoding, indent=args.indent) | ||
) # legacy Python | ||
except TypeError: | ||
) | ||
else: | ||
factory.register_plugin("Replay", toJSON(indent=args.indent)) | ||
replay_json = factory.load_replay(args.path[0]) | ||
print(replay_json) | ||
|
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.
As of #174 Python 2 is no longer supported.