<commit_before>"""Read files that bash will source

bash's `source` builtin will parse out aliases / functions from source files
    and allow their use as commands in the shell

This module provides a source() method to recognise aliases / functions
    and tag them for later use
"""

import yaml
from os import path

_file = '.'.join((path.splitext(__file__)[0], 'yaml'))  # static to importers

optional = False  # volatile to importers

def load():
    """Provide the data from a yaml file"""
    try:
        with open(_file) as stream:
            return yaml.safe_load(stream)
    except:
        if optional:
            return []
        raise


_sources = load()


def save():
    try:<commit_msg>add optional arg to whyp.sources.load()<commit_after>"""Read files that bash will source

bash's `source` builtin will parse out aliases / functions from source files
    and allow their use as commands in the shell

This module provides a source() method to recognise aliases / functions
    and tag them for later use
"""

import yaml
from os import path

_file = '.'.join((path.splitext(__file__)[0], 'yaml'))  # static to importers

optional = False  # volatile to importers

def load(optional):
    """Provide the data from a yaml file"""
    if not path.isfile(_file):
        return optional and [] or False
    try:
        with open(_file) as stream:
            return yaml.safe_load(stream)
    except FileNotFoundError:
        if optional:
            return []
        raise


_sources = load(True)


def save():
    try:
{'fraction_non_alphanumeric': 0.0881399870382372, 'fraction_numerical': 0.0012961762799740765, 'mean_word_length': 2.898989898989899, 'pattern_counts': {'":': 0, '<': 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': '570822', 'n_tokens_mistral': 447, 'n_tokens_neox': 424, 'n_words': 182}