"""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:
        with open(_file, 'w') as stream:
            yaml.safe_dump(_sources, stream)
        return True
    except:
        return optional


def clear():
    global _sources
    _sources = []
    return save() or optional


def source(path_to_file):
    if path.isfile(path_to_file):
        _sources.append(path_to_file)
        save()
        return True
    return optional


def any():
    return bool(_sources) or optional

def all():
    return _sources or ([] if optional else None)


@@ -429,19 +429,27 @@
 ef load(
+optional
 ):%0A
-
     %22%22%22P
@@ -484,16 +484,87 @@
 file%22%22%22%0A
+    if not path.isfile(_file):%0A        return optional and %5B%5D or False%0A
     try:
@@ -644,32 +644,50 @@
 ream)%0A    except
+ FileNotFoundError
 :%0A        if opt
@@ -731,16 +731,16 @@
 raise%0A%0A%0A
-
 _sources
@@ -747,16 +747,20 @@
  = load(
+True
 )%0A%0A%0Adef 

add optional arg to whyp.sources.load()