Package: pyxdg / 0.27-2

add-an-xdg-5-compatibility-layer.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Tue, 12 Jan 2021 14:55:49 +0100
Subject: Add an xdg 5 compatibility layer

---
 xdg/__init__.py | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/xdg/__init__.py b/xdg/__init__.py
index 725eb50..e378678 100644
--- a/xdg/__init__.py
+++ b/xdg/__init__.py
@@ -1,3 +1,39 @@
 __all__ = [ "BaseDirectory", "DesktopEntry", "Menu", "Exceptions", "IniFile", "IconTheme", "Locale", "Config", "Mime", "RecentFiles", "MenuEditor" ]
 
 __version__ = "0.27"
+
+# Compatibility with xdg 5
+
+from pathlib import Path
+from typing import Optional, List
+import os
+
+from . import BaseDirectory
+
+def xdg_cache_home() -> Path:
+    return Path(BaseDirectory.xdg_cache_home)
+
+def xdg_config_dirs() -> List[Path]:
+    return [Path(path) for path in BaseDirectory.xdg_config_dirs]
+
+def xdg_config_home() -> Path:
+    return Path(BaseDirectory.xdg_config_home)
+
+def xdg_data_dirs() -> List[Path]:
+    return [Path(path) for path in BaseDirectory.xdg_data_dirs]
+
+def xdg_data_home() -> Path:
+    return Path(BaseDirectory.xdg_data_home)
+
+def xdg_runtime_dir() -> Optional[Path]:
+    try:
+        return Path(os.environ['XDG_RUNTIME_DIR'])
+    except KeyError:
+        return None
+
+XDG_CACHE_HOME = xdg_cache_home()
+XDG_CONFIG_DIRS = xdg_config_dirs()
+XDG_CONFIG_HOME = xdg_config_home()
+XDG_DATA_DIRS = xdg_data_dirs()
+XDG_DATA_HOME = xdg_data_home()
+XDG_RUNTIME_DIR = xdg_runtime_dir()