summaryrefslogtreecommitdiff
path: root/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/helpers.py b/helpers.py
index 162d39e..87ed9c1 100644
--- a/helpers.py
+++ b/helpers.py
@@ -1,5 +1,7 @@
+from contextlib import contextmanager
from dataclasses import dataclass
from datetime import datetime
+import locale
from operator import attrgetter
from os import path
from pathlib import Path
@@ -21,6 +23,16 @@ def relative_path(*, to, ref):
return path.relpath(to, Path(ref).parent)
+@contextmanager
+def tmplocale(lang):
+ old_lang, encoding = locale.getlocale()
+ try:
+ locale.setlocale(locale.LC_TIME, (lang, encoding))
+ yield
+ finally:
+ locale.setlocale(locale.LC_TIME, (old_lang, encoding))
+
+
_LICENSE_URLS = {
'CC0': 'https://creativecommons.org/publicdomain/zero',
'CC BY': 'https://creativecommons.org/licenses/by',