Skip to content

Commit

Permalink
Use PEP-257 style for docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Filippov committed Jul 5, 2018
1 parent 8a289e5 commit a1e23e3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions mesonwrap/cli.py
Expand Up @@ -44,45 +44,45 @@ def extract_commands(self):
}

def args(self) -> typing.Tuple[str, typing.List[str]]:
'''Returns (program name, list of arguments).'''
"""Returns (program name, list of arguments)."""
func = inspect.stack()[1][3]
command = func[len(self.CMD_PREFIX):]
return ('{} {}'.format(sys.argv[0], command),
sys.argv[2:])

def command_serve(self):
'''Run server'''
"""Run server"""
APP.debug = True
APP.run(host='0.0.0.0')

def command_review(self):
'''Review wrap PR'''
"""Review wrap PR"""
reviewtool.main(*self.args())

def command_new_repo(self):
'''Create and push new wrap repository'''
"""Create and push new wrap repository"""
repoinit.new_repo(*self.args())

def command_new_version(self):
'''Create new version and prefill upstream.wrap'''
"""Create new version and prefill upstream.wrap"""
repoinit.new_version(*self.args())

def command_refresh_repo(self):
'''Refresh statically created file'''
"""Refresh statically created file"""
repoinit.refresh(*self.args())

def command_wrapcreate(self):
'''Create wrap from remote repository'''
"""Create wrap from remote repository"""
wrapcreator.main(*self.args())

def command_wrapupdate(self):
'''Create wrap and import it into local database'''
"""Create wrap and import it into local database"""
wrapupdater.main(*self.args())

def command_dbtool(self):
'''This is a simple tool to do queries and inserts'''
"""This is a simple tool to do queries and inserts"""
dbtool.main(*self.args())

def command_import_from_hosted(self):
'''Import projects from wrapdb into github'''
"""Import projects from wrapdb into github"""
import_from_hosted.main(*self.args())
4 changes: 2 additions & 2 deletions mesonwrap/gitutils.py
Expand Up @@ -26,11 +26,11 @@ def open(cls, repo: git.Repo, path, mode='r'):


def get_revision(repo: git.Repo, commit=None):
'''Get revision from repo and commit.
"""Get revision from repo and commit.
Revision is a number of commits between specified commit
and first commit with upstream.wrap or commit tagged with [wrap version]
in message.'''
in message."""
# BFS over acyclic graph
# revision is number of commits we visit
# we cut off BFS by '[wrap revision]' and 'upstream.wrap'
Expand Down
4 changes: 2 additions & 2 deletions mesonwrap/tools/repoinit.py
Expand Up @@ -63,7 +63,7 @@
class RepoBuilder:

def __init__(self, name, path=None, organization=None, homepage=None):
'''Pushes to github only if organization is set'''
"""Pushes to github only if organization is set."""
self.name = name
try:
self.repo = git.Repo(path)
Expand All @@ -78,7 +78,7 @@ def __init__(self, name, path=None, organization=None, homepage=None):
self.init_github(path, organization, homepage)

def init(self, path, origin=None):
'''Push if origin is not None'''
"""Push if origin is not None."""
self.repo = git.Repo.init(path)
self.refresh('Create repository for project %s' % self.name)
if origin is not None:
Expand Down
12 changes: 6 additions & 6 deletions mesonwrap/tools/reviewtool.py
Expand Up @@ -31,15 +31,15 @@ class CheckError(Exception):
pass


def print_status(msg, check, fatal=True, quiet=False):
'''Prints msg with success indicator based on check parameter.
def print_status(msg, check: bool, fatal: bool = True, quiet: bool = False):
"""Prints msg with success indicator based on check parameter.
Args:
msg: str, status message to print
check: bool, success of the check
fatal: bool, if exception should be raised
quiet: bool, if message should be printed on success
check: success of the check
fatal: if exception should be raised
quiet: if message should be printed on success
Raises: CheckError(msg) if not check and fatal
'''
"""
OK_CHR = '\u2611'
FAIL_CHR = '\u2612'
status = OK_CHR if check else FAIL_CHR
Expand Down
6 changes: 3 additions & 3 deletions mesonwrap/webapi.py
Expand Up @@ -261,14 +261,14 @@ def _get_project_names(self):
return self._api.fetch_v1_projects()['projects']

def projects(self):
'''Returns new version of ProjectSet.
"""Returns new version of ProjectSet.
All operations on ProjectSet are cached.
'''
"""
return ProjectSet(self._api)

def ping(self):
'''Returns True if able to connect'''
"""Returns True if able to connect."""
try:
self._api.fetch('/')
return True
Expand Down
6 changes: 3 additions & 3 deletions run_integration_tests.py
Expand Up @@ -177,23 +177,23 @@ def test_latest(self):
self.assertLatest('test1', '1.3.0', 3)

def test_latest_semantic_version_comparison(self):
'''Lexicographical comparison leads to the opposite results.'''
"""Lexicographical comparison leads to the opposite results."""
f = FakeProject('test', self.tmpdir)
for version in ['1.2.8', '1.2.11']:
f.create_version(version)
self.wrapupdater(f.name, f.url, version)
self.assertLatest('test', '1.2.11', 1)

def test_latest_non_semantic_version_no_minor(self):
'''Not every project supports semantic versioning, test fallback.'''
"""Not every project supports semantic versioning, test fallback."""
f = FakeProject('test', self.tmpdir)
for version in ['1.2', '1.3', '1.7']:
f.create_version(version)
self.wrapupdater(f.name, f.url, version)
self.assertLatest(f.name, '1.7', 1)

def test_latest_non_semantic_version_single_number(self):
'''If it is not a semantic version just sort lexicographically.'''
"""If it is not a semantic version just sort lexicographically."""
f = FakeProject('test', self.tmpdir)
for version in ['212345', '123456']:
f.create_version(version)
Expand Down

0 comments on commit a1e23e3

Please sign in to comment.