Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Implement DMType #4

@miile7

Description

@miile7

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 name
  • dm_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 TagGroup
  • aliases : 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, uses parseForPython() if not overwritten
  • parsePersistentTagGroupValueForPython(path : int|str) -> T # Get the value from the persistent tag group and parse it, uses parseTagGroupValueForPython() if not overwritten
  • getDMCodeValue(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 value
  • getDMCodeDefineVariable(var_name : str, value : T) -> str # Get the dm-code for defining this variable
  • getDMCodeWriteToTagGroup(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), uses getDMCodeValue() if not overwritten
  • writeToPersistentTags(path : int|str, value : T) -> None # Write the value directly to the persistent tags, uses dm_taggroup_type_name to find the correct write function on the python side

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions