diff --git a/ext/guessit/__main__.py b/ext/guessit/__main__.py index fad196d6bb..1adf078a7c 100644 --- a/ext/guessit/__main__.py +++ b/ext/guessit/__main__.py @@ -4,14 +4,12 @@ Entry point module """ # pragma: no cover -from __future__ import print_function - import json import logging -import os import sys -import six +from collections import OrderedDict + from rebulk.__version__ import __version__ as __rebulk_version__ from guessit import api @@ -20,12 +18,6 @@ from guessit.options import argument_parser, parse_options, load_config, merge_options -try: - from collections import OrderedDict -except ImportError: # pragma: no-cover - from ordereddict import OrderedDict # pylint:disable=import-error - - def guess_filename(filename, options): """ Guess a single filename using given options @@ -48,6 +40,7 @@ def guess_filename(filename, options): if options.get('json'): print(json.dumps(guess, cls=GuessitEncoder, ensure_ascii=False)) elif options.get('yaml'): + # pylint:disable=import-outside-toplevel import yaml from guessit import yamlutils @@ -78,6 +71,7 @@ def display_properties(options): else: print(json.dumps(list(properties.keys()), cls=GuessitEncoder, ensure_ascii=False)) elif options.get('yaml'): + # pylint:disable=import-outside-toplevel import yaml from guessit import yamlutils if options.get('values'): @@ -97,24 +91,10 @@ def display_properties(options): print(4 * ' ' + '[!] %s' % (property_value,)) -def fix_argv_encoding(): - """ - Fix encoding of sys.argv on windows Python 2 - """ - if six.PY2 and os.name == 'nt': # pragma: no cover - # see http://bugs.python.org/issue2128 - import locale - - for i, j in enumerate(sys.argv): - sys.argv[i] = j.decode(locale.getpreferredencoding()) - - def main(args=None): # pylint:disable=too-many-branches """ Main function for entry point """ - fix_argv_encoding() - if args is None: # pragma: no cover options = parse_options() else: @@ -142,7 +122,7 @@ def main(args=None): # pylint:disable=too-many-branches if options.get('yaml'): try: - import yaml # pylint:disable=unused-variable,unused-import + import yaml # pylint:disable=unused-variable,unused-import,import-outside-toplevel except ImportError: # pragma: no cover del options['yaml'] print('PyYAML is not installed. \'--yaml\' option will be ignored ...', file=sys.stderr) @@ -156,10 +136,7 @@ def main(args=None): # pylint:disable=too-many-branches for filename in options.get('filename'): filenames.append(filename) if options.get('input_file'): - if six.PY2: - input_file = open(options.get('input_file'), 'r') - else: - input_file = open(options.get('input_file'), 'r', encoding='utf-8') + input_file = open(options.get('input_file'), 'r', encoding='utf-8') try: filenames.extend([line.strip() for line in input_file.readlines()]) finally: diff --git a/ext/guessit/__version__.py b/ext/guessit/__version__.py index e505897bb7..4a298b0447 100644 --- a/ext/guessit/__version__.py +++ b/ext/guessit/__version__.py @@ -4,4 +4,4 @@ Version module """ # pragma: no cover -__version__ = '3.1.1' +__version__ = '3.2.0' diff --git a/ext/guessit/api.py b/ext/guessit/api.py index 8e306340b4..81904b6010 100644 --- a/ext/guessit/api.py +++ b/ext/guessit/api.py @@ -4,15 +4,12 @@ API functions that can be used by external software """ -try: - from collections import OrderedDict -except ImportError: # pragma: no-cover - from ordereddict import OrderedDict # pylint:disable=import-error +from collections import OrderedDict +from pathlib import Path import os import traceback -import six from rebulk.introspector import introspect from .__version__ import __version__ @@ -26,18 +23,18 @@ class GuessitException(Exception): """ def __init__(self, string, options): - super(GuessitException, self).__init__("An internal error has occured in guessit.\n" - "===================== Guessit Exception Report =====================\n" - "version=%s\n" - "string=%s\n" - "options=%s\n" - "--------------------------------------------------------------------\n" - "%s" - "--------------------------------------------------------------------\n" - "Please report at " - "https://github.com/guessit-io/guessit/issues.\n" - "====================================================================" % - (__version__, str(string), str(options), traceback.format_exc())) + super().__init__("An internal error has occured in guessit.\n" + "===================== Guessit Exception Report =====================\n" + "version=%s\n" + "string=%s\n" + "options=%s\n" + "--------------------------------------------------------------------\n" + "%s" + "--------------------------------------------------------------------\n" + "Please report at " + "https://github.com/guessit-io/guessit/issues.\n" + "====================================================================" % + (__version__, str(string), str(options), traceback.format_exc())) self.string = string self.options = options @@ -113,9 +110,7 @@ def _fix_encoding(cls, value): return [cls._fix_encoding(item) for item in value] if isinstance(value, dict): return {cls._fix_encoding(k): cls._fix_encoding(v) for k, v in value.items()} - if six.PY2 and isinstance(value, six.text_type): - return value.encode('utf-8') - if six.PY3 and isinstance(value, six.binary_type): + if isinstance(value, bytes): return value.decode('ascii') return value @@ -175,16 +170,12 @@ def guessit(self, string, options=None): # pylint: disable=too-many-branches :return: :rtype: """ - try: - from pathlib import Path - if isinstance(string, Path): - try: - # Handle path-like object - string = os.fspath(string) - except AttributeError: - string = str(string) - except ImportError: - pass + if isinstance(string, Path): + try: + # Handle path-like object + string = os.fspath(string) + except AttributeError: + string = str(string) try: options = parse_options(options, True) @@ -194,32 +185,23 @@ def guessit(self, string, options=None): # pylint: disable=too-many-branches result_decode = False result_encode = False - if six.PY2: - if isinstance(string, six.text_type): - string = string.encode("utf-8") - result_decode = True - elif isinstance(string, six.binary_type): - string = six.binary_type(string) - if six.PY3: - if isinstance(string, six.binary_type): - string = string.decode('ascii') - result_encode = True - elif isinstance(string, six.text_type): - string = six.text_type(string) + if isinstance(string, bytes): + string = string.decode('ascii') + result_encode = True matches = self.rebulk.matches(string, options) if result_decode: for match in matches: - if isinstance(match.value, six.binary_type): + if isinstance(match.value, bytes): match.value = match.value.decode("utf-8") if result_encode: for match in matches: - if isinstance(match.value, six.text_type): + if isinstance(match.value, str): match.value = match.value.encode("ascii") return matches.to_dict(options.get('advanced', False), options.get('single_value', False), options.get('enforce_list', False)) - except: - raise GuessitException(string, options) + except Exception as err: + raise GuessitException(string, options) from err def properties(self, options=None): """ @@ -235,8 +217,8 @@ def properties(self, options=None): options = merge_options(config, options) unordered = introspect(self.rebulk, options).properties ordered = OrderedDict() - for k in sorted(unordered.keys(), key=six.text_type): - ordered[k] = list(sorted(unordered[k], key=six.text_type)) + for k in sorted(unordered.keys(), key=str): + ordered[k] = list(sorted(unordered[k], key=str)) if hasattr(self.rebulk, 'customize_properties'): ordered = self.rebulk.customize_properties(ordered) return ordered diff --git a/ext/guessit/backports.py b/ext/guessit/backports.py deleted file mode 100644 index c149a6b5d4..0000000000 --- a/ext/guessit/backports.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -Backports -""" -# pragma: no-cover -# pylint: skip-file - -def cmp_to_key(mycmp): - """functools.cmp_to_key backport""" - class KeyClass(object): - """Key class""" - def __init__(self, obj, *args): # pylint: disable=unused-argument - self.obj = obj - def __lt__(self, other): - return mycmp(self.obj, other.obj) < 0 - def __gt__(self, other): - return mycmp(self.obj, other.obj) > 0 - def __eq__(self, other): - return mycmp(self.obj, other.obj) == 0 - def __le__(self, other): - return mycmp(self.obj, other.obj) <= 0 - def __ge__(self, other): - return mycmp(self.obj, other.obj) >= 0 - def __ne__(self, other): - return mycmp(self.obj, other.obj) != 0 - return KeyClass diff --git a/ext/guessit/monkeypatch.py b/ext/guessit/monkeypatch.py index 33e7c46ee2..14ddf6e89b 100644 --- a/ext/guessit/monkeypatch.py +++ b/ext/guessit/monkeypatch.py @@ -4,10 +4,7 @@ Monkeypatch initialisation functions """ -try: - from collections import OrderedDict -except ImportError: # pragma: no-cover - from ordereddict import OrderedDict # pylint:disable=import-error +from collections import OrderedDict from rebulk.match import Match diff --git a/ext/guessit/options.py b/ext/guessit/options.py index 8fa6825ccb..21654ce702 100644 --- a/ext/guessit/options.py +++ b/ext/guessit/options.py @@ -11,8 +11,6 @@ from argparse import ArgumentParser -import six - def build_argument_parser(): """ @@ -108,7 +106,7 @@ def parse_options(options=None, api=False): :return: :rtype: """ - if isinstance(options, six.string_types): + if isinstance(options, str): args = shlex.split(options) options = vars(argument_parser.parse_args(args)) elif options is None: @@ -153,7 +151,7 @@ def load_config(options): cwd = os.getcwd() yaml_supported = False try: - import yaml # pylint:disable=unused-variable,unused-import + import yaml # pylint:disable=unused-variable,unused-import,import-outside-toplevel yaml_supported = True except ImportError: pass @@ -250,13 +248,13 @@ def load_config_file(filepath): return json.load(config_file_data) if filepath.endswith('.yaml') or filepath.endswith('.yml'): try: - import yaml + import yaml # pylint:disable=import-outside-toplevel with open(filepath) as config_file_data: return yaml.load(config_file_data, yaml.SafeLoader) - except ImportError: # pragma: no cover + except ImportError as err: # pragma: no cover raise ConfigurationException('Configuration file extension is not supported. ' 'PyYAML should be installed to support "%s" file' % ( - filepath,)) + filepath,)) from err try: # Try to load input as JSON diff --git a/ext/guessit/rules/common/__init__.py b/ext/guessit/rules/common/__init__.py index 444dc72a90..24f9433dd4 100644 --- a/ext/guessit/rules/common/__init__.py +++ b/ext/guessit/rules/common/__init__.py @@ -3,7 +3,7 @@ """ Common module """ -import re +from rebulk.remodule import re seps = r' [](){}+*|=-_~#/\\.,;:' # list of tags/words separators seps_no_groups = seps.replace('[](){}', '') diff --git a/ext/guessit/rules/common/comparators.py b/ext/guessit/rules/common/comparators.py index f46f0c1196..2774931443 100644 --- a/ext/guessit/rules/common/comparators.py +++ b/ext/guessit/rules/common/comparators.py @@ -3,10 +3,8 @@ """ Comparators """ -try: - from functools import cmp_to_key -except ImportError: - from ...backports import cmp_to_key + +from functools import cmp_to_key def marker_comparator_predicate(match): @@ -14,10 +12,10 @@ def marker_comparator_predicate(match): Match predicate used in comparator """ return ( - not match.private - and match.name not in ('proper_count', 'title') - and not (match.name == 'container' and 'extension' in match.tags) - and not (match.name == 'other' and match.value == 'Rip') + not match.private + and match.name not in ('proper_count', 'title') + and not (match.name == 'container' and 'extension' in match.tags) + and not (match.name == 'other' and match.value == 'Rip') ) diff --git a/ext/guessit/rules/common/expected.py b/ext/guessit/rules/common/expected.py index eae562a2da..19f2f88745 100644 --- a/ext/guessit/rules/common/expected.py +++ b/ext/guessit/rules/common/expected.py @@ -3,7 +3,7 @@ """ Expected property factory """ -import re +from rebulk.remodule import re from rebulk import Rebulk from rebulk.utils import find_all diff --git a/ext/guessit/rules/common/quantity.py b/ext/guessit/rules/common/quantity.py index bbd41fbb92..8d3f21d4a1 100644 --- a/ext/guessit/rules/common/quantity.py +++ b/ext/guessit/rules/common/quantity.py @@ -3,10 +3,9 @@ """ Quantities: Size """ -import re from abc import abstractmethod -import six +from rebulk.remodule import re from ..common import seps @@ -50,7 +49,7 @@ def __hash__(self): return hash(str(self)) def __eq__(self, other): - if isinstance(other, six.string_types): + if isinstance(other, str): return str(self) == other if not isinstance(other, self.__class__): return NotImplemented diff --git a/ext/guessit/rules/processors.py b/ext/guessit/rules/processors.py index 5b018140c8..069e75d2de 100644 --- a/ext/guessit/rules/processors.py +++ b/ext/guessit/rules/processors.py @@ -6,8 +6,6 @@ from collections import defaultdict import copy -import six - from rebulk import Rebulk, Rule, CustomRule, POST_PROCESS, PRE_PROCESS, AppendMatch, RemoveMatch from .common import seps_no_groups @@ -68,7 +66,7 @@ def when(self, matches, context): for name in matches.names: for hole in list(holes): for current_match in matches.named(name): - if isinstance(current_match.value, six.string_types) and \ + if isinstance(current_match.value, str) and \ hole.value.lower() == current_match.value.lower(): if 'equivalent-ignore' in current_match.tags: continue @@ -96,7 +94,7 @@ class RemoveAmbiguous(Rule): consequence = RemoveMatch def __init__(self, sort_function=marker_sorted, predicate=None): - super(RemoveAmbiguous, self).__init__() + super().__init__() self.sort_function = sort_function self.predicate = predicate @@ -131,7 +129,7 @@ class RemoveLessSpecificSeasonEpisode(RemoveAmbiguous): keep the one tagged as 'SxxExx' or in the rightmost filepart. """ def __init__(self, name): - super(RemoveLessSpecificSeasonEpisode, self).__init__( + super().__init__( sort_function=(lambda markers, matches: marker_sorted(list(reversed(markers)), matches, lambda match: match.name == name and 'SxxExx' in match.tags)), diff --git a/ext/guessit/rules/properties/audio_codec.py b/ext/guessit/rules/properties/audio_codec.py index 815caff995..0aa7d31bce 100644 --- a/ext/guessit/rules/properties/audio_codec.py +++ b/ext/guessit/rules/properties/audio_codec.py @@ -130,7 +130,7 @@ class AudioProfileRule(Rule): consequence = RemoveMatch def __init__(self, codec): - super(AudioProfileRule, self).__init__() + super().__init__() self.codec = codec def enabled(self, context): @@ -166,7 +166,7 @@ class DtsHDRule(AudioProfileRule): """ def __init__(self): - super(DtsHDRule, self).__init__('DTS-HD') + super().__init__('DTS-HD') class DtsRule(AudioProfileRule): @@ -175,7 +175,7 @@ class DtsRule(AudioProfileRule): """ def __init__(self): - super(DtsRule, self).__init__('DTS') + super().__init__('DTS') class AacRule(AudioProfileRule): @@ -184,7 +184,7 @@ class AacRule(AudioProfileRule): """ def __init__(self): - super(AacRule, self).__init__('AAC') + super().__init__('AAC') class DolbyDigitalRule(AudioProfileRule): @@ -193,7 +193,7 @@ class DolbyDigitalRule(AudioProfileRule): """ def __init__(self): - super(DolbyDigitalRule, self).__init__('Dolby Digital') + super().__init__('Dolby Digital') class HqConflictRule(Rule): diff --git a/ext/guessit/rules/properties/bit_rate.py b/ext/guessit/rules/properties/bit_rate.py index d279c9f1cd..640a6a2e4d 100644 --- a/ext/guessit/rules/properties/bit_rate.py +++ b/ext/guessit/rules/properties/bit_rate.py @@ -3,7 +3,7 @@ """ video_bit_rate and audio_bit_rate properties """ -import re +from rebulk.remodule import re from rebulk import Rebulk from rebulk.rules import Rule, RemoveMatch, RenameMatch diff --git a/ext/guessit/rules/properties/episode_title.py b/ext/guessit/rules/properties/episode_title.py index ece8921d21..2c4fab6696 100644 --- a/ext/guessit/rules/properties/episode_title.py +++ b/ext/guessit/rules/properties/episode_title.py @@ -47,7 +47,7 @@ class RemoveConflictsWithEpisodeTitle(Rule): consequence = RemoveMatch def __init__(self, previous_names): - super(RemoveConflictsWithEpisodeTitle, self).__init__() + super().__init__() self.previous_names = previous_names self.next_names = ('streaming_service', 'screen_size', 'source', 'video_codec', 'audio_codec', 'other', 'container') @@ -129,7 +129,7 @@ class EpisodeTitleFromPosition(TitleBaseRule): dependency = TitleToEpisodeTitle def __init__(self, previous_names): - super(EpisodeTitleFromPosition, self).__init__('episode_title', ['title']) + super().__init__('episode_title', ['title']) self.previous_names = previous_names def hole_filter(self, hole, matches): @@ -150,12 +150,12 @@ def filepart_filter(self, filepart, matches): def should_remove(self, match, matches, filepart, hole, context): if match.name == 'episode_details': return False - return super(EpisodeTitleFromPosition, self).should_remove(match, matches, filepart, hole, context) + return super().should_remove(match, matches, filepart, hole, context) def when(self, matches, context): # pylint:disable=inconsistent-return-statements if matches.named('episode_title'): return - return super(EpisodeTitleFromPosition, self).when(matches, context) + return super().when(matches, context) class AlternativeTitleReplace(Rule): @@ -166,7 +166,7 @@ class AlternativeTitleReplace(Rule): consequence = RenameMatch def __init__(self, previous_names): - super(AlternativeTitleReplace, self).__init__() + super().__init__() self.previous_names = previous_names def when(self, matches, context): # pylint:disable=inconsistent-return-statements diff --git a/ext/guessit/rules/properties/episodes.py b/ext/guessit/rules/properties/episodes.py index 345c785deb..7aa2245ae6 100644 --- a/ext/guessit/rules/properties/episodes.py +++ b/ext/guessit/rules/properties/episodes.py @@ -479,7 +479,7 @@ class SeePatternRange(Rule): consequence = [RemoveMatch, AppendMatch] def __init__(self, range_separators): - super(SeePatternRange, self).__init__() + super().__init__() self.range_separators = range_separators def when(self, matches, context): @@ -516,7 +516,7 @@ class AbstractSeparatorRange(Rule): consequence = [RemoveMatch, AppendMatch] def __init__(self, range_separators, property_name): - super(AbstractSeparatorRange, self).__init__() + super().__init__() self.range_separators = range_separators self.property_name = property_name @@ -608,7 +608,7 @@ class EpisodeNumberSeparatorRange(AbstractSeparatorRange): """ def __init__(self, range_separators): - super(EpisodeNumberSeparatorRange, self).__init__(range_separators, "episode") + super().__init__(range_separators, "episode") class SeasonSeparatorRange(AbstractSeparatorRange): @@ -617,7 +617,7 @@ class SeasonSeparatorRange(AbstractSeparatorRange): """ def __init__(self, range_separators): - super(SeasonSeparatorRange, self).__init__(range_separators, "season") + super().__init__(range_separators, "season") class RemoveWeakIfMovie(Rule): @@ -662,7 +662,7 @@ class RemoveWeak(Rule): consequence = RemoveMatch, AppendMatch def __init__(self, episode_words): - super(RemoveWeak, self).__init__() + super().__init__() self.episode_words = episode_words def when(self, matches, context): diff --git a/ext/guessit/rules/properties/language.py b/ext/guessit/rules/properties/language.py index 3f83bc344b..c1f9e6a17b 100644 --- a/ext/guessit/rules/properties/language.py +++ b/ext/guessit/rules/properties/language.py @@ -396,7 +396,7 @@ def when(self, matches, context): def then(self, matches, when_response, context): to_rename, to_remove = when_response - super(SubtitlePrefixLanguageRule, self).then(matches, to_remove, context) + super().then(matches, to_remove, context) for prefix, match in to_rename: # Remove suffix equivalent of prefix. suffix = copy.copy(prefix) @@ -435,7 +435,7 @@ def when(self, matches, context): def then(self, matches, when_response, context): to_rename, to_remove = when_response - super(SubtitleSuffixLanguageRule, self).then(matches, to_remove, context) + super().then(matches, to_remove, context) for match in to_rename: matches.remove(match) match.name = 'subtitle_language' @@ -488,7 +488,7 @@ class RemoveInvalidLanguages(Rule): def __init__(self, common_words): """Constructor.""" - super(RemoveInvalidLanguages, self).__init__() + super().__init__() self.common_words = common_words def when(self, matches, context): diff --git a/ext/guessit/rules/properties/release_group.py b/ext/guessit/rules/properties/release_group.py index ecff808b44..09e845f568 100644 --- a/ext/guessit/rules/properties/release_group.py +++ b/ext/guessit/rules/properties/release_group.py @@ -98,7 +98,7 @@ class DashSeparatedReleaseGroup(Rule): def __init__(self, value_formatter): """Default constructor.""" - super(DashSeparatedReleaseGroup, self).__init__() + super().__init__() self.value_formatter = value_formatter @classmethod @@ -212,7 +212,7 @@ class SceneReleaseGroup(Rule): def __init__(self, value_formatter): """Default constructor.""" - super(SceneReleaseGroup, self).__init__() + super().__init__() self.value_formatter = value_formatter @staticmethod @@ -321,7 +321,6 @@ def when(self, matches, context): for filepart in marker_sorted(matches.markers.named('path'), matches): - # pylint:disable=bad-continuation empty_group = matches.markers.range(filepart.start, filepart.end, lambda marker: (marker.name == 'group' diff --git a/ext/guessit/rules/properties/screen_size.py b/ext/guessit/rules/properties/screen_size.py index 77d5d0521f..966fc3c1df 100644 --- a/ext/guessit/rules/properties/screen_size.py +++ b/ext/guessit/rules/properties/screen_size.py @@ -69,7 +69,7 @@ class PostProcessScreenSize(Rule): consequence = AppendMatch def __init__(self, standard_heights, min_ar, max_ar): - super(PostProcessScreenSize, self).__init__() + super().__init__() self.standard_heights = standard_heights self.min_ar = min_ar self.max_ar = max_ar diff --git a/ext/guessit/rules/properties/size.py b/ext/guessit/rules/properties/size.py index c61580c044..0a09700205 100644 --- a/ext/guessit/rules/properties/size.py +++ b/ext/guessit/rules/properties/size.py @@ -3,7 +3,7 @@ """ size property """ -import re +from rebulk.remodule import re from rebulk import Rebulk diff --git a/ext/guessit/rules/properties/streaming_service.py b/ext/guessit/rules/properties/streaming_service.py index f467f20a6d..cccd16df34 100644 --- a/ext/guessit/rules/properties/streaming_service.py +++ b/ext/guessit/rules/properties/streaming_service.py @@ -3,7 +3,7 @@ """ streaming_service property """ -import re +from rebulk.remodule import re from rebulk import Rebulk from rebulk.rules import Rule, RemoveMatch diff --git a/ext/guessit/rules/properties/title.py b/ext/guessit/rules/properties/title.py index 0d26301670..2a065cb047 100644 --- a/ext/guessit/rules/properties/title.py +++ b/ext/guessit/rules/properties/title.py @@ -53,7 +53,7 @@ class TitleBaseRule(Rule): consequence = [AppendMatch, RemoveMatch] def __init__(self, match_name, match_tags=None, alternative_match_name=None): - super(TitleBaseRule, self).__init__() + super().__init__() self.match_name = match_name self.match_tags = match_tags self.alternative_match_name = alternative_match_name @@ -299,7 +299,7 @@ class TitleFromPosition(TitleBaseRule): properties = {'title': [None], 'alternative_title': [None]} def __init__(self): - super(TitleFromPosition, self).__init__('title', ['title'], 'alternative_title') + super().__init__('title', ['title'], 'alternative_title') def enabled(self, context): return not is_disabled(context, 'alternative_title') diff --git a/ext/guessit/test/test_api.py b/ext/guessit/test/test_api.py index 391dbced87..5422925807 100644 --- a/ext/guessit/test/test_api.py +++ b/ext/guessit/test/test_api.py @@ -3,10 +3,9 @@ # pylint: disable=no-self-use, pointless-statement, missing-docstring, invalid-name, pointless-string-statement import json import os -import sys +from pathlib import Path import pytest -import six from ..api import guessit, properties, suggested_expected, GuessitException @@ -19,25 +18,19 @@ def test_default(): def test_forced_unicode(): - ret = guessit(u'Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') - assert ret and 'title' in ret and isinstance(ret['title'], six.text_type) + ret = guessit('Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') + assert ret and 'title' in ret and isinstance(ret['title'], str) def test_forced_binary(): ret = guessit(b'Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') - assert ret and 'title' in ret and isinstance(ret['title'], six.binary_type) + assert ret and 'title' in ret and isinstance(ret['title'], bytes) -@pytest.mark.skipif(sys.version_info < (3, 4), reason="Path is not available") def test_pathlike_object(): - try: - from pathlib import Path - - path = Path('Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') - ret = guessit(path) - assert ret and 'title' in ret - except ImportError: # pragma: no-cover - pass + path = Path('Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') + ret = guessit(path) + assert ret and 'title' in ret def test_unicode_japanese(): @@ -51,16 +44,8 @@ def test_unicode_japanese_options(): def test_forced_unicode_japanese_options(): - ret = guessit(u"[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": [u"阿维达"]}) - assert ret and 'title' in ret and ret['title'] == u"阿维达" - -# TODO: This doesn't compile on python 3, but should be tested on python 2. -""" -if six.PY2: - def test_forced_binary_japanese_options(): - ret = guessit(b"[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": [b"阿维达"]}) - assert ret and 'title' in ret and ret['title'] == b"阿维达" -""" + ret = guessit("[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": ["阿维达"]}) + assert ret and 'title' in ret and ret['title'] == "阿维达" def test_properties(): diff --git a/ext/guessit/test/test_api_unicode_literals.py b/ext/guessit/test/test_api_unicode_literals.py index 826f7cd163..79bbbca15a 100644 --- a/ext/guessit/test/test_api_unicode_literals.py +++ b/ext/guessit/test/test_api_unicode_literals.py @@ -3,12 +3,9 @@ # pylint: disable=no-self-use, pointless-statement, missing-docstring, invalid-name, pointless-string-statement -from __future__ import unicode_literals - import os import pytest -import six from ..api import guessit, properties, GuessitException @@ -21,13 +18,13 @@ def test_default(): def test_forced_unicode(): - ret = guessit(u'Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') - assert ret and 'title' in ret and isinstance(ret['title'], six.text_type) + ret = guessit('Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') + assert ret and 'title' in ret and isinstance(ret['title'], str) def test_forced_binary(): ret = guessit(b'Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv') - assert ret and 'title' in ret and isinstance(ret['title'], six.binary_type) + assert ret and 'title' in ret and isinstance(ret['title'], bytes) def test_unicode_japanese(): @@ -41,24 +38,18 @@ def test_unicode_japanese_options(): def test_forced_unicode_japanese_options(): - ret = guessit(u"[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": [u"阿维达"]}) - assert ret and 'title' in ret and ret['title'] == u"阿维达" - -# TODO: This doesn't compile on python 3, but should be tested on python 2. -""" -if six.PY2: - def test_forced_binary_japanese_options(): - ret = guessit(b"[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": [b"阿维达"]}) - assert ret and 'title' in ret and ret['title'] == b"阿维达" -""" + ret = guessit("[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi", options={"expected_title": ["阿维达"]}) + assert ret and 'title' in ret and ret['title'] == "阿维达" -def test_ensure_standard_string_class(): +def test_ensure_custom_string_class(): class CustomStr(str): pass - ret = guessit(CustomStr('1080p'), options={'advanced': True}) - assert ret and 'screen_size' in ret and not isinstance(ret['screen_size'].input_string, CustomStr) + ret = guessit(CustomStr('some.title.1080p.mkv'), options={'advanced': True}) + assert ret and 'screen_size' in ret and isinstance(ret['screen_size'].input_string, CustomStr) + assert ret and 'title' in ret and isinstance(ret['title'].input_string, CustomStr) + assert ret and 'container' in ret and isinstance(ret['container'].input_string, CustomStr) def test_properties(): diff --git a/ext/guessit/test/test_main.py b/ext/guessit/test/test_main.py index cbdba7aa4c..974b822db9 100644 --- a/ext/guessit/test/test_main.py +++ b/ext/guessit/test/test_main.py @@ -24,7 +24,7 @@ def test_main_unicode(): def test_main_forced_unicode(): - main([u'Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv']) + main(['Fear.and.Loathing.in.Las.Vegas.FRENCH.ENGLISH.720p.HDDVD.DTS.x264-ESiR.mkv']) def test_main_verbose(): diff --git a/ext/guessit/test/test_yml.py b/ext/guessit/test/test_yml.py index 040796deac..93ea619bc8 100644 --- a/ext/guessit/test/test_yml.py +++ b/ext/guessit/test/test_yml.py @@ -7,7 +7,6 @@ from io import open # pylint: disable=redefined-builtin import babelfish -import six # pylint:disable=wrong-import-order import yaml # pylint:disable=wrong-import-order from rebulk.remodule import re from rebulk.utils import is_iterable @@ -161,7 +160,7 @@ def pytest_generate_tests(self, metafunc): for string, expected in data.items(): TestYml.set_default(expected, default) - string = TestYml.fix_encoding(string, expected) + string = TestYml.fix_encoding(string) entries.append((filename, string, expected)) unique_id = self._get_unique_id(entry_set, '[' + filename + '] ' + str(string)) @@ -178,17 +177,7 @@ def set_default(expected, default): expected[k] = v @classmethod - def fix_encoding(cls, string, expected): - if six.PY2: - if isinstance(string, six.text_type): - string = string.encode('utf-8') - converts = [] - for k, v in expected.items(): - if isinstance(v, six.text_type): - v = v.encode('utf-8') - converts.append((k, v)) - for k, v in converts: - expected[k] = v + def fix_encoding(cls, string): if not isinstance(string, str): string = str(string) return string diff --git a/ext/guessit/yamlutils.py b/ext/guessit/yamlutils.py index d04be641ba..f038a99bc3 100644 --- a/ext/guessit/yamlutils.py +++ b/ext/guessit/yamlutils.py @@ -4,10 +4,7 @@ Options """ -try: - from collections import OrderedDict -except ImportError: # pragma: no-cover - from ordereddict import OrderedDict # pylint:disable=import-error +from collections import OrderedDict import babelfish import yaml # pylint:disable=wrong-import-order @@ -24,8 +21,8 @@ class OrderedDictYAMLLoader(yaml.SafeLoader): def __init__(self, *args, **kwargs): yaml.SafeLoader.__init__(self, *args, **kwargs) - self.add_constructor(u'tag:yaml.org,2002:map', type(self).construct_yaml_map) - self.add_constructor(u'tag:yaml.org,2002:omap', type(self).construct_yaml_map) + self.add_constructor('tag:yaml.org,2002:map', type(self).construct_yaml_map) + self.add_constructor('tag:yaml.org,2002:omap', type(self).construct_yaml_map) def construct_yaml_map(self, node): data = OrderedDict() diff --git a/ext/readme.md b/ext/readme.md index 23ac7a5687..5b36d73039 100644 --- a/ext/readme.md +++ b/ext/readme.md @@ -23,7 +23,7 @@ ext | `dogpile.cache` | [0.9.2](https://pypi.org/project/dogpile.cache/0.9.2/) | ext | **`enzyme`** | pymedusa/[665cf69](https://github.com/pymedusa/enzyme/tree/665cf6948aab1c249dcc99bd9624a81d17b3302a) | `knowit`, `subliminal` | - ext | **`feedparser`** | [6.0.2](https://pypi.org/project/feedparser/6.0.2/) | **`medusa`** | Requires `sgmllib3k` on Python 3 ext | **`gntp`** | [1.0.3](https://pypi.org/project/gntp/1.0.3/) | **`medusa`** | - -ext | **`guessit`** | [3.1.1](https://pypi.org/project/guessit/3.1.1/) | **`medusa`**, `subliminal` | - +ext | **`guessit`** | [3.2.0](https://pypi.org/project/guessit/3.2.0/) | **`medusa`**, `subliminal` | - ext | **`html5lib`** | [1.1](https://pypi.org/project/html5lib/1.1/) | **`medusa`** (via `beautifulsoup4`) | - ext | **`idna`** | [2.8](https://pypi.org/project/idna/2.8/) | `requests` | - ext | **`imdbpie`** | [5.6.4](https://pypi.org/project/imdbpie/5.6.4/) | **`medusa`** | - @@ -46,12 +46,12 @@ ext | **`pytimeparse`** | pymedusa/[8f28325](https://github.com/pymedusa/pytimep ext | **`pytz`** | [2018.4](https://pypi.org/project/pytz/2018.4/) | `subliminal` | - ext | `PyYAML` | [5.3.1](https://pypi.org/project/PyYAML/5.3.1/) | `knowit` | Module: `yaml` ext | `rarfile` | [3.1](https://pypi.org/project/rarfile/3.1/) | **`medusa`**, `subliminal` | File: `rarfile.py` -ext | **`rebulk`** | [2.0.1](https://pypi.org/project/rebulk/2.0.1/) | **`medusa`**, `guessit` | - +ext | **`rebulk`** | [3.0.1](https://pypi.org/project/rebulk/3.0.1/) | **`medusa`**, `guessit` | - ext | **`requests`** | [2.25.1](https://pypi.org/project/requests/2.25.1/) | **`medusa`**, `adba`, `boto`, `CacheControl`, `cloudscraper`, `PyGithub`, `python-twitter`, `pytvmaze`, `requests-oauthlib`, `requests-toolbelt`, `rtorrent-python`, `simpleanidb`, `subliminal`, `tmdbsimple`, `traktor`, `tvdbapiv2` | - ext | `requests-oauthlib` | [1.3.0](https://pypi.org/project/requests-oauthlib/1.3.0/) | **`medusa`**, `python-twitter` | Module: `requests_oauthlib` ext | `requests-toolbelt` | [0.9.1](https://pypi.org/project/requests-toolbelt/0.9.1/) | `cloudscraper` | Module: `requests_toolbelt` **ext3** | `sgmllib3k` | [1.0.0](https://pypi.org/project/sgmllib3k/1.0.0/) | `feedparser` | File: `sgmllib.py` -ext | `six` | [1.15.0](https://pypi.org/project/six/1.15.0/) | **`medusa`**, `adba`, `configobj`, `guessit`, `html5lib`, `imdbpie`, `knowit`, `PyGithub`, `rebulk`, `subliminal`, `tvdbapiv2`, `validators` | File: `six.py` +ext | `six` | [1.15.0](https://pypi.org/project/six/1.15.0/) | **`medusa`**, `adba`, `configobj`, `html5lib`, `imdbpie`, `knowit`, `PyGithub`, `subliminal`, `tvdbapiv2`, `validators` | File: `six.py` ext | **`soupsieve`** | [1.9.6](https://pypi.org/project/soupsieve/1.9.6/) | `beautifulsoup4` | - ext | **`stevedore`** | [1.30.1](https://pypi.org/project/stevedore/1.30.1/) | `subliminal` | - ext | **`subliminal`** | [2.1.0](https://pypi.org/project/subliminal/2.1.0/) | **`medusa`** | - diff --git a/ext/rebulk/__init__.py b/ext/rebulk/__init__.py index 93d5e4774a..360731bc52 100644 --- a/ext/rebulk/__init__.py +++ b/ext/rebulk/__init__.py @@ -7,4 +7,4 @@ from .rebulk import Rebulk from .rules import Rule, CustomRule, AppendMatch, RemoveMatch, RenameMatch, AppendTags, RemoveTags from .processors import ConflictSolver, PrivateRemover, POST_PROCESS, PRE_PROCESS -from .pattern import REGEX_AVAILABLE +from .pattern import REGEX_ENABLED diff --git a/ext/rebulk/__version__.py b/ext/rebulk/__version__.py index 939c554ca5..1312bb6896 100644 --- a/ext/rebulk/__version__.py +++ b/ext/rebulk/__version__.py @@ -4,4 +4,4 @@ Version module """ # pragma: no cover -__version__ = '2.0.1' +__version__ = '3.0.1' diff --git a/ext/rebulk/builder.py b/ext/rebulk/builder.py index c91420aa3a..c0053f2acf 100644 --- a/ext/rebulk/builder.py +++ b/ext/rebulk/builder.py @@ -7,16 +7,13 @@ from copy import deepcopy from logging import getLogger -from six import add_metaclass - from .loose import set_defaults from .pattern import RePattern, StringPattern, FunctionalPattern log = getLogger(__name__).log -@add_metaclass(ABCMeta) -class Builder(object): +class Builder(metaclass=ABCMeta): """ Base builder class for patterns """ @@ -147,7 +144,7 @@ def build_chain(self, **kwargs): :return: :rtype: """ - from .chain import Chain + from .chain import Chain # pylint:disable=import-outside-toplevel set_defaults(self._chain_defaults, kwargs) set_defaults(self._defaults, kwargs) chain = Chain(self, **kwargs) diff --git a/ext/rebulk/chain.py b/ext/rebulk/chain.py index ba31ec9a5f..f2ed66c011 100644 --- a/ext/rebulk/chain.py +++ b/ext/rebulk/chain.py @@ -125,7 +125,7 @@ def _process_match(self, match, match_index, child=False): :rtype: """ # pylint: disable=too-many-locals - ret = super(Chain, self)._process_match(match, match_index, child=child) + ret = super()._process_match(match, match_index, child=child) if ret: return True @@ -144,7 +144,7 @@ def _process_match(self, match, match_index, child=False): for last_match in last_matches: match.children.remove(last_match) match.end = match.children[-1].end if match.children else match.start - ret = super(Chain, self)._process_match(match, match_index, child=child) + ret = super()._process_match(match, match_index, child=child) if ret: return True diff --git a/ext/rebulk/introspector.py b/ext/rebulk/introspector.py index bfefcb7574..f4a4f70a49 100644 --- a/ext/rebulk/introspector.py +++ b/ext/rebulk/introspector.py @@ -6,13 +6,11 @@ from abc import ABCMeta, abstractmethod from collections import defaultdict -import six from .pattern import StringPattern, RePattern, FunctionalPattern from .utils import extend_safe -@six.add_metaclass(ABCMeta) -class Description(object): +class Description(metaclass=ABCMeta): """ Abstract class for a description. """ diff --git a/ext/rebulk/match.py b/ext/rebulk/match.py index d8e72df42e..b3f84c4f45 100644 --- a/ext/rebulk/match.py +++ b/ext/rebulk/match.py @@ -15,7 +15,6 @@ from collections import OrderedDict # pylint:disable=ungrouped-imports except ImportError: # pragma: no cover from ordereddict import OrderedDict # pylint:disable=import-error -import six from .loose import ensure_list, filter_index from .utils import is_iterable @@ -28,7 +27,7 @@ class MatchesDict(OrderedDict): """ def __init__(self): - super(MatchesDict, self).__init__() + super().__init__() self.matches = defaultdict(list) self.values_list = defaultdict(list) @@ -67,7 +66,7 @@ def _name_dict(self): def _start_dict(self): if self.__start_dict is None: self.__start_dict = defaultdict(_BaseMatches._base) - for start, values in itertools.groupby([m for m in self._delegate], lambda item: item.start): + for start, values in itertools.groupby(list(self._delegate), lambda item: item.start): _BaseMatches._base_extend(self.__start_dict[start], values) return self.__start_dict @@ -76,7 +75,7 @@ def _start_dict(self): def _end_dict(self): if self.__end_dict is None: self.__end_dict = defaultdict(_BaseMatches._base) - for start, values in itertools.groupby([m for m in self._delegate], lambda item: item.end): + for start, values in itertools.groupby(list(self._delegate), lambda item: item.end): _BaseMatches._base_extend(self.__end_dict[start], values) return self.__end_dict @@ -534,13 +533,6 @@ def to_dict(self, details=False, first_value=False, enforce_list=False): ret[match.name] = value return ret - if six.PY2: # pragma: no cover - def clear(self): - """ - Python 3 backport - """ - del self[:] - def __len__(self): return len(self._delegate) @@ -583,11 +575,11 @@ class Matches(_BaseMatches): def __init__(self, matches=None, input_string=None): self.markers = Markers(input_string=input_string) - super(Matches, self).__init__(matches=matches, input_string=input_string) + super().__init__(matches=matches, input_string=input_string) def _add_match(self, match): assert not match.marker, "A marker match should not be added to object" - super(Matches, self)._add_match(match) + super()._add_match(match) class Markers(_BaseMatches): @@ -596,11 +588,11 @@ class Markers(_BaseMatches): """ def __init__(self, matches=None, input_string=None): - super(Markers, self).__init__(matches=None, input_string=input_string) + super().__init__(matches=None, input_string=input_string) def _add_match(self, match): assert match.marker, "A non-marker match should not be added to object" - super(Markers, self)._add_match(match) + super()._add_match(match) class Match(object): diff --git a/ext/rebulk/pattern.py b/ext/rebulk/pattern.py index beb8b2731f..890ad4a67f 100644 --- a/ext/rebulk/pattern.py +++ b/ext/rebulk/pattern.py @@ -7,19 +7,16 @@ from abc import ABCMeta, abstractmethod, abstractproperty -import six - from . import debug from .formatters import default_formatter from .loose import call, ensure_list, ensure_dict from .match import Match -from .remodule import re, REGEX_AVAILABLE +from .remodule import re, REGEX_ENABLED from .utils import find_all, is_iterable, get_first_defined from .validators import allways_true -@six.add_metaclass(ABCMeta) -class BasePattern(object): +class BasePattern(metaclass=ABCMeta): """ Base class for Pattern like objects """ @@ -41,8 +38,7 @@ def matches(self, input_string, context=None, with_raw_matches=False): pass -@six.add_metaclass(ABCMeta) -class Pattern(BasePattern): +class Pattern(BasePattern, metaclass=ABCMeta): """ Definition of a particular pattern to search for. """ @@ -396,7 +392,7 @@ class StringPattern(Pattern): """ def __init__(self, *patterns, **kwargs): - super(StringPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self._patterns = patterns self._kwargs = kwargs self._match_kwargs = filter_match_kwargs(kwargs) @@ -422,11 +418,11 @@ class RePattern(Pattern): """ def __init__(self, *patterns, **kwargs): - super(RePattern, self).__init__(**kwargs) - self.repeated_captures = REGEX_AVAILABLE + super().__init__(**kwargs) + self.repeated_captures = REGEX_ENABLED if 'repeated_captures' in kwargs: self.repeated_captures = kwargs.get('repeated_captures') - if self.repeated_captures and not REGEX_AVAILABLE: # pragma: no cover + if self.repeated_captures and not REGEX_ENABLED: # pragma: no cover raise NotImplementedError("repeated_capture is available only with regex module.") self.abbreviations = kwargs.get('abbreviations', []) self._kwargs = kwargs @@ -434,7 +430,7 @@ def __init__(self, *patterns, **kwargs): self._children_match_kwargs = filter_match_kwargs(kwargs, children=True) self._patterns = [] for pattern in patterns: - if isinstance(pattern, six.string_types): + if isinstance(pattern, str): if self.abbreviations and pattern: for key, replacement in self.abbreviations: pattern = pattern.replace(key, replacement) @@ -494,7 +490,7 @@ class FunctionalPattern(Pattern): """ def __init__(self, *patterns, **kwargs): - super(FunctionalPattern, self).__init__(**kwargs) + super().__init__(**kwargs) self._patterns = patterns self._kwargs = kwargs self._match_kwargs = filter_match_kwargs(kwargs) diff --git a/ext/rebulk/rebulk.py b/ext/rebulk/rebulk.py index a6a0fd2fba..972b92abe9 100644 --- a/ext/rebulk/rebulk.py +++ b/ext/rebulk/rebulk.py @@ -53,7 +53,7 @@ def __init__(self, disabled=lambda context: False, default_rules=True): :return: :rtype: """ - super(Rebulk, self).__init__() + super().__init__() if not callable(disabled): self.disabled = lambda context: disabled else: diff --git a/ext/rebulk/remodule.py b/ext/rebulk/remodule.py index d1d68d1946..7bdd42d657 100644 --- a/ext/rebulk/remodule.py +++ b/ext/rebulk/remodule.py @@ -5,13 +5,17 @@ """ # pylint: disable-all import os +import logging -REGEX_AVAILABLE = False -if os.environ.get('REGEX_DISABLED') in ["1", "true", "True", "Y"]: - import re -else: +log = logging.getLogger(__name__).log + +REGEX_ENABLED = False +if os.environ.get('REBULK_REGEX_ENABLED') in ["1", "true", "True", "Y"]: try: import regex as re - REGEX_AVAILABLE = True + REGEX_ENABLED = True except ImportError: + log.warning('regex module is not available. Unset REBULK_REGEX_ENABLED environment variable, or install regex module to enabled it.') import re +else: + import re diff --git a/ext/rebulk/rules.py b/ext/rebulk/rules.py index 2514904f48..264792a650 100644 --- a/ext/rebulk/rules.py +++ b/ext/rebulk/rules.py @@ -8,7 +8,6 @@ from itertools import groupby from logging import getLogger -import six from .utils import is_iterable from .toposort import toposort @@ -18,8 +17,7 @@ log = getLogger(__name__).log -@six.add_metaclass(ABCMeta) -class Consequence(object): +class Consequence(metaclass=ABCMeta): """ Definition of a consequence to apply. """ @@ -40,8 +38,7 @@ def then(self, matches, when_response, context): # pragma: no cover pass -@six.add_metaclass(ABCMeta) -class Condition(object): +class Condition(metaclass=ABCMeta): """ Definition of a condition to check. """ @@ -60,8 +57,7 @@ def when(self, matches, context): # pragma: no cover pass -@six.add_metaclass(ABCMeta) -class CustomRule(Condition, Consequence): +class CustomRule(Condition, Consequence, metaclass=ABCMeta): """ Definition of a rule to apply """ @@ -243,7 +239,7 @@ class Rules(list): """ def __init__(self, *rules): - super(Rules, self).__init__() + super().__init__() self.load(*rules) def load(self, *rules): diff --git a/ext/rebulk/test/test_match.py b/ext/rebulk/test/test_match.py index 8750733a5e..2359149b2f 100644 --- a/ext/rebulk/test/test_match.py +++ b/ext/rebulk/test/test_match.py @@ -3,7 +3,6 @@ # pylint: disable=no-self-use, pointless-statement, missing-docstring, unneeded-not, len-as-condition import pytest -import six from ..match import Match, Matches from ..pattern import StringPattern, RePattern @@ -72,23 +71,18 @@ def test_compare(self): assert match2 > match1 assert match2 >= match1 - if six.PY3: - with pytest.raises(TypeError): - match1 < other + with pytest.raises(TypeError): + match1 < other - with pytest.raises(TypeError): - match1 <= other + with pytest.raises(TypeError): + match1 <= other - with pytest.raises(TypeError): - match1 > other + with pytest.raises(TypeError): + match1 > other + + with pytest.raises(TypeError): + match1 >= other - with pytest.raises(TypeError): - match1 >= other - else: - assert match1 < other - assert match1 <= other - assert not match1 > other - assert not match1 >= other def test_value(self): match1 = Match(1, 3) diff --git a/ext/rebulk/test/test_pattern.py b/ext/rebulk/test/test_pattern.py index beee17042d..b80b034c30 100644 --- a/ext/rebulk/test/test_pattern.py +++ b/ext/rebulk/test/test_pattern.py @@ -1,11 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# pylint: disable=no-self-use, pointless-statement, missing-docstring, unbalanced-tuple-unpacking, len-as-condition +# pylint: disable=no-self-use, pointless-statement, missing-docstring, unbalanced-tuple-unpacking, len-as-condition, no-member import re import pytest -from ..pattern import StringPattern, RePattern, FunctionalPattern, REGEX_AVAILABLE +from ..pattern import StringPattern, RePattern, FunctionalPattern, REGEX_ENABLED from ..match import Match class TestStringPattern(object): @@ -706,7 +706,7 @@ def test_repeated_captures_option(self): assert len(matches) == 1 match = matches[0] - if REGEX_AVAILABLE: + if REGEX_ENABLED: assert len(match.children) == 5 assert [child.value for child in match.children] == ["02", "03", "04", "05", "06"] else: diff --git a/ext/rebulk/toposort.py b/ext/rebulk/toposort.py index 2bcba9ae6b..9f3a7310ce 100644 --- a/ext/rebulk/toposort.py +++ b/ext/rebulk/toposort.py @@ -22,7 +22,7 @@ class CyclicDependency(ValueError): def __init__(self, cyclic): s = 'Cyclic dependencies exist among these items: {0}'.format(', '.join(repr(x) for x in cyclic.items())) - super(CyclicDependency, self).__init__(s) + super().__init__(s) self.cyclic = cyclic diff --git a/requirements.txt b/requirements.txt index 8339a4e881..00aa4d0a2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ dogpile.cache==0.9.2 enzyme @ https://codeload.github.com/pymedusa/enzyme/tar.gz/665cf6948aab1c249dcc99bd9624a81d17b3302a feedparser==6.0.2 gntp==1.0.3 -guessit==3.1.1 +guessit==3.2.0 html5lib==1.1 imdbpie==5.6.4 jsonrpclib-pelix==0.4.2 @@ -27,7 +27,7 @@ python-dateutil==2.8.1 python-twitter==3.5 pytimeparse @ https://codeload.github.com/pymedusa/pytimeparse/tar.gz/8f2832597235c6ec98c44de4dab3274927f67e29 rarfile==3.1 -rebulk==2.0.1 +rebulk==3.0.1 requests==2.25.1 requests-oauthlib==1.3.0 six==1.15.0