isogeo_pysdk.api.routes_format module

Isogeo API v1 - API Routes for Formats entities

See: http://help.isogeo.com/api/complete/index.html

NOTE TO DEV: format being the name of a Python built-in function (see: https://docs.python.org/3/library/functions.html#format), we use the frmt shorter as replacement.

class isogeo_pysdk.api.routes_format.ApiFormat(api_client=None)[source]

Bases: object

Routes as methods of Isogeo API used to manipulate formats.

create(frmt: isogeo_pysdk.models.format.Format, check_exists: bool = 1) → isogeo_pysdk.models.format.Format[source]

Add a new format to the Isogeo formats database.

If a format with the same code already exists, the Isogeo API returns a 500 HTTP code. To prevent this error, use the check_exists option or check by yourself before.

Parameters:
  • frmt (Format) – Format model object to create
  • check_exists (bool) – check if a format with the same code exists before
Return type:

Format or tuple

Example:
format_to_add = Format(
    code="geojson",
    name="GeoJSON",
    type="vectorDataset"
)
isogeo.formats.create(format_to_add)
delete(frmt: isogeo_pysdk.models.format.Format)[source]

Delete a format from Isogeo database.

Parameters:frmt (Format) – Format model object to delete
get(format_code: str) → isogeo_pysdk.models.format.Format[source]

Get details about a specific format.

Parameters:format_code (str) – format code
Return type:Format
Example:
>>> pprint.pprint(isogeo.formats.get("postgis"))
{
    '_id': string (uuid),
    '_tag': 'format:postgis',
    'aliases': [],
    'code': 'postgis',
    'name': 'PostGIS',
    'type': 'dataset',
    'versions': [
        '2.2',
        '2.1',
        '2.0',
        '1.5',
        '1.4',
        '1.3',
        '1.2',
        '1.1',
        '1.0',
        '0.9',
        None
        ]
}
listing(data_type: str = None, caching: bool = 1) → list[source]

List formats available in Isogeo API.

Parameters:
  • data_type (str) – type of metadata to filter on
  • caching (bool) – option to cache the response
Returns:

list of dicts

Return type:

list

Example:
>>> formats = isogeo.formats.listing()
>>> # count all formats
>>> print(len(formats))
32
>>> # count formats which are only for vector dataset
>>> print(len(isogeo.formats.listing(data_type="vector-dataset")))
21
>>> # list all unique codes
>>> formats_codes = [i.get("code") for i in formats]
>>> pprint.pprint(formats_codes)
[
    'apic',
    'arcsde',
    'dgn',
    'dwg',
    'dxf',
    ...
]

Search within data formats available in Isogeo API for NON GEOGRAPHICAL DATA ONLY.

Parameters:
  • query (str) – search terms. Equivalent of q parameter in Isogeo API.
  • page_size (int) – limits the number of results. Useful to paginate results display. Default value: 10. Max value: 100.
  • offset (int) – offset to start page size from a specific results index
Returns:

list of dicts

Return type:

list

Example:
>>> isogeo.formats.search(query="a", page_size=1, offset=0)
[
    {
        'aliases': [],
        'name': 'Adobe PDF',
        'versions':
        [
            '7',
            '1.7',
            None,
            None
        ]
    }
]
update(frmt: isogeo_pysdk.models.format.Format) → isogeo_pysdk.models.format.Format[source]

Update a format in Isogeo database.

Parameters:frmt (Format) – Format model object to update
Return type:Format
Example:
>>> # retrieve format to update
>>> fmt_postgis = isogeo.formats.get("postgis")
>>> # add new versions locally
>>> fmt_postgis.versions.extend(["3.0", "3.1"])
>>> # update online
>>> fmt_postgis_updted = isogeo.formats.update(fmt_pgis)