MECO™ API Reference
Public Member Functions | Static Public Member Functions | List of all members
mMecoPackage.packageLib.Package Class Reference

[ CLASS ] - Class to operate on Meco packages. More...

Inheritance diagram for mMecoPackage.packageLib.Package:

Public Member Functions

def __init__ (self, path=None)
 Constructor. More...
 
def __str__ (self)
 String representation. More...
 
def setPackage (self, path)
 Set a package. More...
 
PROPERTIES
def name (self)
 Property. More...
 
def version (self)
 Property. More...
 
def description (self)
 Property. More...
 
def keywords (self)
 Property. More...
 
def platforms (self)
 Platforms. More...
 
def documents (self)
 Documents. More...
 
def applications (self)
 Applications. More...
 
def pythonVersions (self)
 Python versions. More...
 
def isActive (self)
 Property. More...
 
def isExternal (self)
 Property. More...
 
def developers (self)
 Property. More...
 
def dependentPackages (self)
 Property. More...
 
def pythonPackages (self)
 Property. More...
 
def isVersioned (self)
 Property. More...
 
def path (self)
 Property. More...
 
REPRESENTATION
def asStr (self)
 Get string representation of the class. More...
 
def asDict (self)
 Get package information as a dict instance. More...
 
def asHTML (self)
 Get HTML representation of the package. More...
 
CREATE
def createPythonPackage (self, pythonPackageName)
 Create a Python module for the given Python package. More...
 
def createPythonModule (self, pythonModuleName, pythonPackageName=None)
 Create a Python module for the given Python package of the package. More...
 
RELEASE
def getPackageReleaseRelativePath (self)
 Get relative release path of the package. More...
 
def getReleaseFiles (self, relative=True)
 Get files to be released. More...
 
CONTENT
def getPythonPackages (self, ignoreDefault=False)
 Get Python package names contained by this package. More...
 
def getLocalDocument (self, folder)
 Get absolute path of the requested local document. More...
 
def getLineOfCode (self)
 Get line of code contained by this package. More...
 
def getFiles (self, folder, pythonPackageName=None, absPath=True, extension=None, suffix=None)
 Get files for the requested local folder of the package. More...
 
def runUnitTests (self, pythonPackageName=None)
 Run unit tests of the package. More...
 
LOCATION
def getLocation (self)
 Get location of the packages, where this package belongs to. More...
 
def getPythonPath (self)
 Get the Python path of the package in PATH/PACKAGE_NAME/python format. More...
 
def getPythonPackagePath (self, pythonPackageName=None)
 Get the Python package path for given pythonPackageName in PATH/PACKAGE_NAME/python/PACKAGE_NAME format. More...
 
def getLocalPath (self, relativePath)
 Get absolute path of given relativePath of the package. More...
 

Static Public Member Functions

def getRootOfThisPackage ()
 Get the root of this particular package. More...
 
QUERY
def isRootOfAPackage (path)
 Check whether the given path is root of a package. More...
 
def isInfoModuleFile (path)
 Check whether given path is a package info module file. More...
 
DISCOVER
def getPackageName (path)
 Get package name from given package info module file path. More...
 
def getInfoModuleFile (path)
 Get package info module file path from given path. More...
 
def getInfoModule (path)
 Get package info module from given path. More...
 
def getPackageByImport (name)
 Import package and get Package class instance that represents it. More...
 
def list ()
 List all packages. More...
 
CREATE A PACKAGE
def create (name, description='', path=os.getcwd(), external=False)
 Create a package. More...
 

Detailed Description

[ CLASS ] - Class to operate on Meco packages.

Constructor & Destructor Documentation

◆ __init__()

def mMecoPackage.packageLib.Package.__init__ (   self,
  path = None 
)

Constructor.

Parameters
path[ str | None | in ] - Absolute path of an package info module.
Exceptions
N/A
Returns
None - None.

Member Function Documentation

◆ __str__()

def mMecoPackage.packageLib.Package.__str__ (   self)

String representation.

Exceptions
N/A
Returns
str - String representation.

◆ name()

def mMecoPackage.packageLib.Package.name (   self)

Property.

Exceptions
N/A
Returns
str - Name.

◆ version()

def mMecoPackage.packageLib.Package.version (   self)

