Ejemplo n.º 1
0
def get_filenames_in_curdir(text: str, current_dir):
    result = []
    files = try_except_log_ret(listdir, current_dir)
    for x in files:
        if start_swith_filter(text, x):
            result.append(x)
    return tuple(result)
Ejemplo n.º 2
0
def write_serialize_data(text: str, data, remove_arg=True):
    current_dir = try_except_log_ret(path.abspath, curdir)
    if remove_arg:
        files = get_filenames_in_curdir(text, current_dir)
        if files:
            remove_files(files, current_dir)
    with open(text + '.pickle', 'wb') as f:
        try_except_log(dump, data, f)
Ejemplo n.º 3
0
def read_serialize_data(text: str, remove_arg=True):
    current_dir = try_except_log_ret(path.abspath, curdir)
    files = get_filenames_in_curdir(text, current_dir)
    if files != None:
        data = open_load_file(files)
        if remove_arg:
            remove_files(files, current_dir)
    else:
        data = None
    return data
Ejemplo n.º 4
0
def delete_screens_and_log():
    current_dir = try_except_log_ret(path.abspath, curdir)
    screens = get_filenames_in_curdir('screen_', current_dir)
    log_txt = get_filenames_in_curdir('log', current_dir)
    dict_main_elements = get_filenames_in_curdir('dict_main_elements',
                                                 current_dir)
    if len(screens) > 0:
        remove_files(screens, current_dir)
    if len(log_txt) > 0:
        logging.shutdown()
        remove_files(log_txt, current_dir)
    if len(dict_main_elements) > 0:
        remove_files(dict_main_elements, current_dir)
Ejemplo n.º 5
0
def parse_file_scenario(data_list: tuple):
    tuple_commands = tuple()
    current_dir = try_except_log_ret(path.abspath, curdir)
    for x in data_list:
        res = get_filenames_in_curdir(x, current_dir)
        if len(res) == 1:
            tuple_commands = tuple_commands + start_read_file(res)
        else:
            log_record(
                'файл ' + x +
                ' отсутствует, либо по данному наименованию присутствует больше чем один файл'
            )
    return tuple_commands
Ejemplo n.º 6
0
def open_load_file(files: tuple):
    data = None
    for i in files:
        with open(i, 'rb') as f:
            data = try_except_log_ret(load, f)
    return data