Skip to content

Commit

Permalink
Merge pull request globocom#212 from mauricioabreu/remove-python2
Browse files Browse the repository at this point in the history
Remove Python2 references
  • Loading branch information
leandromoreira authored Jun 13, 2020
2 parents b885b25 + f4c2aa6 commit 5cea953
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.8@m3u8
3.7.6@m3u8
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: python
sudo: false
python:
- "2.7"
- "3.5"
- "3.6"
- "3.6-dev"
- "3.7"
- "3.7-dev"
- "3.8"
- "3.8-dev"
- "nightly"
script: ./runtests
after_success: coveralls
19 changes: 3 additions & 16 deletions m3u8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ def load(uri, timeout=None, headers={}, custom_tags_parser=None, verify_ssl=True
'''
Retrieves the content from a given URI and returns a M3U8 object.
Raises ValueError if invalid content or IOError if request fails.
Raises socket.timeout(python 2.7+) or urllib2.URLError(python 2.6) if
timeout happens when loading from uri
'''
if is_url(uri):
return _load_from_uri(uri, timeout, headers, custom_tags_parser, verify_ssl)
Expand All @@ -69,10 +67,9 @@ def _load_from_uri(uri, timeout=None, headers={}, custom_tags_parser=None, verif
context = ssl._create_unverified_context()
resource = urlopen(request, timeout=timeout, context=context)
base_uri = _parsed_url(resource.geturl())
if PYTHON_MAJOR_VERSION < (3,):
content = _read_python2x(resource)
else:
content = _read_python3x(resource)
content = resource.read().decode(
resource.headers.get_content_charset(failobj="utf-8")
)
return M3U8(content, base_uri=base_uri, custom_tags_parser=custom_tags_parser)


Expand All @@ -83,16 +80,6 @@ def _parsed_url(url):
return urljoin(prefix, base_path)


def _read_python2x(resource):
return resource.read().strip()


def _read_python3x(resource):
return resource.read().decode(
resource.headers.get_content_charset(failobj="utf-8")
)


def _load_from_file(uri, custom_tags_parser=None):
with open(uri) as fileobj:
raw_content = fileobj.read().strip()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
url="https://github.com/globocom/m3u8",
description="Python m3u8 parser",
long_description=long_description,
python_requires='>=2.7'
python_requires='>=3.5'
)

0 comments on commit 5cea953

Please sign in to comment.