Stash Software API
2.0.0
|
[ CLASS ] - Class to operate on Stash packages. More...
Public Member Functions | |
def | __init__ (self, absolutePath=None, setByStack=False) |
Constructor. More... | |
def | __str__ (self) |
String representation. More... | |
def | setPackage (self, absolutePath=None) |
Set package. More... | |
def | clear (self) |
Clear the instance. More... | |
def | getLocalPath (self, relativePath) |
Get absolute path of given relativePath . More... | |
def | getLocalHelpFile (self, folder) |
Get absolute path of the requested local help file. More... | |
def | getPackagesLocation (self) |
Get location of the packages. More... | |
def | getPythonPath (self) |
Get the Python path of the package in absolutePath/packageName/python format. More... | |
def | getDefaultPythonPackagePath (self) |
Get the default Python package path of the package in absolutePath/packageName/python/packageName format. More... | |
def | getPythonPackagePath (self, pythonPackageName=None) |
Get the Python package path for given Python package name in absolutePath/packageName/python/packageName format. More... | |
def | getPythonPackages (self, ignoreDefault=False) |
Get python package names 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 | getPackageReleaseRelativePath (self) |
Get relative release path of the package. More... | |
def | getReleaseFiles (self, relativePath=True) |
Get files to be released. More... | |
def | getAllDependencies (self) |
Get all dependent packages used by this package. More... | |
def | getReleaseData (self) |
Get release data for this package. More... | |
def | runUnitTests (self, pythonPackageName=None) |
Run unit tests of the package. More... | |
def | getLineOfCode (self) |
Get line of code contained by this package. More... | |
def | createPythonModule (self, pythonModuleName, pythonPackageName=None) |
Create a Python module for the given Python package of the package. More... | |
def | createPythonPackage (self, pythonPackageName) |
Create a Python module for the given Python package. More... | |
def | asStr (self) |
Get string representation of the class. More... | |
def | asHTML (self) |
Get HTML representation of the package. More... | |
def | asDict (self) |
Get package information as a dict instance. 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... | |
Static Public Member Functions | |
def | getRootOfThisPackage () |
Get the root of this particular package. More... | |
def | getRootFromStack () |
Get the root path of the package in use by using stack. More... | |
def | getRootFromPath (absolutePath) |
Get the root path of the package from given path. More... | |
def | isRootOfAPackage (absolutePath) |
Check whether the given path is root of a package. More... | |
def | isPackageNameValid (name) |
Check whether the given package name is valid. More... | |
def | findInfoFile (absolutePath) |
Find package info Python file from given path. More... | |
def | findInfoModule (absolutePath) |
Find, import package info Python module and return it. More... | |
def | removePythonObjects (verbose=False) |
Remove all files with .pyc and .pyo extension recursively in python path. More... | |
def | list () |
List all packages. More... | |
def | find (name) |
Find package with given name. More... | |
def | findPythonPackage (name) |
Find Python package with given name. More... | |
def | listAsDict () |
List all packages as dict instances. More... | |
def | listAllCommands (includeBinary=False) |
List all commands in packages. More... | |
def | create (name, description=None, path=None, isExternal=False, createBin=True, createLib=True, createBuild=True, createConfig=True, createDoc=True, createData=True, createResources=True, createSource=True, createTemp=True, createTest=True, createHoudini=True, createKatana=True, createMari=True, createMaya=True, createNuke=True, extras=True) |
Create a package. More... | |
Static Public Attributes | |
string | NAME_PREFIX = '' |
[ str ] - Prefix of the package names. More... | |
string | PACKAGE_NAME_REGEX = r'[a-z]{1,}[A-Z]{1,}\S+' |
[ str ] - Regular Expression for a valid package name. More... | |
string | CURRENT_VERSION = '0.0.0' |
[ str ] - Current version. More... | |
[ CLASS ] - Class to operate on Stash packages.
def sStashPackage.packageLib.Package.__init__ | ( | self, | |
absolutePath = None , |
|||
setByStack = False |
|||
) |
Constructor.
You can pass True
via setByStack
argument if you want to set the package by using stack. You do not need to provide a value for setByStack
argument if you provide a path via absolutePath
argument.
If you don't provide any value for absolutePath
and setByStack
no package will be set. You can also use Package.setPackage method.
absolutePath | [ str | None | in ] - Absolute path of package info file. |
setByStack | [ bool | False | in ] - Whether to set package by using stack. |
N/A |
def sStashPackage.packageLib.Package.__str__ | ( | self | ) |
String representation.
N/A |
def sStashPackage.packageLib.Package.name | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.version | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.description | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.keywords | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.platforms | ( | self | ) |
Platforms.
N/A |
def sStashPackage.packageLib.Package.documents | ( | self | ) |
Documents.
N/A |
def sStashPackage.packageLib.Package.applications | ( | self | ) |
Applications.
N/A |
def sStashPackage.packageLib.Package.pythonVersions | ( | self | ) |
Python versions.
N/A |
def sStashPackage.packageLib.Package.isActive | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.isExternal | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.developers | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.dependentPackages | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.pythonPackages | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.isVersioned | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.path | ( | self | ) |
Property.
N/A |
def sStashPackage.packageLib.Package.setPackage | ( | self, | |
absolutePath = None |
|||
) |
Set package.
A package info Python module can be provided for absolutePath argument.
Method finds package info Python file by using given absolutePath. If absolutePath argument is not provided, stack will be used (by invoking sStashPackage.packageLib.Package.getRootFromStack() method) to find the package info Python file.
absolutePath | [ str, module | None | in ] - Absolute path of package info Python file or its module. |
AttributeError | - If info module does not have any of required attributes. |
sStashPackage.exceptionLib.PackageNameError | - If folder name of the package doesn't match with the name in the package info module. |
def sStashPackage.packageLib.Package.clear | ( | self | ) |
Clear the instance.
N/A |
def sStashPackage.packageLib.Package.getLocalPath | ( | self, | |
relativePath | |||
) |
Get absolute path of given relativePath
.
Method doesn't check whether the returned path exists.
relativePath | [ str | None | in ] - Structure from sStashPackage.packageLib.FolderStructure (i.e. sStashPackage.packageLib.FolderStructure.kBinLinux). |
N/A |
def sStashPackage.packageLib.Package.getLocalHelpFile | ( | self, | |
folder | |||
) |
Get absolute path of the requested local help file.
folder | [ str | None | in ] - Structure from sStashPackage.packageLib.FolderStructure (i.e. sStashPackage.packageLib.FolderStructure.kDocPythonAPIReference). |
N/A |
def sStashPackage.packageLib.Package.getPackagesLocation | ( | self | ) |
Get location of the packages.
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.
N/A |
def sStashPackage.packageLib.Package.getPythonPath | ( | self | ) |
Get the Python path of the package in absolutePath/packageName/python format.
N/A |
def sStashPackage.packageLib.Package.getDefaultPythonPackagePath | ( | self | ) |
Get the default Python package path of the package in absolutePath/packageName/python/packageName format.
Default Python package name is the name of the package itself.
N/A |
def sStashPackage.packageLib.Package.getPythonPackagePath | ( | self, | |
pythonPackageName = None |
|||
) |
Get the Python package path for given Python package name in absolutePath/packageName/python/packageName format.
If pythonPackageName
argument is not provided, default name of the package will be used.
pythonPackageName | [ str | None | in ] - Name of the Python package. |
N/A |
def sStashPackage.packageLib.Package.getPythonPackages | ( | self, | |
ignoreDefault = False |
|||
) |
Get python package names contained by this package.
ignoreDefault | [ bool | False | in ] - Whether to ignore default package, which is the package with the same name as this package. |
N/A |
def sStashPackage.packageLib.Package.getFiles | ( | self, | |
folder, | |||
pythonPackageName = None , |
|||
absPath = True , |
|||
extension = None , |
|||
suffix = None |
|||
) |
Get files for the requested local folder of the package.
If sStashPackage.packageLib.Package.FolderStructure.kPython is provided for folder argument, folder will be set as absolutePath/packageName/python/pythonPackageName.
If no value provided for pythonPackageName
argument, name of the package will be used.
folder | [ str | None | in ] - Structure from sStashPackage.packageLib.Package.FolderStructure (i.e. sStashPackage.packageLib.FolderStructure.kPython). |
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. |
IOError | - If requested local folder doesn't exist. |
def sStashPackage.packageLib.Package.getPackageReleaseRelativePath | ( | self | ) |
Get relative release path of the package.
This is the release destination path that includes the version.
Return format: packageName/version/packageName (i.e. sQtWidgets/1.4.8/sQtWidgets)
N/A |
def sStashPackage.packageLib.Package.getReleaseFiles | ( | self, | |
relativePath = True |
|||
) |
Get files to be released.
relativePath | [ bool | True | in ] - Whether the file path will be relative to root of the package. |
N/A |
def sStashPackage.packageLib.Package.getAllDependencies | ( | self | ) |
Get all dependent packages used by this package.
N/A |
def sStashPackage.packageLib.Package.getReleaseData | ( | self | ) |
Get release data for this package.
N/A |
def sStashPackage.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.
pythonPackageName | [ str | None | in ] - Name of the Python package, which the tests will be run for. |
N/A |
def sStashPackage.packageLib.Package.getLineOfCode | ( | self | ) |
Get line of code contained by this package.
N/A |
def sStashPackage.packageLib.Package.createPythonModule | ( | self, | |
pythonModuleName, | |||
pythonPackageName = None |
|||
) |
Create a Python module for the given Python package of the package.
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 for. |
sStashPackage.exceptionLib.PackageLocationError | - If this package is versioned. |
IOError | - If no relevant Python package found for Python module creation. |
def sStashPackage.packageLib.Package.createPythonPackage | ( | self, | |
pythonPackageName | |||
) |
Create a Python module for the given Python package.
pythonPackageName | [ str | None | in ] - Name of the Python package under this package, which the Python module will be created for. |
sStashPackage.exceptionLib.PackageLocationError | - If this package is versioned. |
sStashPackage.exceptionLib.PythonPackageNameError | - If a Python package with given name already exists under this package. |
def sStashPackage.packageLib.Package.asStr | ( | self | ) |
Get string representation of the class.
N/A |
def sStashPackage.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.
N/A |
def sStashPackage.packageLib.Package.asDict | ( | self | ) |
Get package information as a dict instance.
Keys of the returned dict instance are available in sStashPackage.packageLib.InfoModuleAttribute enum class. Additionally PATH
and IS_VERSIONED
keys are dynamically added to the returned dict instance.
N/A |
|
static |
Get the root of this particular package.
N/A |
|
static |
Get the root path of the package in use by using stack.
Stack path should contain a path something like absolutePath/packageName/python/additionalPath so method can obtain the root path of the package properly. Return path will be in absolutePath/packageName format.
N/A |
|
static |
Get the root path of the package from given path.
Return path will be in absolutePath/packageName format.
absolutePath | [ str | None | in ] - Path. |
N/A |
|
static |
Check whether the given path is root of a package.
Following pattern will be checked: absolutePath/packageName
absolutePath | [ str | None | in ] - Path. |
N/A |
|
static |
Check whether the given package name is valid.
name | [ str | None | in ] - Name. |
N/A |
|
static |
Find package info Python file from given path.
absolutePath | [ str | None | in ] - Absolute path of package info file or an absolute path. |
N/A |
|
static |
Find, import package info Python module and return it.
If given package is not in Python path, it will be added temporarily and will be removed after the package info Python module is imported.
absolutePath | [ None | None | in ] - Absolute path of package info Python file or an absolute path. |
N/A |
|
static |
Remove all files with .pyc and .pyo extension recursively in python path.
verbose | [ bool | False | in ] - Display deleted files. |
N/A |
|
static |
List all packages.
Method searches packages by using sys.path.
N/A |
|
static |
Find package with given name.
Method finds the package with given name by searching Python paths. Please note, searching is case insensitive.
name | [ str | None | in ] - Name of the package to be found. |
N/A |
|
static |
Find Python package with given name.
Method finds the Python package with given name by searching Python paths. If the Python package found and it is under a Stash package, an instance of sStashPackage.packageLib.Package class will return, which would represent the Stash package that contains the Python package.
Please note, searching is case sensitive.
name | [ str | None | in ] - Name of the Python package to be found. |
N/A |
|
static |
List all packages as dict instances.
Keys of the returned dict instances are available in sStashPackage.packageLib.InfoModuleAttribute enum class. Additionally PATH
and IS_VERSIONED
keys are dynamically added to the dict instance.
N/A |
|
static |
List all commands in packages.
Return dict instances contains the following keys.
includeBinary | [ bool | False | in ] - Whether to include binary commands (executables). |
N/A |
|
static |
Create a package.
Current working directory will be used if path argument is not provided.
name | [ str | None | in ] - Name of the package. |
description | [ str | None | in ] - Description of the package. |
path | [ str | None | in ] - Absolute path where the package will be created. |
isExternal | [ bool | False | in ] - Whether the package is external. |
createBin | [ bool | False | in ] - Whether to create bin folder structure for the package. |
createLib | [ bool | False | in ] - Whether to create lib folder structure for the package. |
createBuild | [ bool | False | in ] - Whether to create build folder structure for the package. |
createConfig | [ bool | False | in ] - Whether to create config folder structure for the package. |
createDoc | [ bool | False | in ] - Whether to create doc folder structure for the package. |
createData | [ bool | False | in ] - Whether to create data folder structure for the package. |
createResources | [ bool | False | in ] - Whether to create resources folder structure for the package. |
createSource | [ bool | False | in ] - Whether to create source folder structure for the package. |
createTemp | [ bool | False | in ] - Whether to create temp folder structure for the package. |
createTest | [ bool | False | in ] - Whether to create unit test folder structure for the package. |
createHoudini | [ bool | False | in ] - Whether to create Houdini folder structure for the package. |
createKatana | [ bool | False | in ] - Whether to create Katana folder structure for the package. |
createMari | [ bool | False | in ] - Whether to create Mari folder structure for the package. |
createMaya | [ bool | False | in ] - Whether to create Maya folder structure for the package. |
createNuke | [ bool | False | in ] - Whether to create Nuke folder structure for the package. |
extras | [ bool | False | in ] - Create extra files, gitignore, README.md, etc. |
sStashPackage.exceptionLib.PackageNameError | - If provided package name doesn't match with the naming convention. |
|
static |
[ str ] - Prefix of the package names.
|
static |
[ str ] - Regular Expression for a valid package name.
|
static |
[ str ] - Current version.