diff --git a/prospector-more.yml b/prospector-more.yml index c12a686a734..4e0aafc3909 100644 --- a/prospector-more.yml +++ b/prospector-more.yml @@ -6,7 +6,6 @@ ignore-paths: - core/ - doc_builder/ - donate/ - - privacy/ - projects/ - redirects/ - restapi/ diff --git a/readthedocs/privacy/backend.py b/readthedocs/privacy/backend.py index 95d5dc944ed..674765bb733 100644 --- a/readthedocs/privacy/backend.py +++ b/readthedocs/privacy/backend.py @@ -1,3 +1,4 @@ +"""Django Managers and Querysets to apply project privacy restrictions.""" from django.db import models from guardian.shortcuts import get_objects_for_user @@ -85,7 +86,7 @@ def from_queryset(cls, queryset_class, class_name=None): # no direct members. queryset_class = get_override_class( VersionQuerySet, - VersionQuerySet._default_class + VersionQuerySet._default_class # pylint: disable=protected-access ) return super(VersionManager, cls).from_queryset(queryset_class, class_name) diff --git a/readthedocs/privacy/backends/syncers.py b/readthedocs/privacy/backends/syncers.py index 25c97d5dc65..9659c775e8b 100644 --- a/readthedocs/privacy/backends/syncers.py +++ b/readthedocs/privacy/backends/syncers.py @@ -1,3 +1,9 @@ +"""Classes allowing copying files around. + +"Syncers" copy files from the local machine, while "Pullers" copy files to +the local machine. + +""" import getpass import logging import os @@ -11,10 +17,10 @@ class LocalSyncer(object): @classmethod - def copy(cls, path, target, file=False, **kwargs): + def copy(cls, path, target, is_file=False, **__): """A copy command that works with files or directories.""" - log.info("Local Copy %s to %s" % (path, target)) - if file: + log.info("Local Copy %s to %s", path, target) + if is_file: if path == target: # Don't copy the same file over itself return @@ -30,7 +36,7 @@ def copy(cls, path, target, file=False, **kwargs): class RemoteSyncer(object): @classmethod - def copy(cls, path, target, file=False, **kwargs): + def copy(cls, path, target, is_file=False, **__): """ A better copy command that works with files or directories. @@ -39,14 +45,14 @@ def copy(cls, path, target, file=False, **kwargs): sync_user = getattr(settings, 'SYNC_USER', getpass.getuser()) app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', []) if app_servers: - log.info("Remote Copy %s to %s" % (path, target)) + log.info("Remote Copy %s to %s on %s", path, target, app_servers) for server in app_servers: mkdir_cmd = ("ssh %s@%s mkdir -p %s" % (sync_user, server, target)) ret = os.system(mkdir_cmd) if ret != 0: log.info("COPY ERROR to app servers:") log.info(mkdir_cmd) - if file: + if is_file: slash = "" else: slash = "/" @@ -68,7 +74,7 @@ def copy(cls, path, target, file=False, **kwargs): class DoubleRemotePuller(object): @classmethod - def copy(cls, path, target, host, file=False, **kwargs): + def copy(cls, path, target, host, is_file=False, **__): """ A better copy command that works from the webs. @@ -76,11 +82,11 @@ def copy(cls, path, target, host, file=False, **kwargs): """ sync_user = getattr(settings, 'SYNC_USER', getpass.getuser()) app_servers = getattr(settings, 'MULTIPLE_APP_SERVERS', []) - if not file: + if not is_file: path += "/" - log.info("Remote Copy %s to %s" % (path, target)) + log.info("Remote Copy %s to %s", path, target) for server in app_servers: - if not file: + if not is_file: mkdir_cmd = "ssh {user}@{server} mkdir -p {target}".format( user=sync_user, server=server, target=target ) @@ -106,16 +112,16 @@ def copy(cls, path, target, host, file=False, **kwargs): class RemotePuller(object): @classmethod - def copy(cls, path, target, host, file=False, **kwargs): + def copy(cls, path, target, host, is_file=False, **__): """ A better copy command that works from the webs. Respects the ``MULTIPLE_APP_SERVERS`` setting when copying. """ sync_user = getattr(settings, 'SYNC_USER', getpass.getuser()) - if not file: + if not is_file: path += "/" - log.info("Local Copy %s to %s" % (path, target)) + log.info("Local Copy %s to %s", path, target) os.makedirs(target) # Add a slash when copying directories sync_cmd = "rsync -e 'ssh -T' -av --delete {user}@{host}:{path} {target}".format( diff --git a/readthedocs/privacy/loader.py b/readthedocs/privacy/loader.py index bb0829a496d..7e973b23481 100644 --- a/readthedocs/privacy/loader.py +++ b/readthedocs/privacy/loader.py @@ -1,3 +1,10 @@ +"""A namespace of privacy classes configured by settings. + +Importing classes from this module allows the classes used to be overridden +using Django settings. + +""" + from readthedocs.core.utils.extend import SettingsOverrideObject from readthedocs.privacy import backend diff --git a/readthedocs/privacy/templatetags/privacy_tags.py b/readthedocs/privacy/templatetags/privacy_tags.py index 6edebd8e108..335d7ed5d3b 100644 --- a/readthedocs/privacy/templatetags/privacy_tags.py +++ b/readthedocs/privacy/templatetags/privacy_tags.py @@ -1,3 +1,5 @@ +"""Template tags to query projects by privacy.""" + from django import template from ..loader import AdminPermission diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py index c79ee0a1188..c7a492717b8 100644 --- a/readthedocs/projects/tasks.py +++ b/readthedocs/projects/tasks.py @@ -854,7 +854,7 @@ def update_static_metadata(project_pk, path=None): fh = open(path, 'w+') json.dump(metadata, fh) fh.close() - Syncer.copy(path, path, host=socket.gethostname(), file=True) + Syncer.copy(path, path, host=socket.gethostname(), is_file=True) except (AttributeError, IOError) as e: log.debug(LOG_TEMPLATE.format( project=project.slug,