KoD 1.0
- completato il supporto ai torrent e aggiunto ilcorsaronero.xyz - aggiunto supporto agli episodi locali, ovvero poter inserire nella libreria di kodi un misto tra puntate di kod e file scaricati altrove - le viste ora si salvano di nuovo dal menu laterale, ma rimangono salvate per il tipo di contenuto visualizzato e non per il singolo menu - ripensato il menu rapido, che ora è più rapido, ridisegnate alcune finestre
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Expected property factory
|
||||
"""
|
||||
import re
|
||||
|
||||
from rebulk import Rebulk
|
||||
from rebulk.utils import find_all
|
||||
|
||||
from . import dash, seps
|
||||
|
||||
|
||||
def build_expected_function(context_key):
|
||||
"""
|
||||
Creates a expected property function
|
||||
:param context_key:
|
||||
:type context_key:
|
||||
:param cleanup:
|
||||
:type cleanup:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
def expected(input_string, context):
|
||||
"""
|
||||
Expected property functional pattern.
|
||||
:param input_string:
|
||||
:type input_string:
|
||||
:param context:
|
||||
:type context:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
ret = []
|
||||
for search in context.get(context_key):
|
||||
if search.startswith('re:'):
|
||||
search = search[3:]
|
||||
search = search.replace(' ', '-')
|
||||
matches = Rebulk().regex(search, abbreviations=[dash], flags=re.IGNORECASE) \
|
||||
.matches(input_string, context)
|
||||
for match in matches:
|
||||
ret.append(match.span)
|
||||
else:
|
||||
value = search
|
||||
for sep in seps:
|
||||
input_string = input_string.replace(sep, ' ')
|
||||
search = search.replace(sep, ' ')
|
||||
for start in find_all(input_string, search, ignore_case=True):
|
||||
ret.append({'start': start, 'end': start + len(search), 'value': value})
|
||||
return ret
|
||||
|
||||
return expected
|
||||
Reference in New Issue
Block a user