Coverage for gws-app/gws/__init__.py: 97%
1893 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
1"""Basic types.
3This module contains essential type definitions and utilities from the core GWS library.
4It should be imported in every gws module.
5"""
7from typing import (
8 TYPE_CHECKING,
9 TypeAlias,
10 cast,
11 Any,
12 Callable,
13 ContextManager,
14 Iterable,
15 Iterator,
16 Literal,
17 Optional,
18 Protocol,
19 Union,
20)
22from collections.abc import (
23 Mapping,
24 Sequence,
25)
27import enum
29if TYPE_CHECKING:
30 import datetime
31 import sqlalchemy
32 import sqlalchemy.orm
33 import numpy.typing
35# mypy: disable-error-code="empty-body"
38from . import ext
40from .core import (
41 log,
42 debug,
43 env,
44 const as c,
45 util as u,
46)
49################################################################################
50# /core/_data.pyinc
53# basic data type
55class Data:
56 """Basic data object.
58 This object can be instantiated by passing one or or ``dict`` arguments
59 and/or keyword args. All dicts keys and keywords become attributes of the object.
61 Accessing an undefined attribute returns ``None`` and no error is raised,
62 unless the attribute name starts with an underscore.
63 """
65 def __init__(self, *args, **kwargs):
66 self.update(*args, **kwargs)
68 def __repr__(self):
69 return repr(vars(self))
71 def __getitem__(self, key):
72 return vars(self).get(key)
74 def __setitem__(self, key, value):
75 vars(self)[key] = value
77 def get(self, key, default=None):
78 """Get an attribute value.
80 Args:
81 key: Attribute name.
82 default: Default value, returned if the attribute is undefined.
83 """
84 return vars(self).get(key, default)
86 def setdefault(self, key, val):
87 """Set an attribute value if not already set.
89 Args:
90 key: Attribute name.
91 val: Attribute value.
92 """
93 return vars(self).setdefault(key, val)
95 def set(self, key, val):
96 """Set an attribute value.
98 Args:
99 key: Attribute name.
100 val: Attribute value.
101 """
102 vars(self)[key] = val
104 def update(self, *args, **kwargs):
105 """Update the object with keys and values from args and keywords.
107 Args:
108 *args: Dicts or Mappings.
109 kwargs: Keyword args.
110 """
112 d = {}
113 for a in args:
114 if isinstance(a, Mapping):
115 d.update(a)
116 elif isinstance(a, Data):
117 d.update(vars(a))
118 d.update(kwargs)
119 vars(self).update(d)
122# getattr needs to be defined out of class, otherwise IDEA accepts all attributes
124def _data_getattr(self, attr):
125 if attr.startswith('_'):
126 # do not use None fallback for special props
127 raise AttributeError(attr)
128 return None
131setattr(Data, '__getattr__', _data_getattr)
134def is_data_object(x):
135 """True if the argument is a ``Data`` object."""
136 return isinstance(x, Data)
139def to_data_object(x) -> 'Data':
140 """Convert a value to a ``Data`` object.
142 If the argument is already a ``Data`` object, simply return it.
143 If the argument is ``None``, an empty object is returned.
145 Args:
146 x: A Mapping or ``None``.
147 """
149 if is_data_object(x):
150 return x
151 if isinstance(x, Mapping):
152 return Data(x)
153 if x is None:
154 return Data()
155 raise ValueError(f'cannot convert {x!r} to Data')
156################################################################################
160u.is_data_object = is_data_object
161u.to_data_object = to_data_object
165################################################################################
166# /core/_basic.pyinc
169class Enum(enum.Enum):
170 """Enumeration type.
172 Despite being declared as extending ``Enum`` (for IDE support), this class is actually just a simple object
173 and intended to be used as a collection of attributes. It doesn't provide any ``Enum``-specific utilities.
175 The rationale behind this is that we need ``Enum`` members (e.g. ``Color.RED``) to be scalars,
176 and not complex objects as in the standard ``Enum``.
177 """
178 pass
181# hack to make Enum a simple object
182globals()['Enum'] = type('Enum', (), {})
184Extent: TypeAlias = tuple[float, float, float, float]
185"""An array of 4 elements representing extent coordinates ``[min-x, min-y, max-x, max-y]``."""
187Point: TypeAlias = tuple[float, float]
188"""Point coordinates ``[x, y]``."""
190Size: TypeAlias = tuple[float, float]
191"""Size ``[width, height]``."""
194class Origin(Enum):
195 """Grid origin."""
197 nw = 'nw'
198 """north-west"""
199 sw = 'sw'
200 """south-west"""
201 ne = 'ne'
202 """north-east"""
203 se = 'se'
204 """south-east"""
205 lt = 'nw'
206 """left top"""
207 lb = 'sw'
208 """left bottom"""
209 rt = 'ne'
210 """right top"""
211 rb = 'se'
212 """right bottom"""
215FilePath: TypeAlias = str
216"""File path on the server."""
218DirPath: TypeAlias = str
219"""Directory path on the server."""
221Duration: TypeAlias = str
222"""Duration like ``1w 2d 3h 4m 5s`` or an integer number of seconds."""
224Color: TypeAlias = str
225"""CSS color name."""
227Regex: TypeAlias = str
228"""Regular expression, as used in Python."""
230FormatStr: TypeAlias = str
231"""Format string as used in Python."""
233DateStr: TypeAlias = str
234"""ISO date string like ``2019-01-30``."""
236DateTimeStr: TypeAlias = str
237"""ISO datetime string like ``2019-01-30 01:02:03``."""
239Url: TypeAlias = str
240"""URL."""
242ClassRef: TypeAlias = type | str
243"""Class reference, a type, and 'ext' object or a class name."""
246class Config(Data):
247 """Object configuration."""
249 uid: str = ''
250 """Unique ID."""
253class Props(Data):
254 """Object properties."""
256 uid: str = ''
257 """Unique ID."""
260class Request(Data):
261 """Command request."""
263 projectUid: Optional[str]
264 """Unique ID of the project."""
265 localeUid: Optional[str]
266 """Locale ID for this request."""
269class EmptyRequest(Data):
270 """Empty command request."""
272 pass
275class ResponseError(Data):
276 """Response error."""
278 code: Optional[int]
279 """Error code."""
280 info: Optional[str]
281 """Information about the error."""
284class Response(Data):
285 """Command response."""
287 error: Optional[ResponseError]
288 """Response error."""
289 status: int
290 """Response status or exit code."""
293class ContentResponse(Response):
294 """Web response with literal content."""
296 asAttachment: bool
297 """Serve the content as an attachment."""
298 attachmentName: str
299 """Name for the attachment."""
300 content: bytes | str
301 """Response content."""
302 contentPath: str
303 """Local path with the content."""
304 mime: str
305 """Response mime type."""
306 headers: dict
307 """Additional headers."""
310class RedirectResponse(Response):
311 """Web redirect response."""
313 location: str
314 """Redirect URL."""
315 headers: dict
316 """Additional headers."""
319class AttributeType(Enum):
320 """Feature attribute type."""
322 bool = 'bool'
323 bytes = 'bytes'
324 date = 'date'
325 datetime = 'datetime'
326 feature = 'feature'
327 featurelist = 'featurelist'
328 file = 'file'
329 float = 'float'
330 floatlist = 'floatlist'
331 geometry = 'geometry'
332 int = 'int'
333 intlist = 'intlist'
334 str = 'str'
335 strlist = 'strlist'
336 time = 'time'
339class GeometryType(Enum):
340 """Feature geometry type.
342 OGC and SQL/MM geometry types.
344 References:
346 OGC 06-103r4 (https://www.ogc.org/standards/sfa), https://postgis.net/docs/manual-3.3/using_postgis_dbmanagement.html
347 """
349 geometry = 'geometry'
351 point = 'point'
352 curve = 'curve'
353 surface = 'surface'
355 geometrycollection = 'geometrycollection'
357 linestring = 'linestring'
358 line = 'line'
359 linearring = 'linearring'
361 polygon = 'polygon'
362 triangle = 'triangle'
364 polyhedralsurface = 'polyhedralsurface'
365 tin = 'tin'
367 multipoint = 'multipoint'
368 multicurve = 'multicurve'
369 multilinestring = 'multilinestring'
370 multipolygon = 'multipolygon'
371 multisurface = 'multisurface'
373 circularstring = 'circularstring'
374 compoundcurve = 'compoundcurve'
375 curvepolygon = 'curvepolygon'
378class CliParams(Data):
379 """CLI params"""
380 pass
381################################################################################
384################################################################################
385# /core/_access.pyinc
388Acl: TypeAlias = list[tuple[int, str]]
389"""Access Control list.
391A list of tuples ``(ACL bit, role-name)`` where ``ACL bit`` is ``1`` if the access is allowed and ``0`` otherwise.
392"""
394AclStr: TypeAlias = str
395"""A string of comma-separated pairs ``allow <role>`` or ``deny <role>``."""
398class Access(Enum):
399 """Access mode."""
401 read = 'read'
402 write = 'write'
403 create = 'create'
404 delete = 'delete'
407class PermissionsConfig:
408 """Permissions configuration."""
410 all: Optional[AclStr]
411 """All permissions."""
412 read: Optional[AclStr]
413 """Permission to read the object."""
414 write: Optional[AclStr]
415 """Permission to change the object."""
416 create: Optional[AclStr]
417 """Permission to create new objects."""
418 delete: Optional[AclStr]
419 """Permission to delete objects."""
420 edit: Optional[AclStr]
421 """A combination of write, create and delete."""
424class ConfigWithAccess(Config):
425 """Basic config with permissions."""
427 access: Optional[AclStr]
428 """Permission to read or use the object."""
429 permissions: Optional[PermissionsConfig]
430 """Access permissions."""
431################################################################################
434################################################################################
435# /core/_error.pyinc
438"""App Error object"""
440class Error(Exception):
441 """GWS error."""
442 def __repr__(self):
443 return log.exception_backtrace(self)[0]
446class ConfigurationError(Error):
447 """GWS Configuration error."""
448 pass
451class NotFoundError(Error):
452 """Generic 'object not found' error."""
453 pass
456class ForbiddenError(Error):
457 """Generic 'forbidden' error."""
458 pass
461class BadRequestError(Error):
462 """Generic 'bad request' error."""
463 pass
466class ResponseTooLargeError(Error):
467 """Generic error when a response is too large."""
468 pass
471##
472################################################################################
476################################################################################
477# /spec/types.pyinc
480class ApplicationManifestPlugin(Data):
481 """Plugin description."""
483 path: DirPath
484 """Path to the plugin python module."""
486 name: str = ''
487 """Optional name, when omitted, the directory name will be used."""
490class ApplicationManifest(Data):
491 """Application manifest."""
493 excludePlugins: Optional[list[str]]
494 """Names of the core plugins that should be deactivated."""
495 plugins: Optional[list[ApplicationManifestPlugin]]
496 """Custom plugins."""
497 locales: list[str]
498 """Locale names supported by this application."""
499 withFallbackConfig: bool = False
500 """Use a minimal fallback configuration."""
501 withStrictConfig: bool = False
502 """Stop the application upon a configuration error."""
505class ExtObjectDescriptor(Data):
506 """Extension object descriptor."""
508 extName: str
509 """Full extension name like ``gws.ext.object.layer.wms``."""
510 extType: str
511 """Extension type like ``wms``."""
512 classPtr: type
513 """Class object."""
514 ident: str
515 """Identifier."""
516 modName: str
517 """Name of the module that contains the class."""
518 modPath: str
519 """Path to the module that contains the class."""
522class ExtCommandDescriptor(Data):
523 extName: str
524 """Full extension name like ``gws.ext.object.layer.wms``."""
525 extType: str
526 """Extension type like ``wms``."""
527 methodName: str
528 """Command method name."""
529 methodPtr: Callable
530 """Command method."""
531 request: 'Request'
532 """Request sent to the command."""
533 tArg: str
534 """Type of the command argument."""
535 tOwner: str
536 """Type of the command owner."""
537 owner: ExtObjectDescriptor
538 """Descriptor of the command owner."""
541class SpecReadOption(Enum):
542 """Read options."""
544 acceptExtraProps = 'acceptExtraProps'
545 """Accept extra object properties."""
546 allowMissing = 'allowMissing'
547 """Allow otherwise required properties to be missing."""
548 caseInsensitive = 'caseInsensitive'
549 """Case insensitive search for properties. """
550 convertValues = 'convertValues'
551 """Try to convert values to specified types."""
552 ignoreExtraProps = 'ignoreExtraProps'
553 """Silently ignore extra object properties."""
554 verboseErrors = 'verboseErrors'
555 """Provide verbose error messages."""
558class CommandCategory(Enum):
559 """Command category."""
561 api = 'api'
562 """API command."""
563 cli = 'cli'
564 """CLI command."""
565 get = 'get'
566 """Web GET command."""
567 post = 'post'
568 """Web POST command."""
571class SpecRuntime:
572 """Specification runtime."""
574 version: str
575 """Application version."""
576 manifest: ApplicationManifest
577 """Application manifest."""
578 appBundlePaths: list[str]
579 """List of client bundle paths."""
581 def read(self, value, type_name: str, path: str = '', options=Optional[set[SpecReadOption]]):
582 """Read a raw value according to a spec.
584 Args:
585 value: Raw value from config or request.
586 type_name: Object type name.
587 path: Config file path.
588 options: Read options.
590 Returns:
591 A parsed object.
592 """
594 def object_descriptor(self, type_name: str) -> Optional[ExtObjectDescriptor]:
595 """Get an object descriptor.
597 Args:
598 type_name: Object type name.
600 Returns:
601 A descriptor or ``None`` if the type is not found.
602 """
604 def command_descriptor(self, command_category: CommandCategory, command_name: str) -> Optional[ExtCommandDescriptor]:
605 """Get a command descriptor.
607 Args:
608 command_category: Command category.
609 command_name: Command name.
611 Returns:
612 A descriptor or ``None`` if the command is not found.
613 """
615 def register_object(self, ext_name: ClassRef, obj_type: str, cls: type):
616 """Dynamically register an extension object."""
618 def get_class(self, classref: ClassRef, ext_type: Optional[str] = None) -> Optional[type]:
619 """Get a class object for a class reference.
621 Args:
622 classref: Class reference.
623 ext_type: Extension type.
625 Returns:
626 A class or ``None`` if the reference is not found.
627 """
629 def parse_classref(self, classref: ClassRef) -> tuple[Optional[type], str, str]:
630 """Parse a class reference.
632 Args:
633 classref: Class reference.
635 Returns:
636 A tuple ``(class object, class name, extension name)``.
637 """
638################################################################################
642################################################################################
643# /core/_tree.pyinc
646class Object:
647 """GWS object."""
649 permissions: dict[Access, Acl]
650 """Mapping from an access mode to a list of ACL tuples."""
652 def props(self, user: 'User') -> Props:
653 """Generate a ``Props`` struct for this object.
655 Args:
656 user: The user for which the props should be generated.
657 """
659 def __init__(self):
660 self.permissions = {}
663from .core import tree_impl
665setattr(tree_impl, 'Access', Access)
666setattr(tree_impl, 'Error', Error)
667setattr(tree_impl, 'ConfigurationError', ConfigurationError)
668setattr(tree_impl, 'Data', Data)
669setattr(tree_impl, 'Props', Props)
670setattr(tree_impl, 'Object', Object)
672Object.__repr__ = tree_impl.object_repr
675class Node(Object):
676 """Configurable GWS object."""
678 extName: str
679 """Full extension name like ``gws.ext.object.layer.wms``."""
680 extType: str
681 """Extension type like ``wms``."""
683 config: Config
684 """Configuration for this object."""
685 root: 'Root'
686 """Root object."""
687 parent: 'Node'
688 """Parent object."""
689 children: list['Node']
690 """Child objects."""
691 uid: str
692 """Unique ID."""
694 def initialize(self, config):
695 return tree_impl.node_initialize(self, config)
697 def pre_configure(self):
698 """Pre-configuration hook."""
700 def configure(self):
701 """Configuration hook."""
703 def post_configure(self):
704 """Post-configuration hook."""
706 def activate(self):
707 """Activation hook."""
709 def create_child(self, classref: ClassRef, config: Config = None, **kwargs):
710 """Create a child object.
712 Args:
713 classref: Class reference.
714 config: Configuration.
715 **kwargs: Additional configuration properties.
717 Returns:
718 A newly created object or ``None`` if the object cannot be initialized.
719 """
720 return tree_impl.node_create_child(self, classref, config, **kwargs)
722 def create_child_if_configured(self, classref: ClassRef, config=None, **kwargs):
723 """Create a child object if the configuration is not None.
725 Args:
726 classref: Class reference.
727 config: Configuration.
728 **kwargs: Additional configuration properties.
730 Returns:
731 A newly created object or ``None`` if the configuration is ``None`` or the object cannot be initialized.
732 """
733 return tree_impl.node_create_child_if_configured(self, classref, config, **kwargs)
735 def create_children(self, classref: ClassRef, configs: list[Config], **kwargs):
736 """Create a list of child objects from a list of configurations.
738 Args:
739 classref: Class reference.
740 configs: List of configurations.
741 **kwargs: Additional configuration properties.
743 Returns:
744 A list of newly created objects.
745 """
746 return tree_impl.node_create_children(self, classref, configs, **kwargs)
748 def cfg(self, key: str, default=None):
749 """Fetch a configuration property.
751 Args:
752 key: Property key. If it contains dots, fetch nested properties.
753 default: Default to return if the property is not found.
755 Returns:
756 A property value.
757 """
758 return tree_impl.node_cfg(self, key, default)
760 def is_a(self, classref: ClassRef):
761 """Check if a the node matches the class reference.
763 Args:
764 classref: Class reference.
766 Returns:
767 A boolean.
768 """
769 return tree_impl.is_a(self.root, self, classref)
771 def find_all(self, classref: ClassRef):
772 """Find all children that match a specific class.
774 Args:
775 classref: Class reference.
777 Returns:
778 A list of objects.
779 """
780 return tree_impl.node_find_all(self, classref)
782 def find_first(self, classref: ClassRef):
783 """Find the first child that matches a specific class.
785 Args:
786 classref: Class reference.
788 Returns:
789 An object or ``None``.
790 """
791 return tree_impl.node_find_first(self, classref)
793 def find_closest(self, classref: ClassRef):
794 """Find the closest node ancestor that matches a specific class.
796 Args:
797 classref: Class reference.
799 Returns:
800 An object or ``None``.
801 """
803 return tree_impl.node_find_closest(self, classref)
805 def find_ancestors(self, classref: Optional[ClassRef] = None):
806 """Find node ancestors that match a specific class.
808 Args:
809 classref: Class reference.
811 Returns:
812 A list of objects.
813 """
814 return tree_impl.node_find_ancestors(self, classref)
816 def find_descendants(self, classref: Optional[ClassRef] = None):
817 """Find node descendants that match a specific class.
819 Args:
820 classref: Class reference.
822 Returns:
823 A list of objects in the depth-first order.
824 """
826 return tree_impl.node_find_descendants(self, classref)
828 def enter_middleware(self, req: 'WebRequester') -> Optional['WebResponder']:
829 """Begin middleware processing.
831 Args:
832 req: Requester object.
834 Returns:
835 A Responder object or ``None``.
836 """
838 def exit_middleware(self, req: 'WebRequester', res: 'WebResponder'):
839 """Finish middleware processing.
841 Args:
842 req: Requester object.
843 res: Current responder object.
844 """
846 def register_middleware(self, name: str, depends_on: Optional[list[str]] = None):
847 """Register itself as a middleware handler.
849 Args:
850 name: Handler name.
851 depends_on: List of handler names this handler depends on.
852 """
853 return tree_impl.node_register_middleware(self, name, depends_on)
856class Root:
857 """Root node of the object tree."""
859 app: 'Application'
860 """Application object."""
861 specs: 'SpecRuntime'
862 """Specs runtime."""
863 configErrors: list
864 """List of configuration errors."""
866 nodes: list['Node']
867 uidMap: dict[str, 'Node']
868 uidCount: int
869 configStack: list['Node']
871 def __init__(self, specs: 'SpecRuntime'):
872 tree_impl.root_init(self, specs)
874 def initialize(self, obj, config):
875 return tree_impl.root_initialize(self, obj, config)
877 def post_initialize(self):
878 """Post-initialization hook."""
879 return tree_impl.root_post_initialize(self)
881 def activate(self):
882 return tree_impl.root_activate(self)
884 def find_all(self, classref: ClassRef):
885 """Find all objects that match a specific class.
887 Args:
888 classref: Class reference.
890 Returns:
891 A list of objects.
892 """
893 return tree_impl.root_find_all(self, classref)
895 def find_first(self, classref: ClassRef):
896 """Find the first object that match a specific class.
898 Args:
899 classref: Class reference.
901 Returns:
902 An object or ``None``.
903 """
904 return tree_impl.root_find_first(self, classref)
906 def get(self, uid: str = None, classref: Optional[ClassRef] = None):
907 """Get an object by its unique ID.
909 Args:
910 uid: Object uid.
911 classref: Class reference. If provided, ensures that the object matches the reference.
913 Returns:
914 An object or ``None``.
915 """
916 return tree_impl.root_get(self, uid, classref)
918 def object_count(self) -> int:
919 """Return the number of objects in the tree."""
920 return tree_impl.root_object_count(self)
922 def create(self, classref: ClassRef, parent: Optional['Node'] = None, config: Config = None, **kwargs):
923 """Create an object.
925 Args:
926 classref: Class reference.
927 parent: Parent object.
928 config: Configuration.
929 **kwargs: Additional configuration properties.
931 Returns:
932 A newly created object or ``None`` if the object cannot be initialized.
933 """
934 return tree_impl.root_create(self, classref, parent, config, **kwargs)
936 def create_shared(self, classref: ClassRef, config: Config = None, **kwargs):
937 """Create a shared object, attached directly to the root.
939 Args:
940 classref: Class reference.
941 config: Configuration.
942 **kwargs: Additional configuration properties.
944 Returns:
945 A newly created object or ``None`` if the object cannot be initialized.
946 """
947 return tree_impl.root_create_shared(self, classref, config, **kwargs)
949 def create_temporary(self, classref: ClassRef, config: Config = None, **kwargs):
950 """Create a temporary object, not attached to the tree.
952 Args:
953 classref: Class reference.
954 config: Configuration.
955 **kwargs: Additional configuration properties.
957 Returns:
958 A newly created object or ``None`` if the object cannot be initialized.
959 """
960 return tree_impl.root_create_temporary(self, classref, config, **kwargs)
962 def create_application(self, config: Config = None, **kwargs) -> 'Application':
963 """Create the Application object.
965 Args:
966 config: Configuration.
967 **kwargs: Additional configuration properties.
969 Returns:
970 The Application object.
971 """
972 return tree_impl.root_create_application(self, config, **kwargs)
975def create_root(specs: 'SpecRuntime') -> Root:
976 return Root(specs)
979def props_of(obj: Object, user: 'User', *context) -> Optional['Props']:
980 return tree_impl.props_of(obj, user, *context)
981################################################################################
985################################################################################
986# /lib/image/types.pyinc
989class ImageFormat(Enum):
990 """Image format"""
992 png8 = 'png8'
993 """png 8-bit"""
994 png24 = 'png24'
995 """png 24-bit"""
998class Image:
999 """Image object."""
1001 def size(self) -> Size:
1002 """Get the image size.
1004 Returns:
1005 A tuple ``(width, height)``.
1006 """
1008 def mode(self) -> str:
1009 """Get the image mode.
1011 Returns:
1012 PIL image mode.
1013 """
1015 def add_box(self, color=None) -> 'Image':
1016 """Creates a 1 pixel wide box on the image's edge.
1018 Args:
1019 color: Color of the box's lines.
1021 Returns:
1022 The image with a box around the edges.
1023 """
1025 def add_text(self, text: str, x=0, y=0, color=None) -> 'Image':
1026 """Adds text to an image object.
1028 Args:
1029 text: Text to be displayed.
1031 x: x-coordinate.
1033 y: y-coordinate.
1035 color: Color of the text.
1037 Returns:
1038 The image object with the text displayed.
1039 """
1041 def compose(self, other: 'Image', opacity=1) -> 'Image':
1042 """Places other image on top of the current image.
1044 Args:
1045 other: Image to place on top.
1046 opacity: other image's opacity.
1048 Returns:
1049 The image object with the other image on top as an alpha composition.
1050 """
1052 def crop(self, box) -> 'Image':
1053 """Crops the image with respect to the given box.
1055 Args:
1056 box: `(width, height)`
1058 Returns:
1059 The cropped image object.
1060 """
1062 def paste(self, other: 'Image', where=None) -> 'Image':
1063 """Pastes an image to a specific location.
1065 Args:
1066 other: Image that will be placed.
1068 where: `(x-coord, y-coord)` indicating where the upper left corer should be pasted.
1070 Returns:
1071 The image object with the other image placed inside.
1072 """
1074 def resize(self, size: Size, **kwargs) -> 'Image':
1075 """Resizes the image and scales it to fit the new size.
1077 Args:
1078 size: `(width, height)`
1080 Returns:
1081 The resized image object.
1082 """
1084 def rotate(self, angle: int, **kwargs) -> 'Image':
1085 """Rotates the image.
1087 Args:
1088 angle: Angle to rotate the image.
1090 Returns:
1091 The rotated image object.
1092 """
1094 def to_bytes(self, mime: Optional[str] = None, options: Optional[dict] = None) -> bytes:
1095 """Converts the image object to bytes.
1097 The ``options`` dict can contain any PIL save option
1098 (see https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html).
1100 An additional option ``mode`` is the image mode
1101 (see https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes).
1102 If provided, the image is converted to that mode before saving.
1104 An additional option ``background`` sets the color to replace the alpha channel with
1105 when converting from RGBA to RGB (default is white).
1107 Args:
1108 mime: The mime type.
1109 options: A dict of options.
1111 Returns:
1112 The image as bytes.
1113 """
1115 def to_base64(self, mime: Optional[str] = None, options: Optional[dict] = None) -> str:
1116 """Return the image content as a base64 encoded string."""
1118 def to_data_url(self, mime: Optional[str] = None, options: Optional[dict] = None) -> str:
1119 """Return the image content as a base64-based data url."""
1121 def to_path(self, path: str, mime: Optional[str] = None, options: Optional[dict] = None) -> str:
1122 """Saves the image object at a given path.
1124 Args:
1125 path: Image's path location.
1126 mime: The mime type.
1127 options: A dict of options.
1129 Returns:
1130 The path to the image.
1131 """
1133 def to_array(self) -> 'numpy.typing.NDArray':
1134 """Converts the image to an array.
1136 Returns:
1137 The image as an array. For each row each entry contains the pixel information.
1138 """
1140 def compare_to(self, other: 'Image') -> float:
1141 """Compare this image to another one.
1143 @TODO describe the alogrithm
1145 Returns:
1146 The similarity factor as a float (the more, the different).
1147 '0' means images are equal.
1148 """
1149################################################################################
1152################################################################################
1153# /lib/intl/types.pyinc
1156class Locale(Data):
1157 """Locale data."""
1159 uid: str
1160 dateFormatLong: str
1161 dateFormatMedium: str
1162 dateFormatShort: str
1163 dateUnits: str
1164 """date unit names, e.g. 'YMD' for 'en', 'JMT' for 'de'"""
1165 dayNamesLong: list[str]
1166 dayNamesShort: list[str]
1167 dayNamesNarrow: list[str]
1168 firstWeekDay: int
1170 language: str
1171 """Language code: ``de``"""
1172 language3: str
1173 """ISO 3166-1 alpha-3 language code: ``deu``."""
1174 languageBib: str
1175 """Bibliographic language code.."""
1176 languageName: str
1177 """Native language name: ``Deutsch``."""
1178 languageNameEn: str
1179 """English language name: ``German``."""
1181 territory: str
1182 territoryName: str
1183 monthNamesLong: list[str]
1184 monthNamesShort: list[str]
1185 monthNamesNarrow: list[str]
1186 numberDecimal: str
1187 numberGroup: str
1190class DateTimeFormat(Enum):
1191 """Enumeration indicating the length of the date/time format."""
1192 short = 'short'
1193 """Local short format."""
1194 medium = 'medium'
1195 """Local medium format."""
1196 long = 'long'
1197 """Local long format."""
1198 iso = 'iso'
1199 """ISO 8601 format."""
1202class NumberFormat(Enum):
1203 """Enumeration indicating the number format."""
1204 decimal = 'decimal'
1205 """Locale decimal format."""
1206 grouped = 'grouped'
1207 """Locale grouped format."""
1208 currency = 'currency'
1209 """Locale currency format"""
1210 percent = 'percent'
1211 """Locale percent format."""
1214class DateFormatter:
1215 """Locale-aware date formatter."""
1217 def format(self, fmt: DateTimeFormat | str, date: Optional[Union['datetime.date', str]] = None) -> str:
1218 """Formats the date.
1220 Args:
1221 fmt: Format type or a `strftime` format string
1222 date: Date, if none is given the current date will be used as default.
1224 Returns:
1225 A formatted date string.
1226 """
1228 def short(self, date=None) -> str:
1229 """Returns the date in the short format ``11.12.13``."""
1231 def medium(self, date=None) -> str:
1232 """Returns the date in the medium format ``11.12.2013``."""
1234 def long(self, date=None) -> str:
1235 """Returns the date in the medium format ``11. Dezember 2013``."""
1237 def iso(self, date=None) -> str:
1238 """Returns the date in the ISO 8601 format ``2013-12-11``."""
1241class TimeFormatter:
1242 """Locale-aware time formatter."""
1244 def format(self, fmt: DateTimeFormat | str, time: Optional[Union['datetime.time', str]] = None) -> str:
1245 """Formats the time.
1247 Args:
1248 fmt: Format type or a `strftime` format string
1249 time: Time, if none is given the current time will be used as default.
1251 Returns:
1252 A formatted time string.
1253 """
1255 def short(self, time=None) -> str:
1256 """Returns the time in the short format ``11:22``."""
1258 def medium(self, time=None) -> str:
1259 """Returns the time in the medium format ``11:22:33``."""
1261 def long(self, time=None) -> str:
1262 """Returns the time in the medium format ``11:22:33``."""
1264 def iso(self, time=None) -> str:
1265 """Returns the time and date in the ISO 8601 format."""
1268class NumberFormatter:
1269 """Locale-aware number formatter."""
1271 def format(self, fmt: NumberFormat | str, n, *args, **kwargs) -> str:
1272 """Formats the number with respect to the locale.
1274 Args:
1275 fmt: Format type or a python `format` string
1276 n: Number.
1277 kwargs: Passes the currency parameter forward.
1279 Returns:
1280 A formatted number.
1281 """
1283 def decimal(self, n, *args, **kwargs) -> str:
1284 """Returns formatted decimal value."""
1286 def grouped(self, n, *args, **kwargs) -> str:
1287 """Returns formatted decimal value with group separators."""
1289 def currency(self, n, currency: str, *args, **kwargs) -> str:
1290 """Returns formatted currency value."""
1292 def percent(self, n, *args, **kwargs) -> str:
1293 """Returns formatted percent value."""
1294################################################################################
1297################################################################################
1298# /lib/job/types.pyinc
1301class JobState(Enum):
1302 """Background job state."""
1304 init = 'init'
1305 """The job is being created."""
1306 open = 'open'
1307 """The job is just created and waiting for start."""
1308 running = 'running'
1309 """The job is running."""
1310 complete = 'complete'
1311 """The job has been completed successfully."""
1312 error = 'error'
1313 """There was an error."""
1314 cancel = 'cancel'
1315 """The job was cancelled."""
1318class Job:
1319 """Background Job object."""
1321 error: str
1322 payload: dict
1323 state: JobState
1324 uid: str
1325 user: 'User'
1327 def run(self): ...
1329 def update(self, payload: Optional[dict] = None, state: Optional[JobState] = None, error: Optional[str] = None): ...
1331 def cancel(self): ...
1333 def remove(self): ...
1334################################################################################
1337################################################################################
1338# /lib/metadata/types.pyinc
1341class MetadataLink(Data):
1342 """Link metadata."""
1344 about: Optional[str]
1345 description: Optional[str]
1346 format: Optional[str]
1347 formatVersion: Optional[str]
1348 function: Optional[str]
1349 mimeType: Optional[str]
1350 scheme: Optional[str]
1351 title: Optional[str]
1352 type: Optional[str]
1353 url: Optional[Url]
1356class MetadataAccessConstraint(Data):
1357 """Metadata AccessConstraint."""
1359 title: Optional[str]
1360 type: Optional[str]
1363class MetadataLicense(Data):
1364 """Metadata License."""
1366 title: Optional[str]
1367 url: Optional[Url]
1370class MetadataAttribution(Data):
1371 """Metadata Attribution."""
1373 title: Optional[str]
1374 url: Optional[Url]
1377class Metadata(Data):
1378 """Metadata."""
1380 abstract: Optional[str]
1381 accessConstraints: Optional[list[MetadataAccessConstraint]]
1382 attribution: Optional[MetadataAttribution]
1383 authorityIdentifier: Optional[str]
1384 authorityName: Optional[str]
1385 authorityUrl: Optional[str]
1386 catalogCitationUid: Optional[str]
1387 catalogUid: Optional[str]
1388 fees: Optional[str]
1389 image: Optional[str]
1390 keywords: Optional[list[str]]
1391 language3: Optional[str]
1392 language: Optional[str]
1393 languageName: Optional[str]
1394 license: Optional[MetadataLicense]
1395 name: Optional[str]
1396 parentIdentifier: Optional[str]
1397 title: Optional[str]
1399 contactAddress: Optional[str]
1400 contactAddressType: Optional[str]
1401 contactArea: Optional[str]
1402 contactCity: Optional[str]
1403 contactCountry: Optional[str]
1404 contactEmail: Optional[str]
1405 contactFax: Optional[str]
1406 contactOrganization: Optional[str]
1407 contactPerson: Optional[str]
1408 contactPhone: Optional[str]
1409 contactPosition: Optional[str]
1410 contactProviderName: Optional[str]
1411 contactProviderSite: Optional[str]
1412 contactRole: Optional[str]
1413 contactUrl: Optional[str]
1414 contactZip: Optional[str]
1416 dateBegin: Optional[str]
1417 dateCreated: Optional[str]
1418 dateEnd: Optional[str]
1419 dateUpdated: Optional[str]
1421 inspireKeywords: Optional[list[str]]
1422 inspireMandatoryKeyword: Optional[str]
1423 inspireDegreeOfConformity: Optional[str]
1424 inspireResourceType: Optional[str]
1425 inspireSpatialDataServiceType: Optional[str]
1426 inspireSpatialScope: Optional[str]
1427 inspireSpatialScopeName: Optional[str]
1428 inspireTheme: Optional[str]
1429 inspireThemeName: Optional[str]
1430 inspireThemeNameEn: Optional[str]
1432 isoMaintenanceFrequencyCode: Optional[str]
1433 isoQualityConformanceExplanation: Optional[str]
1434 isoQualityConformanceQualityPass: Optional[bool]
1435 isoQualityConformanceSpecificationDate: Optional[str]
1436 isoQualityConformanceSpecificationTitle: Optional[str]
1437 isoQualityLineageSource: Optional[str]
1438 isoQualityLineageSourceScale: Optional[int]
1439 isoQualityLineageStatement: Optional[str]
1440 isoRestrictionCode: Optional[str]
1441 isoServiceFunction: Optional[str]
1442 isoScope: Optional[str]
1443 isoScopeName: Optional[str]
1444 isoSpatialRepresentationType: Optional[str]
1445 isoTopicCategories: Optional[list[str]]
1446 isoSpatialResolution: Optional[str]
1448 metaLinks: Optional[list[MetadataLink]]
1449 serviceMetaLink: Optional[MetadataLink]
1450 extraLinks: Optional[list[MetadataLink]]
1451################################################################################
1454################################################################################
1455# /lib/style/types.pyinc
1458class StyleValues(Data):
1459 """CSS Style values."""
1461 fill: Color
1463 stroke: Color
1464 stroke_dasharray: list[int]
1465 stroke_dashoffset: int
1466 stroke_linecap: Literal['butt', 'round', 'square']
1467 stroke_linejoin: Literal['bevel', 'round', 'miter']
1468 stroke_miterlimit: int
1469 stroke_width: int
1471 marker: Literal['circle', 'square', 'arrow', 'cross']
1472 marker_fill: Color
1473 marker_size: int
1474 marker_stroke: Color
1475 marker_stroke_dasharray: list[int]
1476 marker_stroke_dashoffset: int
1477 marker_stroke_linecap: Literal['butt', 'round', 'square']
1478 marker_stroke_linejoin: Literal['bevel', 'round', 'miter']
1479 marker_stroke_miterlimit: int
1480 marker_stroke_width: int
1482 with_geometry: Literal['all', 'none']
1483 with_label: Literal['all', 'none']
1485 label_align: Literal['left', 'right', 'center']
1486 label_background: Color
1487 label_fill: Color
1488 label_font_family: str
1489 label_font_size: int
1490 label_font_style: Literal['normal', 'italic']
1491 label_font_weight: Literal['normal', 'bold']
1492 label_line_height: int
1493 label_max_scale: int
1494 label_min_scale: int
1495 label_offset_x: int
1496 label_offset_y: int
1497 label_padding: list[int]
1498 label_placement: Literal['start', 'end', 'middle']
1499 label_stroke: Color
1500 label_stroke_dasharray: list[int]
1501 label_stroke_dashoffset: int
1502 label_stroke_linecap: Literal['butt', 'round', 'square']
1503 label_stroke_linejoin: Literal['bevel', 'round', 'miter']
1504 label_stroke_miterlimit: int
1505 label_stroke_width: int
1507 point_size: int
1508 icon: str
1510 offset_x: int
1511 offset_y: int
1514class StyleProps(Props):
1515 """CSS Style properties."""
1517 cssSelector: Optional[str]
1518 text: Optional[str]
1519 values: Optional[dict]
1522class Style:
1523 """CSS Style object."""
1525 cssSelector: str
1526 text: str
1527 values: StyleValues
1528################################################################################
1531################################################################################
1532# /lib/xmlx/types.pyinc
1535class XmlNamespace(Data):
1536 """XML namespace."""
1538 uid: str
1539 """Unique ID."""
1540 xmlns: str
1541 """Default prefix for this Namespace."""
1542 uri: Url
1543 """Namespace uri."""
1544 schemaLocation: Url
1545 """Namespace schema location."""
1546 version: str
1547 """Namespace version."""
1548 extendsGml: bool
1549 """Namespace schema extends the GML3 schema."""
1552class XmlElement(Iterable):
1553 """XML Element.
1556 Extends ``ElementTree.Element`` (https://docs.python.org/3/library/xml.etree.elementtree.html#element-objects).
1557 """
1559 tag: str
1560 """Tag name, with an optional namespace in the Clark notation."""
1562 text: Optional[str]
1563 """Text before first subelement."""
1565 tail: Optional[str]
1566 """Text after this element's end tag."""
1568 attrib: dict
1569 """Dictionary of element attributes."""
1571 name: str
1572 """Element name (tag without a namespace)."""
1574 lcName: str
1575 """Element name (tag without a namespace) in lower case."""
1577 caseInsensitive: bool
1578 """Element is case-insensitive."""
1580 def __len__(self) -> int: ...
1582 def __iter__(self) -> Iterator['XmlElement']: ...
1584 def __getitem__(self, item: int) -> 'XmlElement': ...
1586 def append(self, subelement: 'XmlElement'):
1587 """Adds the element subelement to the end of this element’s internal list of subelements."""
1589 def attr(self, key: str, default=None):
1590 """Finds the value for a given key in the ``XmlElementImpl``.
1592 Args:
1593 key: Key of the attribute.
1594 default: The default return.
1596 Returns:
1597 The vale of the key, If the key is not found the default is returned.
1598 """
1600 def clear(self):
1601 """Resets an element."""
1603 def extend(self, subelements: Iterable['XmlElement']):
1604 """Appends subelements from a sequence object with zero or more elements."""
1606 def find(self, path: str) -> Optional['XmlElement']:
1607 """Finds first matching element by tag name or path."""
1609 def findall(self, path: str) -> list['XmlElement']:
1610 """Finds all matching subelements by name or path."""
1612 def findtext(self, path: str, default: Optional[str] = None) -> str:
1613 """Finds text for first matching element by name or path."""
1615 def get(self, key: str, default=None):
1616 """Returns the value to a given key."""
1618 def insert(self, index: int, subelement: 'XmlElement'):
1619 """Inserts subelement at the given position in this element."""
1621 def items(self) -> Iterable[tuple[str, Any]]:
1622 """Returns the element attributes as a sequence of (name, value) pairs."""
1624 def iter(self, tag: Optional[str] = None) -> Iterable['XmlElement']:
1625 """Creates a tree iterator."""
1627 def iterfind(self, path: Optional[str] = None) -> Iterable['XmlElement']:
1628 """Returns an iterable of all matching subelements by name or path."""
1630 def itertext(self) -> Iterable[str]:
1631 """Creates a text iterator and returns all inner text."""
1633 def keys(self) -> Iterable[str]:
1634 """Returns the elements attribute names as a list."""
1636 def remove(self, other: 'XmlElement'):
1637 """Removes the other element from the element."""
1639 def set(self, key: str, value: Any):
1640 """Set the attribute key on the element to value."""
1642 # extensions
1644 def add(self, tag: str, attrib: Optional[dict] = None, **extra) -> 'XmlElement':
1645 """Creates a new ``XmlElementImpl`` and adds it as a child.
1647 Args:
1648 tag: XML tag.
1649 attrib: XML attributes ``{key, value}``.
1651 Returns:
1652 A XmlElementImpl.
1653 """
1655 def children(self) -> list['XmlElement']:
1656 """Returns the children of the current ``XmlElementImpl``."""
1658 def findfirst(self, *paths) -> Optional['XmlElement']:
1659 """Returns the first element in the current element.
1661 Args:
1662 paths: Path as ``tag/tag2/tag3`` to the Element to search in.
1664 Returns:
1665 Returns the first found element.
1666 """
1668 def textof(self, *paths) -> str:
1669 """Returns the text of a given child-element.
1671 Args:
1672 paths: Path as ``tag/tag2/tag3`` to the Element.
1674 Returns:
1675 The text of the element.
1676 """
1678 def textlist(self, *paths, deep=False) -> list[str]:
1679 """Collects texts from child-elements.
1681 Args:
1682 paths: Path as ``tag/tag2/tag3`` to the Element to collect texts from.
1683 deep: If ``False`` it only looks into direct children, otherwise it searches for texts in the complete children-tree.
1685 Returns:
1686 A list containing all the text from the child-elements.
1687 """
1689 def textdict(self, *paths, deep=False) -> dict[str, str]:
1690 """Collects texts from child-elements.
1692 Args:
1693 paths: Path as ``tag/tag2/tag3`` to the Element to collect texts from.
1694 deep: If ``False`` it only looks into direct children, otherwise it searches for texts in the complete children-tree.
1696 Returns:
1697 A dict containing all the text from the child-elements.
1698 """
1700 def to_string(
1701 self,
1702 extra_namespaces: Optional[list[XmlNamespace]] = None,
1703 compact_whitespace: bool = False,
1704 remove_namespaces: bool = False,
1705 with_namespace_declarations: bool = False,
1706 with_schema_locations: bool = False,
1707 with_xml_declaration: bool = False,
1708 ) -> str:
1709 """Converts the Element object to a string.
1711 Args:
1712 extra_namespaces: Extra namespaces to add to the document.
1713 compact_whitespace: Remove all whitespace outside of tags and elements.
1714 remove_namespaces: Remove all namespace references.
1715 with_namespace_declarations: Include the namespace declarations.
1716 with_schema_locations: Include schema locations.
1717 with_xml_declaration: Include the xml declaration.
1719 Returns:
1720 An XML string.
1721 """
1723 def to_dict(self) -> dict:
1724 """Creates a dictionary from an XmlElement object."""
1726 def to_list(
1727 self,
1728 fold_tags: bool = True,
1729 remove_namespaces: bool = False,
1730 ) -> list:
1731 """Parse an XML element into a list of arguments.
1733 Args:
1734 fold_tags: If true, folds nested tag names into ``parent/child`` names.
1735 remove_namespaces: If true, removes all namespaces.
1736 """
1737################################################################################
1740################################################################################
1741# /lib/uom/types.pyinc
1744class Uom(Enum):
1745 """Unit of measure."""
1747 mi = 'mi'
1748 """statute mile (EPSG 9093)"""
1749 us_ch = 'us-ch'
1750 """us survey chain (EPSG 9033)"""
1751 us_ft = 'us-ft'
1752 """us survey foot (EPSG 9003)"""
1753 us_in = 'us-in'
1754 """us survey inch us_in"""
1755 us_mi = 'us-mi'
1756 """us survey mile (EPSG 9035)"""
1757 us_yd = 'us-yd'
1758 """us survey yard us_yd"""
1759 cm = 'cm'
1760 """centimetre (EPSG 1033)"""
1761 ch = 'ch'
1762 """chain (EPSG 9097)"""
1763 dm = 'dm'
1764 """decimeter dm"""
1765 deg = 'deg'
1766 """degree (EPSG 9102)"""
1767 fath = 'fath'
1768 """fathom (EPSG 9014)"""
1769 ft = 'ft'
1770 """foot (EPSG 9002)"""
1771 grad = 'grad'
1772 """grad (EPSG 9105)"""
1773 inch = 'in'
1774 """inch in"""
1775 km = 'km'
1776 """kilometre (EPSG 9036)"""
1777 link = 'link'
1778 """link (EPSG 9098)"""
1779 m = 'm'
1780 """metre (EPSG 9001)"""
1781 mm = 'mm'
1782 """millimetre (EPSG 1025)"""
1783 kmi = 'kmi'
1784 """nautical mile (EPSG 9030)"""
1785 rad = 'rad'
1786 """radian (EPSG 9101)"""
1787 yd = 'yd'
1788 """yard (EPSG 9096)"""
1789 px = 'px'
1790 """pixel"""
1791 pt = 'pt'
1792 """point"""
1795UomValue: TypeAlias = tuple[float, Uom]
1796"""A value with a unit."""
1798UomValueStr: TypeAlias = str
1799"""A value with a unit like ``5mm``."""
1801UomPoint: TypeAlias = tuple[float, float, Uom]
1802"""A Point with a unit."""
1804UomPointStr: TypeAlias = list[str]
1805"""A Point with a unit like ``["1mm", "2mm"]``."""
1807UomSize: TypeAlias = tuple[float, float, Uom]
1808"""A Size with a unit."""
1810UomSizeStr: TypeAlias = list[str]
1811"""A Size with a unit like ``["1mm", "2mm"]``."""
1813UomExtent: TypeAlias = tuple[float, float, float, float, Uom]
1814"""Extent with a unit."""
1816UomExtentStr: TypeAlias = list[str]
1817"""Extent with a unit like ``["1mm", "2mm", "3mm", "4mm"]``."""
1818################################################################################
1822################################################################################
1823# /gis/crs/types.pyinc
1826CrsName: TypeAlias = int | str
1827"""A CRS code like ``EPSG:3857`` or a SRID like ``3857``."""
1830class CrsFormat(Enum):
1831 """CRS name format."""
1833 none = ''
1834 crs = 'crs'
1835 """Like ``crs84``."""
1836 srid = 'srid'
1837 """Like ``3857``."""
1838 epsg = 'epsg'
1839 """Like ``EPSG:3857``."""
1840 url = 'url'
1841 """Like ``http://www.opengis.net/gml/srs/epsg.xml#3857``."""
1842 uri = 'uri'
1843 """Like ``http://www.opengis.net/def/crs/epsg/0/3857``."""
1844 urnx = 'urnx'
1845 """Like ``urn:x-ogc:def:crs:EPSG:3857``."""
1846 urn = 'urn'
1847 """Like ``urn:ogc:def:crs:EPSG::3857``."""
1850class Axis(Enum):
1851 """Axis orientation."""
1853 xy = 'xy'
1854 yx = 'yx'
1857class Bounds(Data):
1858 """Geo-referenced extent."""
1860 crs: 'Crs'
1861 extent: Extent
1864class Crs:
1865 """Coordinate reference system."""
1867 srid: int
1868 """CRS SRID."""
1869 axis: Axis
1870 """Axis orientation."""
1871 uom: Uom
1872 """CRS unit."""
1873 isGeographic: bool
1874 """This CRS is geographic."""
1875 isProjected: bool
1876 """This CRS is projected."""
1877 isYX: bool
1878 """This CRS has a lat/lon axis."""
1879 proj4text: str
1880 """Proj4 definition."""
1881 wkt: str
1882 """WKT definition."""
1884 epsg: str
1885 """Name in the "epsg" format."""
1886 urn: str
1887 """Name in the "urn" format."""
1888 urnx: str
1889 """Name in the "urnx" format."""
1890 url: str
1891 """Name in the "url" format."""
1892 uri: str
1893 """Name in the "uri" format."""
1895 name: str
1896 """CRS name."""
1897 base: int
1898 """Base CRS code."""
1899 datum: str
1900 """Datum."""
1902 wgsExtent: Extent
1903 """CRS Extent in the WGS projection."""
1904 extent: Extent
1905 """CRS own Extent."""
1906 bounds: Bounds
1907 """CRS own Bounds."""
1909 def axis_for_format(self, fmt: 'CrsFormat') -> Axis:
1910 """Get the axis depending on the string format.
1912 We adhere to the GeoServer convention here:
1913 https://docs.geoserver.org/latest/en/user/services/wfs/axis_order.html
1914 """
1916 def transform_extent(self, extent: Extent, crs_to: 'Crs') -> Extent:
1917 """Transform an Extent from this CRS to another.
1919 Args:
1920 extent: Extent.
1921 crs_to: Target CRS.
1923 Returns:
1924 A transformed Extent.
1925 """
1927 def transformer(self, crs_to: 'Crs') -> Callable:
1928 """Create a transformer function to another CRS.
1930 Args:
1931 crs_to: Target CRS.
1933 Returns:
1934 A function.
1935 """
1937 def to_string(self, fmt: Optional['CrsFormat'] = None) -> str:
1938 """Return a string representation of the CRS.
1940 Args:
1941 fmt: Format to use.
1943 Returns:
1944 A string.
1945 """
1947 def to_geojson(self) -> dict:
1948 """Return a geojson representation of the CRS (as per GJ2008).
1950 Returns:
1951 A GeoJson dict.
1953 References:
1954 https://geojson.org/geojson-spec#named-crs
1955 """
1956################################################################################
1959################################################################################
1960# /gis/render/types.pyinc
1963class MapView(Data):
1964 """Map view."""
1966 bounds: Bounds
1967 center: Point
1968 rotation: int
1969 scale: int
1970 mmSize: Size
1971 pxSize: Size
1972 dpi: int
1975class MapRenderInputPlaneType(Enum):
1976 """Map render input plane type."""
1978 features = 'features'
1979 image = 'image'
1980 imageLayer = 'imageLayer'
1981 svgLayer = 'svgLayer'
1982 svgSoup = 'svgSoup'
1985class MapRenderInputPlane(Data):
1986 """Map render input plane."""
1988 type: MapRenderInputPlaneType
1989 features: list['Feature']
1990 image: 'Image'
1991 layer: 'Layer'
1992 opacity: float
1993 soupPoints: list[Point]
1994 soupTags: list[Any]
1995 styles: list['Style']
1996 subLayers: list[str]
1999class MapRenderInput(Data):
2000 """Map render input."""
2002 backgroundColor: int
2003 bbox: Extent
2004 center: Point
2005 crs: 'Crs'
2006 dpi: int
2007 mapSize: UomSize
2008 notify: Callable
2009 planes: list['MapRenderInputPlane']
2010 project: 'Project'
2011 rotation: int
2012 scale: int
2013 user: 'User'
2014 visibleLayers: Optional[list['Layer']]
2017class MapRenderOutputPlaneType(Enum):
2018 """Map render output plane type."""
2020 image = 'image'
2021 path = 'path'
2022 svg = 'svg'
2025class MapRenderOutputPlane(Data):
2026 """Map render output plane."""
2028 type: MapRenderOutputPlaneType
2029 path: str
2030 elements: list[XmlElement]
2031 image: 'Image'
2034class MapRenderOutput(Data):
2035 """Map render output."""
2037 planes: list['MapRenderOutputPlane']
2038 view: MapView
2041class LayerRenderInputType(Enum):
2042 """Layer render input type."""
2044 box = 'box'
2045 xyz = 'xyz'
2046 svg = 'svg'
2049class LayerRenderInput(Data):
2050 """Layer render input."""
2052 boxBuffer: int
2053 boxSize: int
2054 extraParams: dict
2055 project: 'Project'
2056 style: 'Style'
2057 type: LayerRenderInputType
2058 user: 'User'
2059 view: MapView
2060 x: int
2061 y: int
2062 z: int
2065class LayerRenderOutput(Data):
2066 """Layer render output."""
2068 content: bytes
2069 tags: list[XmlElement]
2070################################################################################
2073################################################################################
2074# /gis/source/types.pyinc
2077class TileMatrix(Data):
2078 """WMTS TileMatrix object."""
2080 uid: str
2081 scale: float
2082 x: float
2083 y: float
2084 width: float
2085 height: float
2086 tileWidth: float
2087 tileHeight: float
2088 extent: Extent
2091class TileMatrixSet(Data):
2092 """WMTS TileMatrixSet object."""
2094 uid: str
2095 crs: 'Crs'
2096 matrices: list[TileMatrix]
2099class SourceStyle(Data):
2100 """Generic OGC Style."""
2102 isDefault: bool
2103 legendUrl: Url
2104 metadata: 'Metadata'
2105 name: str
2108class SourceLayer(Data):
2109 """Generic OGC Layer."""
2111 aLevel: int
2112 aPath: str
2113 aUid: str
2115 dataSource: dict
2116 metadata: 'Metadata'
2118 supportedCrs: list['Crs']
2119 wgsExtent: Extent
2121 isExpanded: bool
2122 isGroup: bool
2123 isImage: bool
2124 isQueryable: bool
2125 isVisible: bool
2127 layers: list['SourceLayer']
2129 name: str
2130 title: str
2132 legendUrl: Url
2133 opacity: int
2134 scaleRange: list[float]
2136 styles: list[SourceStyle]
2137 defaultStyle: Optional[SourceStyle]
2139 tileMatrixIds: list[str]
2140 tileMatrixSets: list[TileMatrixSet]
2141 imageFormat: str
2142 resourceUrls: dict
2144 sourceId: str
2145 properties: dict
2146################################################################################
2150################################################################################
2151# /server/types.pyinc
2154class ServerManager(Node):
2155 """Server configuration manager."""
2157 templates: list['Template']
2159 def create_server_configs(self, target_dir: str, script_path: str, pid_paths: dict):
2160 """Create server configuration files."""
2163class ServerMonitor(Node):
2164 """File Monitor facility."""
2166 def add_directory(self, path: str, pattern: 'Regex'):
2167 """Add a directory to monitor.
2169 Args:
2170 path: Directory path.
2171 pattern: Regex pattern for files to watch.
2172 """
2174 def add_file(self, path: str):
2175 """Add a file to watch.
2177 Args:
2178 path: File path.
2179 """
2181 def start(self):
2182 """Start the monitor."""
2183################################################################################
2187################################################################################
2188# /base/feature/types.pyinc
2191FeatureUid: TypeAlias = str
2192"""Unique Feature id."""
2194class FeatureRecord(Data):
2195 """Raw data from a feature source."""
2197 attributes: dict
2198 meta: dict
2199 uid: Optional[str]
2200 shape: Optional['Shape']
2203class FeatureProps(Props):
2204 """Feature Proprieties."""
2206 attributes: dict
2207 cssSelector: str
2208 errors: Optional[list['ModelValidationError']]
2209 createWithFeatures: Optional[list['FeatureProps']]
2210 isNew: bool
2211 modelUid: str
2212 uid: str
2213 views: dict
2216class Feature:
2217 """Feature object."""
2219 attributes: dict
2220 category: str
2221 cssSelector: str
2222 errors: list['ModelValidationError']
2223 isNew: bool
2224 model: 'Model'
2225 props: 'FeatureProps'
2226 record: 'FeatureRecord'
2227 views: dict
2228 createWithFeatures: list['Feature']
2229 insertedPrimaryKey: str
2231 def get(self, name: str, default=None) -> Any: ...
2233 def has(self, name: str) -> bool: ...
2235 def set(self, name: str, value: Any) -> 'Feature': ...
2237 def raw(self, name: str) -> Any: ...
2239 def render_views(self, templates: list['Template'], **kwargs) -> 'Feature': ...
2241 def shape(self) -> Optional['Shape']: ...
2243 def to_geojson(self, user: 'User') -> dict: ...
2245 def to_svg(self, view: 'MapView', label: Optional[str] = None, style: Optional['Style'] = None) -> list[XmlElement]: ...
2247 def transform_to(self, crs: 'Crs') -> 'Feature': ...
2249 def uid(self) -> FeatureUid: ...
2250################################################################################
2253################################################################################
2254# /base/shape/types.pyinc
2257class ShapeProps(Props):
2258 """Shape properties."""
2260 crs: str
2261 geometry: dict
2264class Shape(Object):
2265 """Geo-referenced geometry."""
2267 type: GeometryType
2268 """Geometry type."""
2270 crs: 'Crs'
2271 """CRS of this shape."""
2273 x: Optional[float]
2274 """X-coordinate for Point geometries, None otherwise."""
2276 y: Optional[float]
2277 """Y-coordinate for Point geometries, None otherwise."""
2279 # common props
2281 def area(self) -> float:
2282 """Computes the area of the geometry."""
2284 def bounds(self) -> Bounds:
2285 """Returns a Bounds object that bounds this shape."""
2287 def centroid(self) -> 'Shape':
2288 """Returns a centroid as a Point shape."""
2290 # formats
2292 def to_wkb(self) -> bytes:
2293 """Returns a WKB representation of this shape as a binary string."""
2295 def to_wkb_hex(self) -> str:
2296 """Returns a WKB representation of this shape as a hex string."""
2298 def to_ewkb(self) -> bytes:
2299 """Returns an EWKB representation of this shape as a binary string."""
2301 def to_ewkb_hex(self) -> str:
2302 """Returns an EWKB representation of this shape as a hex string."""
2304 def to_wkt(self) -> str:
2305 """Returns a WKT representation of this shape."""
2307 def to_ewkt(self) -> str:
2308 """Returns an EWKT representation of this shape."""
2310 def to_geojson(self, always_xy=False) -> dict:
2311 """Returns a GeoJSON representation of this shape."""
2313 def to_props(self) -> ShapeProps:
2314 """Returns a GeoJSON representation of this shape."""
2316 # predicates (https://shapely.readthedocs.io/en/stable/manual.html#predicates-and-relationships)
2318 def is_empty(self) -> bool:
2319 """Returns True if this shape is empty."""
2321 def is_ring(self) -> bool:
2322 """Returns True if this shape is a ring."""
2324 def is_simple(self) -> bool:
2325 """Returns True if this shape is 'simple'."""
2327 def is_valid(self) -> bool:
2328 """Returns True if this shape is valid."""
2330 def equals(self, other: 'Shape') -> bool:
2331 """Returns True if this shape is equal to the other."""
2333 def contains(self, other: 'Shape') -> bool:
2334 """Returns True if this shape contains the other."""
2336 def covers(self, other: 'Shape') -> bool:
2337 """Returns True if this shape covers the other."""
2339 def covered_by(self, other: 'Shape') -> bool:
2340 """Returns True if this shape is covered by the other."""
2342 def crosses(self, other: 'Shape') -> bool:
2343 """Returns True if this shape crosses the other."""
2345 def disjoint(self, other: 'Shape') -> bool:
2346 """Returns True if this shape does not intersect with the other."""
2348 def intersects(self, other: 'Shape') -> bool:
2349 """Returns True if this shape intersects with the other."""
2351 def overlaps(self, other: 'Shape') -> bool:
2352 """Returns True if this shape overlaps the other."""
2354 def touches(self, other: 'Shape') -> bool:
2355 """Returns True if this shape touches the other."""
2357 def within(self, other: 'Shape') -> bool:
2358 """Returns True if this shape is within the other."""
2360 # set operations
2362 def union(self, others: list['Shape']) -> 'Shape':
2363 """Computes a union of this shape and other shapes."""
2365 def intersection(self, *others: 'Shape') -> 'Shape':
2366 """Computes an intersection of this shape and other shapes."""
2368 # convertors
2370 def to_multi(self) -> 'Shape':
2371 """Converts a singly-geometry shape to a multi-geometry one."""
2373 def to_type(self, new_type: 'GeometryType') -> 'Shape':
2374 """Converts a geometry to another type."""
2376 # misc
2378 def tolerance_polygon(self, tolerance=None, quad_segs=None) -> 'Shape':
2379 """Builds a buffer polygon around the shape."""
2381 def transformed_to(self, crs: 'Crs') -> 'Shape':
2382 """Returns this shape transformed to another CRS."""
2383################################################################################
2387################################################################################
2388# /base/action/types.pyinc
2391class ActionManager(Node):
2392 """Action manager."""
2394 def actions_for_project(self, project: 'Project', user: 'User') -> list['Action']:
2395 """Get a list of actions for a Project, to which a User has access to."""
2397 def find_action(self, project: Optional['Project'], ext_type: str, user: 'User') -> Optional['Action']:
2398 """Locate an Action object.
2400 Args:
2401 project: Project to se
2402 ext_type:
2403 user:
2405 Returns:
2407 """
2409 def prepare_action(
2410 self,
2411 command_category: CommandCategory,
2412 command_name: str,
2413 params: dict,
2414 user: 'User',
2415 read_options=None,
2416 ) -> tuple[Callable, Request]: ...
2419class Action(Node):
2420 pass
2421################################################################################
2424################################################################################
2425# /base/auth/types.pyinc
2428class User(Object):
2429 """User object."""
2431 isGuest: bool
2432 """User is a Guest."""
2434 authProvider: 'AuthProvider'
2435 """User authorization provider."""
2437 attributes: dict
2438 """Public user attributes."""
2439 data: dict
2440 """Private user data."""
2441 roles: set[str]
2442 """User roles."""
2443 uid: str
2444 """Global user uid."""
2446 authToken: str
2447 """Token used for authorization."""
2448 displayName: str
2449 """User display name."""
2450 email: str
2451 """User email."""
2452 localUid: str
2453 """User uid within its authorization provider."""
2454 loginName: str
2455 """User login name."""
2456 mfaUid: str
2457 """MFA adapter uid."""
2458 mfaSecret: str
2459 """MFA secret."""
2461 def acl_bit(self, access: 'Access', obj: 'Object') -> Optional[int]:
2462 """Get the ACL bit for a specific object.
2464 Args:
2465 access: Access mode.
2466 obj: Requested object.
2468 Returns:
2469 ``1`` or ``0`` if the user's permissions have the bit and ``None`` otherwise.
2470 """
2472 def can(self, access: Access, obj: 'Object', *context) -> bool:
2473 """Check if the user can access an object.
2475 Args:
2476 access: Access mode.
2477 obj: Requested object.
2478 *context: Further objects to check.
2480 Returns:
2481 ``True`` is access is granted.
2482 """
2484 def can_create(self, obj: 'Object', *context) -> bool:
2485 """Check if the user has "create" permission on an object."""
2487 def can_delete(self, obj: 'Object', *context) -> bool:
2488 """Check if the user has "delete" permission on an object."""
2490 def can_read(self, obj: 'Object', *context) -> bool:
2491 """Check if the user has "read" permission on an object."""
2493 def can_use(self, obj: 'Object', *context) -> bool:
2494 """Check if the user has "read" permission on an object."""
2496 def can_write(self, obj: 'Object', *context) -> bool:
2497 """Check if the user has "write" permission on an object."""
2499 def can_edit(self, obj: 'Object', *context) -> bool:
2500 """Check if the user has "edit" permissions on an object."""
2502 def acquire(self, uid: str = None, classref: Optional[ClassRef] = None, access: Optional[Access] = None) -> Optional['Object']:
2503 """Get a readable object by uid.
2505 Args:
2506 uid: Object uid.
2507 classref: Class reference. If provided, ensures that the object matches the reference.
2508 access: Access mode, assumed ``Access.read`` if omitted.
2510 Returns:
2511 A readable object or ``None`` if the object does not exists or user doesn't have a permission.
2512 """
2514 def require(self, uid: str = None, classref: Optional[ClassRef] = None, access: Optional[Access] = None) -> 'Object':
2515 """Get a readable object by uid and fail if not found.
2517 Args:
2518 uid: Object uid.
2519 classref: Class reference. If provided, ensures that the object matches the reference.
2520 access: Access mode, assumed ``Access.read`` if omitted.
2522 Returns:
2523 A readable object.
2525 Raises:
2526 ``NotFoundError`` if the object doesn't exist.
2527 ``ForbiddenError`` if the user cannot read the object.
2528 """
2530 def require_project(self, uid: str = None) -> 'Project':
2531 """Get a readable Project object.
2533 Args:
2534 uid: Project uid.
2536 Returns:
2537 A Project object.
2538 """
2540 def require_layer(self, uid=None) -> 'Layer':
2541 """Get a readable Layer object.
2543 Args:
2544 uid: Layer uid.
2546 Returns:
2547 A Layer object.
2548 """
2551class AuthManager(Node):
2552 """Authentication manager."""
2554 guestSession: 'AuthSession'
2555 """Preconfigured Guest session."""
2557 guestUser: 'User'
2558 """Preconfigured Guest user."""
2559 systemUser: 'User'
2560 """Preconfigured System user."""
2562 providers: list['AuthProvider']
2563 """Authentication providers."""
2564 methods: list['AuthMethod']
2565 """Authentication methods."""
2566 mfAdapters: list['AuthMultiFactorAdapter']
2567 """Authentication MFA handlers."""
2569 sessionMgr: 'AuthSessionManager'
2570 """Session manager."""
2572 def authenticate(self, method: 'AuthMethod', credentials: Data) -> Optional['User']:
2573 """Authenticate a user.
2575 Args:
2576 method: Authentication method.
2577 credentials: Credentials object.
2579 Returns:
2580 An authenticated User or ``None`` if authentication failed.
2581 """
2583 def get_user(self, user_uid: str) -> Optional['User']:
2584 """Get a User by its global uid.
2586 Args:
2587 user_uid: Global user uid.
2588 Returns:
2589 A User or ``None``.
2590 """
2592 def get_provider(self, uid: str) -> Optional['AuthProvider']:
2593 """Get an authentication Provider by its uid.
2595 Args:
2596 uid: Uid.
2597 Returns:
2598 A Provider or ``None``.
2599 """
2601 def get_method(self, uid: str) -> Optional['AuthMethod']:
2602 """Get an authentication Method by its uid.
2604 Args:
2605 uid: Uid.
2606 Returns:
2607 A Method or ``None``.
2608 """
2610 def get_mf_adapter(self, uid: str) -> Optional['AuthMultiFactorAdapter']:
2611 """Get an authentication Provider by its uid.
2613 Args:
2614 uid: Uid.
2615 Returns:
2616 A Provider or ``None``.
2617 """
2619 def serialize_user(self, user: 'User') -> str:
2620 """Return a string representation of a User.
2622 Args:
2623 user: A User object.
2625 Returns:
2626 A json string.
2627 """
2629 def unserialize_user(self, ser: str) -> Optional['User']:
2630 """Restore a User object from a serialized representation.
2632 Args:
2633 ser: A json string.
2635 Returns:
2636 A User object.
2637 """
2640class AuthMethod(Node):
2641 """Authentication Method."""
2643 authMgr: 'AuthManager'
2645 secure: bool
2646 """Method is only allowed in a secure context."""
2648 def open_session(self, req: 'WebRequester') -> Optional['AuthSession']:
2649 """Attempt to open a Session for a Requester.
2651 Args:
2652 req: Requester object.
2654 Returns:
2655 A Session or ``None``.
2656 """
2658 def close_session(self, req: 'WebRequester', res: 'WebResponder') -> bool:
2659 """Close a previously opened Session.
2661 Args:
2662 req: Requester object.
2663 res: Responder object.
2665 Returns:
2666 True if the Session was successfully closed.
2667 """
2670class AuthMultiFactorState(Enum):
2671 open = 'open'
2672 ok = 'ok'
2673 retry = 'retry'
2674 failed = 'failed'
2677class AuthMultiFactorTransaction(Data):
2678 state: AuthMultiFactorState
2679 restartCount: int
2680 verifyCount: int
2681 secret: str
2682 startTime: int
2683 generateTime: int
2684 message: str
2685 adapter: 'AuthMultiFactorAdapter'
2686 user: 'User'
2689class AuthMultiFactorAdapter(Node):
2690 """Multi-factor authentication adapter."""
2692 message: str
2693 lifeTime: int
2694 maxRestarts: int
2695 maxVerifyAttempts: int
2697 def start(self, user: 'User') -> Optional[AuthMultiFactorTransaction]:
2698 """Initialize an MFA transaction for the user."""
2700 def verify(self, mfa: AuthMultiFactorTransaction, payload: dict) -> AuthMultiFactorTransaction:
2701 """Verify a payload."""
2703 def cancel(self, mfa: AuthMultiFactorTransaction):
2704 """Cancel the transaction."""
2706 def check_state(self, mfa: AuthMultiFactorTransaction) -> bool:
2707 """Check if the MFA transaction is valid."""
2709 def check_restart(self, mfa: AuthMultiFactorTransaction) -> bool:
2710 """Check if the transaction can be restarted."""
2712 def restart(self, mfa: AuthMultiFactorTransaction) -> Optional[AuthMultiFactorTransaction]:
2713 """Restart the transaction."""
2715 def key_uri(self, secret: str | bytes, issuer_name: str, account_name: str) -> Optional[str]:
2716 """Generate a key uri for this adapter."""
2719class AuthProvider(Node):
2720 """Authentication Provider."""
2722 allowedMethods: list[str]
2723 """List of Method types allowed to be used with this Provider."""
2725 def get_user(self, local_uid: str) -> Optional['User']:
2726 """Get a User from its local uid.
2728 Args:
2729 local_uid: User local uid.
2731 Returns:
2732 A User or ``None``.
2733 """
2735 def authenticate(self, method: 'AuthMethod', credentials: Data) -> Optional['User']:
2736 """Authenticate a user.
2738 Args:
2739 method: Authentication method.
2740 credentials: Credentials object.
2742 Returns:
2743 An authenticated User or ``None`` if authentication failed.
2744 """
2746 def serialize_user(self, user: 'User') -> str:
2747 """Return a string representation of a User.
2749 Args:
2750 user: A User object.
2752 Returns:
2753 A json string.
2754 """
2756 def unserialize_user(self, ser: str) -> Optional['User']:
2757 """Restore a User object from a serialized representation.
2759 Args:
2760 ser: A json string.
2762 Returns:
2763 A User object.
2764 """
2767class AuthSession:
2768 """Authentication session."""
2770 uid: str
2771 """Session uid."""
2772 method: Optional['AuthMethod']
2773 """Authentication method that created the session."""
2774 user: 'User'
2775 """Authorized User."""
2776 data: dict
2777 """Session data."""
2778 created: 'datetime.datetime'
2779 """Session create time."""
2780 updated: 'datetime.datetime'
2781 """Session update time."""
2782 isChanged: bool
2783 """Session has changed since the last update.."""
2785 def get(self, key: str, default=None):
2786 """Get a session data value.
2788 Args:
2789 key: Value name.
2790 default: Default value.
2792 Returns:
2793 A value or the default.
2794 """
2796 def set(self, key: str, value):
2797 """Set a session data value.
2799 Args:
2800 key: Value name.
2801 value: A value.
2802 """
2805class AuthSessionManager(Node):
2806 """Authentication session Manager."""
2808 lifeTime: int
2809 """Session lifetime in seconds."""
2811 def create(self, method: 'AuthMethod', user: 'User', data: Optional[dict] = None) -> 'AuthSession':
2812 """Create a new Session,
2814 Args:
2815 method: Auth Method that creates the Session.
2816 user: 'User' for which the Session is created.
2817 data: Session data.
2819 Returns:
2820 A new Session.
2821 """
2823 def delete(self, sess: 'AuthSession'):
2824 """Delete a Session.
2826 Args:
2827 sess: Session object.
2828 """
2830 def delete_all(self):
2831 """Delete all Sessions.
2832 """
2834 def get(self, uid: str) -> Optional['AuthSession']:
2835 """Get Session by its uid.
2837 Args:
2838 uid: Session uid.
2840 Returns:
2841 A Session or ``None``.
2842 """
2844 def get_valid(self, uid: str) -> Optional['AuthSession']:
2845 """Get a valid Session by its uid.
2847 Args:
2848 uid: Session uid.
2850 Returns:
2851 A Session or ``None`` if uid does not exists or the Session is not valid.
2852 """
2854 def get_all(self) -> list['AuthSession']:
2855 """Get all sessions."""
2857 def save(self, sess: 'AuthSession'):
2858 """Save the Session state into a persistent storage.
2860 Args:
2861 sess: Session object.
2862 """
2864 def touch(self, sess: 'AuthSession'):
2865 """Update the Session last activity timestamp.
2867 Args:
2868 sess: Session object.
2869 """
2871 def cleanup(self):
2872 """Remove invalid Sessions from the storage.
2873 """
2874################################################################################
2878################################################################################
2879# /base/layer/types.pyinc
2882class LayerDisplayMode(Enum):
2883 """Layer display mode."""
2885 box = 'box'
2886 """Display a layer as one big image (WMS-alike)."""
2887 tile = 'tile'
2888 """Display a layer in a tile grid."""
2889 client = 'client'
2890 """Draw a layer in the client."""
2893class LayerClientOptions(Data):
2894 """Client options for a layer."""
2896 expanded: bool
2897 """A layer is expanded in the list view."""
2898 unlisted: bool
2899 """A layer is hidden in the list view."""
2900 selected: bool
2901 """A layer is initially selected."""
2902 hidden: bool
2903 """A layer is initially hidden."""
2904 unfolded: bool
2905 """A layer is not listed, but its children are."""
2906 exclusive: bool
2907 """Only one of this layer's children is visible at a time."""
2910class TileGrid(Data):
2911 """Tile grid."""
2913 uid: str
2914 bounds: Bounds
2915 origin: Origin
2916 resolutions: list[float]
2917 tileSize: int
2920class LayerCache(Data):
2921 """Layer cache."""
2923 maxAge: int
2924 maxLevel: int
2925 requestBuffer: int
2926 requestTiles: int
2929class FeatureLoadingStrategy(Enum):
2930 """Loading strategy for features."""
2932 all = 'all'
2933 """Load all features."""
2934 bbox = 'bbox'
2935 """Load only features in the current map extent."""
2936 lazy = 'lazy'
2937 """Load features on demand."""
2940class LayerOws(Node):
2941 """Layer OWS controller."""
2943 allowedServiceUids: list[str]
2944 deniedServiceUids: list[str]
2945 featureName: str
2946 geometryName: str
2947 layerName: str
2948 models: list['Model']
2949 xmlNamespace: Optional['XmlNamespace']
2952class Layer(Node):
2953 """Layer object."""
2955 canRenderBox: bool
2956 canRenderSvg: bool
2957 canRenderXyz: bool
2959 isEnabledForOws: bool
2960 isGroup: bool
2961 isSearchable: bool
2963 hasLegend: bool
2965 bounds: Bounds
2966 zoomBounds: Bounds
2967 wgsExtent: Extent
2968 mapCrs: 'Crs'
2969 clientOptions: LayerClientOptions
2970 displayMode: LayerDisplayMode
2971 loadingStrategy: FeatureLoadingStrategy
2972 imageFormat: str
2973 opacity: float
2974 resolutions: list[float]
2975 title: str
2977 grid: Optional[TileGrid]
2978 cache: Optional[LayerCache]
2980 metadata: 'Metadata'
2981 legend: Optional['Legend']
2982 legendUrl: str
2984 finders: list['Finder']
2985 templates: list['Template']
2986 models: list['Model']
2987 ows: 'LayerOws'
2989 layers: list['Layer']
2991 sourceLayers: list['SourceLayer']
2993 def render(self, lri: LayerRenderInput) -> Optional['LayerRenderOutput']: ...
2995 def find_features(self, search: 'SearchQuery', user: 'User') -> list['Feature']: ...
2997 def render_legend(self, args: Optional[dict] = None) -> Optional['LegendRenderOutput']: ...
2999 def url_path(self, kind: str) -> str: ...
3001 def ancestors(self) -> list['Layer']: ...
3003 def descendants(self) -> list['Layer']: ...
3004################################################################################
3007################################################################################
3008# /base/legend/types.pyinc
3011class LegendRenderOutput(Data):
3012 """Legend render output."""
3014 html: str
3015 image: 'Image'
3016 image_path: str
3017 size: Size
3018 mime: str
3021class Legend(Node):
3022 """Legend object."""
3024 def render(self, args: Optional[dict] = None) -> Optional[LegendRenderOutput]: ...
3025################################################################################
3028################################################################################
3029# /base/map/types.pyinc
3032class Map(Node):
3033 """Map object."""
3035 rootLayer: 'Layer'
3037 bounds: Bounds
3038 center: Point
3039 coordinatePrecision: int
3040 initResolution: float
3041 resolutions: list[float]
3042 title: str
3043 wgsExtent: Extent
3044################################################################################
3048################################################################################
3049# /base/model/types.pyinc
3052class ModelClientOptions(Data):
3053 """Client options for a model"""
3055 keepFormOpen: Optional[bool]
3057class ModelValidationError(Data):
3058 """Validation error."""
3060 fieldName: str
3061 message: str
3064class ModelOperation(Enum):
3065 """Model operation."""
3067 read = 'read'
3068 create = 'create'
3069 update = 'update'
3070 delete = 'delete'
3073class ModelReadTarget(Enum):
3074 """Target for the read operation."""
3076 map = 'map'
3077 """The feature is to be drawn on a map."""
3078 searchResults = 'searchResults'
3079 """The feature is to be displayed in the search results list."""
3080 list = 'list'
3081 """The feature is to be displayed in a list view."""
3082 editList = 'editList'
3083 """The feature is to be displayed in an editable list view."""
3084 editForm = 'editForm'
3085 """The feature is to be displayed in an edit form ."""
3088class ModelDbSelect(Data):
3089 """Database select statement."""
3091 columns: list['sqlalchemy.Column']
3092 geometryWhere: list
3093 keywordWhere: list
3094 where: list
3095 order: list
3098class ModelContext(Data):
3099 """Model context."""
3101 op: ModelOperation
3102 target: ModelReadTarget
3103 user: 'User'
3104 project: 'Project'
3105 relDepth: int = 0
3106 maxDepth: int = 0
3107 search: 'SearchQuery'
3108 dbSelect: ModelDbSelect
3109 dbConnection: 'sqlalchemy.Connection'
3112EmptyValue = object()
3113"""Special value for empty fields."""
3115ErrorValue = object()
3116"""Special value for invalid fields."""
3119class ModelWidget(Node):
3120 """Model widget."""
3122 supportsTableView: bool = True
3125class ModelValidator(Node):
3126 """Model Validator."""
3128 message: str
3129 ops: set[ModelOperation]
3131 def validate(self, field: 'ModelField', feature: 'Feature', mc: ModelContext) -> bool: ...
3134class ModelValue(Node):
3135 """Model value."""
3137 isDefault: bool
3138 ops: set[ModelOperation]
3140 def compute(self, field: 'ModelField', feature: 'Feature', mc: 'ModelContext'): ...
3143class ModelField(Node):
3144 """Model field."""
3146 name: str
3147 title: str
3149 attributeType: AttributeType
3151 widget: Optional['ModelWidget'] = None
3153 values: list['ModelValue']
3154 validators: list['ModelValidator']
3156 isPrimaryKey: bool
3157 isRequired: bool
3158 isUnique: bool
3159 isAuto: bool
3161 supportsFilterSearch: bool = False
3162 supportsGeometrySearch: bool = False
3163 supportsKeywordSearch: bool = False
3165 model: 'Model'
3167 def before_select(self, mc: ModelContext): ...
3169 def after_select(self, features: list['Feature'], mc: ModelContext): ...
3171 def before_create(self, feature: 'Feature', mc: ModelContext): ...
3173 def after_create(self, feature: 'Feature', mc: ModelContext): ...
3175 def before_create_related(self, to_feature: 'Feature', mc: ModelContext): ...
3177 def after_create_related(self, to_feature: 'Feature', mc: ModelContext): ...
3179 def before_update(self, feature: 'Feature', mc: ModelContext): ...
3181 def after_update(self, feature: 'Feature', mc: ModelContext): ...
3183 def before_delete(self, feature: 'Feature', mc: ModelContext): ...
3185 def after_delete(self, feature: 'Feature', mc: ModelContext): ...
3187 def do_init(self, feature: 'Feature', mc: ModelContext): ...
3189 def do_init_related(self, to_feature: 'Feature', mc: ModelContext): ...
3191 def do_validate(self, feature: 'Feature', mc: ModelContext): ...
3193 def from_props(self, feature: 'Feature', mc: ModelContext): ...
3195 def to_props(self, feature: 'Feature', mc: ModelContext): ...
3197 def from_record(self, feature: 'Feature', mc: ModelContext): ...
3199 def to_record(self, feature: 'Feature', mc: ModelContext): ...
3201 def related_models(self) -> list['Model']: ...
3203 def find_relatable_features(self, search: 'SearchQuery', mc: ModelContext) -> list['Feature']: ...
3205 def raw_to_python(self, feature: 'Feature', value, mc: ModelContext): ...
3207 def prop_to_python(self, feature: 'Feature', value, mc: ModelContext): ...
3209 def python_to_raw(self, feature: 'Feature', value, mc: ModelContext): ...
3211 def python_to_prop(self, feature: 'Feature', value, mc: ModelContext): ...
3213 def describe(self) -> Optional['ColumnDescription']: ...
3216class Model(Node):
3217 """Data Model."""
3219 clientOptions: ModelClientOptions
3220 defaultSort: list['SearchSort']
3221 fields: list['ModelField']
3222 geometryCrs: Optional['Crs']
3223 geometryName: str
3224 geometryType: Optional[GeometryType]
3225 isEditable: bool
3226 loadingStrategy: 'FeatureLoadingStrategy'
3227 title: str
3228 uidName: str
3229 withTableView: bool
3231 def find_features(self, search: 'SearchQuery', mc: ModelContext) -> list['Feature']: ...
3233 def get_features(self, uids: Iterable[str | int], mc: ModelContext) -> list['Feature']: ...
3235 def init_feature(self, feature: 'Feature', mc: ModelContext): ...
3237 def create_feature(self, feature: 'Feature', mc: ModelContext) -> FeatureUid: ...
3239 def update_feature(self, feature: 'Feature', mc: ModelContext) -> FeatureUid: ...
3241 def delete_feature(self, feature: 'Feature', mc: ModelContext) -> FeatureUid: ...
3243 def validate_feature(self, feature: 'Feature', mc: ModelContext) -> bool: ...
3245 def feature_from_props(self, props: 'FeatureProps', mc: ModelContext) -> 'Feature': ...
3247 def feature_to_props(self, feature: 'Feature', mc: ModelContext) -> 'FeatureProps': ...
3249 def feature_to_view_props(self, feature: 'Feature', mc: ModelContext) -> 'FeatureProps': ...
3251 def describe(self) -> Optional['DataSetDescription']: ...
3253 def field(self, name: str) -> Optional['ModelField']: ...
3255 def related_models(self) -> list['Model']: ...
3258class ModelManager(Node):
3259 """Model manager."""
3261 def get_model(self, uid: str, user: 'User' = None, access: Access = None) -> Optional['Model']: ...
3263 def find_model(self, *objects, user: 'User' = None, access: Access = None) -> Optional['Model']: ...
3265 def editable_models(self, project: 'Project', user: 'User') -> list['Model']: ...
3267 def default_model(self) -> 'Model': ...
3268################################################################################
3271################################################################################
3272# /base/database/types.pyinc
3275class DatabaseModel(Model):
3276 """Database-based data model."""
3278 db: 'DatabaseProvider'
3279 sqlFilter: str
3280 tableName: str
3282 def table(self) -> 'sqlalchemy.Table': ...
3284 def column(self, column_name: str) -> 'sqlalchemy.Column': ...
3286 def uid_column(self) -> 'sqlalchemy.Column': ...
3291class ColumnDescription(Data):
3292 """Database column description."""
3294 columnIndex: int
3295 comment: str
3296 default: str
3297 geometrySrid: int
3298 geometryType: GeometryType
3299 isAutoincrement: bool
3300 isNullable: bool
3301 isPrimaryKey: bool
3302 isUnique: bool
3303 hasDefault: bool
3304 name: str
3305 nativeType: str
3306 options: dict
3307 type: AttributeType
3310class RelationshipDescription(Data):
3311 """Database relationship description."""
3313 name: str
3314 schema: str
3315 fullName: str
3316 foreignKeys: str
3317 referredKeys: str
3320class DataSetDescription(Data):
3321 """Description of a database Table or a GDAL Dataset."""
3323 columns: list[ColumnDescription]
3324 columnMap: dict[str, ColumnDescription]
3325 fullName: str
3326 geometryName: str
3327 geometrySrid: int
3328 geometryType: GeometryType
3329 name: str
3330 schema: str
3333class DatabaseManager(Node):
3334 """Database manager."""
3336 providers: list['DatabaseProvider']
3338 def create_provider(self, cfg: Config, **kwargs) -> 'DatabaseProvider': ...
3340 def find_provider(self, uid: Optional[str] = None, ext_type: Optional[str] = None) -> Optional['DatabaseProvider']: ...
3343DatabaseTableAlike: TypeAlias = Union['sqlalchemy.Table', str]
3344"""SA ``Table`` object or a string table name."""
3347class DatabaseProvider(Node):
3348 """Database Provider.
3350 A database Provider wraps SQLAlchemy ``Engine`` and ``Connection`` objects
3351 and provides common db functionality.
3352 """
3354 url: str
3355 """Connection url."""
3357 def column(self, table: DatabaseTableAlike, column_name: str) -> 'sqlalchemy.Column':
3358 """SA ``Column`` object for a specific column."""
3360 def connect(self) -> ContextManager['sqlalchemy.Connection']:
3361 """Context manager for a SA ``Connection``.
3363 Context calls to this method can be nested. An inner call is a no-op, as no new connection is created.
3364 Only the outermost connection is closed upon exit::
3366 with db.connect():
3367 ...
3368 with db.connect(): # no-op
3369 ...
3370 # connection remains open
3371 ...
3372 # connection closed
3373 """
3375 def describe(self, table: DatabaseTableAlike) -> 'DataSetDescription':
3376 """Describe a table."""
3378 def count(self, table: DatabaseTableAlike) -> int:
3379 """Return table record count or 0 if the table does not exist."""
3381 def engine(self, **kwargs) -> 'sqlalchemy.Engine':
3382 """SA ``Engine`` object for this provider."""
3384 def has_column(self, table: DatabaseTableAlike, column_name: str) -> bool:
3385 """Check if a specific column exists."""
3387 def has_table(self, table_name: str) -> bool:
3388 """Check if a specific table exists."""
3390 def join_table_name(self, schema: str, name: str) -> str:
3391 """Create a full table name from the schema and table names."""
3393 def split_table_name(self, table_name: str) -> tuple[str, str]:
3394 """Split a full table name into the schema and table names."""
3396 def table(self, table_name: str, **kwargs) -> 'sqlalchemy.Table':
3397 """SA ``Table`` object for a specific table."""
3399 def table_bounds(self, table: DatabaseTableAlike) -> Optional[Bounds]:
3400 """Compute a bounding box for the table primary geometry."""
3402 def select_text(self, sql: str, **kwargs) -> list[dict]:
3403 """Execute a textual SELECT statement and return a list of record dicts."""
3405 def execute_text(self, sql: str, **kwargs) -> 'sqlalchemy.CursorResult':
3406 """Execute a textual DML statement and return a result."""
3407################################################################################
3411################################################################################
3412# /base/ows/types.pyinc
3415import gws
3418class OwsProtocol(Enum):
3419 """Supported OWS protocol."""
3421 WMS = 'WMS'
3422 WMTS = 'WMTS'
3423 WCS = 'WCS'
3424 WFS = 'WFS'
3425 CSW = 'CSW'
3428class OwsAuthorization(Data):
3429 type: str
3430 username: str
3431 password: str
3434class OwsVerb(Enum):
3435 """OWS verb."""
3437 CreateStoredQuery = 'CreateStoredQuery'
3438 DescribeCoverage = 'DescribeCoverage'
3439 DescribeFeatureType = 'DescribeFeatureType'
3440 DescribeLayer = 'DescribeLayer'
3441 DescribeRecord = 'DescribeRecord'
3442 DescribeStoredQueries = 'DescribeStoredQueries'
3443 DropStoredQuery = 'DropStoredQuery'
3444 GetCapabilities = 'GetCapabilities'
3445 GetFeature = 'GetFeature'
3446 GetFeatureInfo = 'GetFeatureInfo'
3447 GetFeatureWithLock = 'GetFeatureWithLock'
3448 GetLegendGraphic = 'GetLegendGraphic'
3449 GetMap = 'GetMap'
3450 GetPrint = 'GetPrint'
3451 GetPropertyValue = 'GetPropertyValue'
3452 GetRecordById = 'GetRecordById'
3453 GetRecords = 'GetRecords'
3454 GetTile = 'GetTile'
3455 ListStoredQueries = 'ListStoredQueries'
3456 LockFeature = 'LockFeature'
3457 Transaction = 'Transaction'
3460class OwsOperation(Data):
3461 """OWS operation."""
3463 allowedParameters: dict[str, list[str]]
3464 constraints: dict[str, list[str]]
3465 formats: list[str]
3466 handlerName: str
3467 params: dict[str, str]
3468 postUrl: Url
3469 preferredFormat: str
3470 url: Url
3471 verb: OwsVerb
3474class OwsCapabilities(Data):
3475 """OWS capabilities structure."""
3477 metadata: 'Metadata'
3478 operations: list['OwsOperation']
3479 sourceLayers: list['SourceLayer']
3480 tileMatrixSets: list['TileMatrixSet']
3481 version: str
3484class OwsImageFormat(Data):
3485 mimeTypes: list[str]
3486 """Mime types for this format."""
3487 options: dict
3488 """Image options."""
3491class OwsService(Node):
3492 """OWS Service."""
3494 isRasterService: bool = False
3495 """Service provides raster services."""
3496 isVectorService: bool = False
3497 """Service provides vector services."""
3498 isOwsCommon: bool = False
3499 """Conforms to OGC Web Services Common Standard."""
3501 alwaysXY: bool
3502 """Force lon/lat order for geographic projections."""
3503 metadata: 'Metadata'
3504 """Service metadata."""
3505 name: str
3506 """Service name."""
3507 project: Optional['Project']
3508 """Project this service is configured for."""
3509 rootLayer: Optional['Layer']
3510 """Root layer of the service."""
3511 protocol: OwsProtocol
3512 """Supported protocol."""
3513 defaultFeatureCount: int
3514 """Default limit of features per page."""
3515 maxFeatureCount: int
3516 """Max limit of features per page."""
3517 searchTolerance: UomValue
3518 """Default tolerance for spatial search."""
3519 supportedBounds: list[Bounds]
3520 """Supported bounds."""
3521 supportedVersions: list[str]
3522 """Supported versions."""
3523 supportedOperations: list['OwsOperation']
3524 """Supported operations."""
3525 templates: list['Template']
3526 """Service templates."""
3527 imageFormats: list[OwsImageFormat]
3528 """Supported image formats."""
3529 updateSequence: str
3530 """Service update sequence."""
3531 withInspireMeta: bool
3532 """Include INSPIRE metadata."""
3533 withStrictParams: bool
3534 """Strict parameter checking."""
3536 def handle_request(self, req: 'WebRequester') -> ContentResponse:
3537 """Handle a service request."""
3539 def layer_is_suitable(self, layer: 'Layer') -> bool:
3540 """True if layer can be used in this service."""
3543class OwsProvider(Node):
3544 """OWS services Provider."""
3546 alwaysXY: bool
3547 authorization: Optional['OwsAuthorization']
3548 bounds: Optional[Bounds]
3549 forceCrs: 'Crs'
3550 maxRequests: int
3551 metadata: 'Metadata'
3552 operations: list['OwsOperation']
3553 protocol: 'OwsProtocol'
3554 sourceLayers: list['SourceLayer']
3555 url: Url
3556 version: str
3557 wgsExtent: Optional[Extent]
3559 def get_operation(self, verb: 'OwsVerb', method: Optional['RequestMethod'] = None) -> Optional['OwsOperation']: ...
3561 def get_features(self, args: 'SearchQuery', source_layers: list['SourceLayer']) -> list['FeatureRecord']: ...
3562################################################################################
3565################################################################################
3566# /base/printer/types.pyinc
3569class PrintPlaneType(Enum):
3570 """Print plane type."""
3572 bitmap = 'bitmap'
3573 url = 'url'
3574 features = 'features'
3575 raster = 'raster'
3576 vector = 'vector'
3577 soup = 'soup'
3580class PrintPlane(Data):
3581 """Print plane."""
3583 type: PrintPlaneType
3585 opacity: Optional[float]
3586 cssSelector: Optional[str]
3588 bitmapData: Optional[bytes]
3589 bitmapMode: Optional[str]
3590 bitmapWidth: Optional[int]
3591 bitmapHeight: Optional[int]
3593 url: Optional[str]
3595 features: Optional[list['FeatureProps']]
3597 layerUid: Optional[str]
3598 subLayers: Optional[list[str]]
3600 soupPoints: Optional[list[Point]]
3601 soupTags: Optional[list[Any]]
3604class PrintMap(Data):
3605 """Map properties for printing."""
3607 backgroundColor: Optional[int]
3608 bbox: Optional[Extent]
3609 center: Optional[Point]
3610 planes: list[PrintPlane]
3611 rotation: Optional[int]
3612 scale: int
3613 styles: Optional[list['StyleProps']]
3614 visibleLayers: Optional[list[str]]
3617class PrintRequestType(Enum):
3618 """Type of the print request."""
3620 template = 'template'
3621 map = 'map'
3624class PrintRequest(Request):
3625 """Print request."""
3627 type: PrintRequestType
3629 args: Optional[dict]
3630 crs: Optional[CrsName]
3631 outputFormat: Optional[str]
3632 maps: Optional[list[PrintMap]]
3634 printerUid: Optional[str]
3635 dpi: Optional[int]
3636 outputSize: Optional[Size]
3639class PrintJobResponse(Response):
3640 """Print job information response."""
3642 jobUid: str
3643 progress: int
3644 state: 'JobState'
3645 stepType: str
3646 stepName: str
3647 url: str
3650class Printer(Node):
3651 """Printer object."""
3653 title: str
3654 template: 'Template'
3655 models: list['Model']
3656 qualityLevels: list['TemplateQualityLevel']
3659class PrinterManager(Node):
3660 """Print Manager."""
3662 def printers_for_project(self, project: 'Project', user: 'User') -> list['Printer']: ...
3664 def start_job(self, request: PrintRequest, user: 'User') -> 'Job': ...
3666 def get_job(self, uid: str, user: 'User') -> Optional['Job']: ...
3668 def run_job(self, request: PrintRequest, user: 'User'): ...
3670 def cancel_job(self, job: 'Job'): ...
3672 def result_path(self, job: 'Job') -> str: ...
3674 def status(self, job: 'Job') -> PrintJobResponse: ...
3675################################################################################
3678################################################################################
3679# /base/project/types.pyinc
3682class Client(Node):
3683 """GWS Client control object."""
3685 options: dict
3686 elements: list
3689class Project(Node):
3690 """Project object."""
3692 assetsRoot: Optional['WebDocumentRoot']
3693 client: 'Client'
3695 localeUids: list[str]
3696 map: 'Map'
3697 metadata: 'Metadata'
3699 actions: list['Action']
3700 finders: list['Finder']
3701 models: list['Model']
3702 printers: list['Printer']
3703 templates: list['Template']
3704 owsServices: list['OwsService']
3705################################################################################
3708################################################################################
3709# /base/search/types.pyinc
3712class SearchSort(Data):
3713 """Search sort specification."""
3715 fieldName: str
3716 reverse: bool
3719class SearchOgcFilter(Data):
3720 """Search filter."""
3722 name: str
3723 operator: str
3724 shape: 'Shape'
3725 subFilters: list['SearchOgcFilter']
3726 value: str
3729class SearchQuery(Data):
3730 """Search query."""
3732 access: Access
3733 all: bool
3734 bounds: Bounds
3735 extraColumns: list
3736 extraParams: dict
3737 extraWhere: list
3738 keyword: str
3739 layers: list['Layer']
3740 limit: int
3741 ogcFilter: SearchOgcFilter
3742 project: 'Project'
3743 relDepth: int
3744 resolution: float
3745 shape: 'Shape'
3746 sort: list[SearchSort]
3747 tolerance: 'UomValue'
3748 uids: list[str]
3751class SearchResult(Data):
3752 """Search result."""
3754 feature: 'Feature'
3755 layer: 'Layer'
3756 finder: 'Finder'
3759class TextSearchType(Enum):
3760 """Text search type."""
3762 exact = 'exact'
3763 """Match the whole string."""
3764 begin = 'begin'
3765 """Match the beginning of the string."""
3766 end = 'end'
3767 """Match the end of the string."""
3768 any = 'any'
3769 """Match any substring."""
3770 like = 'like'
3771 """Use the percent sign as a placeholder."""
3774class TextSearchOptions(Data):
3775 """Text search options."""
3777 type: TextSearchType
3778 """Type of the search."""
3779 minLength: int = 0
3780 """Minimal pattern length."""
3781 caseSensitive: bool = False
3782 """Use the case sensitive search."""
3785class SortOptions(Data):
3786 """Sort options."""
3787 fieldName: str
3788 reverse: bool = False
3791class SearchManager(Node):
3792 """Search Manager."""
3794 def run_search(self, search: 'SearchQuery', user: 'User') -> list['SearchResult']: ...
3797class Finder(Node):
3798 """Finder object."""
3800 title: str
3802 supportsFilterSearch: bool = False
3803 supportsGeometrySearch: bool = False
3804 supportsKeywordSearch: bool = False
3806 withFilter: bool
3807 withGeometry: bool
3808 withKeyword: bool
3810 templates: list['Template']
3811 models: list['Model']
3812 sourceLayers: list['SourceLayer']
3814 tolerance: 'UomValue'
3816 def run(self, search: SearchQuery, user: 'User', layer: Optional['Layer'] = None) -> list['Feature']: ...
3818 def can_run(self, search: SearchQuery, user: 'User') -> bool: ...
3819################################################################################
3822################################################################################
3823# /base/storage/types.pyinc
3826class StorageManager(Node):
3827 """Storage manager."""
3829 providers: list['StorageProvider']
3831 def create_provider(self, cfg: Config, **kwargs) -> 'StorageProvider': ...
3833 def find_provider(self, uid: Optional[str] = None) -> Optional['StorageProvider']: ...
3837class StorageRecord(Data):
3838 """Storage record."""
3840 name: str
3841 userUid: str
3842 data: str
3843 created: int
3844 updated: int
3847class StorageProvider(Node):
3848 """Storage provider."""
3850 def list_names(self, category: str) -> list[str]: ...
3852 def read(self, category: str, name: str) -> Optional['StorageRecord']: ...
3854 def write(self, category: str, name: str, data: str, user_uid: str): ...
3856 def delete(self, category: str, name: str): ...
3857################################################################################
3860################################################################################
3861# /base/template/types.pyinc
3864class TemplateArgs(Data):
3865 """Template arguments."""
3867 app: 'Application'
3868 """Application object."""
3869 gwsVersion: str
3870 """GWS version. (deprecated in 8.1)"""
3871 gwsBaseUrl: str
3872 """GWS server base url. (deprecated in 8.1)"""
3873 locale: 'Locale'
3874 """Current locale."""
3875 date: 'DateFormatter'
3876 """Locale-aware date formatter."""
3877 time: 'TimeFormatter'
3878 """Locale-aware time formatter."""
3879 number: 'NumberFormatter'
3880 """Locale-aware number formatter."""
3883class TemplateRenderInput(Data):
3884 """Template render input."""
3886 args: dict | Data
3887 crs: 'Crs'
3888 dpi: int
3889 locale: 'Locale'
3890 maps: list[MapRenderInput]
3891 mimeOut: str
3892 notify: Callable
3893 project: 'Project'
3894 user: 'User'
3897class TemplateQualityLevel(Data):
3898 """Template quality level."""
3900 name: str
3901 dpi: int
3904class Template(Node):
3905 """Template object."""
3907 mapSize: UomSize
3908 """Default map size for the template."""
3909 mimeTypes: list[str]
3910 """MIME types the template can generate."""
3911 pageSize: UomSize
3912 """Default page size for printing."""
3913 pageMargin: UomExtent
3914 """Default page margin for printing."""
3915 subject: str
3916 """Template subject (category)."""
3917 title: str
3918 """Template title."""
3920 def render(self, tri: TemplateRenderInput) -> ContentResponse:
3921 """Render the template and return the generated response."""
3924class TemplateManager(Node):
3925 """Template manager."""
3927 def find_template(self, subject: str, where: list[Node], user: 'User' = None, mime: str = None) -> Optional['Template']: ...
3929 def template_from_path(self, path: str) -> Optional['Template']: ...
3930################################################################################
3933################################################################################
3934# /base/web/types.pyinc
3937class RequestMethod(Enum):
3938 """Web request method."""
3940 GET = 'GET'
3941 HEAD = 'HEAD'
3942 POST = 'POST'
3943 PUT = 'PUT'
3944 DELETE = 'DELETE'
3945 CONNECT = 'CONNECT'
3946 OPTIONS = 'OPTIONS'
3947 TRACE = 'TRACE'
3948 PATCH = 'PATCH'
3951class WebRequester:
3952 """Web Requester object."""
3954 environ: dict
3955 """Request environment."""
3956 method: RequestMethod
3957 """Request method."""
3958 root: 'Root'
3959 """Object tree root."""
3960 site: 'WebSite'
3961 """Website the request is processed for."""
3963 session: 'AuthSession'
3964 """Current session."""
3965 user: 'User'
3966 """Current use."""
3968 isApi: bool
3969 """The request is an 'api' request."""
3970 isGet: bool
3971 """The request is a 'get' request."""
3972 isPost: bool
3973 """The request is a 'post' request."""
3974 isSecure: bool
3975 """The request is secure."""
3977 def params(self) -> dict:
3978 """GET parameters."""
3980 def struct(self) -> dict:
3981 """Structured JSON payload."""
3983 def command(self) -> str:
3984 """Command name to execute."""
3986 def cookie(self, key: str, default: str = '') -> str:
3987 """Get a cookie.
3989 Args:
3990 key: Cookie name.
3991 default: Default value.
3993 Returns:
3994 A cookie value.
3995 """
3997 def header(self, key: str, default: str = '') -> str:
3998 """Get a header.
4000 Args:
4001 key: Header name.
4002 default: Default value.
4004 Returns:
4005 A header value.
4006 """
4008 def has_param(self, key: str) -> bool:
4009 """Check if a GET parameter exists.
4011 Args:
4012 key: Parameter name.
4013 """
4015 def param(self, key: str, default: str = '') -> str:
4016 """Get a GET parameter.
4018 Args:
4019 key: Parameter name.
4020 default: Default value.
4022 Returns:
4023 A parameter value.
4024 """
4026 def env(self, key: str, default: str = '') -> str:
4027 """Get an environment variable.
4029 Args:
4030 key: Variable name.
4031 default: Default value.
4033 Returns:
4034 A variable value.
4035 """
4037 def data(self) -> Optional[bytes]:
4038 """Get POST data.
4040 Returns:
4041 Data bytes or ``None`` if request is not a POST.
4042 """
4044 def text(self) -> Optional[str]:
4045 """Get POST data as a text.
4047 Returns:
4048 Data string or ``None`` if request is not a POST.
4049 """
4051 def content_responder(self, response: ContentResponse) -> 'WebResponder':
4052 """Return a Responder object for a content response.
4054 Args:
4055 response: Response object.
4057 Returns:
4058 A Responder.
4059 """
4061 def redirect_responder(self, response: RedirectResponse) -> 'WebResponder':
4062 """Return a Responder object for a redirect response.
4064 Args:
4065 response: Response object.
4067 Returns:
4068 A Responder.
4069 """
4071 def api_responder(self, response: Response) -> 'WebResponder':
4072 """Return a Responder object for an Api (structured) response.
4074 Args:
4075 response: Response object.
4077 Returns:
4078 A Responder.
4079 """
4081 def error_responder(self, exc: Exception) -> 'WebResponder':
4082 """Return a Responder object for an Exception.
4084 Args:
4085 exc: An Exception.
4087 Returns:
4088 A Responder.
4089 """
4091 def url_for(self, request_path: str, **kwargs) -> str:
4092 """Return a canonical Url for the given request path.
4094 Args:
4095 request_path: Request path.
4096 **kwargs: Additional GET parameters.
4098 Returns:
4099 An URL.
4100 """
4102 def set_session(self, session: 'AuthSession'):
4103 """Attach a session to the requester.
4105 Args:
4106 session: A Session object.
4107 """
4110class WebResponder:
4111 """Web Responder object."""
4113 status: int
4114 """Response status."""
4116 def send_response(self, environ: dict, start_response: Callable):
4117 """Send the response to the client.
4119 Args:
4120 environ: WSGI environment.
4121 start_response: WSGI ``start_response`` function.
4122 """
4124 def set_cookie(self, key: str, value: str, **kwargs):
4125 """Set a cookie.
4127 Args:
4128 key: Cookie name.
4129 value: Cookie value.
4130 **kwargs: Cookie options.
4131 """
4133 def delete_cookie(self, key: str, **kwargs):
4134 """Delete a cookie.
4136 Args:
4137 key: Cookie name.
4138 **kwargs: Cookie options.
4139 """
4141 def set_status(self, status: int):
4142 """Set the response status.
4144 Args:
4145 status: HTTP status code.
4146 """
4148 def add_header(self, key: str, value: str):
4149 """Add a header.
4151 Args:
4152 key: Header name.
4153 value: Header value.
4154 """
4157class WebDocumentRoot(Data):
4158 """Web document root."""
4160 dir: DirPath
4161 """Local directory."""
4162 allowMime: list[str]
4163 """Allowed mime types."""
4164 denyMime: list[str]
4165 """Restricted mime types."""
4168class WebRewriteRule(Data):
4169 """Rewrite rule."""
4171 pattern: Regex
4172 """URL matching pattern."""
4173 target: str
4174 """Rule target, with dollar placeholders."""
4175 options: dict
4176 """Extra options."""
4177 reversed: bool
4178 """Reversed rewrite rule."""
4181class WebCors(Data):
4182 """CORS options."""
4184 allowCredentials: bool
4185 allowHeaders: str
4186 allowMethods: str
4187 allowOrigin: str
4190class WebManager(Node):
4191 """Web manager."""
4193 sites: list['WebSite']
4194 """Configured web sites."""
4196 def site_from_environ(self, environ: dict) -> 'WebSite':
4197 """Returns a site object for the given request environment.
4199 Args:
4200 environ: WSGI environment.
4202 Returns:
4203 A Site object.
4204 """
4207class WebSite(Node):
4208 """Web site."""
4210 assetsRoot: Optional[WebDocumentRoot]
4211 """Root directory for assets."""
4212 corsOptions: WebCors
4213 """CORS options."""
4214 errorPage: Optional['Template']
4215 """Error page template."""
4216 host: str
4217 """Host name for this site."""
4218 rewriteRules: list[WebRewriteRule]
4219 """Rewrite rule."""
4220 staticRoot: WebDocumentRoot
4221 """Root directory for static files."""
4223 def url_for(self, req: 'WebRequester', path: str, **kwargs) -> str:
4224 """Rewrite a request path to an Url.
4226 Args:
4227 req: Web Requester.
4228 path: Raw request path.
4229 **kwargs: Extra GET params.
4231 Returns:
4232 A rewritten URL.
4233 """
4234################################################################################
4238################################################################################
4239# /base/application/types.pyinc
4242class MiddlewareManager(Node):
4243 def register(self, obj: Node, name: str, depends_on: Optional[list[str]] = None):
4244 """Register an object as a middleware."""
4246 def objects(self) -> list[Node]:
4247 """Return a list of registered middleware objects."""
4250class Application(Node):
4251 """The main Application object."""
4253 client: 'Client'
4254 localeUids: list[str]
4255 metadata: 'Metadata'
4256 monitor: 'ServerMonitor'
4257 version: str
4258 versionString: str
4259 defaultPrinter: 'Printer'
4261 actionMgr: 'ActionManager'
4262 authMgr: 'AuthManager'
4263 databaseMgr: 'DatabaseManager'
4264 modelMgr: 'ModelManager'
4265 printerMgr: 'PrinterManager'
4266 searchMgr: 'SearchManager'
4267 storageMgr: 'StorageManager'
4268 templateMgr: 'TemplateManager'
4269 serverMgr: 'ServerManager'
4270 webMgr: 'WebManager'
4271 middlewareMgr: 'MiddlewareManager'
4273 actions: list['Action']
4274 projects: list['Project']
4275 finders: list['Finder']
4276 templates: list['Template']
4277 printers: list['Printer']
4278 models: list['Model']
4279 owsServices: list['OwsService']
4281 def project(self, uid: str) -> Optional['Project']:
4282 """Get a Project object by its uid."""
4284 def helper(self, ext_type: str) -> Optional['Node']:
4285 """Get a Helper object by its extension type."""
4287 def developer_option(self, key: str):
4288 """Get a value of a developer option."""
4289################################################################################