Set ascii to the default encoding.
This commit is contained in:
@@ -8,18 +8,17 @@ import requests
|
|||||||
|
|
||||||
from .errors import SubmissionURLError, SubredditNameError
|
from .errors import SubmissionURLError, SubredditNameError
|
||||||
|
|
||||||
FORCE_ASCII = True
|
UNICODE = False
|
||||||
|
|
||||||
def clean(string):
|
def clean(string):
|
||||||
|
|
||||||
encoding = 'ascii' if FORCE_ASCII else 'utf-8'
|
encoding = 'utf-8' if UNICODE else 'ascii'
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
out = string.encode(encoding, 'replace')
|
out = string.encode(encoding, 'replace')
|
||||||
else:
|
else:
|
||||||
out = string.encode().decode(encoding, 'replace')
|
out = string.encode().decode(encoding, 'replace')
|
||||||
|
|
||||||
out = out.replace('\\', '')
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def split_text(big_text, width):
|
def split_text(big_text, width):
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ def main():
|
|||||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
||||||
parser.add_argument('-l', dest='link', help='full link to a submission')
|
parser.add_argument('-l', dest='link', help='full link to a submission')
|
||||||
parser.add_argument('--force-ascii', dest='force_ascii',
|
parser.add_argument('--unicode', help='enable unicode (beta)',
|
||||||
help='disable unicode', action='store_true')
|
action='store_true')
|
||||||
|
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
'authentication (optional)',
|
'authentication (optional)',
|
||||||
@@ -64,7 +64,7 @@ def main():
|
|||||||
if getattr(args, key) is None:
|
if getattr(args, key) is None:
|
||||||
setattr(args, key, val)
|
setattr(args, key, val)
|
||||||
|
|
||||||
content.FORCE_ASCII = args.force_ascii
|
content.UNICODE = args.unicode
|
||||||
|
|
||||||
if args.subreddit is None:
|
if args.subreddit is None:
|
||||||
args.subreddit = 'front'
|
args.subreddit = 'front'
|
||||||
|
|||||||
Reference in New Issue
Block a user