Skip to content

Commit

Permalink
Exposed DATE_TRANSFORMERS (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
couling authored Dec 5, 2022
1 parent 46036a0 commit a0e867e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ XSBE is a novel library intended for *rapid development* of XML related python c
It takes the approach of using lightly annotated example XML documents to act as a schema. Using these schemas it can
then transform an XML document into a more friendly data structures built of dictionaries and lists such as you might
expect through parsing json or yaml.

It's composed of two main libraries:
- `xsbe.simple_node` Offers a reduced object model for representing XML document *content*. See [simple_node](simple_node.md)
- `xsbe.transform` Offers schema definition and transformer components. See [transform](transform.md)

5 changes: 4 additions & 1 deletion source/xsbe/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ def _create_element_transformer(element: ElementTree.Element, ignore_unexpected:
return result


DATE_TRANSFORMERS = [ISODateTransformer, ISOZuluDateTransformer, EmailDateTransformer]


def _identify_text_type(text: str, result_name: Optional[str] = None) -> ValueTransformer:
if text in BooleanTransformer.MAP:
return BooleanTransformer(result_name=result_name)
Expand All @@ -508,7 +511,7 @@ def _identify_text_type(text: str, result_name: Optional[str] = None) -> ValueTr
return FloatTransformer(result_name=result_name)
return IntTransformer(result_name=result_name)

for date_type in (ISODateTransformer, ISOZuluDateTransformer, EmailDateTransformer):
for date_type in DATE_TRANSFORMERS:
try:
transformer = date_type(result_name=result_name)
transformer.transform_from_xml(text)
Expand Down

0 comments on commit a0e867e

Please sign in to comment.