API Documentation
This part of the project documentation focuses on
an information-oriented approach. Use it as a
reference for the technical implementation of the
pylobid
project code.
pylobid
main module
GNDAPIError
Bases: Exception
Broad exception if something unexpected happens.
Source code in src/pylobid/pylobid.py
17 18 |
|
GNDIdError
Bases: ValueError
Exception raised if the GND-ID is invalid.
Source code in src/pylobid/pylobid.py
9 10 |
|
GNDNotFoundError
Bases: Exception
Exception raised if the API returns Not Found for a GND-ID.
Source code in src/pylobid/pylobid.py
13 14 |
|
PyLobidClient
Main Class to interact with LOBID-API.
Source code in src/pylobid/pylobid.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
alt_names
property
Return a list of alternative names.
ent_type
property
Return the entity type.
gnd_id
property
Return the GND ID, e.g. 118650130.
gnd_url
property
Return the GND URL e.g. http://d-nb.info/gnd/118650130
is_org
property
Return True if this instance is an organization entity, False otherwise.
is_person
property
Return True if this instance is a person entity, False otherwise.
is_place
property
Return True if this instance is a place entity, False otherwise.
is_work
property
Return True if this instance is a work entity, False otherwise.
pref_name
property
Return the preferred name.
same_as
property
Return a list of alternative norm-data-ids.
__init__(gnd_id=None, fetch_related=False)
Class constructor.
Source code in src/pylobid/pylobid.py
191 192 193 194 195 196 197 198 199 200 201 |
|
extract_id(url)
Extract the GND-ID from an GND-URL.
:param url: A GND-URL, e.g. http://d-nb.info/gnd/118650130 :type url: str
:raises: GNDIdError if no GND-ID is found. :return: The GND-ID, e.g. 118650130 :rtype: str
Source code in src/pylobid/pylobid.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
factory()
Return a matching instance for the GND URL or ID.
- Type
PlaceOrGeographicName
returns aPyLobidPlace
instance. - Type
CorporateBody
returns aPyLobidOrg
instance. - Type
Person
returns aPyLobidPerson
instance. - Type
Work
returns aPyLobidWork
instance. - All other types a
PyLobidPerson
instance
:return: An matching object for the GND URL or Id
:rtype: PyLobidPlace
, PyLobidOrg
, PyLobidPerson
, PyLobidPerson
Source code in src/pylobid/pylobid.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
get_alt_names()
Get the list of alternative names.
:return: a list of alternative names :rtype: list
Source code in src/pylobid/pylobid.py
173 174 175 176 177 178 179 180 181 182 183 |
|
get_entity_json(url=None)
Get the LOBID-JSON response of a given GND-URL.
:param url: A GND_URL :type url: str, optional
:raises: GNDNotFoundError, GNDAPIError :return: The matching JSON representation fetched from LOBID :rtype: dict
Source code in src/pylobid/pylobid.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
get_entity_lobid_url(url)
creates a lobid-entity URL from an GND-URL
:param url: A GND-URL, e.g. http://d-nb.info/gnd/118650130 :type url: str
:return: A LOBID-ENTITY-URL, e.g. http://lobid.org/gnd/116000562 :rtype: str
Source code in src/pylobid/pylobid.py
121 122 123 124 125 126 127 128 129 130 131 |
|
get_pref_name()
Get the preferred name.
:return: The preferred Name vale, e.g. 'Assmann, Richard' :rtype: str
Source code in src/pylobid/pylobid.py
164 165 166 167 168 169 170 171 |
|
get_same_as()
Get the list of alternative norm-data-ids.
:return: A list of tuples like ('GeoNames', 'http://sws.geonames.org/2782067'), :rtype: list
Source code in src/pylobid/pylobid.py
153 154 155 156 157 158 159 160 161 162 |
|
process_data(gnd_id=None, data=None)
Fetch and/or process entity data.
The arguments gnd_id
and data
are mutually exclusive.
:param gnd_id: any kind of GND_URI/URL :type gnd_id: str, optional :param data: an already fetched ent_dict :type data: dict, optional
Source code in src/pylobid/pylobid.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
PyLobidOrg
Bases: PyLobidClient
A python class representing an Organisation Entity.
Source code in src/pylobid/pylobid.py
255 256 257 258 259 260 261 262 263 264 |
|
located_in
property
Return a list of locations.
PyLobidPerson
Bases: PyLobidClient
A python class representing a Person Entity.
Source code in src/pylobid/pylobid.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
get_coords(place_of='Birth')
Get a list of coordinates.
:param place_of: Passed in value concatenates to 'PlaceOfBirth|Death' defaults to 'Birth' :type place_of: str
:return: A list of longitude, latitude coords like ['+009.689780', '+051.210970'] :rtype: list
Source code in src/pylobid/pylobid.py
377 378 379 380 381 382 383 384 385 386 387 388 |
|
get_coords_str(place_of='Birth')
Get a string of coordinates.
:param place_of: Passed in value concatenates to 'PlaceOfBirth|Death' defaults to 'Birth' :type place_of: str
:return: A string containing coordinates :rtype: str
Source code in src/pylobid/pylobid.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
|
get_life_dates()
Get birth- and death dates.
:return: A dict with keys birth_date_str and death_date_str :rtype: dict
Source code in src/pylobid/pylobid.py
324 325 326 327 328 329 330 331 332 333 |
|
get_place_alt_name(place_of='Birth')
Get the list of alternative names.
:param place_of: Passed in value concatenates to 'PlaceOfBirth|Death' defaults to 'Birth' :type place_of: str
:return: a list of alternative names :rtype: list
Source code in src/pylobid/pylobid.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
place_of_dict(place_of='Birth')
Get the LOBID-JSON of a PlaceOfBirth|Death (if present).
:param place_of: Passed in value concatenates to 'PlaceOfBirth|Death' defaults to 'Birth' :type place_of: str
:return: The LOBID-JSON of the PlaceOfBirth|Death :rtype: dict
Source code in src/pylobid/pylobid.py
349 350 351 352 353 354 355 356 357 358 359 360 |
|
place_of_values(place_of='Birth')
Find values for PlaceOfBirth/Death.
:param place_of: Passed in value concatenates to 'PlaceOfBirth|Death' defaults to 'Birth' :type place_of: str
:return: The ID of the Place :rtype: dict
Source code in src/pylobid/pylobid.py
335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
process_data(gnd_id=None, data=None)
Fetch and/or process entity data.
The arguments gnd_id
and data
are mutually exclusive.
:param gnd_id: any kind of GND_URI/URL :type gnd_id: str, optional :param data: an already fetched ent_dict :type data: dict, optional
Source code in src/pylobid/pylobid.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
PyLobidPlace
Bases: PyLobidClient
A python class representing a Place Entity.
Source code in src/pylobid/pylobid.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
coords
property
Return a list of coordinates.
get_coords()
Get a list of coordinates.
:return: A list of longitude, latitude coords like ['+009.689780', '+051.210970'] :rtype: list
Source code in src/pylobid/pylobid.py
237 238 239 240 241 242 243 244 |
|
get_coords_str()
Get a string of coordinates.
:return: A string containing coordinates :rtype: str
Source code in src/pylobid/pylobid.py
226 227 228 229 230 231 232 233 234 235 |
|
PyLobidWork
Bases: PyLobidClient
A python class representing a Work Entity
Source code in src/pylobid/pylobid.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
creators
property
provides a list of dicts providing information of all persons involved in the creation of the work and their role
Returns: |
|
---|
date_of_creation
property
returns the date of the works creations using dateOfPublication
if dateOfPublication
is not provided dateOfProduction
is used
Returns: |
|
---|
date_of_production
property
returns the date of the works creations using dateOfProduction
Returns: |
|
---|
date_of_publication
property
returns the date of the works creations using dateOfPublication
Returns: |
|
---|
pylobid.utils
some (one) utility function
extract_coords(some_str)
Utility function to extract coordinates from a (WKT) string
:param some_str: A string providing coordinates :type some_str: str
:return: A list with the coordinates :rtype: list
Source code in src/pylobid/utils.py
4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
pylobid.validators
WTForms GND validator module.
WTForms GND validator module.
GNDOrgEntity
Bases: GNDValidator
Validator for org. entities.
:param: Message to display if validation fails. :raises: ValidationError is the GND type does not match the set entity type.
Source code in src/pylobid/validators.py
74 75 76 77 78 79 80 81 82 83 84 |
|
__init__(message=None)
Class constructor.
Source code in src/pylobid/validators.py
81 82 83 84 |
|
GNDPersonEntity
Bases: GNDValidator
Validator class for person entities.
:param: Message to display if validation fails. :raises: ValidationError is the GND type does not match the set entity type.
Source code in src/pylobid/validators.py
61 62 63 64 65 66 67 68 69 70 71 |
|
__init__(message=None)
Class constructor.
Source code in src/pylobid/validators.py
68 69 70 71 |
|
GNDPlaceEntity
Bases: GNDValidator
Validator class for place entities.
:param: Message to display if validation fails. :raises: ValidationError is the GND type does not match the set entity type.
Source code in src/pylobid/validators.py
48 49 50 51 52 53 54 55 56 57 58 |
|
__init__(message=None)
Class constructor.
Source code in src/pylobid/validators.py
55 56 57 58 |
|
GNDValidator
Base class for GND validators.
:param: Message to display if validation fails. :raises: ValidationError is the GND type does not match the set entity type.
Source code in src/pylobid/validators.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
__call__(form, field)
Class call method.
:param form: A WTForms Form instance. :param field: A WTForm Form Field instance. :raises: ValidationError is the GND type does not match the set entity type.
Source code in src/pylobid/validators.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
__init__(entity_flag=None, message=None)
Class constructor.
Source code in src/pylobid/validators.py
17 18 19 20 |
|