Skip to content

Commit f97833b

Browse files
committed
Lint
1 parent 9ca62db commit f97833b

File tree

6 files changed

+35
-38
lines changed

6 files changed

+35
-38
lines changed

readthedocs/builds/syncers.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""
42
Classes to copy files between build and web servers.
53
@@ -174,7 +172,8 @@ def copy(cls, path, target, host, is_file=False, **kwargs): # pylint: disable=a
174172
class SelectiveStorageRemotePuller(RemotePuller):
175173

176174
"""
177-
Exactly like RemotePuller except that certain files are copied via Django's storage system
175+
Exactly like RemotePuller except that certain files are copied via Django's
176+
storage system.
178177
179178
If a file with extensions specified by ``extensions`` is copied, it will be copied to storage
180179
and the original is removed.
@@ -187,7 +186,7 @@ class SelectiveStorageRemotePuller(RemotePuller):
187186
@classmethod
188187
def get_storage_path(cls, path):
189188
"""
190-
Gets the path to the file within the storage engine
189+
Gets the path to the file within the storage engine.
191190
192191
For example, if the path was $MEDIA_ROOT/pdfs/latest.pdf
193192
the storage_path is 'pdfs/latest.pdf'
@@ -213,7 +212,7 @@ def copy(cls, path, target, host, is_file=False, **kwargs): # pylint: disable=a
213212

214213
if is_file and os.path.exists(target) and \
215214
any([target.lower().endswith(ext) for ext in cls.extensions]):
216-
log.info("Selective Copy %s to media storage", target)
215+
log.info('Selective Copy %s to media storage', target)
217216

218217
storage_path = cls.get_storage_path(target)
219218

readthedocs/projects/models.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Project models."""
42

53
import fnmatch
@@ -514,7 +512,7 @@ def get_subproject_urls(self):
514512

515513
def get_storage_path(self, type_, version_slug=LATEST):
516514
"""
517-
Get a path to a build artifact for use with Django's storage system
515+
Get a path to a build artifact for use with Django's storage system.
518516
519517
:param type_: Media content type, ie - 'pdf', 'htmlzip'
520518
:param version_slug: Project version slug for lookup
@@ -748,20 +746,32 @@ def has_aliases(self):
748746
def has_pdf(self, version_slug=LATEST):
749747
if not self.enable_pdf_build:
750748
return False
751-
path = self.get_production_media_path(type_='pdf', version_slug=version_slug)
752-
storage_path = self.get_storage_path(type_='pdf', version_slug=version_slug)
749+
path = self.get_production_media_path(
750+
type_='pdf', version_slug=version_slug
751+
)
752+
storage_path = self.get_storage_path(
753+
type_='pdf', version_slug=version_slug
754+
)
753755
return os.path.exists(path) or storage.exists(storage_path)
754756

755757
def has_epub(self, version_slug=LATEST):
756758
if not self.enable_epub_build:
757759
return False
758-
path = self.get_production_media_path(type_='epub', version_slug=version_slug)
759-
storage_path = self.get_storage_path(type_='epub', version_slug=version_slug)
760+
path = self.get_production_media_path(
761+
type_='epub', version_slug=version_slug
762+
)
763+
storage_path = self.get_storage_path(
764+
type_='epub', version_slug=version_slug
765+
)
760766
return os.path.exists(path) or storage.exists(storage_path)
761767

762768
def has_htmlzip(self, version_slug=LATEST):
763-
path = self.get_production_media_path(type_='htmlzip', version_slug=version_slug)
764-
storage_path = self.get_storage_path(type_='htmlzip', version_slug=version_slug)
769+
path = self.get_production_media_path(
770+
type_='htmlzip', version_slug=version_slug
771+
)
772+
storage_path = self.get_storage_path(
773+
type_='htmlzip', version_slug=version_slug
774+
)
765775
return os.path.exists(path) or storage.exists(storage_path)
766776

767777
@property

readthedocs/projects/tasks.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""
42
Tasks related to projects.
53
@@ -854,7 +852,8 @@ def build_docs_html(self):
854852
type='app',
855853
task=move_files,
856854
args=[
857-
self.version.pk, socket.gethostname(), self.config.doctype
855+
self.version.pk,
856+
socket.gethostname(), self.config.doctype
858857
],
859858
kwargs=dict(html=True),
860859
)
@@ -926,15 +925,8 @@ def is_type_sphinx(self):
926925
# Web tasks
927926
@app.task(queue='web')
928927
def sync_files(
929-
project_pk,
930-
version_pk,
931-
doctype,
932-
hostname=None,
933-
html=False,
934-
localmedia=False,
935-
search=False,
936-
pdf=False,
937-
epub=False,
928+
project_pk, version_pk, doctype, hostname=None, html=False,
929+
localmedia=False, search=False, pdf=False, epub=False,
938930
delete_unsynced_media=True
939931
):
940932
"""

readthedocs/projects/views/public.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Public project views."""
42

53
import json
@@ -15,7 +13,7 @@
1513
from django.contrib.auth.models import User
1614
from django.core.cache import cache
1715
from django.core.files.storage import get_storage_class
18-
from django.http import Http404, HttpResponse, HttpResponseRedirect
16+
from django.http import HttpResponse, HttpResponseRedirect
1917
from django.shortcuts import get_object_or_404, render
2018
from django.urls import reverse
2119
from django.views.decorators.cache import never_cache
@@ -208,7 +206,9 @@ def project_download_media(request, project_slug, type_, version_slug):
208206
)
209207
privacy_level = getattr(settings, 'DEFAULT_PRIVACY_LEVEL', 'public')
210208
if privacy_level == 'public' or settings.DEBUG:
211-
storage_path = version.project.get_storage_path(type_=type_, version_slug=version_slug)
209+
storage_path = version.project.get_storage_path(
210+
type_=type_, version_slug=version_slug
211+
)
212212
if storage.exists(storage_path):
213213
return HttpResponseRedirect(storage.url(storage_path))
214214

readthedocs/rtd_tests/tests/test_project.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import datetime
32
import json
43

@@ -253,10 +252,8 @@ def test_user_can_not_add_other_user_project_as_translation(self):
253252
self.assertIsNone(project_b.main_language_project)
254253

255254
def test_previous_users_can_list_and_delete_translations_not_owner(self):
256-
"""
257-
Test to make sure that previous users can list and delete
258-
projects where they aren't owners.
259-
"""
255+
"""Test to make sure that previous users can list and delete projects
256+
where they aren't owners."""
260257
user_a = User.objects.get(username='eric')
261258
project_a = get(
262259
Project, users=[user_a],

readthedocs/rtd_tests/tests/test_project_views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# -*- coding: utf-8 -*-
21

32
from datetime import timedelta
43

5-
from mock import patch
4+
from allauth.account.models import EmailAddress
65
from django.contrib.auth.models import User
76
from django.contrib.messages import constants as message_const
87
from django.http.response import HttpResponseRedirect
@@ -11,7 +10,7 @@
1110
from django.utils import timezone
1211
from django.views.generic.base import ContextMixin
1312
from django_dynamic_fixture import get, new
14-
from allauth.account.models import EmailAddress
13+
from mock import patch
1514

1615
from readthedocs.builds.constants import LATEST
1716
from readthedocs.builds.models import Build, Version

0 commit comments

Comments
 (0)