Revision 28578e52 snf-webproject/synnefo/webproject/management/commands/__init__.py

b/snf-webproject/synnefo/webproject/management/commands/__init__.py
36 36
from django.core.management.base import BaseCommand, CommandError
37 37
from django.core.exceptions import FieldError
38 38

  
39
from synnefo.webproject.management import util
39
from synnefo.webproject.management import utils
40 40
from synnefo.lib.astakos import UserCache
41 41

  
42 42

  
43
class SynnefoCommand(BaseCommand):
44
    option_list = BaseCommand.option_list + (
45
        make_option(
46
            "--output-format",
47
            dest="output_format",
48
            metavar="[pretty, csv, json]",
49
            default="pretty",
50
            choices=["pretty", "csv", "json"],
51
            help="Select the output format: pretty [the default], tabs"
52
                 " [tab-separated output], csv [comma-separated output]"),
53
    )
54

  
55

  
43 56
class ListCommand(BaseCommand):
44 57
    """Generic *-list management command.
45 58

  
......
192 205

  
193 206
        # --filter-by option
194 207
        if options["filter_by"]:
195
            filters, excludes = util.parse_filters(options["filter_by"])
208
            filters, excludes = utils.parse_filters(options["filter_by"])
196 209
        else:
197 210
            filters, excludes = ({}, {})
198 211

  
......
270 283
        output_format = options["output_format"]
271 284
        if output_format != "json" and not options["headers"]:
272 285
            headers = None
273
        util.pprint_table(self.stdout, table, headers, output_format)
286
        utils.pprint_table(self.stdout, table, headers, output_format)
274 287

  
275 288
    def handle_args(self, *args, **kwargs):
276 289
        pass
......
286 299
        table = []
287 300
        for field, (_, help_msg) in self.FIELDS.items():
288 301
            table.append((field, help_msg))
289
        util.pprint_table(self.stdout, table, headers)
302
        utils.pprint_table(self.stdout, table, headers)
290 303

  
291 304
    def validate_fields(self, fields):
292 305
        for f in fields:
......
300 313
        table = []
301 314
        for field in self.object_class._meta.fields:
302 315
            table.append((field.name, field.verbose_name, field.help_text))
303
        util.pprint_table(self.stdout, table, headers)
316
        utils.pprint_table(self.stdout, table, headers)

Also available in: Unified diff