Merge dce459d39ace25f03edbabdad1735064787568f7 into df129c7ba30aaa9ffffb81a48f53aa7253b0b4e6

This commit is contained in:
Lumír 'Frenzy' Balhar 2024-02-07 10:59:16 +00:00 committed by GitHub
commit 72a4adec3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 7 additions and 42 deletions

View File

@ -1,8 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from past.builtins import basestring
from ._utils import basestring
from .nodes import ( from .nodes import (
filter_operator, filter_operator,
GlobalNode, GlobalNode,
@ -79,7 +76,7 @@ def output(*streams_and_filename, **kwargs):
""" """
streams_and_filename = list(streams_and_filename) streams_and_filename = list(streams_and_filename)
if 'filename' not in kwargs: if 'filename' not in kwargs:
if not isinstance(streams_and_filename[-1], basestring): if not isinstance(streams_and_filename[-1], str):
raise ValueError('A filename must be provided') raise ValueError('A filename must be provided')
kwargs['filename'] = streams_and_filename.pop(-1) kwargs['filename'] = streams_and_filename.pop(-1)
streams = streams_and_filename streams = streams_and_filename

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .dag import get_outgoing_edges, topo_sort from .dag import get_outgoing_edges, topo_sort
from ._utils import basestring, convert_kwargs_to_cmd_line_args from ._utils import convert_kwargs_to_cmd_line_args
from builtins import str from builtins import str
from functools import reduce from functools import reduce
import copy import copy
@ -140,7 +140,7 @@ def _get_output_args(node, stream_name_map):
args += ['-b:a', str(kwargs.pop('audio_bitrate'))] args += ['-b:a', str(kwargs.pop('audio_bitrate'))]
if 'video_size' in kwargs: if 'video_size' in kwargs:
video_size = kwargs.pop('video_size') video_size = kwargs.pop('video_size')
if not isinstance(video_size, basestring) and isinstance(video_size, Iterable): if not isinstance(video_size, str) and isinstance(video_size, Iterable):
video_size = '{}x{}'.format(video_size[0], video_size[1]) video_size = '{}x{}'.format(video_size[0], video_size[1])
args += ['-video_size', video_size] args += ['-video_size', video_size]
args += convert_kwargs_to_cmd_line_args(kwargs) args += convert_kwargs_to_cmd_line_args(kwargs)
@ -185,7 +185,7 @@ def compile(stream_spec, cmd='ffmpeg', overwrite_output=False):
This is the same as calling :meth:`get_args` except that it also This is the same as calling :meth:`get_args` except that it also
includes the ``ffmpeg`` command as the first argument. includes the ``ffmpeg`` command as the first argument.
""" """
if isinstance(cmd, basestring): if isinstance(cmd, str):
cmd = [cmd] cmd = [cmd]
elif type(cmd) != list: elif type(cmd) != list:
cmd = list(cmd) cmd = list(cmd)

View File

@ -1,31 +1,15 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from builtins import str from builtins import str
from past.builtins import basestring
import hashlib import hashlib
import sys import sys
if sys.version_info.major == 2:
# noinspection PyUnresolvedReferences,PyShadowingBuiltins
str = str
try: try:
from collections.abc import Iterable from collections.abc import Iterable
except ImportError: except ImportError:
from collections import Iterable from collections import Iterable
# `past.builtins.basestring` module can't be imported on Python3 in some environments (Ubuntu).
# This code is copy-pasted from it to avoid crashes.
class BaseBaseString(type):
def __instancecheck__(cls, instance):
return isinstance(instance, (bytes, str))
def __subclasshook__(cls, thing):
# TODO: What should go here?
raise NotImplemented
def with_metaclass(meta, *bases): def with_metaclass(meta, *bases):
class metaclass(meta): class metaclass(meta):
__call__ = type.__call__ __call__ = type.__call__
@ -39,25 +23,13 @@ def with_metaclass(meta, *bases):
return metaclass('temporary_class', None, {}) return metaclass('temporary_class', None, {})
if sys.version_info.major >= 3:
class basestring(with_metaclass(BaseBaseString)):
pass
else:
# noinspection PyUnresolvedReferences,PyCompatibility
from builtins import basestring
def _recursive_repr(item): def _recursive_repr(item):
"""Hack around python `repr` to deterministically represent dictionaries. """Hack around python `repr` to deterministically represent dictionaries.
This is able to represent more things than json.dumps, since it does not require This is able to represent more things than json.dumps, since it does not require
things to be JSON serializable (e.g. datetimes). things to be JSON serializable (e.g. datetimes).
""" """
if isinstance(item, basestring): if isinstance(item, list):
result = str(item)
elif isinstance(item, list):
result = '[{}]'.format(', '.join([_recursive_repr(x) for x in item])) result = '[{}]'.format(', '.join([_recursive_repr(x) for x in item]))
elif isinstance(item, dict): elif isinstance(item, dict):
kv_pairs = [ kv_pairs = [

View File

@ -1,6 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from past.builtins import basestring
from .dag import KwargReprNode from .dag import KwargReprNode
from ._utils import escape_chars, get_hash_int from ._utils import escape_chars, get_hash_int
from builtins import object from builtins import object
@ -68,7 +67,7 @@ class Stream(object):
""" """
if self.selector is not None: if self.selector is not None:
raise ValueError('Stream already has a selector: {}'.format(self)) raise ValueError('Stream already has a selector: {}'.format(self))
elif not isinstance(index, basestring): elif not isinstance(index, str):
raise TypeError("Expected string index (e.g. 'a'); got {!r}".format(index)) raise TypeError("Expected string index (e.g. 'a'); got {!r}".format(index))
return self.node.stream(label=self.label, selector=index) return self.node.stream(label=self.label, selector=index)

View File

@ -6,7 +6,6 @@ certifi==2019.3.9
chardet==3.0.4 chardet==3.0.4
docutils==0.14 docutils==0.14
filelock==3.0.12 filelock==3.0.12
future==0.17.1
idna==2.8 idna==2.8
imagesize==1.1.0 imagesize==1.1.0
importlib-metadata==0.17 importlib-metadata==0.17

View File

@ -68,10 +68,9 @@ setup(
download_url=download_url, download_url=download_url,
keywords=keywords, keywords=keywords,
long_description=long_description, long_description=long_description,
install_requires=['future'], install_requires=[],
extras_require={ extras_require={
'dev': [ 'dev': [
'future==0.17.1',
'numpy==1.16.4', 'numpy==1.16.4',
'pytest-mock==1.10.4', 'pytest-mock==1.10.4',
'pytest==4.6.1', 'pytest==4.6.1',

View File

@ -19,6 +19,5 @@ python =
[testenv] [testenv]
commands = py.test -vv commands = py.test -vv
deps = deps =
future
pytest pytest
pytest-mock pytest-mock