8000 Merge pull request #16 from kkroening/cleanup-hashing · lmlsna/ffmpeg-python@d4b8900 · GitHub
[go: up one dir, main page]

Skip to content < 8000 span data-view-component="true" class="progress-pjax-loader Progress position-fixed width-full">

Commit d4b8900

Browse files
authored
Merge pull request kkroening#16 from kkroening/cleanup-hashing
Cleanup hashing
2 parents 1439c88 + f1e6212 commit d4b8900

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

.python-version

Lines changed: 0 additions & 5 deletions
This file was deleted.

ffmpeg/nodes.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,36 @@
88
class Node(object):
99
"""Node base"""
1010
def __init__(self, parents, name, *args, **kwargs):
11-
parent_hashes = [parent._hash for parent in parents]
11+
parent_hashes = [hash(parent) for parent in parents]
1212
assert len(parent_hashes) == len(set(parent_hashes)), 'Same node cannot be included as parent multiple times'
1313
self._parents = parents
14+
self._hash = None
1415
self._name = name
1516
self._args = args
1617
self._kwargs = kwargs
17-
self._update_hash()
1818

1919
def __repr__(self):
2020
formatted_props = ['{}'.format(arg) for arg in self._args]
2121
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
2222
return '{}({})'.format(self._name, ','.join(formatted_props))
2323

2424
def __hash__(self):
25-
return int(self._hash, base=16)
25+
if self._hash is None:
26+
self._update_hash()
27+
return self._hash
2628

2729
def __eq__(self, other):
28-
return self._hash == other._hash
30+
return hash(self) == hash(other)
2931

3032
def _update_hash(self):
3133
props = {'args': self._args, 'kwargs': self._kwargs}
32-
my_hash = hashlib.md5(json.dumps(props, sort_keys=True).encode('utf-8')).hexdigest()
33-
parent_hashes = [parent._hash for parent in self._parents]
34+
props_str = json.dumps(props, sort_keys=True).encode('utf-8')
35+
my_hash = hashlib.md5(props_str).hexdigest()
36+
parent_hashes = [str(hash(parent)) for parent in self._parents]
3437
hashes = parent_hashes + [my_hash]
35-
self._hash = hashlib.md5(','.join(hashes).encode('utf-8')).hexdigest()
38+
hashes_str = ','.join(hashes).encode('utf-8')
39+
hash_str = hashlib.md5(hashes_str).hexdigest()
40+
self._hash = int(hash_str, base=16)
3641

3742

3843
class InputNode(Node):

setup.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
from textwrap import dedent
33
import subprocess
44

5-
6-
def get_current_commit_hash():
7-
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8-
commit_hash = p.communicate()[0].strip()
9-
return commit_hash
10-
5+
version = '0.1.6'
6+
download_url = 'https://github.com/kkroening/ffmpeg-python/archive/v{}.zip'.format(version)
117

128
long_description = dedent("""\
139
ffmpeg-python: Python bindings for FFmpeg
@@ -18,10 +14,6 @@ def get_current_commit_hash():
1814
""")
1915

2016

21-
22-
commit_hash = get_current_commit_hash()
23-
download_url = 'https://github.com/kkroening/ffmpeg-python/archive/{}.zip'.format(commit_hash)
24-
2517
file_formats = [
2618
'aac',
2719
'ac3',
@@ -67,7 +59,7 @@ def get_current_commit_hash():
6759
packages=['ffmpeg'],
6860
setup_requires=['pytest-runner'],
6961
tests_require=['pytest'],
70-
version='0.1.5',
62+
version=version,
7163
description='Python bindings for FFmpeg - with support for complex filtering',
7264
author='Karl Kroening',
7365
author_email='karlk@kralnet.us',

0 commit comments

Comments
 (0)
0