Skip to content

Commit

Permalink
Merge pull request #40 from sumpfralle/patch-1
Browse files Browse the repository at this point in the history
Fix flake8 issues
  • Loading branch information
sampsyo committed Jul 16, 2018
2 parents 0d56b1d + 9ddcd0a commit 22ea8ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions acoustid.py
Expand Up @@ -39,8 +39,8 @@

API_BASE_URL = 'http://api.acoustid.org/v2/'
DEFAULT_META = 'recordings'
REQUEST_INTERVAL = 0.33 # 3 requests/second.
MAX_AUDIO_LENGTH = 120 # Seconds.
REQUEST_INTERVAL = 0.33 # 3 requests/second.
MAX_AUDIO_LENGTH = 120 # Seconds.
FPCALC_COMMAND = 'fpcalc'
FPCALC_ENVVAR = 'FPCALC'

Expand Down Expand Up @@ -137,7 +137,7 @@ def add_headers(self, request, **kwargs):

# Utilities.

class _rate_limit(object):
class _rate_limit(object): # noqa: N801
"""A decorator that limits the rate at which the function may be
called. The rate is controlled by the REQUEST_INTERVAL module-level
constant; set the value to zero to disable rate limiting. The
Expand Down Expand Up @@ -201,10 +201,10 @@ def fingerprint(samplerate, channels, pcmiter, maxlength=MAX_AUDIO_LENGTH):
fper = chromaprint.Fingerprinter()
fper.start(samplerate, channels)

position = 0 # Samples of audio fed to the fingerprinter.
position = 0 # Samples of audio fed to the fingerprinter.
for block in pcmiter:
fper.feed(block)
position += len(block) // 2 # 2 bytes/sample.
position += len(block) // 2 # 2 bytes/sample.
if position >= endposition:
break

Expand Down
4 changes: 2 additions & 2 deletions chromaprint.py
Expand Up @@ -11,9 +11,9 @@
if sys.version_info[0] >= 3:
BUFFER_TYPES = (memoryview, bytearray,)
elif sys.version_info[1] >= 7:
BUFFER_TYPES = (buffer, memoryview, bytearray,)
BUFFER_TYPES = (buffer, memoryview, bytearray,) # noqa: F821
else:
BUFFER_TYPES = (buffer, bytearray,)
BUFFER_TYPES = (buffer, bytearray,) # noqa: F821


# Find the base library and declare prototypes.
Expand Down
8 changes: 6 additions & 2 deletions fpcalc.py
Expand Up @@ -21,11 +21,13 @@
from __future__ import absolute_import
from __future__ import print_function

import sys
import argparse
import sys

import acoustid
import chromaprint


def main():
parser = argparse.ArgumentParser()
parser.add_argument('-length', metavar='SECS', type=int, default=120,
Expand All @@ -37,7 +39,8 @@ def main():
help='audio file to be fingerprinted')

args = parser.parse_args()
del sys.argv[1:] # to make gst not try to parse the args
# make gst not try to parse the args
del sys.argv[1:]

first = True
for i, path in enumerate(args.paths):
Expand All @@ -57,5 +60,6 @@ def main():
print('DURATION=%d' % duration)
print('FINGERPRINT=%s' % fp.decode('utf8'))


if __name__ == '__main__':
main()
9 changes: 4 additions & 5 deletions setup.py
Expand Up @@ -32,17 +32,16 @@ def _read(fn):

setup(name='pyacoustid',
version='1.1.5',
description=
'bindings for Chromaprint acoustic fingerprinting and the '
'Acoustid API',
description=('bindings for Chromaprint acoustic fingerprinting and the '
'Acoustid API'),
author='Adrian Sampson',
author_email='adrian@radbox.org',
url='https://github.com/sampsyo/pyacoustid',
license='MIT',
platforms='ALL',
long_description=_read('README.rst'),

install_requires = ['audioread', 'requests'],
install_requires=['audioread', 'requests'],

py_modules=[
'chromaprint',
Expand All @@ -55,4 +54,4 @@ def _read(fn):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
],
)
)

0 comments on commit 22ea8ca

Please sign in to comment.