def get_list(alphabet_id=None, from_path=default_from_path): raw_input('good') reg = re.compile(reg_string) if not use_dict: def make_dict(): use_dict = {} for base, dirs, files in os.walk(default_from_path): print(base) for file_name in sorted(files): match = reg.match(file_name) if match: name = match.groups()[0] if name not in use_dict: use_dict[name] = [] use_dict[name].append(make_path(file_name, desired_base_of_target=default_from_path, actual_base_of_target=base)) return use_dict use_dict.update(objectstorage.get_object(name, make_dict, timestamp_dir=default_from_path)) if alphabet_id is None: return use_dict.copy() if alphabet_id not in use_dict: return [] if from_path == default_from_path: return list(use_dict[alphabet_id]) else: return maplist((lambda i: make_path(i, desired_base_of_target=from_path, actual_base_of_target=default_from_path)), use_dict[alphabet_id])
def get_list(alphabet_id=None, id_=None, from_path=default_from_path): if not use_dict: def make_dict(): use_dict = {} for base, dirs, files in os.walk(base_dir): print(base) for file_name in sorted(files): match = reg.match(file_name) if match: name, number, cur_id = match.groups() name = name if name not in use_dict: use_dict[name] = {} if cur_id not in use_dict[name]: use_dict[name][cur_id] = [] use_dict[name][cur_id].append(make_path(file_name, desired_base_of_target=default_from_path, actual_base_of_target=base)) return use_dict use_dict.update(objectstorage.get_object(name, make_dict, timestamp_dir=default_from_path)) if default_from_path == from_path: def fix_path(path): return path else: def fix_path(path): return make_path(path, desired_base_of_target=from_path, actual_base_of_target=default_from_path) if alphabet_id is None: rtn = {} if id_ is None: for alphabet_id in use_dict: rtn[alphabet_id] = {} for id_ in use_dict[alphabet_id]: rtn[alphabet_id][id_] = maplist(fix_path, use_dict[alphabet_id][id_]) else: rtn = {} for alphabet_id in use_dict: if id_ in use_dict[alphabet_id]: rtn[alphabet_id] = maplist(fix_path, use_dict[alphabet_id][id_]) return rtn else: if id_ is None: if alphabet_id not in use_dict: return {} rtn = {} for cur_id in use_dict[alphabet_id]: rtn[cur_id] = maplist(fix_path, use_dict[alphabet_id][cur_id]) return rtn else: if alphabet_id not in use_dict: return [] return maplist((lambda i: relpath(i, from_path)), use_dict[alphabet_id][id_])