Property.

Exceptions
N/A
Returns
str - Version.

◆ description()

def mMecoPackage.packageLib.Package.description (   self)

Property.

Exceptions
N/A
Returns
str - Description.

◆ keywords()

def mMecoPackage.packageLib.Package.keywords (   self)

Property.

Exceptions
N/A
Returns
list of str - Keywords.

◆ platforms()

def mMecoPackage.packageLib.Package.platforms (   self)

Platforms.

Exceptions
N/A
Returns
list of str - Platforms.

◆ documents()

def mMecoPackage.packageLib.Package.documents (   self)

Documents.

Exceptions
N/A
Returns
list of dict - Keys of dict instances are: title, url.

◆ applications()

def mMecoPackage.packageLib.Package.applications (   self)

Applications.

Exceptions
N/A
Returns
list of str - Applications.

◆ pythonVersions()

def mMecoPackage.packageLib.Package.pythonVersions (   self)

Python versions.

Exceptions
N/A
Returns
list of str - Python versions.

◆ isActive()

def mMecoPackage.packageLib.Package.isActive (   self)

Property.

Exceptions
N/A
Returns
bool - Whether this package is active (in use).

◆ isExternal()

def mMecoPackage.packageLib.Package.isExternal (   self)

Property.

Exceptions
N/A
Returns
bool - Whether this package is external.

◆ developers()

def mMecoPackage.packageLib.Package.developers (   self)

Property.

Exceptions
N/A
Returns
list of str - Developers.

◆ dependentPackages()

def mMecoPackage.packageLib.Package.dependentPackages (   self)

Property.

Exceptions
N/A
Returns
list of str - Dependent packages.

◆ pythonPackages()

def mMecoPackage.packageLib.Package.pythonPackages (   self)

Property.

Exceptions
N/A
Returns
list of str - Python packages contained by this package.

◆ isVersioned()

def mMecoPackage.packageLib.Package.isVersioned (   self)

Property.

Exceptions
N/A
Returns
bool - Result.

◆ path()

def mMecoPackage.packageLib.Package.path (   self)

Property.

Exceptions
N/A
Returns
str - Path.

◆ setPackage()

def mMecoPackage.packageLib.Package.setPackage (   self,
  path 
)

Set a package.

Parameters
path[ str | None | in ] - Absolute path of an package info module.
Exceptions
AttributeError- If package info module doesn't have a required attribute.
Returns
None - None.

◆ asStr()

def mMecoPackage.packageLib.Package.asStr (   self)

Get string representation of the class.

Exceptions
N/A
Returns
str - Information about the package in human readable form.

◆ asDict()

def mMecoPackage.packageLib.Package.asDict (   self)

Get package information as a dict instance.

Keys of the returned dict instance are available in mMecoPackage.enumLib.PackageInfoModuleAttribute enum class. Additionally PATH and IS_VERSIONED keys are dynamically added to the returned dict instance.

Exceptions
N/A
Returns
dict - Package information.

◆ asHTML()

def mMecoPackage.packageLib.Package.asHTML (   self)

Get HTML representation of the package.

This method provides information so it can be used on a GUI such as about dialog.

Exceptions
N/A
Returns
str - Information about the package in human readable form in HTML format.

◆ createPythonPackage()

def mMecoPackage.packageLib.Package.createPythonPackage (   self,
  pythonPackageName 
)

Create a Python module for the given Python package.

Parameters
pythonPackageName[ str | None | in ] - Name of the Python package under this package, which the Python module will be created for.
Exceptions
mMecoPackage.exceptionLib.PackageLocationError- If this package is versioned.
mMecoPackage.exceptionLib.PythonPackageNameError- If a Python package with given name already exists under this package.
Returns
str - Absolute path of the created Python package in PATH/PACKAGE_NAME/python/PYTHON_PACKAGE_NAME format.
None - If no package has been set.

◆ createPythonModule()

def mMecoPackage.packageLib.Package.createPythonModule (   self,
  pythonModuleName,
  pythonPackageName = None 
)

Create a Python module for the given Python package of the package.

Parameters
pythonModuleName[ str | None | in ] - Name of the Python module to be created.
pythonPackageName[ str | None | in ] - Name of the Python package under this package, which the Python module will be created in.
Exceptions
mMecoPackage.exceptionLib.PackageLocationError- If this package is versioned.
mMecoPackage.exceptionLib.PythonPackageDoesNotExist- If no relevant Python package found for Python module creation.
Returns
list of str - Absolute path of the created Python modules, first one is the module, second one is the unit test module.
None - If no package has been set.

◆ getPackageReleaseRelativePath()

def mMecoPackage.packageLib.Package.getPackageReleaseRelativePath (   self)

Get relative release path of the package.

This is the release destination path that includes the version.

Return format: PACKAGE_NAME/VERSION/PACKAGE_NAME (i.e. mQtWidgets/1.4.8/mQtWidgets)

Exceptions
N/A
Returns
str - Relative path.

◆ getReleaseFiles()

def mMecoPackage.packageLib.Package.getReleaseFiles (   self,
  relative = True 
)

Get files to be released.

Parameters
relative[ bool | True | in ] - Whether the file paths should be relative to root of the package.
Exceptions
N/A
Returns
list of str - Path of the files.
None - If no package has been set.

◆ getPythonPackages()

def mMecoPackage.packageLib.Package.getPythonPackages (   self,
  ignoreDefault = False 
)

Get Python package names contained by this package.

Python packages are located in PATH/PACKAGE_NAME/python folder.

Parameters
ignoreDefault[ bool | False | in ] - Whether to ignore default package, which is the package with the same name as this package.
Exceptions
N/A
Returns
list of str - Package names, empty if no package has been set.

◆ getLocalDocument()

def mMecoPackage.packageLib.Package.getLocalDocument (   self,
  folder 
)

Get absolute path of the requested local document.

The following values can be provided as folder.

  • mMecoPackage.enumLib.FolderStructure.kDocCPPAPIReference
  • mMecoPackage.enumLib.FolderStructure.kDocPythonAPIReference
Parameters
folder[ str | None | in ] - Document folder.
Exceptions
N/A
Returns
str - Absolute path of the help file.
None - If help file doesn't exist.
None - If no package has been set.

◆ getLineOfCode()

def mMecoPackage.packageLib.Package.getLineOfCode (   self)

Get line of code contained by this package.

Exceptions
N/A
Returns
dict - Keys are, python and cpp.
None - If no package has been set.

◆ getFiles()

def mMecoPackage.packageLib.Package.getFiles (   self,
  folder,
  pythonPackageName = None,
  absPath = True,
  extension = None,
  suffix = None 
)

Get files for the requested local folder of the package.

If mMecoPackage.enumLib.FolderStructure.kPython is provided for folder argument, folder will be set as PATH/PACKAGE_NAME/python/PYTHON_PACKAGE_NAME.

If no value provided for pythonPackageName argument, name of the package will be used.

Parameters
folder[ str | None | in ] - Enum value from mMecoPackage.enumLib.FolderStructure.
pythonPackageName[ str | None | in ] - Name of the Python package.
absPath[ bool | True | in ] - Whether to list files with absolute path.
extension[ str | None | in ] - List files only with given extension.
suffix[ str | None | in ] - List files only with given suffix.
Exceptions
IOError- If requested local folder doesn't exist.
Returns
list of str - Files.
None - If no package has been set.
None - If no file is found.

◆ runUnitTests()

def mMecoPackage.packageLib.Package.runUnitTests (   self,
  pythonPackageName = None 
)

Run unit tests of the package.

Return list contains a dict object for each unit test class. The dict instances contain the following data:

Key Data Type Description
module str Absolute import path of the Python test module.
class str Name of the unit test class.
count int How many tests have been run.
errors list Errors.
failures list Failures.
output str Output.

If no value provided for pythonPackageName argument, Python package with the same name as the package will be used.

Parameters
pythonPackageName[ str | None | in ] - Name of the Python package, which the tests will be run for.
Exceptions
N/A
Returns
list of dict - Result.
None - If no package has been set.

◆ getLocation()

def mMecoPackage.packageLib.Package.getLocation (   self)

Get location of the packages, where this package belongs to.

Since released packages have different path, this method can be used to get the packages path of the package. This is the path where all the packages will be under for any given environment.

