本文整理汇总了Python中document.Document.name方法的典型用法代码示例。如果您正苦于以下问题:Python Document.name方法的具体用法?Python Document.name怎么用?Python Document.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.Document
的用法示例。
在下文中一共展示了Document.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import name [as 别名]
def main():
document = None
page_num = 0
options, args = parseCmdLineOpt()
config_file = options.configFile
config = readConfig(config_file)
channel = create_connection(config)
documents = []
scanner = init_scanner(config)
for output, image_bar in start_scanning(scanner):
for symbol in image_bar:
logger.debug("symbol %s" % symbol.data)
for clef, valeur in config.items("type"):
if re.match(valeur, symbol.data):
page_num = 0
logger.debug("new document detected")
document = Document()
logger.debug(document)
document.name = symbol.data
document.genre = clef
documents.append(document)
break
if re.match(("^%s.*" % config.get("workflow", "key")), symbol.data):
document.workflows.append(symbol.data)
page_num += 1
if document is not None:
filename = "%s_%s.tiff" % (document.name, str(page_num))
else:
document = Document()
filename = "undefined_%s_%s.tiff" % (datetime.today().strftime("%Y%m%d-%H%M%S"), str(page_num))
document.name = "undefined_%s" % datetime.today().strftime("%Y%m%d-%H%M%S")
documents.append(document)
filepath = os.path.join(config.get("output", "tmp_dir"), filename)
output.save(filepath, 'TIFF')
document.files.append(filepath)
for symbol in image_bar:
document.barcodes.append(symbol.data)
print str(document)
ocr = Ocr()
ocr.bin_path = config.get("ocr","ocr_bin")
ocr.input_image = filepath
ocr.parse()
document.ocr.append(ocr.content)
if config.get("scanner", "interactive") == "True":
input_cmd = raw_input("press enter to scan the next document or 'quit' to leave ")
if input_cmd == "quit":
break
for document in documents:
logger.debug("documents : %s" % documents)
logger.debug("document : %s" % document)
old_files = document.files
logger.debug(" old_files :")
logger.debug(old_files)
document.files = []
file_format = config.get("output", "file_format")
for image in old_files:
logger.debug(" image : %s" % image)
document.files.append(convert_file(image,file_format))
if file_format == "PDF":
new_file = merge_files(document.files,file_format)
document.files = [new_file]
logger.debug("we gonna produce a new message in the queue for %s" % document)
produce_msg_document(channel, document, config.get("queues", "documents"))