Beispiel #1
0
def config_named(name):
    if not os.path.isfile(name): # If we cannot find this file easily, try searching the config_path:
        config_paths = config.value_for_key_path('config_path', ['.'])
        if issubclass(type(config_paths), str):
            config_paths = [config_paths]
        found_path = util.find_file_in_path(name, config_paths)
        if found_path:
            name = found_path
        else:
            return None
    return yaml.load(open(name, 'r'))
def config_named(name):
	if not os.path.isfile(name): # If we cannot find this file easily, try searching the config_path:
		config_paths = config.value_for_key_path('config_path', ['.'])
		if issubclass(type(config_paths), str):
			config_paths = [config_paths]
		found_path = util.find_file_in_path(name, config_paths)
		if found_path:
			name = found_path
		else:
			return None
	return yaml.load(open(name, 'r'))
Beispiel #3
0
def font_named(name):
    """Searches the :attr:`font_path` for a font file of the given name and returns an instance of :class:`Font` if it exists."""
    if name in __font_cache:
        return __font_cache[name]
    path = util.find_file_in_path(name, font_path)
    if path:
        import dmd # have to do this to get dmd.Font to work below... odd.
        font = Font(path)
        __font_cache[name] = font
        return font
    else:
        raise ValueError, 'Font named "%s" not found; font_path=%s.  Have you configured font_path in config.yaml?' % (name, font_path)
Beispiel #4
0
def font_named(name):
	"""Searches the :attr:`font_path` for a font file of the given name and returns an instance of :class:`Font` if it exists."""
	if name in __font_cache:
		return __font_cache[name]
	path = util.find_file_in_path(name, font_path)
	if path:
		import dmd # have to do this to get dmd.Font to work below... odd.
		font = Font(path)
		__font_cache[name] = font
		return font
	else:
		raise ValueError, 'Font named "%s" not found; font_path=%s.  Have you configured font_path in config.yaml?' % (name, font_path)
def font_named(name):
    """Searches the :attr:`font_path` for a font file of the given name and returns an instance of :class:`Font` if it exists."""
    if name in __font_cache:
        return __font_cache[name]
    path = util.find_file_in_path(name, font_path)
    if path:
        import dmd # have to do this to get dmd.Font to work below... odd.
        font = Font(path)
        __font_cache[name] = font
        return font
    else:
        if(font_path is None):
            raise ValueError, 'Failed to load font "%s"; font_path was not set in your config.yaml (or config.yaml contains errors)' % (name)    
        raise ValueError, 'Font named "%s" was not found in the following font_path=%s. Add the file or add additional folders to the font path in config.yaml' % (name, font_path)