Skip to content

Commit

Permalink
Moves XML parsing of input and viewing description into public method…
Browse files Browse the repository at this point in the history
…s on the AscColorSpaceBase class
  • Loading branch information
shidarin committed May 4, 2014
1 parent 4055f2f commit 743f74c
Showing 1 changed file with 51 additions and 10 deletions.
61 changes: 51 additions & 10 deletions cdl_convert/cdl_convert.py
Expand Up @@ -190,6 +190,55 @@ def __init__(self):
self.input_desc = None
self.viewing_desc = None

# Public Methods ==========================================================

def parse_xml_input_desc(self, xml_element):
"""Parses an ElementTree element to find & add an input description
**Args:**
xml_element : (``xml.etree.ElementTree.Element``)
The element to parse for an Input Description element. If
found, set our ``input_desc``
**Returns:**
None
**Raises:**
None
"""
# If the text field is empty, this will return None, which is the default
# value of viewing_desc and input_desc anyway.
try:
self.input_desc = xml_element.find('InputDescription').text
except AttributeError:
pass

# =========================================================================


def parse_xml_viewing_desc(self, xml_element):
"""Parses an ElementTree element to find & add a viewing description
**Args:**
xml_element : (``xml.etree.ElementTree.Element``)
The element to parse for a Viewing Description element. If
found, set our ``viewing_desc``
**Returns:**
None
**Raises:**
None
"""
# If the text field is empty, this will return None, which is the default
# value of viewing_desc and input_desc anyway.
try:
self.viewing_desc = xml_element.find('ViewingDescription').text
except AttributeError:
pass

# ==============================================================================


Expand Down Expand Up @@ -1408,17 +1457,9 @@ def parse_cc(cdl_file):
# Grab our descriptions and add them to the cdl
cdl.parse_xml_descs(root)
# See if we have a viewing description.
# If the text field is empty, this will return None, which is the default
# value of viewing_desc and input_desc anyway.
try:
cdl.viewing_desc = root.find('ViewingDescription').text
except AttributeError:
pass
cdl.parse_xml_viewing_desc(root)
# See if we have an input description
try:
cdl.input_desc = root.find('InputDescription').text
except AttributeError:
pass
cdl.parse_xml_input_desc(root)

def find_required(elem, names):
"""Finds the required element and returns the found value.
Expand Down

0 comments on commit 743f74c

Please sign in to comment.