graviti.portex.package#

Package related class.

Module Contents#

Classes#

Package

The base class of Portex package.

BuiltinPackage

The builtin Portex package used to manage builtin types.

LocalPackage

The local Portex package used to manage local types.

ExternalPackage

The external Portex package used to manage external types.

Subpackage

The subset of Portex package, used in Imports.

Packages

The package manager to manage different Portex packages.

Imports

The imports of the Portex template type.

Attributes#

class graviti.portex.package.Package[source]#

Bases: graviti.utility.AttrDict[_T]

The base class of Portex package.

class graviti.portex.package.BuiltinPackage[source]#

Bases: Package[Type[graviti.portex.builtin.PortexBuiltinType]]

The builtin Portex package used to manage builtin types.

class graviti.portex.package.LocalPackage[source]#

Bases: Package[Type[graviti.portex.base.PortexType]]

The local Portex package used to manage local types.

class graviti.portex.package.ExternalPackage(url, revision)[source]#

Bases: Package[Type[graviti.portex.external.PortexExternalType]]

The external Portex package used to manage external types.

Parameters
  • url (str) – The git repo url of the external package.

  • revision (str) – The git repo revision (tag/commit) of the external package.

property repo(self)[source]#

The repo string of the package.

Returns

The “<url>@<rev>” format repo string.

Return type

str

class graviti.portex.package.Subpackage(package)[source]#

Bases: graviti.utility.UserMapping[str, Type[graviti.portex.external.PortexExternalType]]

The subset of Portex package, used in Imports.

Parameters

package (ExternalPackage) – The source package of this subpackage.

classmethod from_pyobj(cls, content)[source]#

Create Subpackage instance from python dict.

Parameters

content (Dict[str, Any]) – A python dict representing a subpackage.

Returns

A Subpackage instance created from the input python dict.

Return type

Subpackage

to_pyobj(self)[source]#

Dump the instance to a python dict.

Returns

A python dict representation of the Subpackage instance.

Return type

Dict[str, Any]

class graviti.portex.package.Packages[source]#

The package manager to manage different Portex packages.

graviti.portex.package.packages[source]#
class graviti.portex.package.Imports[source]#

Bases: Mapping[str, Type[graviti.portex.base.PortexType]], graviti.utility.ReprMixin

The imports of the Portex template type.

Parameters

package – The package the portex belongs to.

update(self, other)[source]#

Update the imports with another imports.

Parameters

other (Imports) – An Imports instance whose types need to be updated to this imports.

Return type

None

classmethod from_pyobj(cls, content)[source]#

Create Imports instance from python list.

Parameters
  • content (List[Dict[str, Any]]) – A python list representing imported types.

  • cls (Type[_I]) –

Returns

A Imports instance created from the input python list.

Return type

_I

to_pyobj(self)[source]#

Dump the instance to a python list.

Returns

A python list representation of the Portex imported types.

Return type

List[Dict[str, Any]]

add_subpackage(self, subpackage)[source]#

Add subpackage to this Imports instance.

Parameters

subpackage (Subpackage) – The subpackage which needs to be added.

Raises

KeyError – When there are duplicate names in the imports instance.

Return type

None