Update and fix the docstrings

This commit is contained in:
Vineet 2014-05-11 00:29:06 +05:30
parent 435dfa6ada
commit ec6c2c6cc2
1 changed files with 34 additions and 12 deletions

View File

@ -11,8 +11,9 @@ flatten = chain.from_iterable
def req_version(req): def req_version(req):
"""Builds the version string for the requirement instance """Builds the version string for the requirement instance
:param req : representing requirement :param req: requirement object
:rtype : string or NoneType :returns: the version in desired format
:rtype: string or NoneType
""" """
return ''.join(req.specs[0]) if req.specs else None return ''.join(req.specs[0]) if req.specs else None
@ -21,10 +22,13 @@ def req_version(req):
def top_pkg_name(pkg): def top_pkg_name(pkg):
"""Builds the package name for top level package """Builds the package name for top level package
The format is the same that's used by `pip freeze` This just prints the name and the version of the package which may
not necessarily match with the output of `pip freeze` which also
includes info such as VCS source for editable packages
:param pkg : pkg_resources.Distribution :param pkg: pkg_resources.Distribution
:rtype : string :returns: the package name and version in the desired format
:rtype: string
""" """
return '{}=={}'.format(pkg.project_name, pkg.version) return '{}=={}'.format(pkg.project_name, pkg.version)
@ -37,9 +41,10 @@ def non_top_pkg_name(req, pkg):
version as well as the version required by it's parent package version as well as the version required by it's parent package
will be specified with it's name will be specified with it's name
:param req : requirements instance :param req: requirements instance
:param pkg : pkg_resources.Distribution :param pkg: pkg_resources.Distribution
:rtype : string :returns: the package name and version in the desired format
:rtype: string
""" """
vers = [] vers = []
@ -55,19 +60,36 @@ def non_top_pkg_name(req, pkg):
def top_pkg_src(pkg): def top_pkg_src(pkg):
"""Returns the frozen package name
The may or may not be the same as the package name.
:param pkg: pkg_resources.Distribution
:returns: frozen name of the package
:rtype: string
"""
return str(pip.FrozenRequirement.from_dist(pkg, [])).strip() return str(pip.FrozenRequirement.from_dist(pkg, [])).strip()
def non_top_pkg_src(_, pkg): def non_top_pkg_src(_req, pkg):
"""FIXME! briefly describe function
:param _req: the requirements instance
:param pkg: pkg_resources.Distribution
:returns: frozen name of the package
:rtype: string
"""
return top_pkg_src(pkg) return top_pkg_src(pkg)
def render_tree(pkgs, freeze, list_all): def render_tree(pkgs, freeze, list_all):
"""Renders a package dependency tree """Renders a package dependency tree
:param pkgs : list of pkg_resources.Distribution :param pkgs: list of pkg_resources.Distribution
:param list_all : boolean :param list_all: boolean
:rtype : string :rtype: string
""" """
pkg_index = {p.key: p for p in pkgs} pkg_index = {p.key: p for p in pkgs}