File: clean.py

package info (click to toggle)
python-rjsmin 1.2.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,000 kB
  • sloc: javascript: 8,503; python: 2,847; ansic: 821; sh: 63; makefile: 19
file content (69 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- encoding: ascii -*-
"""
Cleanup tasks
~~~~~~~~~~~~~

"""

import invoke as _invoke


@_invoke.task()
def py(ctx):
    """ Wipe *.py[co] files """
    for name in ctx.shell.files('.', '*.py[co]'):
        ctx.shell.rm(name)
    for name in ctx.shell.dirs('.', '__pycache__'):
        ctx.shell.rm_rf(name)


@_invoke.task(py)
def dist(ctx):
    """ Wipe all """
    clean(ctx, so=True, cache=True)


@_invoke.task(py, default=True)
def clean(ctx, so=False, cache=False):
    """ Wipe *.py[co] files and test leftovers """
    for name in ctx.shell.files('.', '.coverage*', recursive=False):
        ctx.shell.rm(name)
    for name in ctx.shell.files('bench', '.out.*', recursive=False):
        ctx.shell.rm(name)
    ctx.shell.rm_rf(
        'docs/coverage',
        'docs/gcov',
        'build',
        'dist',
        'wheel/dist',
        ctx.doc.userdoc,
        'docs/_userdoc/_build',
        ctx.doc.website.source,
        ctx.doc.website.target,
    )
    if cache:
        cacheclean(ctx)
    if so:
        soclean(ctx)


@_invoke.task()
def cacheclean(ctx):
    """ Wipe Cache files """
    ctx.shell.rm_rf(
        '.tox',
        'bench/.tox',
        '.cache',
        'tests/.cache',
        'tests/.pytest_cache',
        '.mypy_cache',
    )


@_invoke.task()
def soclean(ctx):
    """ Wipe *.so files """
    for name in ctx.shell.files('.', '*.pyd'):
        ctx.shell.rm(name)
    for name in ctx.shell.files('.', '*.so'):
        ctx.shell.rm(name)