diff --git a/src/server_common/schema/blocks.xsd b/src/server_common/schema/blocks.xsd index fea0e51..6b8f7d0 100644 --- a/src/server_common/schema/blocks.xsd +++ b/src/server_common/schema/blocks.xsd @@ -26,6 +26,11 @@ + + + + + @@ -42,4 +47,8 @@ + + + + diff --git a/src/server_common/utilities.py b/src/server_common/utilities.py index d31d3ab..98d72e8 100644 --- a/src/server_common/utilities.py +++ b/src/server_common/utilities.py @@ -29,6 +29,7 @@ from server_common.common_exceptions import MaxAttemptsExceededException from server_common.loggers.logger import Logger +# ruff: noqa: ANN001, ANN201, ANN002, ANN003, ANN202, E721 # Default to base class - does not actually log anything LOGGER = Logger() _LOGGER_LOCK = threading.RLock() # To prevent message interleaving between different threads. @@ -72,8 +73,8 @@ def print_and_log(message, severity=SEVERITY.INFO, src="BLOCKSVR"): Args: message (string|exception): The message to log - severity (string, optional): Gives the severity of the message. Expected serverities are MAJOR, MINOR and INFO. - Default severity is INFO. + severity (string, optional): Gives the severity of the message. Expected serverities are + MAJOR, MINOR and INFO. Default severity is INFO. src (string, optional): Gives the source of the message. Default source is BLOCKSVR. """ with _LOGGER_LOCK: @@ -115,7 +116,8 @@ def dehex_and_decompress(value): def dehex_and_decompress_waveform(value): - """Decompresses the inputted waveform, assuming it is a array of integers representing characters (null terminated). + """Decompresses the inputted waveform, assuming it is a array of integers + representing characters (null terminated). Args: value (list[int]): The string to be decompressed @@ -181,11 +183,11 @@ def value_list_to_xml(value_list, grp, group_tag, item_tag): """Converts a list of values to corresponding xml. Args: - value_list (dist[str, dict[object, object]]): The dictionary of names and their values, values are in turn a - dictonary of names and value {name: {parameter : value, parameter : value}} + value_list (dist[str, dict[object, object]]): The dictionary of names and their values, + values are in turn a dictonary of names and value {name:{parameter:value,parameter:value}} grp (ElementTree.SubElement): The SubElement object to append the list on to - group_tag (string): The tag that corresponds to the group for the items given in the list e.g. macros - item_tag (string): The tag that corresponds to each item in the list e.g. macro + group_tag (string): The tag that corresponds to the group for the items given in the list + e.g. macros item_tag (string): The tag that corresponds to each item in the list e.g. macro """ xml_list = ElementTree.SubElement(grp, group_tag) if len(value_list) > 0: @@ -218,7 +220,7 @@ def create_pv_name(name, current_pvs, default_pv, limit=6, allow_colon=False): current_pvs (list): List of already allocated pvs default_pv (string): Basis for the PV if name is unreasonable, must be a valid PV name limit (integer): Character limit for the PV - allow_colon (bool): If True, pv name is allowed to contain colons; if False, remove the colons + allow_colon (bool): If True,pv name is allowed to contain colons;if False,remove the colons Returns: string : A valid PV @@ -344,7 +346,8 @@ def remove_from_end(string, text_to_remove): def lowercase_and_make_unique(in_list): """ - Takes a collection of strings, and returns it with all strings lowercased and with duplicates removed. + Takes a collection of strings, and returns it with all strings lowercased and with duplicates + removed. Args: in_list (List[str]): the collection of strings to operate on @@ -371,3 +374,15 @@ def parse_date_time_arg_exit_on_fail(date_arg, error_code=1): except (ValueError, TypeError) as ex: print(f"Can not interpret date '{date_arg}' error: {ex}") exit(error_code) + + +def dehex_and_decompress_waveform_value(value): + """Decompresses the inputted waveform, assuming it is available as string. + + Args: + value (str): The string to be decompressed + + Returns: + str : A decompressed and unhexed version of the input string + """ + return zlib.decompress(binascii.unhexlify(value))