gws.plugin.qgis.project¶
Loading and storing QGIS projects.
Source code: gws.plugin.qgis.project
Module Contents¶
- gws.plugin.qgis.project.from_path(path: str) Object¶
Load a QGIS project from a
.qgsor.qgzfile.- Parameters:
path – Project file path.
- Returns:
The project.
- Raises:
Error – If a
.qgzarchive contains no project or the QGIS version is not supported.
- gws.plugin.qgis.project.from_store(root: gws.Root, store: Store) Object¶
Load a QGIS project from a store.
- Parameters:
root – Root object, used to find the database provider.
store – Project location.
- Returns:
The project.
- Raises:
Error – If the project cannot be found or loaded.
- gws.plugin.qgis.project.from_string(text: str) Object¶
Create a QGIS project from XML text.
- Parameters:
text – Project XML.
- Returns:
The project.
- Raises:
Error – If the QGIS version is not supported.
- class gws.plugin.qgis.project.Object(text: str)¶
A QGIS project, held as XML text.
Only QGIS 3 projects are supported. The parsed XML tree is created on demand and is not pickled.
- text¶
- caps() gws.plugin.qgis.caps.Caps¶
Parse the project capabilities.
- Returns:
Project capabilities.
- Raises:
gws.Error – If the project CRS is invalid.
- to_path(path: str)¶
Save the project to a file.
If the path ends with
.qgz, the project is saved as a zip archive.- Parameters:
path – File path.
- to_store(root: gws.Root, store: Store)¶
Save the project to a store.
In a Postgres store, an existing project with the same name is renamed to
<name>.bak, replacing an older backup.- Parameters:
root – Root object, used to find the database provider.
store – Project location.
- Raises:
Error – If the store type is not supported.
- to_xml()¶
Serialize the project XML.
- Returns:
Project XML text.
- xml_root() gws.XmlElement¶
Return the root element of the project XML.
The XML is parsed on the first call. Changes to the tree are kept and written by
to_xml,to_pathandto_store.- Returns:
Root element.
- class gws.plugin.qgis.project.Store(*args, **kwargs)¶
Bases:
gws.DataLocation of a QGIS project.
- path: gws.FilePath¶
Project file path, for file stores.