-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Remove logic for python2 #312
Open
AbdealiLoKo
wants to merge
6
commits into
JessicaTegner:master
Choose a base branch
from
AbdealiLoKo:ajk-py3
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.
+27
−79
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5a8dcea
init: Remove __future__ statements or py2
AbdealiLoKo 90169d7
py3compat: Remove conditions for py2
AbdealiLoKo 41912de
py3compat: Stop using string/unicode types
AbdealiLoKo 9871a31
py3compat: Move url2path/path2url out of py3compat
AbdealiLoKo 06e7c09
py3compat: Remove cast_bytes()
AbdealiLoKo 47eea0c
py3compat: Remove cast_unicode()
AbdealiLoKo 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, print_function, with_statement | ||
from typing import Iterable | ||
from typing import Union | ||
from typing import Generator | ||
|
@@ -13,10 +12,12 @@ | |
import textwrap | ||
import glob | ||
from pathlib import Path | ||
from urllib.parse import urlparse | ||
from urllib.request import url2pathname | ||
|
||
from .handler import _check_log_handler | ||
from .pandoc_download import DEFAULT_TARGET_FOLDER, download_pandoc | ||
from .py3compat import cast_bytes, cast_unicode, string_types, url2path, urlparse | ||
from .py3compat import _DEFAULT_ENCODING | ||
|
||
__author__ = u'Juho Vepsäläinen' | ||
__author_email__ = "[email protected]" | ||
|
@@ -53,6 +54,11 @@ | |
# Set up the module level logger | ||
logger = logging.getLogger(__name__) | ||
|
||
def url2path(url): # noqa: E303 | ||
# from http://stackoverflow.com/questions/11687478/convert-a-filename-to-a-file-url | ||
return url2pathname(urlparse(url).path) | ||
|
||
|
||
def convert_text(source:str, to:str, format:str, extra_args:Iterable=(), encoding:str='utf-8', | ||
outputfile:Union[None, str, Path]=None, filters:Union[Iterable, None]=None, verify_format:bool=True, | ||
sandbox:bool=True, cworkdir:Union[str, None]=None) -> str: | ||
|
@@ -238,7 +244,10 @@ def _as_unicode(source:any, encoding:str) -> any: | |
# if a source and a different encoding is given, try to decode the the source into a | ||
# unicode string | ||
try: | ||
source = cast_unicode(source, encoding=encoding) | ||
if isinstance(source, bytes): | ||
encoding = encoding or _DEFAULT_ENCODING | ||
source = source.decode(encoding) | ||
|
||
except (UnicodeDecodeError, UnicodeEncodeError): | ||
pass | ||
return source | ||
|
@@ -356,7 +365,7 @@ def _convert_input(source, format, input_type, to, extra_args=(), | |
|
||
# adds the proper filter syntax for each item in the filters list | ||
if filters is not None: | ||
if isinstance(filters, string_types): | ||
if isinstance(filters, str): | ||
filters = filters.split() | ||
f = ['--lua-filter=' + x if x.endswith(".lua") else '--filter=' + x for x in filters] | ||
args.extend(f) | ||
|
@@ -392,7 +401,8 @@ def _convert_input(source, format, input_type, to, extra_args=(), | |
|
||
if string_input: | ||
try: | ||
source = cast_bytes(source, encoding='utf-8') | ||
if not isinstance(source, bytes): | ||
source = source.encode('utf-8') | ||
except (UnicodeDecodeError, UnicodeEncodeError): | ||
# assume that it is already a utf-8 encoded string | ||
pass | ||
|
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
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. could the remaining contents of this module moved into another one? |
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
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.
these headers are also obsolete.