Completed
Push — master ( 4f7ee6...646424 )
by Paolo
08:30 queued 06:53
created

uid.management.commands.truncate_image_tables   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Command.handle() 0 14 2
A Command.add_arguments() 0 7 1
1
2
import logging
3
4
from django.core.management import BaseCommand
5
6
from uid.models import truncate_database, truncate_filled_tables
7
8
# Get an instance of a logger
9
logger = logging.getLogger(__name__)
10
11
12
class Command(BaseCommand):
13
    help = """Truncate uid tables and reset counters"""
14
15
    def add_arguments(self, parser):
16
        # Named (optional) arguments
17
        parser.add_argument(
18
            '--all',
19
            action='store_true',
20
            dest='all',
21
            help='Truncate all uid tables and reset counters',
22
        )
23
24
    def handle(self, *args, **options):
25
        # HINT: maybe UID or InjectTools could be more informative than
26
        # uid suffix?
27
28
        logger.info("Starting truncate_image_tables")
29
30
        if options['all'] is True:
31
            truncate_database()
32
33
        else:
34
            truncate_filled_tables()
35
36
        # debug
37
        logger.info("Done!")
38