add-miniconda: add docstrings to several key functions (#2197)

This commit is contained in:
Fluency 2021-12-23 14:01:28 -04:00 committed by GitHub
parent 40d35f84b4
commit 423de9ae8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -130,6 +130,9 @@ class MinicondaVersion(NamedTuple):
@classmethod @classmethod
def from_str(cls, s): def from_str(cls, s):
"""
Convert a string of the form "miniconda_n-ver" or "miniconda_n-py_ver-ver" to a :class:`MinicondaVersion` object.
"""
components = s.split("-") components = s.split("-")
if len(components) == 3: if len(components) == 3:
miniconda_n, py_ver, ver = components miniconda_n, py_ver, ver = components
@ -146,6 +149,9 @@ class MinicondaVersion(NamedTuple):
return f"miniconda{self.suffix}-{self.version_str}" return f"miniconda{self.suffix}-{self.version_str}"
def default_py_version(self): def default_py_version(self):
"""
:class:`PyVersion` of Python used with this Miniconda version
"""
if self.py_version: if self.py_version:
return self.py_version return self.py_version
elif self.suffix == Suffix.TWO: elif self.suffix == Suffix.TWO:
@ -188,6 +194,9 @@ class MinicondaSpec(NamedTuple):
return spec return spec
def to_install_lines(self): def to_install_lines(self):
"""
Installation command for this version of Miniconda for use in a Pyenv installation script
"""
return install_line_fmt.format( return install_line_fmt.format(
repo=MINICONDA_REPO, repo=MINICONDA_REPO,
suffix=self.version.suffix, suffix=self.version.suffix,
@ -213,6 +222,11 @@ def make_script(specs: List[MinicondaSpec]):
def get_existing_minicondas(): def get_existing_minicondas():
"""
Enumerate existing Miniconda installation scripts in share/python-build/ except rolling releases.
:returns: A generator of :class:`MinicondaVersion` objects.
"""
logger.info("Getting known miniconda versions") logger.info("Getting known miniconda versions")
for p in out_dir.iterdir(): for p in out_dir.iterdir():
name = p.name name = p.name
@ -228,6 +242,12 @@ def get_existing_minicondas():
def get_available_minicondas(): def get_available_minicondas():
"""
Fetch remote miniconda versions.
:returns: A generator of :class:`MinicondaSpec` objects for each release available for download
except rolling releases.
"""
logger.info("Fetching remote miniconda versions") logger.info("Fetching remote miniconda versions")
session = requests_html.HTMLSession() session = requests_html.HTMLSession()
response = session.get(MINICONDA_REPO) response = session.get(MINICONDA_REPO)