| 1 | Patch-Source: https://github.com/kkroening/ffmpeg-python/pull/795
|
| 2 | ---
|
| 3 | From dce459d39ace25f03edbabdad1735064787568f7 Mon Sep 17 00:00:00 2001
|
| 4 | From: Lumir Balhar <[email protected]>
|
| 5 | Date: Wed, 20 Sep 2023 14:18:16 +0200
|
| 6 | Subject: [PATCH] Remove dependency on `future`
|
| 7 |
|
| 8 | ---
|
| 9 | ffmpeg/_ffmpeg.py | 5 +----
|
| 10 | ffmpeg/_run.py | 6 +++---
|
| 11 | ffmpeg/_utils.py | 30 +-----------------------------
|
| 12 | ffmpeg/nodes.py | 3 +--
|
| 13 | requirements.txt | 1 -
|
| 14 | setup.py | 3 +--
|
| 15 | tox.ini | 1 -
|
| 16 | 7 files changed, 7 insertions(+), 42 deletions(-)
|
| 17 |
|
| 18 | diff --git a/ffmpeg/_ffmpeg.py b/ffmpeg/_ffmpeg.py
|
| 19 | index 007624bb..57dc0c96 100644
|
| 20 | |
| 21 | |
| 22 | @@ -1,8 +1,5 @@
|
| 23 | from __future__ import unicode_literals
|
| 24 |
|
| 25 | -from past.builtins import basestring
|
| 26 | -from ._utils import basestring
|
| 27 | -
|
| 28 | from .nodes import (
|
| 29 | filter_operator,
|
| 30 | GlobalNode,
|
| 31 | @@ -79,7 +76,7 @@ def output(*streams_and_filename, **kwargs):
|
| 32 | """
|
| 33 | streams_and_filename = list(streams_and_filename)
|
| 34 | if 'filename' not in kwargs:
|
| 35 | - if not isinstance(streams_and_filename[-1], basestring):
|
| 36 | + if not isinstance(streams_and_filename[-1], str):
|
| 37 | raise ValueError('A filename must be provided')
|
| 38 | kwargs['filename'] = streams_and_filename.pop(-1)
|
| 39 | streams = streams_and_filename
|
| 40 | diff --git a/ffmpeg/_run.py b/ffmpeg/_run.py
|
| 41 | index f42d1d73..7a8b3937 100644
|
| 42 | |
| 43 | |
| 44 | @@ -1,6 +1,6 @@
|
| 45 | from __future__ import unicode_literals
|
| 46 | from .dag import get_outgoing_edges, topo_sort
|
| 47 | -from ._utils import basestring, convert_kwargs_to_cmd_line_args
|
| 48 | +from ._utils import convert_kwargs_to_cmd_line_args
|
| 49 | from builtins import str
|
| 50 | from functools import reduce
|
| 51 | import copy
|
| 52 | @@ -140,7 +140,7 @@ def _get_output_args(node, stream_name_map):
|
| 53 | args += ['-b:a', str(kwargs.pop('audio_bitrate'))]
|
| 54 | if 'video_size' in kwargs:
|
| 55 | video_size = kwargs.pop('video_size')
|
| 56 | - if not isinstance(video_size, basestring) and isinstance(video_size, Iterable):
|
| 57 | + if not isinstance(video_size, str) and isinstance(video_size, Iterable):
|
| 58 | video_size = '{}x{}'.format(video_size[0], video_size[1])
|
| 59 | args += ['-video_size', video_size]
|
| 60 | args += convert_kwargs_to_cmd_line_args(kwargs)
|
| 61 | @@ -185,7 +185,7 @@ def compile(stream_spec, cmd='ffmpeg', overwrite_output=False):
|
| 62 | This is the same as calling :meth:`get_args` except that it also
|
| 63 | includes the ``ffmpeg`` command as the first argument.
|
| 64 | """
|
| 65 | - if isinstance(cmd, basestring):
|
| 66 | + if isinstance(cmd, str):
|
| 67 | cmd = [cmd]
|
| 68 | elif type(cmd) != list:
|
| 69 | cmd = list(cmd)
|
| 70 | diff --git a/ffmpeg/_utils.py b/ffmpeg/_utils.py
|
| 71 | index 9baa2c78..fc8ee92b 100644
|
| 72 | |
| 73 | |
| 74 | @@ -1,31 +1,15 @@
|
| 75 | from __future__ import unicode_literals
|
| 76 | from builtins import str
|
| 77 | -from past.builtins import basestring
|
| 78 | import hashlib
|
| 79 | import sys
|
| 80 |
|
| 81 |
|
| 82 | -if sys.version_info.major == 2:
|
| 83 | - # noinspection PyUnresolvedReferences,PyShadowingBuiltins
|
| 84 | - str = str
|
| 85 | -
|
| 86 | try:
|
| 87 | from collections.abc import Iterable
|
| 88 | except ImportError:
|
| 89 | from collections import Iterable
|
| 90 |
|
| 91 |
|
| 92 | -# `past.builtins.basestring` module can't be imported on Python3 in some environments (Ubuntu).
|
| 93 | -# This code is copy-pasted from it to avoid crashes.
|
| 94 | -class BaseBaseString(type):
|
| 95 | - def __instancecheck__(cls, instance):
|
| 96 | - return isinstance(instance, (bytes, str))
|
| 97 | -
|
| 98 | - def __subclasshook__(cls, thing):
|
| 99 | - # TODO: What should go here?
|
| 100 | - raise NotImplemented
|
| 101 | -
|
| 102 | -
|
| 103 | def with_metaclass(meta, *bases):
|
| 104 | class metaclass(meta):
|
| 105 | __call__ = type.__call__
|
| 106 | @@ -39,25 +23,13 @@ def __new__(cls, name, this_bases, d):
|
| 107 | return metaclass('temporary_class', None, {})
|
| 108 |
|
| 109 |
|
| 110 | -if sys.version_info.major >= 3:
|
| 111 | -
|
| 112 | - class basestring(with_metaclass(BaseBaseString)):
|
| 113 | - pass
|
| 114 | -
|
| 115 | -else:
|
| 116 | - # noinspection PyUnresolvedReferences,PyCompatibility
|
| 117 | - from builtins import basestring
|
| 118 | -
|
| 119 | -
|
| 120 | def _recursive_repr(item):
|
| 121 | """Hack around python `repr` to deterministically represent dictionaries.
|
| 122 |
|
| 123 | This is able to represent more things than json.dumps, since it does not require
|
| 124 | things to be JSON serializable (e.g. datetimes).
|
| 125 | """
|
| 126 | - if isinstance(item, basestring):
|
| 127 | - result = str(item)
|
| 128 | - elif isinstance(item, list):
|
| 129 | + if isinstance(item, list):
|
| 130 | result = '[{}]'.format(', '.join([_recursive_repr(x) for x in item]))
|
| 131 | elif isinstance(item, dict):
|
| 132 | kv_pairs = [
|
| 133 | diff --git a/ffmpeg/nodes.py b/ffmpeg/nodes.py
|
| 134 | index e8b28385..cc219c72 100644
|
| 135 | |
| 136 | |
| 137 | @@ -1,6 +1,5 @@
|
| 138 | from __future__ import unicode_literals
|
| 139 |
|
| 140 | -from past.builtins import basestring
|
| 141 | from .dag import KwargReprNode
|
| 142 | from ._utils import escape_chars, get_hash_int
|
| 143 | from builtins import object
|
| 144 | @@ -68,7 +67,7 @@ def __getitem__(self, index):
|
| 145 | """
|
| 146 | if self.selector is not None:
|
| 147 | raise ValueError('Stream already has a selector: {}'.format(self))
|
| 148 | - elif not isinstance(index, basestring):
|
| 149 | + elif not isinstance(index, str):
|
| 150 | raise TypeError("Expected string index (e.g. 'a'); got {!r}".format(index))
|
| 151 | return self.node.stream(label=self.label, selector=index)
|
| 152 |
|
| 153 | diff --git a/requirements.txt b/requirements.txt
|
| 154 | index f8b347e9..b4bc370e 100644
|
| 155 | |
| 156 | |
| 157 | @@ -6,7 +6,6 @@ certifi==2019.3.9
|
| 158 | chardet==3.0.4
|
| 159 | docutils==0.14
|
| 160 | filelock==3.0.12
|
| 161 | -future==0.17.1
|
| 162 | idna==2.8
|
| 163 | imagesize==1.1.0
|
| 164 | importlib-metadata==0.17
|
| 165 | diff --git a/setup.py b/setup.py
|
| 166 | index 72f381cb..2fbf9a3d 100644
|
| 167 | |
| 168 | |
| 169 | @@ -68,10 +68,9 @@
|
| 170 | download_url=download_url,
|
| 171 | keywords=keywords,
|
| 172 | long_description=long_description,
|
| 173 | - install_requires=['future'],
|
| 174 | + install_requires=[],
|
| 175 | extras_require={
|
| 176 | 'dev': [
|
| 177 | - 'future==0.17.1',
|
| 178 | 'numpy==1.16.4',
|
| 179 | 'pytest-mock==1.10.4',
|
| 180 | 'pytest==4.6.1',
|
| 181 | diff --git a/tox.ini b/tox.ini
|
| 182 | index 98814078..eb8c6622 100644
|
| 183 | |
| 184 | |
| 185 | @@ -19,6 +19,5 @@ python =
|
| 186 | [testenv]
|
| 187 | commands = py.test -vv
|
| 188 | deps =
|
| 189 | - future
|
| 190 | pytest
|
| 191 | pytest-mock
|