Example #1
0
def _create_file_info_list(input_path_list, ext_list, cls):

    file_path_list_list = []
    for input_path_info in input_path_list:
        input_path, filtering = input_path_info
        file_path_list_list.append(
            utility.directory_walk(input_path, ext_list, filtering, 2))

    file_path_list = itertools.chain.from_iterable(file_path_list_list)

    file_info_list = []

    for file_path in file_path_list:
        dt = datetime.datetime.fromtimestamp(os.stat(file_path).st_mtime)
        print(file_path, dt.strftime('%Y%m%d%H%M'))
        file_info_list.append(cls(dt, file_path))

    sorted_file_info_list = sorted(file_info_list, key=lambda v: v.dt)

    file_info_list_by_date = {}
    for file_info in sorted_file_info_list:
        dt = file_info.dt
        file_path = file_info.local_path
        one_day = _get_one_day_directory_name(dt)
        file_list = file_info_list_by_date.get(one_day, None)
        if file_list is None:
            file_list = []
            file_info_list_by_date[one_day] = file_list

        file_list.append(file_info)

    return file_info_list_by_date
Example #2
0
def all_execute(offset_date, offset_our, input_directory_path, exr_list):

    input_file_path_list = utility.directory_walk(input_directory_path,
                                                  exr_list)

    for input_file_path in input_file_path_list:
        offset_time(input_file_path, offset_date, offset_our)
Example #3
0
def all_execute(input_directory_path, output_directory_path):
    
    prog = re.compile(r"\d{4}(\d{4})$")
    
    pass_already_exist_flag = True
    new_ext = ".jpg"
    
    input_file_path_list = utility.directory_walk(input_directory_path, [".ARW", ".arw"])
    print(input_file_path_list)

    for input_file_path in input_file_path_list:
        temp_output_file_path_1 = os.path.join(output_directory_path, os.path.relpath(input_file_path, input_directory_path))
        temp_output_file_path_2 = os.path.normpath(temp_output_file_path_1)
        temp_output_directory_path = os.path.dirname(temp_output_file_path_2)
        temp_output_file_name = os.path.basename(temp_output_file_path_2)

        temp_file_path_tuple = temp_output_directory_path.split(os.path.sep)
        temp_output_directory_name = temp_file_path_tuple[-1]
        m = prog.match(temp_output_directory_name)
        if m:
            temp_new_output_directory_name = "%s%s" % (YEAR, m.group(1))
        else:
            raise Error("wring directory name (%s)" % temp_output_directory_name)
        
        output_file_path = os.path.sep.join((temp_file_path_tuple[:-1] + [temp_new_output_directory_name, temp_output_file_name]))

        print("copy (%s) -> (%s)" % (input_file_path, output_file_path))
        if pass_already_exist_flag:
            if os.path.isfile(output_file_path) == True:
                if os.path.getsize(input_file_path) == os.path.getsize(output_file_path):
                    print("pass %s" % output_file_path)
                    continue
                else:
                    print(output_file_path)
                    output_file_path = "%s_%s%s" % (os.path.splitext(output_file_path)[0], 2, os.path.splitext(output_file_path)[1]) #

                
        directory = os.path.dirname(output_file_path)
        if os.path.isdir(directory) == False:
            os.makedirs(directory)

        shutil.move(input_file_path, output_file_path)
        """
        if os.path.isfile(output_file_path) == True:
            print("delete %s" % input_file_path)
            os.remove(input_file_path)
        """
        # arw_convert(input_file_path, output_file_path)
    print("end")
Example #4
0
def all_execute(input_directory_path, output_directory_path):

    pass_already_exist_flag = True
    new_ext = ".jpg"

    input_file_path_list = utility.directory_walk(input_directory_path, [".ARW", ".arw"])
    log(input_file_path_list)

    for input_file_path in input_file_path_list:
        temp_output_file_path = os.path.join(output_directory_path, os.path.relpath(input_file_path, input_directory_path))
        splited_tuple = os.path.splitext(temp_output_file_path)
        output_file_path = "%s%s" % (splited_tuple[0], new_ext)

        if pass_already_exist_flag:
            if os.path.isfile(output_file_path) == True:
                log("pass %s" % output_file_path)
                continue

        directory, file = os.path.split(output_file_path)
        if os.path.isdir(directory) == False:
            os.makedirs(directory)
        print("convert (%s) -> (%s)" % (input_file_path, output_file_path))
        arw_convert(input_file_path, output_file_path)
