本文整理汇总了Python中note.Note.cdate方法的典型用法代码示例。如果您正苦于以下问题:Python Note.cdate方法的具体用法?Python Note.cdate怎么用?Python Note.cdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.cdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_metadata
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import cdate [as 别名]
def parse_metadata(root):
notes = {}
for page in root.find('pageList').findall('page'):
pg = int(page.attrib['number'])
annotlist = page.find('annotationList')
for annot in annotlist.findall('annotation'):
if ( annot.attrib['type'] == "1" and
pg <= self.ui.documentWidget.num_pages ):
base = annot.find('base')
try:
author = base.attrib['author']
except KeyError:
author = ''
try:
text = base.attrib['contents']
except KeyError:
text = ''
try:
cdate = base.attrib['creationDate']
except KeyError:
cdate = ''
try:
mdate = base.attrib['modifyDate']
except KeyError:
mdate = ''
try:
preamble = base.attrib['preamble']
except KeyError:
preamble = PREAMBLE
try:
uname = base.attrib['uniqueName']
# notorius-1-0 becomes 0
uid = int(uname.rsplit('-')[-1])
except KeyError:
try:
uid = max(notes.keys())
except ValueError:
uid = 0
boundary = base.find('boundary')
x = float(boundary.attrib['l'])
y = float(boundary.attrib['t'])
size = self.ui.documentWidget.Document.page(
pg).pageSizeF()
pos = QtCore.QPointF(x*size.width(),
y*size.height())
note = Note(text, preamble, page = pg, pos = pos,
uid = uid)
notes[uid] = note
note.cdate = datetime.datetime.strptime(cdate, "%Y-%m-%dT%H:%M:%S")
note.mdate = datetime.datetime.strptime(mdate, "%Y-%m-%dT%H:%M:%S")
note.update()
else:
self.okular_notes.append(annot)
return notes