# HG changeset patch # User Amine Sehili # Date 1571431692 -3600 # Node ID 8ed121db987c0938871ba78ed9f00e22d07d2046 # Parent bf4a8834c5ec7590de4887acf69598f107be1f40 Use ABC instead of ABCMeta in util.py diff -r bf4a8834c5ec -r 8ed121db987c auditok/util.py --- a/auditok/util.py Fri Oct 18 21:36:51 2019 +0100 +++ b/auditok/util.py Fri Oct 18 21:48:12 2019 +0100 @@ -11,9 +11,7 @@ """ from __future__ import division import sys -from abc import ABCMeta, abstractmethod -import math -from array import array +from abc import ABC, abstractmethod from functools import partial from audioop import tomono from .io import ( @@ -90,14 +88,12 @@ ) -class DataSource: +class DataSource(ABC): """ Base class for objects passed to :func:`auditok.core.StreamTokenizer.tokenize`. Subclasses should implement a :func:`DataSource.read` method. """ - __metaclass__ = ABCMeta - @abstractmethod def read(self): """ @@ -106,7 +102,7 @@ """ -class DataValidator(metaclass=ABCMeta): +class DataValidator(ABC): """ Base class for a validator object used by :class:`.core.StreamTokenizer` to check if read data is valid. @@ -551,13 +547,8 @@ data = b''.join(data) assert len(data) == int(ads.get_sampling_rate() * 2.25 * ads.get_sample_width() * ads.get_channels()) """ - - # copy user's dicionary (shallow copy) - kwargs = kwargs.copy() - # check and normalize keyword arguments ADSFactory._check_normalize_args(kwargs) - block_dur = kwargs.pop("bd") hop_dur = kwargs.pop("hd") block_size = kwargs.pop("bs") @@ -587,7 +578,7 @@ # Case 3: a data_buffer is supplied elif data_buffer is not None: - audio_source = BufferAudioSource(data_buffer=data_buffer, **kwargs) + audio_source = BufferAudioSource(data=data_buffer, **kwargs) # Case 4: try to access native audio input else: @@ -952,4 +943,4 @@ record=True, max_read=max_read, **kwargs - ) + ) \ No newline at end of file