mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
Update vendored guessit to 3.1.1
Updates python-dateutil to 2.8.2 Updates rebulk to 2.0.1
This commit is contained in:
parent
ebc9718117
commit
2226a74ef8
66 changed files with 2995 additions and 1306 deletions
|
@ -2,11 +2,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=no-self-use, pointless-statement, missing-docstring, no-member, len-as-condition
|
||||
import re
|
||||
|
||||
from functools import partial
|
||||
|
||||
from rebulk.pattern import FunctionalPattern, StringPattern, RePattern
|
||||
from ..rebulk import Rebulk
|
||||
from ..validators import chars_surround
|
||||
from ..rebulk import Rebulk, FunctionalPattern, RePattern, StringPattern
|
||||
|
||||
|
||||
def test_chain_close():
|
||||
|
@ -63,18 +63,61 @@ def test_build_chain():
|
|||
|
||||
def test_chain_defaults():
|
||||
rebulk = Rebulk()
|
||||
rebulk.defaults(validator=lambda x: True, ignore_names=['testIgnore'], children=True)
|
||||
rebulk.defaults(validator=lambda x: x.value.startswith('t'), ignore_names=['testIgnore'], children=True)
|
||||
|
||||
rebulk.chain()\
|
||||
rebulk.chain() \
|
||||
.regex("(?P<test>test)") \
|
||||
.regex(" ").repeater("*") \
|
||||
.regex("(?P<best>best)") \
|
||||
.regex(" ").repeater("*") \
|
||||
.regex("(?P<testIgnore>testIgnore)")
|
||||
matches = rebulk.matches("test testIgnore")
|
||||
matches = rebulk.matches("test best testIgnore")
|
||||
|
||||
assert len(matches) == 1
|
||||
assert matches[0].name == "test"
|
||||
|
||||
|
||||
def test_chain_with_validators():
|
||||
def chain_validator(match):
|
||||
return match.value.startswith('t') and match.value.endswith('t')
|
||||
|
||||
def default_validator(match):
|
||||
return match.value.startswith('t') and match.value.endswith('g')
|
||||
|
||||
def custom_validator(match):
|
||||
return match.value.startswith('b') and match.value.endswith('t')
|
||||
|
||||
rebulk = Rebulk()
|
||||
rebulk.defaults(children=True, validator=default_validator)
|
||||
|
||||
rebulk.chain(validate_all=True, validator={'__parent__': chain_validator}) \
|
||||
.regex("(?P<test>testing)", validator=default_validator).repeater("+") \
|
||||
.regex(" ").repeater("+") \
|
||||
.regex("(?P<best>best)", validator=custom_validator).repeater("+")
|
||||
matches = rebulk.matches("some testing best end")
|
||||
|
||||
assert len(matches) == 2
|
||||
assert matches[0].name == "test"
|
||||
assert matches[1].name == "best"
|
||||
|
||||
|
||||
def test_matches_docs():
|
||||
rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE) \
|
||||
.defaults(children=True, formatter={'episode': int, 'version': int}) \
|
||||
.chain() \
|
||||
.regex(r'e(?P<episode>\d{1,4})').repeater(1) \
|
||||
.regex(r'v(?P<version>\d+)').repeater('?') \
|
||||
.regex(r'[ex-](?P<episode>\d{1,4})').repeater('*') \
|
||||
.close() # .repeater(1) could be omitted as it's the default behavior
|
||||
|
||||
result = rebulk.matches("This is E14v2-15-16-17").to_dict() # converts matches to dict
|
||||
|
||||
assert 'episode' in result
|
||||
assert result['episode'] == [14, 15, 16, 17]
|
||||
assert 'version' in result
|
||||
assert result['version'] == 2
|
||||
|
||||
|
||||
def test_matches():
|
||||
rebulk = Rebulk()
|
||||
|
||||
|
@ -144,8 +187,8 @@ def test_matches():
|
|||
def test_matches_2():
|
||||
rebulk = Rebulk() \
|
||||
.regex_defaults(flags=re.IGNORECASE) \
|
||||
.chain(children=True, formatter={'episode': int}) \
|
||||
.defaults(formatter={'version': int}) \
|
||||
.defaults(children=True, formatter={'episode': int, 'version': int}) \
|
||||
.chain() \
|
||||
.regex(r'e(?P<episode>\d{1,4})') \
|
||||
.regex(r'v(?P<version>\d+)').repeater('?') \
|
||||
.regex(r'[ex-](?P<episode>\d{1,4})').repeater('*') \
|
||||
|
@ -173,25 +216,32 @@ def test_matches_2():
|
|||
def test_matches_3():
|
||||
alt_dash = (r'@', r'[\W_]') # abbreviation
|
||||
|
||||
rebulk = Rebulk()
|
||||
match_names = ['season', 'episode']
|
||||
other_names = ['screen_size', 'video_codec', 'audio_codec', 'audio_channels', 'container', 'date']
|
||||
|
||||
rebulk.chain(formatter={'season': int, 'episode': int},
|
||||
tags=['SxxExx'],
|
||||
abbreviations=[alt_dash],
|
||||
private_names=['episodeSeparator', 'seasonSeparator'],
|
||||
children=True,
|
||||
private_parent=True,
|
||||
conflict_solver=lambda match, other: match
|
||||
if match.name in ['season', 'episode'] and other.name in
|
||||
['screen_size', 'video_codec', 'audio_codec',
|
||||
'audio_channels', 'container', 'date']
|
||||
else '__default__') \
|
||||
rebulk = Rebulk()
|
||||
rebulk.defaults(formatter={'season': int, 'episode': int},
|
||||
tags=['SxxExx'],
|
||||
abbreviations=[alt_dash],
|
||||
private_names=['episodeSeparator', 'seasonSeparator'],
|
||||
children=True,
|
||||
private_parent=True,
|
||||
conflict_solver=lambda match, other: match
|
||||
if match.name in match_names and other.name in other_names
|
||||
else '__default__')
|
||||
|
||||
rebulk.chain() \
|
||||
.defaults(children=True, private_parent=True) \
|
||||
.regex(r'(?P<season>\d+)@?x@?(?P<episode>\d+)') \
|
||||
.regex(r'(?P<episodeSeparator>x|-|\+|&)(?P<episode>\d+)').repeater('*') \
|
||||
.close() \
|
||||
.chain() \
|
||||
.defaults(children=True, private_parent=True) \
|
||||
.regex(r'S(?P<season>\d+)@?(?:xE|Ex|E|x)@?(?P<episode>\d+)') \
|
||||
.regex(r'(?:(?P<episodeSeparator>xE|Ex|E|x|-|\+|&)(?P<episode>\d+))').repeater('*') \
|
||||
.close() \
|
||||
.chain() \
|
||||
.defaults(children=True, private_parent=True) \
|
||||
.regex(r'S(?P<season>\d+)') \
|
||||
.regex(r'(?P<seasonSeparator>S|-|\+|&)(?P<season>\d+)').repeater('*')
|
||||
|
||||
|
@ -240,11 +290,11 @@ def test_matches_4():
|
|||
|
||||
rebulk = Rebulk()
|
||||
rebulk.regex_defaults(flags=re.IGNORECASE)
|
||||
rebulk.defaults(private_names=['episodeSeparator', 'seasonSeparator'], validate_all=True,
|
||||
validator={'__parent__': seps_surround}, children=True, private_parent=True)
|
||||
rebulk.defaults(validate_all=True, children=True)
|
||||
rebulk.defaults(private_names=['episodeSeparator', 'seasonSeparator'], private_parent=True)
|
||||
|
||||
rebulk.chain(formatter={'episode': int, 'version': int}) \
|
||||
.defaults(validator=None) \
|
||||
rebulk.chain(validator={'__parent__': seps_surround}, formatter={'episode': int, 'version': int}) \
|
||||
.defaults(formatter={'episode': int, 'version': int}) \
|
||||
.regex(r'e(?P<episode>\d{1,4})') \
|
||||
.regex(r'v(?P<version>\d+)').repeater('?') \
|
||||
.regex(r'(?P<episodeSeparator>e|x|-)(?P<episode>\d{1,4})').repeater('*')
|
||||
|
@ -262,11 +312,11 @@ def test_matches_5():
|
|||
|
||||
rebulk = Rebulk()
|
||||
rebulk.regex_defaults(flags=re.IGNORECASE)
|
||||
rebulk.defaults(private_names=['episodeSeparator', 'seasonSeparator'], validate_all=True,
|
||||
validator={'__parent__': seps_surround}, children=True, private_parent=True)
|
||||
|
||||
rebulk.chain(formatter={'episode': int, 'version': int}) \
|
||||
.defaults(validator=None) \
|
||||
rebulk.chain(private_names=['episodeSeparator', 'seasonSeparator'], validate_all=True,
|
||||
validator={'__parent__': seps_surround}, children=True, private_parent=True,
|
||||
formatter={'episode': int, 'version': int}) \
|
||||
.defaults(children=True, private_parent=True) \
|
||||
.regex(r'e(?P<episode>\d{1,4})') \
|
||||
.regex(r'v(?P<version>\d+)').repeater('?') \
|
||||
.regex(r'(?P<episodeSeparator>e|x|-)(?P<episode>\d{1,4})').repeater('{2,3}')
|
||||
|
@ -288,7 +338,7 @@ def test_matches_6():
|
|||
validator=None, children=True, private_parent=True)
|
||||
|
||||
rebulk.chain(formatter={'episode': int, 'version': int}) \
|
||||
.defaults(validator=None) \
|
||||
.defaults(children=True, private_parent=True) \
|
||||
.regex(r'e(?P<episode>\d{1,4})') \
|
||||
.regex(r'v(?P<version>\d+)').repeater('?') \
|
||||
.regex(r'(?P<episodeSeparator>e|x|-)(?P<episode>\d{1,4})').repeater('{2,3}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue