Skip to content

Commit df3d547

Browse files
lordmauveagjohnson
authored andcommitted
Fix lint issues for privacy app (readthedocs#2888)
* Fix lint issues for privacy app * Rename file param to Syncers * Roll back comment change
1 parent a2cf44b commit df3d547

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed

prospector-more.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ignore-paths:
66
- core/
77
- doc_builder/
88
- donate/
9-
- privacy/
109
- projects/
1110
- redirects/
1211
- restapi/

readthedocs/privacy/backend.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Django Managers and Querysets to apply project privacy restrictions."""
12
from django.db import models
23

34
from guardian.shortcuts import get_objects_for_user
@@ -85,7 +86,7 @@ def from_queryset(cls, queryset_class, class_name=None):
8586
# no direct members.
8687
queryset_class = get_override_class(
8788
VersionQuerySet,
88-
VersionQuerySet._default_class
89+
VersionQuerySet._default_class # pylint: disable=protected-access
8990
)
9091
return super(VersionManager, cls).from_queryset(queryset_class, class_name)
9192

readthedocs/privacy/backends/syncers.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""Classes allowing copying files around.
2+
3+
"Syncers" copy files from the local machine, while "Pullers" copy files to
4+
the local machine.
5+
6+
"""
17
import getpass
28
import logging
39
import os
@@ -11,10 +17,10 @@
1117
class LocalSyncer(object):
1218

1319
@classmethod
14-
def copy(cls, path, target, file=False, **kwargs):
20+
def copy(cls, path, target, is_file=False, **__):
1521
"""A copy command that works with files or directories."""
16-
log.info("Local Copy %s to %s" % (path, target))
17-
if file:
22+
log.info("Local Copy %s to %s", path, target)
23+
if is_file:
1824
if path == target:
1925
# Don't copy the same file over itself
2026
return
@@ -30,7 +36,7 @@ def copy(cls, path, target, file=False, **kwargs):
3036
class RemoteSyncer(object):
3137

3238
@classmethod
33-
def copy(cls, path, target, file=False, **kwargs):
39+
def copy(cls, path, target, is_file=False, **__):
3440
"""
3541
A better copy command that works with files or directories.
3642
@@ -39,14 +45,14 @@ def copy(cls, path, target, file=False, **kwargs):
3945
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
4046
app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', [])
4147
if app_servers:
42-
log.info("Remote Copy %s to %s" % (path, target))
48+
log.info("Remote Copy %s to %s on %s", path, target, app_servers)
4349
for server in app_servers:
4450
mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (sync_user, server, target))
4551
ret = os.system(mkdir_cmd)
4652
if ret != 0:
4753
log.info("COPY ERROR to app servers:")
4854
log.info(mkdir_cmd)
49-
if file:
55+
if is_file:
5056
slash = ""
5157
else:
5258
slash = "/"
@@ -68,19 +74,19 @@ def copy(cls, path, target, file=False, **kwargs):
6874
class DoubleRemotePuller(object):
6975

7076
@classmethod
71-
def copy(cls, path, target, host, file=False, **kwargs):
77+
def copy(cls, path, target, host, is_file=False, **__):
7278
"""
7379
A better copy command that works from the webs.
7480
7581
Respects the ``MULTIPLE_APP_SERVERS`` setting when copying.
7682
"""
7783
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
7884
app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', [])
79-
if not file:
85+
if not is_file:
8086
path += "/"
81-
log.info("Remote Copy %s to %s" % (path, target))
87+
log.info("Remote Copy %s to %s", path, target)
8288
for server in app_servers:
83-
if not file:
89+
if not is_file:
8490
mkdir_cmd = "ssh {user}@{server} mkdir -p {target}".format(
8591
user=sync_user, server=server, target=target
8692
)
@@ -106,16 +112,16 @@ def copy(cls, path, target, host, file=False, **kwargs):
106112
class RemotePuller(object):
107113

108114
@classmethod
109-
def copy(cls, path, target, host, file=False, **kwargs):
115+
def copy(cls, path, target, host, is_file=False, **__):
110116
"""
111117
A better copy command that works from the webs.
112118
113119
Respects the ``MULTIPLE_APP_SERVERS`` setting when copying.
114120
"""
115121
sync_user = getattr(settings, 'SYNC_USER', getpass.getuser())
116-
if not file:
122+
if not is_file:
117123
path += "/"
118-
log.info("Local Copy %s to %s" % (path, target))
124+
log.info("Local Copy %s to %s", path, target)
119125
os.makedirs(target)
120126
# Add a slash when copying directories
121127
sync_cmd = "rsync -e 'ssh -T' -av --delete {user}@{host}:{path} {target}".format(

readthedocs/privacy/loader.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""A namespace of privacy classes configured by settings.
2+
3+
Importing classes from this module allows the classes used to be overridden
4+
using Django settings.
5+
6+
"""
7+
18
from readthedocs.core.utils.extend import SettingsOverrideObject
29
from readthedocs.privacy import backend
310

readthedocs/privacy/templatetags/privacy_tags.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Template tags to query projects by privacy."""
2+
13
from django import template
24

35
from ..loader import AdminPermission

readthedocs/projects/tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ def update_static_metadata(project_pk, path=None):
854854
fh = open(path, 'w+')
855855
json.dump(metadata, fh)
856856
fh.close()
857-
Syncer.copy(path, path, host=socket.gethostname(), file=True)
857+
Syncer.copy(path, path, host=socket.gethostname(), is_file=True)
858858
except (AttributeError, IOError) as e:
859859
log.debug(LOG_TEMPLATE.format(
860860
project=project.slug,

0 commit comments

Comments
 (0)