mirror of https://github.com/kiwix/libkiwix.git
Using a regular expression with named groups
This commit is contained in:
parent
091786c7d8
commit
1b81ccc5e5
|
@ -44,14 +44,14 @@ def get_resource_revision(res):
|
||||||
resource_revisions[res] = compute_resource_revision(res)
|
resource_revisions[res] = compute_resource_revision(res)
|
||||||
return resource_revisions[res]
|
return resource_revisions[res]
|
||||||
|
|
||||||
RESOURCE_WITH_CACHEID_URL_PATTERN=r'((.*)/skin/([^"?]+))\?KIWIXCACHEID([^"]*)'
|
RESOURCE_WITH_CACHEID_URL_PATTERN=r'(?P<pre>.*/(?P<resource>skin/[^"?]+)\?)KIWIXCACHEID(?P<post>[^"]*)'
|
||||||
|
|
||||||
def set_cacheid(resource_matchobj):
|
def set_cacheid(resource_matchobj):
|
||||||
path = resource_matchobj.group(1)
|
pre = resource_matchobj.group('pre')
|
||||||
resource = 'skin/' + resource_matchobj.group(3)
|
resource = resource_matchobj.group('resource')
|
||||||
extra_query = resource_matchobj.group(4)
|
post = resource_matchobj.group('post')
|
||||||
cacheid = 'cacheid=' + get_resource_revision(resource)
|
cacheid = 'cacheid=' + get_resource_revision(resource)
|
||||||
return path + '?' + cacheid + extra_query
|
return pre + cacheid + post
|
||||||
|
|
||||||
def preprocess_text(s):
|
def preprocess_text(s):
|
||||||
if 'KIWIXCACHEID' in s:
|
if 'KIWIXCACHEID' in s:
|
||||||
|
|
Loading…
Reference in New Issue