This repository was archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
This repository was archived by the owner on Feb 1, 2023. It is now read-only.
Implement DMType #4
Copy link
Copy link
Open
Milestone
Description
DMType
Motivation
Add a DMType class wrapping DigitalMicrograph types and containing the conversion from python to
dm. This way the types can be extended easily supporting images, complex numbers, rgb numbers, etc.
On the other hand all functions will support all types. In addition the maintaining process will be
a lot easier.
Definition
Attributes
python_type : T=type|str# The python type or the namedm_type_name : str# The type expression in dm-script as a string, e.g. number, string, ...dm_taggroup_type_name : str# The type expression as a string that is used to add this value in a TagGroupaliases : str[]# A list of names that can also be used for expressing this type
Methods
parseForPython(dm_value : any) -> T# Parse the value if it is given directly, note that this may not be implementable, note that the types are varying (includes converting Py_TagGroup to dict for dict type, Py_Image to image for image type, ...)parseTagGroupValueForPython(taggroup : Py_TagGroup, index : int|str) -> T# Get the value from the tag group object and parse it, usesparseForPython()if not overwrittenparsePersistentTagGroupValueForPython(path : int|str) -> T# Get the value from the persistent tag group and parse it, usesparseTagGroupValueForPython()if not overwrittengetDMCodeValue(value : T) -> str|None, str, str|None# Get the code to set this value, for strings e.g. this adds the quotes, returns code to add before setting the value, then the value, then code to add after the valuegetDMCodeDefineVariable(var_name : str, value : T) -> str# Get the dm-code for defining this variablegetDMCodeWriteToTagGroup(tg_name : str, tg_path : int|str, value : T) -> str# Get the dm-code for writing the value to the tg_path in the tg_name TagGroup (TagGroup or TagList), usesgetDMCodeValue()if not overwrittenwriteToPersistentTags(path : int|str, value : T) -> None# Write the value directly to the persistent tags, usesdm_taggroup_type_nameto find the correct write function on the python side
Metadata
Metadata
Assignees
Labels
No labels