Skip to content

Commit 8a34164

Browse files
authored
Merge pull request #4373 from rtfd/humitos/command/update_repos
Check for 'options' in update_repos command
2 parents 45a5944 + 1fd676e commit 8a34164

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# -*- coding: utf-8 -*-
2+
23
"""
34
Custom management command to rebuild documentation for all projects.
45
56
Invoked via ``./manage.py update_repos``.
67
"""
78

8-
from __future__ import absolute_import
9+
from __future__ import (
10+
absolute_import, division, print_function, unicode_literals)
911

1012
import logging
11-
from optparse import make_option
1213

1314
from django.core.management.base import BaseCommand
1415

@@ -17,13 +18,12 @@
1718
from readthedocs.projects import tasks
1819
from readthedocs.projects.models import Project
1920

20-
2121
log = logging.getLogger(__name__)
2222

2323

2424
class Command(BaseCommand):
2525

26-
"""Management command for rebuilding documentation on projects"""
26+
"""Management command for rebuilding documentation on projects."""
2727

2828
help = __doc__
2929

@@ -35,39 +35,45 @@ def add_arguments(self, parser):
3535
action='store_true',
3636
dest='record',
3737
default=False,
38-
help='Make a Build'
38+
help='Make a Build',
3939
)
4040

4141
parser.add_argument(
4242
'-f',
4343
action='store_true',
4444
dest='force',
4545
default=False,
46-
help='Force a build in sphinx'
46+
help='Force a build in sphinx',
4747
)
4848

4949
parser.add_argument(
5050
'-V',
5151
dest='version',
5252
default=None,
53-
help='Build a version, or all versions'
53+
help='Build a version, or all versions',
5454
)
5555

5656
def handle(self, *args, **options):
5757
record = options['record']
5858
force = options['force']
5959
version = options['version']
60-
if args:
60+
61+
if options.get('slug', []):
6162
for slug in options['slugs']:
62-
if version and version != "all":
63-
log.info("Updating version %s for %s", version, slug)
64-
for version in Version.objects.filter(project__slug=slug, slug=version):
63+
if version and version != 'all':
64+
log.info('Updating version %s for %s', version, slug)
65+
for version in Version.objects.filter(
66+
project__slug=slug,
67+
slug=version,
68+
):
6569
trigger_build(project=version.project, version=version)
66-
elif version == "all":
67-
log.info("Updating all versions for %s", slug)
68-
for version in Version.objects.filter(project__slug=slug,
69-
active=True,
70-
uploaded=False):
70+
elif version == 'all':
71+
log.info('Updating all versions for %s', slug)
72+
for version in Version.objects.filter(
73+
project__slug=slug,
74+
active=True,
75+
uploaded=False,
76+
):
7177

7278
build_pk = None
7379
if record:
@@ -83,28 +89,30 @@ def handle(self, *args, **options):
8389
pk=version.project_id,
8490
build_pk=build_pk,
8591
record=record,
86-
version_pk=version.pk
92+
version_pk=version.pk,
8793
)
8894
else:
8995
p = Project.all_objects.get(slug=slug)
90-
log.info("Building %s", p)
96+
log.info('Building %s', p)
9197
trigger_build(project=p, force=force, record=record)
9298
else:
93-
if version == "all":
94-
log.info("Updating all versions")
95-
for version in Version.objects.filter(active=True,
96-
uploaded=False):
99+
if version == 'all':
100+
log.info('Updating all versions')
101+
for version in Version.objects.filter(
102+
active=True,
103+
uploaded=False,
104+
):
97105
tasks.UpdateDocsTask().run(
98106
pk=version.project_id,
99107
record=record,
100108
force=force,
101-
version_pk=version.pk
109+
version_pk=version.pk,
102110
)
103111
else:
104-
log.info("Updating all docs")
112+
log.info('Updating all docs')
105113
for project in Project.objects.all():
106114
tasks.UpdateDocsTask().run(
107115
pk=project.pk,
108116
record=record,
109-
force=force
117+
force=force,
110118
)

0 commit comments

Comments
 (0)