def filter(self, mediadesc): from hwp5.dataio import ParseError from hwp5_uno import HwpFileFromInputStream from hwp5_uno import load_hwp5file_into_doc logger.debug('Importer filter') desc = propseq_to_dict(mediadesc) logger.debug('mediadesc: %s', str(desc.keys())) for k, v in desc.items(): logger.debug('%s: %s', k, str(v)) statusindicator = desc.get('StatusIndicator') inputstream = desc['InputStream'] hwpfile = HwpFileFromInputStream(inputstream) try: load_hwp5file_into_doc(hwpfile, self.target, statusindicator) except ParseError as e: e.print_to_logger(logger) return False except Exception as e: logger.exception(e) return False else: return True
def detect(self, mediadesc): from hwp5_uno import typedetect logger.info('hwp5.Detector detect()') desc = propseq_to_dict(mediadesc) for k, v in desc.items(): logger.debug('\t%s: %s', k, v) inputstream = desc['InputStream'] typename = typedetect(inputstream) logger.info('hwp5.Detector: %s detected.', typename) return typename, mediadesc