Browse Source

Interprétation des regexp en fonction de la locale

pull/54/head
Louis 10 years ago
parent
commit
13e81f1ed2
  1. 4
      patacrep/authors.py
  2. 7
      patacrep/index.py
  3. 2
      patacrep/songs.py

4
patacrep/authors.py

@ -23,11 +23,11 @@ def compile_authwords(authwords):
# Compilation
authwords['after'] = [
re.compile(r"^.*%s\b(.*)" % word)
re.compile(r"^.*\b%s\b(.*)$" % word, re.LOCALE)
for word in authwords['after']
]
authwords['sep'] = [
re.compile(r"^(.*)%s (.*)$" % word)
re.compile(r"^(.*)%s +(.*)$" % word, re.LOCALE)
for word in ([" %s" % word for word in authwords['sep']] + [','])
]

7
patacrep/index.py

@ -19,8 +19,8 @@ from patacrep.plastex import simpleparse
EOL = u"\n"
# Pattern set to ignore latex command in title prefix
KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$")
FIRST_LETTER_PATTERN = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)")
KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$", re.LOCALE)
FIRST_LETTER_PATTERN = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)", re.LOCALE)
def sortkey(value):
@ -98,7 +98,8 @@ class Index(object):
if 'prefix' in self.keywords:
for prefix in self.keywords['prefix']:
self.prefix_patterns.append(re.compile(
r"^({prefix})(\b|\\)(\s*.*)$".format(prefix=prefix)
r"^({prefix})(\b|\\)(\s*.*)$".format(prefix=prefix),
re.LOCALE
))
if self.indextype == "AUTHOR":

2
patacrep/songs.py

@ -43,7 +43,7 @@ def unprefixed_title(title, prefixes):
"""Remove the first prefix of the list in the beginning of title (if any).
"""
for prefix in prefixes:
match = re.compile(r"^(%s)\b\s*(.*)$" % prefix).match(title)
match = re.compile(r"^(%s)\b\s*(.*)$" % prefix, re.LOCALE).match(title)
if match:
return match.group(2)
return title

Loading…
Cancel
Save