kdeldycke / mail-deduplicate

@@ -187,14 +187,14 @@
Loading
187 187
    return folder_list
188 188
189 189
190 -
def create_box(path, box_type=False, allow_existing=False):
190 +
def create_box(path, box_type=False, export_append=False):
191 191
    """Creates a brand new box from scratch."""
192 192
    assert isinstance(path, Path)
193 193
    logger.info(
194 194
        f"Creating new {choice_style(box_type)} box at {choice_style(str(path))} ..."
195 195
    )
196 196
197 -
    if path.exists() and allow_existing is not True:
197 +
    if path.exists() and export_append is not True:
198 198
        raise FileExistsError(path)
199 199
200 200
    constructor = BOX_TYPES[box_type]

@@ -130,7 +130,7 @@
Loading
130 130
        "action": None,
131 131
        "export": None,
132 132
        "export_format": "mbox",
133 -
        "allow_existing": False,
133 +
        "export_append": False,
134 134
    }
135 135
136 136
    def __init__(self, **kwargs):
@@ -165,7 +165,7 @@
Loading
165 165
        # expected to exists in the first place.
166 166
        if self.export:
167 167
            self.export = Path(self.export).resolve()
168 -
            if self.export.exists() and self.allow_existing is not True:
168 +
            if self.export.exists() and self.export_append is not True:
169 169
                raise FileExistsError(self.export)
170 170
171 171
    def __getattr__(self, attr_id):

@@ -212,10 +212,13 @@
Loading
212 212
    f"{MOVE_SELECTED} and {MOVE_DISCARDED} actions.",
213 213
)
214 214
@click.option(
215 -
    "--allow-existing",
215 +
    "--export-append",
216 216
    is_flag=True,
217 217
    default=False,
218 -
    help="Allow the destination mail box to already exist.",
218 +
    help="If destination mail box already exists, add mails into it "
219 +
    "instead of interrupting (default behavior). "
220 +
    f"Affect {COPY_SELECTED}, {COPY_DISCARDED}, "
221 +
    f"{MOVE_SELECTED} and {MOVE_DISCARDED} actions.",
219 222
)
220 223
@click.argument(
221 224
    "mail_sources",
@@ -257,7 +260,7 @@
Loading
257 260
    action,
258 261
    export,
259 262
    export_format,
260 -
    allow_existing,
263 +
    export_append,
261 264
    mail_sources,
262 265
):
263 266
    """Deduplicate mails from a set of mail boxes.
@@ -365,7 +368,7 @@
Loading
365 368
        action=action,
366 369
        export=export,
367 370
        export_format=export_format,
368 -
        allow_existing=allow_existing,
371 +
        export_append=export_append,
369 372
    )
370 373
371 374
    dedup = Deduplicate(conf)

@@ -35,7 +35,7 @@
Loading
35 35
def __copy_mails(dedup, mails):
36 36
    """Copy all mails to a brand new box or an existing one."""
37 37
    if not dedup.conf.dry_run:
38 -
        box = create_box(dedup.conf.export, dedup.conf.export_format, dedup.conf.allow_existing)
38 +
        box = create_box(dedup.conf.export, dedup.conf.export_format, dedup.conf.export_append)
39 39
40 40
    for mail in mails:
41 41
        logger.debug(f"Copying {mail!r} to {dedup.conf.export}...")
@@ -54,7 +54,7 @@
Loading
54 54
def __move_mails(dedup, mails):
55 55
    """Move all mails to a brand new box or an existing one."""
56 56
    if not dedup.conf.dry_run:
57 -
        box = create_box(dedup.conf.export, dedup.conf.export_format, dedup.conf.allow_existing)
57 +
        box = create_box(dedup.conf.export, dedup.conf.export_format, dedup.conf.export_append)
58 58
59 59
    for mail in mails:
60 60
        logger.debug(f"Move {mail!r} form {mail.source_path} to {dedup.conf.export}...")
Files Coverage
mail_deduplicate 77.36%
Project Totals (8 files) 77.36%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading