Skip to content

Commit

Permalink
Run pyupgrade for 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
daveisfera authored and mauricioabreu committed Nov 17, 2023
1 parent 9be37de commit 890a1cb
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 34 deletions.
1 change: 0 additions & 1 deletion m3u8/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
6 changes: 3 additions & 3 deletions m3u8/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from urllib.parse import urljoin, urlsplit


class BasePathMixin(object):
class BasePathMixin:
@property
def absolute_uri(self):
if self.uri is None:
Expand Down Expand Up @@ -31,12 +31,12 @@ def get_path_from_uri(self):
def base_path(self, newbase_path):
if self.uri is not None:
if not self.base_path:
self.uri = "%s/%s" % (newbase_path, self.uri)
self.uri = f"{newbase_path}/{self.uri}"
else:
self.uri = self.uri.replace(self.base_path, newbase_path)


class GroupedBasePathMixin(object):
class GroupedBasePathMixin:
def _set_base_uri(self, new_base_uri):
for item in self:
item.base_uri = new_base_uri
Expand Down
27 changes: 13 additions & 14 deletions m3u8/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand All @@ -22,7 +21,7 @@ class MalformedPlaylistError(Exception):
pass


class M3U8(object):
class M3U8:
"""
Represents a single M3U8 playlist. Should be instantiated with
the content as string.
Expand Down Expand Up @@ -376,7 +375,7 @@ def dumps(self):
output.append("#EXT-X-MEDIA-SEQUENCE:" + str(self.media_sequence))
if self.discontinuity_sequence:
output.append(
"#EXT-X-DISCONTINUITY-SEQUENCE:{}".format(self.discontinuity_sequence)
f"#EXT-X-DISCONTINUITY-SEQUENCE:{self.discontinuity_sequence}"
)
if self.allow_cache:
output.append("#EXT-X-ALLOW-CACHE:" + self.allow_cache.upper())
Expand Down Expand Up @@ -680,7 +679,7 @@ def __str__(self):

@property
def base_path(self):
return super(Segment, self).base_path
return super().base_path

@base_path.setter
def base_path(self, newbase_path):
Expand Down Expand Up @@ -995,7 +994,7 @@ def __str__(self):
else:
media_types += [media.type]
media_type = media.type.upper()
stream_inf.append('%s="%s"' % (media_type, media.group_id))
stream_inf.append(f'{media_type}="{media.group_id}"')

return "#EXT-X-STREAM-INF:" + ",".join(stream_inf) + "\n" + self.uri

Expand Down Expand Up @@ -1087,7 +1086,7 @@ def __str__(self):
return "#EXT-X-I-FRAME-STREAM-INF:" + ",".join(iframe_stream_inf)


class StreamInfo(object):
class StreamInfo:
bandwidth = None
closed_captions = None
average_bandwidth = None
Expand Down Expand Up @@ -1266,7 +1265,7 @@ class SessionDataList(TagList):
pass


class Start(object):
class Start:
def __init__(self, time_offset, precise=None):
self.time_offset = float(time_offset)
self.precise = precise
Expand Down Expand Up @@ -1305,7 +1304,7 @@ def __str__(self):
return "\n".join(output)


class ServerControl(object):
class ServerControl:
def __init__(
self,
can_skip_until=None,
Expand Down Expand Up @@ -1346,7 +1345,7 @@ def __str__(self):
return self.dumps()


class Skip(object):
class Skip:
def __init__(self, skipped_segments, recently_removed_dateranges=None):
self.skipped_segments = skipped_segments
self.recently_removed_dateranges = recently_removed_dateranges
Expand All @@ -1366,7 +1365,7 @@ def __str__(self):
return self.dumps()


class PartInformation(object):
class PartInformation:
def __init__(self, part_target=None):
self.part_target = part_target

Expand Down Expand Up @@ -1397,15 +1396,15 @@ def dumps(self):

for attr in ["byterange_start", "byterange_length"]:
if self[attr] is not None:
hint.append("%s=%s" % (denormalize_attribute(attr), self[attr]))
hint.append(f"{denormalize_attribute(attr)}={self[attr]}")

return "#EXT-X-PRELOAD-HINT:" + ",".join(hint)

def __str__(self):
return self.dumps()


class SessionData(object):
class SessionData:
def __init__(self, data_id, value=None, uri=None, language=None):
self.data_id = data_id
self.value = value
Expand All @@ -1432,7 +1431,7 @@ class DateRangeList(TagList):
pass


class DateRange(object):
class DateRange:
def __init__(self, **kwargs):
self.id = kwargs["id"]
self.start_date = kwargs.get("start_date")
Expand Down Expand Up @@ -1479,7 +1478,7 @@ def dumps(self):

# client attributes sorted alphabetically output order is predictable
for attr, value in sorted(self.x_client_attrs):
daterange.append("%s=%s" % (denormalize_attribute(attr), value))
daterange.append(f"{denormalize_attribute(attr)}={value}")

return "#EXT-X-DATERANGE:" + ",".join(daterange)

Expand Down
1 change: 0 additions & 1 deletion m3u8/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion m3u8/protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion tests/m3u8server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion tests/playlists.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
15 changes: 7 additions & 8 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down Expand Up @@ -77,28 +76,28 @@ def test_load_should_create_object_from_uri_with_relative_segments():
urlparsed = urllib.parse.urlparse(playlists.RELATIVE_PLAYLIST_URI)
base_uri = os.path.normpath(urlparsed.path + "/..")
prefix = urlparsed.scheme + "://" + urlparsed.netloc
expected_key_abspath = "%s%skey.bin" % (
expected_key_abspath = "{}{}key.bin".format(
prefix,
os.path.normpath(base_uri + "/..") + "/",
)
expected_key_path = "../key.bin"
expected_ts1_abspath = "%s%sentire1.ts" % (prefix, "/")
expected_ts1_abspath = "{}{}entire1.ts".format(prefix, "/")
expected_ts1_path = "/entire1.ts"
expected_ts2_abspath = "%s%sentire2.ts" % (
expected_ts2_abspath = "{}{}entire2.ts".format(
prefix,
os.path.normpath(base_uri + "/..") + "/",
)
expected_ts2_path = "../entire2.ts"
expected_ts3_abspath = "%s%sentire3.ts" % (
expected_ts3_abspath = "{}{}entire3.ts".format(
prefix,
os.path.normpath(base_uri + "/../.."),
)
expected_ts3_path = "../../entire3.ts"
expected_ts4_abspath = "%s%sentire4.ts" % (prefix, base_uri + "/")
expected_ts4_abspath = "{}{}entire4.ts".format(prefix, base_uri + "/")
expected_ts4_path = "entire4.ts"
expected_ts5_abspath = "%s%sentire5.ts" % (prefix, base_uri + "/")
expected_ts5_abspath = "{}{}entire5.ts".format(prefix, base_uri + "/")
expected_ts5_path = "./entire5.ts"
expected_ts6_abspath = "%s%sentire6.ts" % (prefix, base_uri + "/")
expected_ts6_abspath = "{}{}entire6.ts".format(prefix, base_uri + "/")
expected_ts6_path = ".//entire6.ts"

assert isinstance(obj, m3u8.M3U8)
Expand Down
1 change: 0 additions & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion tests/test_strict_validations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down
1 change: 0 additions & 1 deletion tests/test_variant_m3u8.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# Copyright 2014 Globo.com Player authors. All rights reserved.
# Use of this source code is governed by a MIT License
# license that can be found in the LICENSE file.
Expand Down

0 comments on commit 890a1cb

Please sign in to comment.