diff options
author | Ben Connors <benconnors@outlook.com> | 2019-09-25 23:05:14 -0400 |
---|---|---|
committer | Ben Connors <benconnors@outlook.com> | 2019-09-25 23:05:14 -0400 |
commit | 2b8a53f98c44e6e78d49b7c246731deef75ed6d3 (patch) | |
tree | d85e383c0d54d662ea93384b177a0ad59a40917e /interfaces.py | |
parent | 7f85bd8ed84b23fc4e683ab90fc7babe288f1a27 (diff) |
Change module layout; start chaser work
- Fix up callbacks
- Clean up function implementations
- More properties to prevent editing of attributes
- Start work on chasers
- Implement framework for chaser steps
Diffstat (limited to 'interfaces.py')
-rw-r--r-- | interfaces.py | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/interfaces.py b/interfaces.py deleted file mode 100644 index e0a904a..0000000 --- a/interfaces.py +++ /dev/null @@ -1,47 +0,0 @@ -"""Module containing various interfaces.""" - -from abc import ABCMeta, abstractmethod, abstractclassmethod -import xml.etree.ElementTree as et - -class XMLSerializable(metaclass=ABCMeta): - """Interface for XML-serializable Workspace components.""" - @staticmethod - def int_or_none(v): - if v is None: - return None - - try: - v = int(v) - except (ValueError, TypeError): - return None - - return v - - @staticmethod - def indent(elem, indent=4, level=0): - """Pretty-indent the XML tree.""" - i = "\n" + level*(indent*' ') - if len(elem) > 0: - if not elem.text or not elem.text.strip(): - elem.text = i + (' '*indent) - if not elem.tail or not elem.tail.strip(): - elem.tail = i - for elem in elem: - XMLSerializable.indent(elem, indent=indent, level=level+1) - if not elem.tail or not elem.tail.strip(): - elem.tail = i - else: - if level and (not elem.tail or not elem.tail.strip()): - elem.tail = i - - @abstractmethod - def serialize(self) -> et.Element: - """Serialize the object into an XML element.""" - - @abstractclassmethod - def deserialize(cls, w: "Workspace", e: et.Element): - """Deserialize the object from an XML element. - - This function may assume that all dependencies have already been loaded into the - passed workspace. - """ |