Exemplo n.º 1
0
def load_all_dics() -> Dict[str, Dict[str, Dict]]:
    dic = dict()
    ff: FileFinder = FileFinder("etc/midi", True, ".json", "")
    for _ in range(ff.items_len):
        ff.iterate_dir(True)
        ff.now = ff.next
        file = ff.get_path_now()
        item = ff.get_item_now()[:-len(ff.get_end_with())]
        assert always_true(f"Loading midi config from {file}")
        loader = JsonDictLoader(file)
        default_dic = loader.get(ConfigName.default_config, dict())
        dic1 = dict()

        for key in [
                x for x in loader.get_keys()
                if x not in [ConfigName.default_config, ConfigName.comment]
        ]:
            value = loader.get(key, None)
            assert type(
                value) == dict, f"Must be dictionary key={key} in file {item}"
            assert len(
                value
            ) > 0, f"Dictionary must be non empty key={key} in file {item}"
            dic1[key] = dict(default_dic, **value)

        dic[item] = dic1

    return dic
Exemplo n.º 2
0
    def __init__(self):
        self.__change_after_samples: int = MAX_32_INT
        self.__sample_counter: int = 0
        self.__i: Intensity = Intensity.SILENT

        self.__file_finder = FileFinder(
            "etc/drums", False, "", MainLoader.get(ConfigName.drum_type,
                                                   "pop"))
        tmp = self.__file_finder.get_path_now()
        DrumLoader.load(tmp)
Exemplo n.º 3
0
def findFiles(paths):
    """Takes an array of paths, returns all files found
    """
    valid_files = []

    for cfile in paths:
        cur = FileFinder(cfile,
                         with_extension=Config['valid_extensions'],
                         recursive=Config['recursive'])

        try:
            valid_files.extend(cur.findFiles())
        except InvalidPath:
            warn("Invalid path: %s" % cfile)

    if len(valid_files) == 0:
        raise NoValidFilesFoundError()

    # Remove duplicate files (all paths from FileFinder are absolute)
    valid_files = list(set(valid_files))

    return valid_files
Exemplo n.º 4
0
 def __init__(self):
     super().__init__()
     self._file_finder: FileFinder = FileFinder("save_song", True, ".sng", "")
     self._song_name = ""
     self.__set_song_name()