-
Notifications
You must be signed in to change notification settings - Fork 7
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
python3 migration #20
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
commandline client for bepasty-server | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
import base64 | ||
import re | ||
import os | ||
|
@@ -16,7 +16,7 @@ | |
import codecs | ||
import warnings | ||
try: | ||
from ConfigParser import SafeConfigParser as ConfigParser, Error as ConfigParserError | ||
from configparser import SafeConfigParser as ConfigParser, Error as ConfigParserError | ||
except ImportError: | ||
# Python 3 | ||
from configparser import ConfigParser, Error as ConfigParserError | ||
Comment on lines
18
to
22
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. that doesn't look correct. the upper block is meant for python 2, so it should be if that import fails (e.g. because we are on py3), it is retried in the lower except block. |
||
|
@@ -40,7 +40,7 @@ | |
'MINUTES', 'MINUTES', 'HOURS', 'HOURS', 'DAYS', 'DAYS', 'WEEKS', 'WEEKS', | ||
'MONTHS', 'MONTHS', 'YEARS', 'YEARS', 'FOREVER', 'FOREVER' | ||
) | ||
LIFETIME_MAPPING = dict(zip(LIFETIME_CHOICES, LIFETIME_NAMES)) | ||
LIFETIME_MAPPING = dict(list(zip(LIFETIME_CHOICES, LIFETIME_NAMES))) | ||
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. can you explain why this is needed? |
||
CONFIG_DEFAULTS = dict( | ||
token='', | ||
url='', | ||
|
@@ -74,7 +74,7 @@ def setup_config_parser(override=None): | |
override = dict() | ||
config = ConfigParser() | ||
config.add_section('bepasty-client-cli') | ||
for k, v in CONFIG_DEFAULTS.items(): | ||
for k, v in list(CONFIG_DEFAULTS.items()): | ||
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. why? |
||
v = override.get(k, v) | ||
config.set('bepasty-client-cli', k, str(v)) | ||
return config | ||
|
@@ -106,7 +106,7 @@ def setup_configuration(ctx, param, value): | |
except ConfigParserError as exc: | ||
raise click.UsageError('Error in configuration file: {}'.format(exc)) | ||
ctx.default_map = dict() | ||
for option in CONFIG_DEFAULTS.keys(): | ||
for option in list(CONFIG_DEFAULTS.keys()): | ||
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. why? |
||
if option == 'insecure': | ||
try: | ||
ctx.default_map[option] = config.getboolean('bepasty-client-cli', option) | ||
|
@@ -224,7 +224,7 @@ def print_list(token, url, insecure): | |
verify=not insecure | ||
) | ||
try: | ||
for k, v in response.json().items(): | ||
for k, v in list(response.json().items()): | ||
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. why? |
||
meta = v['file-meta'] | ||
if not meta: | ||
print("{:8}: BROKEN PASTE".format(k)) | ||
|
@@ -259,7 +259,7 @@ def upload(token, filename, fname, url, ftype, insecure, lifetime): | |
first_chunk = fileobj.read(read_size) | ||
if not ftype: | ||
mime = magic.Magic(mime=True) | ||
ftype = mime.from_buffer(first_chunk).decode() | ||
ftype = mime.from_buffer(first_chunk) | ||
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. does it still work on py2 with that? |
||
|
||
if not ftype: | ||
ftype = 'text/plain' | ||
|
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.
does it still work on py2 with that?