def _load_lib(self):
        """
        Load library files as modules and save each of them as attributes
        """
        lib_path = os.path.join(_STASH_ROOT, 'lib')
        os.environ['STASH_ROOT'] = _STASH_ROOT  # libcompleter needs this value
        try:
            for f in os.listdir(lib_path):
                fp = os.path.join(lib_path, f)
                if f.startswith('lib') and f.endswith('.py') and os.path.isfile(fp):
                    name, _ = os.path.splitext(f)
                    if self.runtime.debug:
                        self.logger.debug("Attempting to load library '{}'...".format(name))
                    try:
                        self.__dict__[name] = pyimp.load_source(name, fp)
                    except Exception as e:
                        self.write_message('%s: failed to load library file (%s)' % (f, repr(e)), error=True)
        finally:  # do not modify environ permanently
            os.environ.pop('STASH_ROOT')

        Load library files as modules and save each of them as attributes
        
core.py