<commit_before>import os
import io
import json
import logging
import copy
import glob

import core.event
import util.algorithm
import util.xresources

log = logging.getLogger(__name__)

THEME_BASE_DIR = os.path.dirname(os.path.realpath(__file__))
PATHS = [
    ".",
    os.path.join(THEME_BASE_DIR, "../../themes"),
    os.path.expanduser("~/.config/bumblebee-status/themes"),
    os.path.expanduser("~/.local/share/bumblebee-status/themes"),  # PIP
    "/usr/share/bumblebee-status/themes",
]


def themes():
    themes_dict = {}

    for path in PATHS:
        for filename in glob.iglob("{}/*.json".format(path)):
            if "test" not in filename:
                themes_dict[os.path.basename(filename).replace(".json", "")] = 1
    result = list(themes_dict.keys())
    result.sort()
    return result
<commit_msg>[core/theme] add support for XDG_DATA_DIRS<commit_after>import os
import io
import json
import logging
import copy
import glob

import core.event
import util.algorithm
import util.xresources

log = logging.getLogger(__name__)

THEME_BASE_DIR = os.path.dirname(os.path.realpath(__file__))
PATHS = [
    ".",
    os.path.join(THEME_BASE_DIR, "../../themes")
]

if os.environ.get("XDG_DATA_DIRS"):
    PATHS.extend([
        os.path.join(p, "bumblebee-status/themes") for p in os.environ["XDG_DATA_DIRS"].split(":")
    ])

PATHS.extend([
    os.path.expanduser("~/.config/bumblebee-status/themes"),
    os.path.expanduser("~/.local/share/bumblebee-status/themes"),  # PIP
    "/usr/share/bumblebee-status/themes",
])


def themes():
    themes_dict = {}

    for path in PATHS:
        for filename in glob.iglob("{}/*.json".format(path)):
            if "test" not in filename:
                themes_dict[os.path.basename(filename).replace(".json", "")] = 1
    result = list(themes_dict.keys())
    result.sort()
    return result

{'fraction_non_alphanumeric': 0.15579514824797844, 'fraction_numerical': 0.001078167115902965, 'mean_word_length': 3.2764976958525347, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1530156', 'n_tokens_mistral': 646, 'n_tokens_neox': 620, 'n_words': 118}