mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Address review comments by @danielquinn
This commit is contained in:
parent
f0320fb72d
commit
3b88d6722a
@ -484,11 +484,15 @@ class FileInfo:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
filename = os.path.basename(path)
|
filename = os.path.basename(path)
|
||||||
|
|
||||||
|
# Mutate filename in-place before parsing its components
|
||||||
|
# by applying at most one of the configured transformations.
|
||||||
for (pattern, repl) in settings.FILENAME_PARSE_TRANSFORMS:
|
for (pattern, repl) in settings.FILENAME_PARSE_TRANSFORMS:
|
||||||
(filename, count) = pattern.subn(repl, filename)
|
(filename, count) = pattern.subn(repl, filename)
|
||||||
if count:
|
if count:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Parse filename components.
|
||||||
for regex in cls.REGEXES.values():
|
for regex in cls.REGEXES.values():
|
||||||
m = regex.match(filename)
|
m = regex.match(filename)
|
||||||
if m:
|
if m:
|
||||||
|
@ -321,12 +321,8 @@ FILENAME_DATE_ORDER = os.getenv("PAPERLESS_FILENAME_DATE_ORDER")
|
|||||||
|
|
||||||
# Transformations applied before filename parsing
|
# Transformations applied before filename parsing
|
||||||
FILENAME_PARSE_TRANSFORMS = []
|
FILENAME_PARSE_TRANSFORMS = []
|
||||||
_filename_parse_transforms = os.getenv("PAPERLESS_FILENAME_PARSE_TRANSFORMS")
|
for t in json.loads(os.getenv("PAPERLESS_FILENAME_PARSE_TRANSFORMS", "[]")):
|
||||||
if _filename_parse_transforms:
|
FILENAME_PARSE_TRANSFORMS.append((re.compile(t["pattern"]), t["repl"]))
|
||||||
FILENAME_PARSE_TRANSFORMS = [(
|
|
||||||
re.compile(t["pattern"]), t["repl"])
|
|
||||||
for t in json.loads(_filename_parse_transforms)
|
|
||||||
]
|
|
||||||
|
|
||||||
# Specify for how many years a correspondent is considered recent. Recent
|
# Specify for how many years a correspondent is considered recent. Recent
|
||||||
# correspondents will be shown in a separate "Recent correspondents" filter as
|
# correspondents will be shown in a separate "Recent correspondents" filter as
|
||||||
|
Loading…
x
Reference in New Issue
Block a user