Exceptions
N/A
Returns
str - Absolute path of the location of the package.
None - If no package has been set.

◆ getPythonPath()

def mMecoPackage.packageLib.Package.getPythonPath (   self)

Get the Python path of the package in PATH/PACKAGE_NAME/python format.

Exceptions
N/A
Returns
str - Absolute path.
None - If no package has been set.

◆ getPythonPackagePath()

def mMecoPackage.packageLib.Package.getPythonPackagePath (   self,
  pythonPackageName = None 
)

Get the Python package path for given pythonPackageName in PATH/PACKAGE_NAME/python/PACKAGE_NAME format.

If pythonPackageName argument is not provided, name of the package will be used as Python package name.

Parameters
pythonPackageName[ str | None | in ] - Name of the Python package.
Exceptions
N/A
Returns
str - Absolute path.
None - If no package has been set.
None - If no Python package with given name contained by this package.

◆ getLocalPath()

def mMecoPackage.packageLib.Package.getLocalPath (   self,
  relativePath 
)

Get absolute path of given relativePath of the package.

Method doesn't check whether the returned path exists.

Parameters
relativePath[ str | None | in ] - Relative path.
Exceptions
N/A
Returns
str - Absolute path of the requested folder.
None - If no package has been set.

◆ getRootOfThisPackage()

def mMecoPackage.packageLib.Package.getRootOfThisPackage ( )
static

Get the root of this particular package.

Exceptions
N/A
Returns
str - Absolute path of the root of this package.

◆ isRootOfAPackage()

def mMecoPackage.packageLib.Package.isRootOfAPackage (   path)
static

Check whether the given path is root of a package.

Following pattern will be checked: path/PACKAGE_NAME/python/PACKAGE_NAME/packageInfoLib.py against given path.

Parameters
path[ str | None | in ] - Path.
Exceptions
N/A
Returns
bool - Result.

◆ isInfoModuleFile()

def mMecoPackage.packageLib.Package.isInfoModuleFile (   path)
static

Check whether given path is a package info module file.

Method first checks whether given path exists.

Parameters
path[ str | None | in ] - Path.
Exceptions
N/A
Returns
str - Root path of the package, which given path (package info module file) belongs to.
None - If given path is not a package info module file or it doesn't exist.

◆ getPackageName()

def mMecoPackage.packageLib.Package.getPackageName (   path)
static

Get package name from given package info module file path.

Parameters
path[ str | None | in ] - Package info module file path.
Exceptions
N/A
Returns
str - Name of the package.
None - If path doesn't belong to any package or path doesn't exist.

◆ getInfoModuleFile()

def mMecoPackage.packageLib.Package.getInfoModuleFile (   path)
static

Get package info module file path from given path.

Parameters
path[ str | None | in ] - Path, directory or file.
Exceptions
N/A
Returns
str - Absolute path of the package info module file.
None - If package info module file couldn't be found.

◆ getInfoModule()

def mMecoPackage.packageLib.Package.getInfoModule (   path)
static

Get package info module from given path.

Parameters
path[ str | None | in ] - Path, directory or file.
Exceptions
N/A
Returns
str - Absolute path of the package info module file.
module - Imported package info module.

◆ getPackageByImport()

def mMecoPackage.packageLib.Package.getPackageByImport (   name)
static

Import package and get Package class instance that represents it.

Parameters
name[ str | None | in ] - Import name of the package.
Exceptions
N/A
Returns
mMecoPackage.packageLib.Package - Package class instance.
None - If no package with name available .

◆ list()

def mMecoPackage.packageLib.Package.list ( )
static

List all packages.

Method searches packages by using sys.path.

Exceptions
N/A
Returns
list of module - Imported package info Python modules.

◆ create()

def mMecoPackage.packageLib.Package.create (   name,
  description = '',
  path = os.getcwd(),
  external = False 
)
static

Create a package.

Method doesn't touch existing files.

Parameters
name[ str | None | in ] - Name of the package.
description[ str | None | in ] - Description about the package.
path[ str | None | in ] - Path, where the package will be created.
external[ bool | None | in ] - Whether this package should be marked external.
Exceptions
N/A
Returns
mMecoPackage.packageLib.Package - Package class instance.

The documentation for this class was generated from the following file: