summaryrefslogtreecommitdiff
path: root/python/typearchive.py
diff options
context:
space:
mode:
authorGalen Williamson <galen@vector35.com>2024-04-19 17:11:04 -0400
committerGalen Williamson <galen@vector35.com>2024-04-19 17:11:04 -0400
commitc788961c5a7ff667d0b6237711f7747cac5be610 (patch)
tree2723627873dfbb033b9bb4fbe0ba3d8325d57f8d /python/typearchive.py
parentcff2f4df2ad48f6e386e7eeed862dfca6659ab6d (diff)
docstring hygiene maintenance in python API
Diffstat (limited to 'python/typearchive.py')
-rw-r--r--python/typearchive.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/python/typearchive.py b/python/typearchive.py
index 26b15b5f..96e5378d 100644
--- a/python/typearchive.py
+++ b/python/typearchive.py
@@ -70,6 +70,7 @@ class TypeArchive:
def open(path: str) -> Optional['TypeArchive']:
"""
Open the Type Archive at the given path, if it exists.
+
:param path: Path to Type Archive file
:return: Type Archive, or None if it could not be loaded.
"""
@@ -82,6 +83,7 @@ class TypeArchive:
def create(path: str, platform: 'platform.Platform') -> Optional['TypeArchive']:
"""
Create a Type Archive at the given path.
+
:param path: Path to Type Archive file
:param platform: Relevant platform for types in the archive
:return: Type Archive, or None if it could not be created.
@@ -95,6 +97,7 @@ class TypeArchive:
def lookup_by_id(id: str) -> Optional['TypeArchive']:
"""
Get a reference to the Type Archive with the known id, if one exists.
+
:param id: Type Archive id
:return: Type archive, or None if it could not be found.
"""
@@ -107,6 +110,7 @@ class TypeArchive:
def path(self) -> Optional[str]:
"""
Get the path to the Type Archive's file
+
:return: File path
"""
return core.BNGetTypeArchivePath(self.handle)
@@ -115,6 +119,7 @@ class TypeArchive:
def id(self) -> Optional[str]:
"""
Get the guid for a Type Archive
+
:return: Guid string
"""
return core.BNGetTypeArchiveId(self.handle)
@@ -123,6 +128,7 @@ class TypeArchive:
def platform(self) -> 'platform.Platform':
"""
Get the associated Platform for a Type Archive
+
:return: Platform object
"""
handle = core.BNGetTypeArchivePlatform(self.handle)
@@ -133,6 +139,7 @@ class TypeArchive:
def current_snapshot_id(self) -> str:
"""
Get the id of the current snapshot in the type archive
+
:return: Snapshot id
"""
result = core.BNGetTypeArchiveCurrentSnapshotId(self.handle)
@@ -144,6 +151,7 @@ class TypeArchive:
def current_snapshot_id(self, value: str):
"""
Revert the type archive's current snapshot to the given snapshot
+
:param value: Snapshot id
"""
core.BNSetTypeArchiveCurrentSnapshot(self.handle, value)
@@ -152,6 +160,7 @@ class TypeArchive:
def all_snapshot_ids(self) -> List[str]:
"""
Get a list of every snapshot's id
+
:return: All ids (including the empty first snapshot)
"""
count = ctypes.c_ulonglong(0)
@@ -169,6 +178,7 @@ class TypeArchive:
def get_snapshot_parent_ids(self, snapshot: str) -> Optional[List[str]]:
"""
Get the ids of the parents to the given snapshot
+
:param snapshot: Child snapshot id
:return: Parent snapshot ids, or empty list if the snapshot is a root
"""
@@ -187,6 +197,7 @@ class TypeArchive:
def get_snapshot_child_ids(self, snapshot: str) -> Optional[List[str]]:
"""
Get the ids of the children to the given snapshot
+
:param snapshot: Parent snapshot id
:return: Child snapshot ids, or empty list if the snapshot is a leaf
"""
@@ -207,6 +218,7 @@ class TypeArchive:
Add named types to the type archive. Type must have all dependant named types added
prior to being added, or this function will fail.
If the type already exists, it will be overwritten.
+
:param name: Name of new type
:param type: Definition of new type
"""
@@ -217,6 +229,7 @@ class TypeArchive:
Add named types to the type archive. Types must have all dependant named
types prior to being added, or included in the list, or this function will fail.
Types already existing with any added names will be overwritten.
+
:param new_types: Names and definitions of new types
"""
api_types = (core.BNQualifiedNameAndType * len(new_types))()
@@ -237,6 +250,7 @@ class TypeArchive:
def rename_type(self, old_name: '_types.QualifiedNameType', new_name: '_types.QualifiedNameType') -> None:
"""
Change the name of an existing type in the type archive.
+
:param old_name: Old type name in archive
:param new_name: New type name
"""
@@ -246,6 +260,7 @@ class TypeArchive:
def rename_type_by_id(self, id: str, new_name: '_types.QualifiedNameType') -> None:
"""
Change the name of an existing type in the type archive.
+
:param id: Old id of type in archive
:param new_name: New type name
"""
@@ -257,6 +272,7 @@ class TypeArchive:
def delete_type(self, name: '_types.QualifiedNameType') -> None:
"""
Delete an existing type in the type archive.
+
:param name: Type name
"""
id = self.get_type_id(name)
@@ -267,6 +283,7 @@ class TypeArchive:
def delete_type_by_id(self, id: str) -> None:
"""
Delete an existing type in the type archive.
+
:param id: Type id
"""
if not core.BNDeleteTypeArchiveType(self.handle, id):
@@ -275,6 +292,7 @@ class TypeArchive:
def get_type_by_name(self, name: '_types.QualifiedNameType', snapshot: Optional[str] = None) -> Optional[_types.Type]:
"""
Retrieve a stored type in the archive
+
:param name: Type name
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Type, if it exists. Otherwise None
@@ -291,6 +309,7 @@ class TypeArchive:
def get_type_by_id(self, id: str, snapshot: Optional[str] = None) -> Optional[_types.Type]:
"""
Retrieve a stored type in the archive by id
+
:param id: Type id
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Type, if it exists. Otherwise None
@@ -306,6 +325,7 @@ class TypeArchive:
def get_type_name_by_id(self, id: str, snapshot: Optional[str] = None) -> Optional['_types.QualifiedName']:
"""
Retrieve a type's name by its id
+
:param id: Type id
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Type name, if it exists. Otherwise None
@@ -324,6 +344,7 @@ class TypeArchive:
def get_type_id(self, name: '_types.QualifiedNameType', snapshot: Optional[str] = None) -> Optional[str]:
"""
Retrieve a type's id by its name
+
:param name: Type name
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Type id, if it exists. Otherwise None
@@ -343,6 +364,7 @@ class TypeArchive:
def types(self) -> Dict[_types.QualifiedName, _types.Type]:
"""
Retrieve all stored types in the archive at the current snapshot
+
:return: Map of all types, by name
"""
return self.get_types()
@@ -351,6 +373,7 @@ class TypeArchive:
def types_and_ids(self) -> Dict[str, Tuple[_types.QualifiedName, _types.Type]]:
"""
Retrieve all stored types in the archive at the current snapshot
+
:return: Map of type id to type name and definition
"""
return self.get_types_and_ids()
@@ -358,6 +381,7 @@ class TypeArchive:
def get_types(self, snapshot: Optional[str] = None) -> Dict[_types.QualifiedName, _types.Type]:
"""
Retrieve all stored types in the archive at a snapshot
+
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Map of all types, by name
"""
@@ -369,6 +393,7 @@ class TypeArchive:
def get_types_and_ids(self, snapshot: Optional[str] = None) -> Dict[str, Tuple[_types.QualifiedName, _types.Type]]:
"""
Retrieve all stored types in the archive at a snapshot
+
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Map of type id to type name and definition
"""
@@ -391,6 +416,7 @@ class TypeArchive:
def type_ids(self) -> List[str]:
"""
Get a list of all types' ids in the archive at the current snapshot
+
:return: All type ids
"""
return self.get_type_ids()
@@ -398,6 +424,7 @@ class TypeArchive:
def get_type_ids(self, snapshot: Optional[str] = None) -> List[str]:
"""
Get a list of all types' ids in the archive at a snapshot
+
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: All type ids
"""
@@ -425,6 +452,7 @@ class TypeArchive:
def get_type_names(self, snapshot: Optional[str] = None) -> List['_types.QualifiedName']:
"""
Get a list of all types' names in the archive at a snapshot
+
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: All type names
"""
@@ -445,6 +473,7 @@ class TypeArchive:
def type_names_and_ids(self) -> Dict[str, '_types.QualifiedName']:
"""
Get a list of all types' names and ids in the archive at the current snapshot
+
:return: Mapping of all type ids to names
"""
return self.get_type_names_and_ids()
@@ -452,6 +481,7 @@ class TypeArchive:
def get_type_names_and_ids(self, snapshot: Optional[str] = None) -> Dict[str, '_types.QualifiedName']:
"""
Get a list of all types' names and ids in the archive at a current snapshot
+
:param snapshot: Snapshot id to search for types, or None to search the latest snapshot
:return: Mapping of all type ids to names
"""
@@ -475,6 +505,7 @@ class TypeArchive:
def get_outgoing_direct_references(self, id: str, snapshot: Optional[str] = None) -> List[str]:
"""
Get all types a given type references directly
+
:param id: Source type id
:param snapshot: Snapshot id to search for types, or empty string to search the latest snapshot
:return: Target type ids
@@ -497,6 +528,7 @@ class TypeArchive:
def get_outgoing_recursive_references(self, id: str, snapshot: Optional[str] = None) -> List[str]:
"""
Get all types a given type references, and any types that the referenced types reference
+
:param id: Source type id
:param snapshot: Snapshot id to search for types, or empty string to search the latest snapshot
:return: Target type ids
@@ -519,6 +551,7 @@ class TypeArchive:
def get_incoming_direct_references(self, id: str, snapshot: Optional[str] = None) -> List[str]:
"""
Get all types that reference a given type
+
:param id: Target type id
:param snapshot: Snapshot id to search for types, or empty string to search the latest snapshot
:return: Source type ids
@@ -541,6 +574,7 @@ class TypeArchive:
def get_incoming_recursive_references(self, id: str, snapshot: Optional[str] = None) -> List[str]:
"""
Get all types that reference a given type, and all types that reference them, recursively
+
:param id: Target type id
:param snapshot: Snapshot id to search for types, or empty string to search the latest snapshot
:return: Source type ids
@@ -563,6 +597,7 @@ class TypeArchive:
def query_metadata(self, key: str) -> Optional['metadata.MetadataValueType']:
"""
Look up a metadata entry in the archive
+
:param string key: key to query
:rtype: Metadata associated with the key, if it exists. Otherwise, None
:Example:
@@ -580,6 +615,7 @@ class TypeArchive:
def store_metadata(self, key: str, md: 'metadata.MetadataValueType') -> None:
"""
Store a key/value pair in the archive's metadata storage
+
:param string key: key value to associate the Metadata object with
:param Varies md: object to store.
:Example:
@@ -597,6 +633,7 @@ class TypeArchive:
def remove_metadata(self, key: str) -> None:
"""
Delete a given metadata entry in the archive
+
:param string key: key associated with metadata
:Example:
@@ -609,6 +646,7 @@ class TypeArchive:
def serialize_snapshot(self, snapshot: str) -> 'databuffer.DataBuffer':
"""
Turn a given snapshot into a data stream
+
:param snapshot: Snapshot id
:return: Buffer containing serialized snapshot data
"""
@@ -620,6 +658,7 @@ class TypeArchive:
def deserialize_snapshot(self, data: 'databuffer.DataBufferInputType') -> str:
"""
Take a serialized snapshot data stream and create a new snapshot from it
+
:param data: Snapshot data
:return: String of created snapshot id
"""
@@ -632,6 +671,7 @@ class TypeArchive:
def register_notification(self, notify: 'TypeArchiveNotification') -> None:
"""
Register a notification listener
+
:param notify: Object to receive notifications
"""
cb = TypeArchiveNotificationCallbacks(self, notify)
@@ -641,6 +681,7 @@ class TypeArchive:
def unregister_notification(self, notify: 'TypeArchiveNotification') -> None:
"""
Unregister a notification listener
+
:param notify: Object to no longer receive notifications
"""
if notify in self._notifications:
@@ -660,6 +701,7 @@ class TypeArchiveNotification:
def type_added(self, archive: 'TypeArchive', id: str, definition: '_types.Type') -> None:
"""
Called when a type is added to the archive
+
:param archive: Source Type archive
:param id: Id of type added
:param definition: Definition of type
@@ -669,6 +711,7 @@ class TypeArchiveNotification:
def type_updated(self, archive: 'TypeArchive', id: str, old_definition: '_types.Type', new_definition: '_types.Type') -> None:
"""
Called when a type in the archive is updated to a new definition
+
:param archive: Source Type archive
:param id: Id of type
:param old_definition: Previous definition
@@ -679,6 +722,7 @@ class TypeArchiveNotification:
def type_renamed(self, archive: 'TypeArchive', id: str, old_name: '_types.QualifiedName', new_name: '_types.QualifiedName') -> None:
"""
Called when a type in the archive is renamed
+
:param archive: Source Type archive
:param id: Type id
:param old_name: Previous name
@@ -689,6 +733,7 @@ class TypeArchiveNotification:
def type_deleted(self, archive: 'TypeArchive', id: str, definition: '_types.Type') -> None:
"""
Called when a type in the archive is deleted from the archive
+
:param archive: Source Type archive
:param id: Id of type deleted
:param definition: Definition of type deleted