# Path: munin/session.py
# def get_cache_path(extra_name=None):
#     """Tries to find out the XDG caching path of your system.
# 
#     This is done preferrably with PyXDG. If it's not installed,
#     we try the XDG_CACHE_HOME environment variable or default to ~/.cache/
# 
#     If the path does not exist yet it will be created for you.
# 
#     :param extra_name: Extra path component to append to the path (or None).
#     :returns: The full path, e.g.: /home/user/.cache/libmunin/<extra_name>
#     """
#     if HAS_XDG and 0:
#         base_dir = BaseDirectory.xdg_cache_home
#     else:
#         base_dir = os.environ.get('XDG_CACHE_HOME')
#         if base_dir is None:
#             base_dir = os.path.join(os.path.expanduser('~'), '.cache')
# 
#     base_dir = os.path.join(base_dir, 'libmunin')
#     check_or_mkdir(base_dir)
#     return base_dir if not extra_name else os.path.join(base_dir, extra_name)


import os
import re
import pickle
import json
from urllib.request import urlopen
from urllib.parse import urlencode
from munin.session import get_cache_path
        # Pickle the list if desired:
        if dump_path is not None:
            with open(dump_path, 'wb') as handle:
                pickle.dump(genres, handle)

        return genres


def load_genrelist():
    """Load a genre list from both wikipedia and echonest (merge them).

    If there's a 'genre.list' file in the same directory as this script
    it gets loaded, otherwise a live search is performed and the result
    gets written to 'genre.list'.
    """
    relative_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        'genre.list'
    )

    try:
        with open(relative_path, 'r') as handle:
            genres = []
            for genre in handle:
                genres.append(genre.strip())
            return genres
    except OSError:
        pass

    wiki_genres = load_genrelist_from_wikipedia(

# Path: munin/session.py
# def get_cache_path(extra_name=None):
#     """Tries to find out the XDG caching path of your system.
# 
#     This is done preferrably with PyXDG. If it's not installed,
#     we try the XDG_CACHE_HOME environment variable or default to ~/.cache/
# 
#     If the path does not exist yet it will be created for you.
# 
#     :param extra_name: Extra path component to append to the path (or None).
#     :returns: The full path, e.g.: /home/user/.cache/libmunin/<extra_name>
#     """
#     if HAS_XDG and 0:
#         base_dir = BaseDirectory.xdg_cache_home
#     else:
#         base_dir = os.environ.get('XDG_CACHE_HOME')
#         if base_dir is None:
#             base_dir = os.path.join(os.path.expanduser('~'), '.cache')
# 
#     base_dir = os.path.join(base_dir, 'libmunin')
#     check_or_mkdir(base_dir)
#     return base_dir if not extra_name else os.path.join(base_dir, extra_name)


# Path: munin/provider/generate_genre_list.py
import os
import re
import pickle
import json
from urllib.request import urlopen
from urllib.parse import urlencode
from munin.session import get_cache_path

        # Pickle the list if desired:
        if dump_path is not None:
            with open(dump_path, 'wb') as handle:
                pickle.dump(genres, handle)

        return genres


def load_genrelist():
    """Load a genre list from both wikipedia and echonest (merge them).

    If there's a 'genre.list' file in the same directory as this script
    it gets loaded, otherwise a live search is performed and the result
    gets written to 'genre.list'.
    """
    relative_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        'genre.list'
    )

    try:
        with open(relative_path, 'r') as handle:
            genres = []
            for genre in handle:
                genres.append(genre.strip())
            return genres
    except OSError:
        pass

    wiki_genres = load_genrelist_from_wikipedia(

        get_cache_path('genre_list_wikipedia.dump')