Code Duplication    Length = 50-50 lines in 2 locations

elodie.py 1 location

@@ 74-123 (lines=50) @@
71
    return dest_path or None
72
73
74
@click.command('import')
75
@click.option('--destination', type=click.Path(file_okay=False),
76
              required=True, help='Copy imported files into this directory.')
77
@click.option('--source', type=click.Path(file_okay=False),
78
              help='Import files from this directory, if specified.')
79
@click.option('--file', type=click.Path(dir_okay=False),
80
              help='Import this file, if specified.')
81
@click.option('--album-from-folder', default=False, is_flag=True,
82
              help="Use images' folders as their album names.")
83
@click.option('--trash', default=False, is_flag=True,
84
              help='After copying files, move the old files to the trash.')
85
@click.option('--allow-duplicates', default=False, is_flag=True,
86
              help='Import the file even if it\'s already been imported.')
87
@click.option('--debug', default=False, is_flag=True,
88
              help='Override the value in constants.py with True.')
89
@click.argument('paths', nargs=-1, type=click.Path())
90
def _import(destination, source, file, album_from_folder, trash, allow_duplicates, debug, paths):
91
    """Import files or directories by reading their EXIF and organizing them accordingly.
92
    """
93
    constants.debug = debug
94
    has_errors = False
95
    result = Result()
96
97
    destination = _decode(destination)
98
    destination = os.path.abspath(os.path.expanduser(destination))
99
100
    files = set()
101
    paths = set(paths)
102
    if source:
103
        source = _decode(source)
104
        paths.add(source)
105
    if file:
106
        paths.add(file)
107
    for path in paths:
108
        path = os.path.expanduser(path)
109
        if os.path.isdir(path):
110
            files.update(FILESYSTEM.get_all_files(path, None))
111
        else:
112
            files.add(path)
113
114
    for current_file in files:
115
        dest_path = import_file(current_file, destination, album_from_folder,
116
                    trash, allow_duplicates)
117
        result.append((current_file, dest_path))
118
        has_errors = has_errors is True or not dest_path
119
120
    result.write()
121
122
    if has_errors:
123
        sys.exit(1)
124
125
126
@click.command('generate-db')

elodie/elodie.py 1 location

@@ 74-123 (lines=50) @@
71
    return dest_path or None
72
73
74
@click.command('import')
75
@click.option('--destination', type=click.Path(file_okay=False),
76
              required=True, help='Copy imported files into this directory.')
77
@click.option('--source', type=click.Path(file_okay=False),
78
              help='Import files from this directory, if specified.')
79
@click.option('--file', type=click.Path(dir_okay=False),
80
              help='Import this file, if specified.')
81
@click.option('--album-from-folder', default=False, is_flag=True,
82
              help="Use images' folders as their album names.")
83
@click.option('--trash', default=False, is_flag=True,
84
              help='After copying files, move the old files to the trash.')
85
@click.option('--allow-duplicates', default=False, is_flag=True,
86
              help='Import the file even if it\'s already been imported.')
87
@click.option('--debug', default=False, is_flag=True,
88
              help='Override the value in constants.py with True.')
89
@click.argument('paths', nargs=-1, type=click.Path())
90
def _import(destination, source, file, album_from_folder, trash, allow_duplicates, debug, paths):
91
    """Import files or directories by reading their EXIF and organizing them accordingly.
92
    """
93
    constants.debug = debug
94
    has_errors = False
95
    result = Result()
96
97
    destination = _decode(destination)
98
    destination = os.path.abspath(os.path.expanduser(destination))
99
100
    files = set()
101
    paths = set(paths)
102
    if source:
103
        source = _decode(source)
104
        paths.add(source)
105
    if file:
106
        paths.add(file)
107
    for path in paths:
108
        path = os.path.expanduser(path)
109
        if os.path.isdir(path):
110
            files.update(FILESYSTEM.get_all_files(path, None))
111
        else:
112
            files.add(path)
113
114
    for current_file in files:
115
        dest_path = import_file(current_file, destination, album_from_folder,
116
                    trash, allow_duplicates)
117
        result.append((current_file, dest_path))
118
        has_errors = has_errors is True or not dest_path
119
120
    result.write()
121
122
    if has_errors:
123
        sys.exit(1)
124
125
126
@click.command('generate-db')