<commit_before>import sys
import os.path as osp
from collections import OrderedDict as odict
from . import util

from ruamel import yaml
from ruamel.yaml.comments import CommentedMap as CommentedMap

if yaml.version_info < (0, 15):
    raise Exception("cmany now requires ruamel.yaml>=0.15.0")

# -----------------------------------------------------------------------------
SHARE_DIR = osp.abspath(
    osp.join(
        osp.dirname(osp.dirname(sys.executable)),
        'share', 'c4', 'cmany'
    )
)
CONF_DIR = osp.join(SHARE_DIR, 'conf')
DOC_DIR = osp.join(SHARE_DIR, 'doc')
USER_DIR = osp.expanduser("~/.cmany/")

# maybe cmany is not installed. Then it must be a source distribution.
if not osp.exists(SHARE_DIR):
    SHARE_DIR = osp.abspath(osp.join(osp.dirname(__file__), "../../.."))
    CONF_DIR = osp.join(SHARE_DIR, 'conf')
    DOC_DIR = osp.join(SHARE_DIR, 'doc/_build/text')

assert osp.exists(SHARE_DIR), "cmany: share dir not found: {}".format(SHARE_DIR)
assert osp.exists(CONF_DIR), "cmany: conf dir not found: {}".format(CONF_DIR)
assert osp.exists(DOC_DIR), "cmany: doc dir not found: {}".format(DOC_DIR)
assert osp.exists(USER_DIR), "cmany: user dir not found: {}".format(USER_DIR)

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
class Configs:

    @staticmethod
    def load_seq(file_seq):
        curr = None
        for fn in file_seq:
            if not osp.exists(fn):
                continue
            if curr is None:
                curr = Configs()
                curr.load(fn)
            else:
                tmp = Configs()
                tmp.load(fn)
                curr.merge_from(tmp)
        return curr

    def __init__(self):
        self._load_yml("""\
project: {}
config: {}
flag_aliases: {}
""")

    def _load_yml(self, yml):
        YAML = yaml.YAML()<commit_msg>do not assert that USER_DIR exists; it might not.<commit_after>import sys
import os.path as osp
from collections import OrderedDict as odict
from . import util

from ruamel import yaml
from ruamel.yaml.comments import CommentedMap as CommentedMap

if yaml.version_info < (0, 15):
    raise Exception("cmany now requires ruamel.yaml>=0.15.0")

# -----------------------------------------------------------------------------
SHARE_DIR = osp.abspath(
    osp.join(
        osp.dirname(osp.dirname(sys.executable)),
        'share', 'c4', 'cmany'
    )
)
CONF_DIR = osp.join(SHARE_DIR, 'conf')
DOC_DIR = osp.join(SHARE_DIR, 'doc')
USER_DIR = osp.expanduser("~/.cmany/")

# maybe cmany is not installed. Then it must be a source distribution.
if not osp.exists(SHARE_DIR):
    SHARE_DIR = osp.abspath(osp.join(osp.dirname(__file__), "../../.."))
    CONF_DIR = osp.join(SHARE_DIR, 'conf')
    DOC_DIR = osp.join(SHARE_DIR, 'doc/_build/text')

assert osp.exists(SHARE_DIR), "cmany: share dir not found: {}".format(SHARE_DIR)
assert osp.exists(CONF_DIR), "cmany: conf dir not found: {}".format(CONF_DIR)
assert osp.exists(DOC_DIR), "cmany: doc dir not found: {}".format(DOC_DIR)
# assert osp.exists(USER_DIR), "cmany: user dir not found: {}".format(USER_DIR)

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
class Configs:

    @staticmethod
    def load_seq(file_seq):
        curr = None
        for fn in file_seq:
            if not osp.exists(fn):
                continue
            if curr is None:
                curr = Configs()
                curr.load(fn)
            else:
                tmp = Configs()
                tmp.load(fn)
                curr.merge_from(tmp)
        return curr

    def __init__(self):
        self._load_yml("""\
project: {}
config: {}
flag_aliases: {}
""")

    def _load_yml(self, yml):
        YAML = yaml.YAML()
{'fraction_non_alphanumeric': 0.2646768623581648, 'fraction_numerical': 0.003946719289590528, 'mean_word_length': 1.617817947062621, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6397355', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1197, 'n_words': 295}