|
1 | 1 | import importlib |
2 | 2 | import json |
3 | | -from distutils.version import StrictVersion |
4 | | -from optparse import make_option |
5 | 3 |
|
6 | | -from django import get_version as get_django_version |
7 | 4 | from django.core.management.base import BaseCommand, CommandError |
8 | 5 |
|
9 | 6 | from graphene_django.settings import graphene_settings |
10 | 7 |
|
11 | | -LT_DJANGO_1_8 = StrictVersion(get_django_version()) < StrictVersion('1.8') |
12 | | - |
13 | | -if LT_DJANGO_1_8: |
14 | | - class CommandArguments(BaseCommand): |
15 | | - option_list = BaseCommand.option_list + ( |
16 | | - make_option( |
17 | | - '--schema', |
18 | | - type=str, |
19 | | - dest='schema', |
20 | | - default='', |
21 | | - help='Django app containing schema to dump, e.g. myproject.core.schema.schema', |
22 | | - ), |
23 | | - make_option( |
24 | | - '--out', |
25 | | - type=str, |
26 | | - dest='out', |
27 | | - default='', |
28 | | - help='Output file (default: schema.json)' |
29 | | - ), |
30 | | - make_option( |
31 | | - '--indent', |
32 | | - type=int, |
33 | | - dest='indent', |
34 | | - default=None, |
35 | | - help='Output file indent (default: None)' |
36 | | - ), |
37 | | - ) |
38 | | -else: |
39 | | - class CommandArguments(BaseCommand): |
40 | | - |
41 | | - def add_arguments(self, parser): |
42 | | - parser.add_argument( |
43 | | - '--schema', |
44 | | - type=str, |
45 | | - dest='schema', |
46 | | - default=graphene_settings.SCHEMA, |
47 | | - help='Django app containing schema to dump, e.g. myproject.core.schema.schema') |
48 | | - |
49 | | - parser.add_argument( |
50 | | - '--out', |
51 | | - type=str, |
52 | | - dest='out', |
53 | | - default=graphene_settings.SCHEMA_OUTPUT, |
54 | | - help='Output file (default: schema.json)') |
55 | | - |
56 | | - parser.add_argument( |
57 | | - '--indent', |
58 | | - type=int, |
59 | | - dest='indent', |
60 | | - default=graphene_settings.SCHEMA_INDENT, |
61 | | - help='Output file indent (default: None)') |
| 8 | + |
| 9 | +class CommandArguments(BaseCommand): |
| 10 | + |
| 11 | + def add_arguments(self, parser): |
| 12 | + parser.add_argument( |
| 13 | + '--schema', |
| 14 | + type=str, |
| 15 | + dest='schema', |
| 16 | + default=graphene_settings.SCHEMA, |
| 17 | + help='Django app containing schema to dump, e.g. myproject.core.schema.schema') |
| 18 | + |
| 19 | + parser.add_argument( |
| 20 | + '--out', |
| 21 | + type=str, |
| 22 | + dest='out', |
| 23 | + default=graphene_settings.SCHEMA_OUTPUT, |
| 24 | + help='Output file (default: schema.json)') |
| 25 | + |
| 26 | + parser.add_argument( |
| 27 | + '--indent', |
| 28 | + type=int, |
| 29 | + dest='indent', |
| 30 | + default=graphene_settings.SCHEMA_INDENT, |
| 31 | + help='Output file indent (default: None)') |
62 | 32 |
|
63 | 33 |
|
64 | 34 | class Command(CommandArguments): |
|
0 commit comments