def axml_display(d): # <owc:display> # <owc:pixelWidth> if is_empty(d): return None else: try: creator_display = etree.Element(ns_elem("owc", "display"), nsmap=ns) pixel_width = try_int(extract_p('pixelWidth', d, None)) if pixel_width is not None: etree.SubElement(creator_display, ns_elem("owc", "pixelWidth")).text = str(pixel_width) pixel_height = try_int(extract_p('pixelHeight', d, None)) if pixel_height is not None: etree.SubElement(creator_display, ns_elem( "owc", "pixelHeight")).text = str(pixel_height) mm_per_pixel = try_float(extract_p('mmPerPixel', d, None)) if mm_per_pixel is not None: etree.SubElement(creator_display, ns_elem( "owc", "mmPerPixel")).text = str(mm_per_pixel) return creator_display except Exception as ex: log.warning('could encode creator_display', ex) return None
def axml_link(d): # < link rel = "via" type = "application/xml" href = "..." title = "..." if is_empty(d): return None else: try: link = etree.Element("link", nsmap=ns) href = extract_p('href', d, None) if href is not None: link.set("href", href) rel = extract_p('rel', d, None) if rel is not None: link.set("rel", rel) mimetype = extract_p('type', d, None) if mimetype is not None: link.set("type", mimetype) lang = extract_p('lang', d, None) if lang is not None: link.set("lang", lang) title = extract_p('title', d, None) if title is not None: link.set("title", title) length = try_int(extract_p('length', d, None)) if length is not None: link.set("length", str(length)) return link except Exception as ex: log.warning('could not encode link', ex) return None
def from_dict(cls, d): return OwcLink( href=extract_p('href', d, None), rel=extract_p('rel', d, None), mimetype=extract_p('type', d, None), lang=extract_p('lang', d, None), title=extract_p('title', d, None), length=try_int(extract_p('length', d, None)) )
def axml_display(d): # <owc:display> # <owc:pixelWidth> if is_empty(d): return None else: try: creator_display = etree.Element(ns_elem("owc", "display"), nsmap=ns) pixel_width = try_int(extract_p('pixelWidth', d, None)) if pixel_width is not None: etree.SubElement(creator_display, ns_elem("owc", "pixelWidth")).text = str(pixel_width) pixel_height = try_int(extract_p('pixelHeight', d, None)) if pixel_height is not None: etree.SubElement(creator_display, ns_elem("owc", "pixelHeight")).text = str(pixel_height) mm_per_pixel = try_float(extract_p('mmPerPixel', d, None)) if mm_per_pixel is not None: etree.SubElement(creator_display, ns_elem("owc", "mmPerPixel")).text = str(mm_per_pixel) return creator_display except Exception as ex: log.warn('could encode creator_display', ex) return None
def axml_link(d): # < link rel = "via" type = "application/xml" href = "..." title = "..." if is_empty(d): return None else: try: link = etree.Element("link", nsmap=ns) href = extract_p('href', d, None) if href is not None: link.set("href", href) rel = extract_p('rel', d, None) if rel is not None: link.set("rel", rel) mimetype = extract_p('type', d, None) if mimetype is not None: link.set("type", mimetype) lang = extract_p('lang', d, None) if lang is not None: link.set("lang", lang) title = extract_p('title', d, None) if title is not None: link.set("title", title) length = try_int(extract_p('length', d, None)) if length is not None: link.set("length", str(length)) return link except Exception as ex: log.warn('could not encode link', ex) return None
def from_dict(cls, d): return OwcCreatorDisplay( pixel_width=try_int(extract_p('pixelWidth', d, None)), pixel_height=try_int(extract_p('pixelHeight', d, None)), mm_per_pixel=try_float(extract_p('mmPerPixel', d, None)) )