KDE 4.7 PyKDE API Reference

- KDE's Python API

# Package Class Reference

`from PyKDE4.plasma import *`

Namespace: Plasma

## Detailed Description

Package plasma/package.h <Plasma/Package>

object representing an installed Plasmagik package

## Methods
| __init__ (self, QString packageRoot, QString package, KSharedPtr structure)
| __init__ (self, QString packagePath, KSharedPtr structure)
| __init__ (self, Plasma.Package other)
| __init__ (self)
QString | contentsHash (self)
QStringList | entryList (self, QString fileType)
QString | filePath (self, QString fileType, QString filename)
QString | filePath (self, QString fileType)
bool | isValid (self)
Plasma.PackageMetadata | metadata (self)
QString | path (self)
| setPath (self, QString path)
KSharedPtr | structure (self)
## Static Methods
bool | createPackage (Plasma.PackageMetadata metadata, QString source, QString destination, QString icon=QString())
bool | installPackage (QString package, QString packageRoot, QString servicePrefix)
QStringList | listInstalled (QString packageRoot)
QStringList | listInstalledPaths (QString packageRoot)
bool | registerPackage (Plasma.PackageMetadata data, QString iconPath)
bool | uninstallPackage (QString package, QString packageRoot, QString servicePrefix)

## Method Documentation

__init__ | ( | self, |
|  | QString | packageRoot,
|  | QString | package,
|  | KSharedPtr | structure
| ) |  |  |

Construct a Package object

Parameters:

  | packageRoot | path to the package installation root
  | package | the name of the package
  | structure | the package structure describing this package

__init__ | ( | self, |
|  | QString | packagePath,
|  | KSharedPtr | structure
| ) |  |  |

Construct a Package object.

Parameters:

  | packagePath | full path to the package directory
  | structure | the package structure describing this package

__init__ | ( | self, |
|  | Plasma.Package | other
| ) |  |  |

Copy constructore

Since:
  4.6

__init__ | ( |  | self ) |

Default constructor that creates an invalid Package

Since:
  4.6

QString contentsHash | ( |  | self ) |

Returns:
  a SHA1 hash digest of the contents of the package in hexadecimal form

Since:
  4.4

QStringList entryList | ( | self, |
|  | QString | fileType
| ) |  |  |

Get the list of files of a given type.

Parameters:

  | fileType | the type of file to look for, as defined in the package structure.

Returns:
  list of files by name, suitable for passing to filePath

QString filePath | ( | self, |
|  | QString | fileType,
|  | QString | filename
| ) |  |  |

Get the path to a given file.

Parameters:

  | fileType | the type of file to look for, as defined in the package structure. The type must refer to a file in the package structure and not a directory.

Returns:
  path to the file on disk. QString() if not found

QString filePath | ( | self, |
|  | QString | fileType
| ) |  |  |

Get the path to a given file.

Parameters:

  | fileType | the type of file to look for, as defined in the package structure. The type must refer to a file in the package structure and not a directory.

Returns:
  path to the file on disk. QString() if not found

bool isValid | ( |  | self ) |

Returns:
  true if all the required components as defined in the PackageStructure exist

Plasma.PackageMetadata metadata | ( |  | self ) |

Returns:
  the package metadata object.

QString path | ( |  | self ) |

Returns:
  the path to the root of this particular package

setPath | ( | self, |
|  | QString | path
| ) |  |  |

Sets the path to the root of this package

Parameters:

  | path | and absolute path

Since:
  4.3

KSharedPtr structure | ( |  | self ) |

Returns:
  the PackageStructure use in this Package

## Static Method Documentation

bool createPackage | ( | Plasma.PackageMetadata | metadata,
|  | QString | source,
|  | QString | destination,
|  | QString | icon=QString()
| ) |  |  |

Creates a package based on the metadata from the files contained in the source directory

Parameters:

  | metadata | description of the package to create
  | source | path to local directory containing the individual files to be added to the package
  | destination | path to the package that should be created
  | icon | path to the package icon

bool installPackage | ( | QString | package,
|  | QString | packageRoot,
|  | QString | servicePrefix
| ) |  |  |

Installs a package.

Parameters:

  | package | path to the Plasmagik package
  | packageRoot | path to the directory where the package should be installed to
  | servicePrefix | the prefix for the desktop file, so as not to interfere with unrelated services (eg: "plasma-applet-"). If no prefix is set (e.g. a QString() is passed in), then the package will NOT be registered as a service

Returns:
  true on successful installation, false otherwise

QStringList listInstalled | ( | QString | packageRoot
| ) |  |  |

Returns a list of all installed packages by name

Parameters:

  | packageRoot | path to the directory where Plasmagik packages have been installed to

Returns:
  a list of installed Plasmagik packages

QStringList listInstalledPaths | ( | QString | packageRoot
| ) |  |  |

Returns a list of all paths of installed packages in the given root

Parameters:

  | packageRoot | path to the directory where Plasmagik packages have been installed to

Returns:
  a list of installed Plasmagik packages by path

bool registerPackage | ( | Plasma.PackageMetadata | data,
|  | QString | iconPath
| ) |  |  |

Registers a package described by the given desktop file

Parameters:

  | the | full path to the desktop file (must be KPluginInfo compatible)

Returns:
  true on success, false on failure

bool uninstallPackage | ( | QString | package,
|  | QString | packageRoot,
|  | QString | servicePrefix
| ) |  |  |

Uninstalls a package.

Parameters:

  | package | path to the Plasmagik package
  | packageRoot | path to the directory where the package should be installed to
  | servicePrefix | the prefix for the desktop file, so as not to interfere with unrelated services (eg: "plasma-applet-")

Returns:
  true on successful uninstallation, false otherwise