python-platformdirs: Add new package

This also includes a test.sh script for the packages feed CI.

From the README:

When writing desktop application, finding the right location to store
user data and configuration varies per platform. Even for
single-platform apps, there may by plenty of nuances in figuring out the
right location.

This kind of thing is what the platformdirs package is for.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
Jeffery To
2023-12-04 14:05:55 +08:00
committed by Tianling Shen
parent a2c057312f
commit 5e1b12e55e
2 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#!/bin/sh
[ "$1" = python3-platformdirs ] || exit 0
python3 - << 'EOF'
from platformdirs import *
appname = "SuperApp"
appauthor = "Acme"
assert user_data_dir(appname, appauthor) == '/root/.local/share/SuperApp'
assert user_cache_dir(appname, appauthor) == '/root/.cache/SuperApp'
assert user_log_dir(appname, appauthor) == '/root/.local/state/SuperApp/log'
assert user_config_dir(appname) == '/root/.config/SuperApp'
assert user_documents_dir() == '/root/Documents'
assert user_downloads_dir() == '/root/Downloads'
assert user_pictures_dir() == '/root/Pictures'
assert user_videos_dir() == '/root/Videos'
assert user_music_dir() == '/root/Music'
assert user_desktop_dir() == '/root/Desktop'
assert user_runtime_dir(appname, appauthor) == '/run/user/0/SuperApp'
assert site_data_dir(appname, appauthor) == '/usr/local/share/SuperApp'
assert site_data_dir(appname, appauthor, multipath=True) == '/usr/local/share/SuperApp:/usr/share/SuperApp'
assert site_config_dir(appname) == '/etc/xdg/SuperApp'
import os
os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
assert site_config_dir(appname, multipath=True) == '/etc/SuperApp:/usr/local/etc/SuperApp'
EOF