Code Duplication    Length = 28-28 lines in 2 locations

elodie.py 1 location

@@ 126-153 (lines=28) @@
123
        sys.exit(1)
124
125
126
@click.command('generate-db')
127
@click.option('--source', type=click.Path(file_okay=False),
128
              required=True, help='Source of your photo library.')
129
@click.option('--debug', default=False, is_flag=True,
130
              help='Override the value in constants.py with True.')
131
def _generate_db(source, debug):
132
    """Regenerate the hash.json database which contains all of the sha256 signatures of media files. The hash.json file is located at ~/.elodie/.
133
    """
134
    constants.debug = debug
135
    result = Result()
136
    source = os.path.abspath(os.path.expanduser(source))
137
138
    if not os.path.isdir(source):
139
        log.error('Source is not a valid directory %s' % source)
140
        sys.exit(1)
141
        
142
    db = Db()
143
    db.backup_hash_db()
144
    db.reset_hash_db()
145
146
    for current_file in FILESYSTEM.get_all_files(source):
147
        result.append((current_file, True))
148
        db.add_hash(db.checksum(current_file), current_file)
149
        log.progress()
150
    
151
    db.update_hash_db()
152
    log.progress('', True)
153
    result.write()
154
155
@click.command('verify')
156
@click.option('--debug', default=False, is_flag=True,

elodie/elodie.py 1 location

@@ 126-153 (lines=28) @@
123
        sys.exit(1)
124
125
126
@click.command('generate-db')
127
@click.option('--source', type=click.Path(file_okay=False),
128
              required=True, help='Source of your photo library.')
129
@click.option('--debug', default=False, is_flag=True,
130
              help='Override the value in constants.py with True.')
131
def _generate_db(source, debug):
132
    """Regenerate the hash.json database which contains all of the sha256 signatures of media files. The hash.json file is located at ~/.elodie/.
133
    """
134
    constants.debug = debug
135
    result = Result()
136
    source = os.path.abspath(os.path.expanduser(source))
137
138
    if not os.path.isdir(source):
139
        log.error('Source is not a valid directory %s' % source)
140
        sys.exit(1)
141
        
142
    db = Db()
143
    db.backup_hash_db()
144
    db.reset_hash_db()
145
146
    for current_file in FILESYSTEM.get_all_files(source):
147
        result.append((current_file, True))
148
        db.add_hash(db.checksum(current_file), current_file)
149
        log.progress()
150
    
151
    db.update_hash_db()
152
    log.progress('', True)
153
    result.write()
154
155
@click.command('verify')
156
@click.option('--debug', default=False, is_flag=True,