Source Docs¶
kepler.sword¶
-
class
kepler.sword.
SWORDPackage
(uuid, metadata=None, datafiles=[])¶ A SWORD Package.
This provids a container for the metadata and data files comprising a SWORD package. Use the
write()
method to serialize the package:from kepler.sword import SWORDPackage pkg = SWORDPackage(uuid='1234', metadata='<xml...>') pkg.datafiles.append('some/data/file.tif') pkg.write('sword.zip')
Parameters: - uuid – file uuid
- metadata – metadata string to be added to mods record
- datafiles – list of filenames to be added to SWORD package
-
write
(file)¶ Serialize the SWORD package.
Parameters: file – file name or file pointer to write package to
-
kepler.sword.
create_mets
(**kwargs)¶ Create a METS file for inclusion in SWORD package.
This will look for a
mets.xml
template in the current app’s template directory and apply the suppliedkwargs
as a context.Parameters: kwargs – context for METS template
-
kepler.sword.
submit
(service, package, auth=None)¶ Submit a SWORD package.
Submits the given package to the specified SWORD service. If the submission was successful, the handle of the created resource will be returned.
Parameters: - service – URL for SWORD service
- package – path to SWORD package on file system
- auth – tuple containing username and password for authenticating to SWORD service if required
-
kepler.sword.
sword_headers
(filename)¶ Returns SWORD headers for specified package.
Params filename: name of SWORD package
kepler.tasks¶
kepler.tasks¶
This module provides a set of tasks that send data to different Web services. Each task has the same signature:
task(job, data)
In most cases, the data will be an absolute path to a bag.
-
kepler.tasks.
_index_from_fgdc
(job, bag, **kwargs)¶ Index a GeoServer-bound layer from the attached FGDC metadata.
This will pull the FGDC metadata out of the Bag and add any necessary fields before indexing in Solr.
Parameters: - job –
Job
- bag – absolute path to bag containing FGDC metadata
- **kwargs – additional fields to add to the record
- job –
-
kepler.tasks.
_index_records
(records)¶ Indexes records in Solr.
Parameters: records – iterator of dictionaries to be added to Solr
-
kepler.tasks.
_upload_to_geoserver
(job, data, mimetype)¶ Uploads Shapefiles and GeoTIFFs to GeoServer.
This is a generic task for uploading data to GeoServer. You should instead use the specific data type functions:
upload_shapefile()
andupload_geotiff()
.Parameters: - job –
Job
- data – absolute path to either Shapefile or GeoTIFF
- mimetype – one of
application/zip
orimage/tiff
- job –
-
kepler.tasks.
get_geotiff_url_from_dspace
(job)¶ Retrieve the GeoTIFF URL from a DSpace Handle.
Note
assumes the OAI-ORE only contains a single TIFF.
Parameters: job – Job
-
kepler.tasks.
index_geotiff
(job, data)¶ Index an uploaded GeoTIFF file in Solr.
Parameters: - job –
Job
- bag – absolute path to bag containing GeoTIFF
- job –
-
kepler.tasks.
index_shapefile
(job, data)¶ Index an uploaded Shapefile in Solr.
Parameters: - job –
Job
- bag – absolute path to bag containing Shapefile
- job –
-
kepler.tasks.
submit_to_dspace
(job, data)¶ Upload GeoTIFF to DSpace.
Note
only runs if Item.handle has not previously been set.
Parameters: - job –
Job
- data – absolute path to bag containing GeoTIFF
- job –
-
kepler.tasks.
upload_geotiff
(job, data)¶ Upload GeoTIFF to GeoServer.
Parameters: - job –
Job
- data – absolute path to bag containing GeoTIFF
- job –
-
kepler.tasks.
upload_shapefile
(job, data)¶ Upload Shapefile to GeoServer.
Parameters: - job –
Job
- data – absolute path to bag containing Shapefile
- job –