Example #5
0
def all_execute(input_directory_path, output_directory_path):
    
    pass_already_exist_flag = True
    new_ext = ".jpg"
    
    input_file_path_list = utility.directory_walk(input_directory_path, [".ARW", ".arw"])
    log(input_file_path_list)

    for input_file_path in input_file_path_list:
        temp_output_file_path = os.path.join(output_directory_path, os.path.relpath(input_file_path, input_directory_path))
        splited_tuple = os.path.splitext(temp_output_file_path)
        output_file_path = "%s%s" % (splited_tuple[0], new_ext)
        
        if pass_already_exist_flag:
            if os.path.isfile(output_file_path) == True:
                log("pass %s" % output_file_path)
                continue
        
        directory, file = os.path.split(output_file_path)
        if os.path.isdir(directory) == False:
            os.makedirs(directory)
        print("convert (%s) -> (%s)" % (input_file_path, output_file_path))
        arw_convert(input_file_path, output_file_path)
Example #6
0
def all_execute(input_directory_path, output_directory_path):

    prog = re.compile(r"\d{4}(\d{4})$")

    pass_already_exist_flag = True
    new_ext = ".jpg"

    input_file_path_list = utility.directory_walk(
        input_directory_path, [".ARW", ".arw", ".JPG", ".jpg"])
    print(input_file_path_list)

    for input_file_path in input_file_path_list:
        temp_output_file_path_1 = os.path.join(
            output_directory_path,
            os.path.relpath(input_file_path, input_directory_path))
        temp_output_file_path_2 = os.path.normpath(temp_output_file_path_1)
        temp_output_directory_path = os.path.dirname(temp_output_file_path_2)
        temp_output_file_name = os.path.basename(temp_output_file_path_2)

        temp_file_path_tuple = temp_output_directory_path.split(os.path.sep)
        temp_output_directory_name = temp_file_path_tuple[-1]
        m = prog.match(temp_output_directory_name)
        year = _get_year(input_file_path)
        if m:
            temp_new_output_directory_name = "%s_%s" % (year, m.group(1))
        else:
            if (True):
                print("wring directory name (%s)" % temp_output_directory_name)
                continue
            else:
                raise Error("wring directory name (%s)" %
                            temp_output_directory_name)

        output_file_path = os.path.sep.join(
            (temp_file_path_tuple[:-1] +
             [temp_new_output_directory_name, temp_output_file_name]))

        print("copy (%s) -> (%s)" % (input_file_path, output_file_path))
        if pass_already_exist_flag:
            if os.path.isfile(output_file_path) == True:
                if os.path.getsize(input_file_path) == os.path.getsize(
                        output_file_path):
                    print("pass %s" % output_file_path)
                    continue
                else:
                    print(output_file_path)
                    output_file_path = "%s_%s%s" % (
                        os.path.splitext(output_file_path)[0], 2,
                        os.path.splitext(output_file_path)[1])

        directory = os.path.dirname(output_file_path)
        if os.path.isdir(directory) == False:
            os.makedirs(directory)

        shutil.move(input_file_path, output_file_path)
        """
        if os.path.isfile(output_file_path) == True:
            print("delete %s" % input_file_path)
            os.remove(input_file_path)
        """
        # arw_convert(input_file_path, output_file_path)
    print("end")
Example #7
0
def get_folders():
    output = utility.directory_walk(
        os.path.join(current_app.config.get('BASEDIR'), 'uploads'))
    return jsonify({'success': True, 'data': output})
Example #8
0
def override_date_from_directory(target_directory, target_override_date):

    file_path_list = utility.directory_walk(target_directory, [".jpg"])

    for file_path in file_path_list:
        override_date(file_path, target_override_date)