Skip to content

Commit 125421e

Browse files
alexwlchanagjohnson
authored andcommitted
Docstring/PEP 257 fixes for the vcs_support app (#2823)
1 parent 212be7e commit 125421e

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

readthedocs/vcs_support/backends/git.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ def branches(self):
131131

132132
def parse_branches(self, data):
133133
"""
134-
Parse output of git branch -r, eg:
134+
Parse output of git branch -r
135+
136+
e.g.:
137+
135138
origin/2.0.X
136139
origin/HEAD -> origin/master
137140
origin/develop

readthedocs/vcs_support/backends/hg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ def branches(self):
4949
return self.parse_branches(stdout)
5050

5151
def parse_branches(self, data):
52-
"""
53-
stable
54-
default
55-
"""
56-
52+
"""Stable / default"""
5753
names = [name.lstrip() for name in data.splitlines()]
5854
return [VCSVersion(self, name, name) for name in names if name]
5955

readthedocs/vcs_support/base.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
class VCSVersion(object):
13+
1314
"""
1415
Represents a Version (tag or branch) in a VCS.
1516
@@ -18,6 +19,7 @@ class VCSVersion(object):
1819
It can act as a context manager to temporarily switch to this tag (eg to
1920
build docs for this tag).
2021
"""
22+
2123
def __init__(self, repository, identifier, verbose_name):
2224
self.repository = repository
2325
self.identifier = identifier
@@ -30,23 +32,23 @@ def __repr__(self):
3032

3133
class VCSProject(namedtuple("VCSProject",
3234
"name default_branch working_dir repo_url")):
35+
3336
"""Transient object to encapsulate a projects stuff"""
37+
3438
pass
3539

3640

3741
class BaseCLI(object):
38-
"""
39-
Helper class for CLI-heavy classes.
40-
"""
42+
43+
"""Helper class for CLI-heavy classes."""
44+
4145
log_tmpl = u'VCS[{name}:{ident}]: {args}'
4246

4347
def __call__(self, *args):
4448
return self.run(args)
4549

4650
def run(self, *args):
47-
"""
48-
:param bits: list of command and args. See `subprocess` docs
49-
"""
51+
""":param bits: list of command and args. See `subprocess` docs"""
5052
process = subprocess.Popen(args, stdout=subprocess.PIPE,
5153
stderr=subprocess.PIPE,
5254
cwd=self.working_dir, shell=False,
@@ -74,10 +76,13 @@ def env(self):
7476

7577

7678
class BaseVCS(BaseCLI):
79+
7780
"""
7881
Base for VCS Classes.
82+
7983
Built on top of the BaseCLI.
8084
"""
85+
8186
supports_tags = False # Whether this VCS supports tags or not.
8287
supports_branches = False # Whether this VCS supports branches or not.
8388

@@ -96,12 +101,14 @@ def check_working_dir(self):
96101
os.makedirs(self.working_dir)
97102

98103
def make_clean_working_dir(self):
99-
"Ensures that the working dir exists and is empty"
104+
"""Ensures that the working dir exists and is empty"""
100105
shutil.rmtree(self.working_dir, ignore_errors=True)
101106
self.check_working_dir()
102107

103108
def update(self):
104109
"""
110+
Update a local copy of the repository in self.working_dir.
111+
105112
If self.working_dir is already a valid local copy of the repository,
106113
update the repository, else create a new local copy of the repository.
107114
"""
@@ -116,24 +123,24 @@ def update(self):
116123
@property
117124
def tags(self):
118125
"""
119-
Returns a list of VCSVersion objects. See VCSVersion for more
120-
information.
126+
Returns a list of VCSVersion objects.
127+
128+
See VCSVersion for more information.
121129
"""
122130
raise NotImplementedError
123131

124132
@property
125133
def branches(self):
126134
"""
127-
Returns a list of VCSVersion objects. See VCSVersion for more
128-
information.
135+
Returns a list of VCSVersion objects.
136+
137+
See VCSVersion for more information.
129138
"""
130139
raise NotImplementedError
131140

132141
@property
133142
def commit(self):
134-
"""
135-
Returns a string representing the current commit.
136-
"""
143+
"""Returns a string representing the current commit."""
137144
raise NotImplementedError
138145

139146
def checkout(self, identifier=None):

readthedocs/vcs_support/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class LockTimeout(Exception):
1111

1212

1313
class Lock(object):
14+
1415
"""
1516
A simple file based lock with timeout
1617
@@ -58,6 +59,7 @@ def __exit__(self, exc, value, tb):
5859

5960

6061
class NonBlockingLock(object):
62+
6163
"""
6264
Instead of waiting for a lock, depending on the lock file age, either
6365
acquire it immediately or throw LockTimeout

0 commit comments

Comments
 (0)