API Reference

class seaport.portfile.Port(name)[source]

Scrapes portfile info for usage in Python modules.

Examples

>>> from seaport.portfile import Port
>>> port = Port("py-base91")
>>> port.version
'1.0.1'
>>> from seaport.portfile import Port
>>> port = Port("py-base91")
>>> port.revision
0
>>> from seaport.portfile import Port
>>> try:
...     port = Port("non-existent-port")
... except RuntimeError:
...     pass
>>> # This raises an exception
Parameters:

name (str) –

name

The name of the port e.g. gping

Type:

str

checksums(_name=None)[source]

Determines the current checksums of a portfile.

For python ports, their pyXY- subport is used to determine the checksums. Note that this method only works for ports with the standard rmd/sha/size setup (not the older format), and it can also be quite slow since it’s scraping port distfiles NAME

Examples

>>> # Determines rmd160/sha256/size/website
>>> from seaport.portfile import Port
>>> port = Port("py-base91")
>>> port.checksums()
('c1bd97759a8d7bfdb95cd76ada05efa9e9d99f28', '5b284a2ba3c97be1eb9473f3af94a9bf141d61005d836e75e645d2798da58799', '2331', 'https://files.pythonhosted.org/packages/source/b/base91/base91-1.0.1.tar.gz')
Returns:

rmd160, sha256, size and the website that provided the distfile.

Parameters:

_name (Optional[str]) –

Return type:

Tuple[str, str, str, str]

livecheck()[source]

Runs port livecheck to check for any new versions.

If no livecheck is available or the portfile is already the latest version, the current version is outputted. Note that this can be slow, since it’s scraping port livecheck.

Examples

>>> from seaport.portfile import Port
>>> port = Port("py-base91")
>>> port.livecheck()
'1.0.1'
>>> from seaport.portfile import Port
>>> port = Port("py39-base91")
>>> port.livecheck()
'1.0.1'
Returns:

A string representing the latest version.

Return type:

str

primary_category()[source]

Determines the first category of a port.

This is useful to determine which folder of the macports repo the port would reside in.

Examples

>>> from seaport.portfile import Port
>>> port = Port("gping")
>>> port.primary_category()
'net'
Returns:

The category of the port e.g. sysutils.

Return type:

str

static rightcapitalised(input_name, port_path='/opt/local/bin')[source]

Get the correct capitalisation of a port.

Parameters:
  • input_name (str) – The potentially wrong-capitalised name of a port

  • port_path (str) – The path to the port binary (default /opt/local/bin)

Returns:

Tuple[str, str]

A tuple representing the right-capitalised name and the scraped

port info.

Return type:

Tuple[str, str]

subports()[source]

Determines a list of subports of a port.

If there are no subports available, None is outputted.

Examples

>>> # Subports available
>>> from seaport.portfile import Port
>>> port = Port("py-base91")
>>> port.subports()
['py38-base91', 'py39-base91']
>>> # Subports not available
>>> from seaport.portfile import Port
>>> port = Port("folderify")
>>> print(port.subports())
None
Returns:

A list representing all the subports of the port.

Return type:

Optional[List[str]]