本文整理汇总了Python中note.Note.update方法的典型用法代码示例。如果您正苦于以下问题:Python Note.update方法的具体用法?Python Note.update怎么用?Python Note.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_metadata
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import update [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
示例2: MainWindow
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import update [as 别名]
#.........这里部分代码省略.........
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
loaded = False
if filename:
self.ui.nextPageButton.setEnabled(True)
self.ui.previousPageButton.setEnabled(True)
self.ui.pageSpinBox.setEnabled(True)
self.ui.offsetCheckBox.setEnabled(True)
self.ui.offsetCheckBox.setChecked(False)
self.ui.scaleSpinBox.setEnabled(True)
self.ui.scaleComboBox.setEnabled(True)
#file_dir = os.path.dirname(filename)
self.okular_notes = []
if filename.endswith(('.zip', '.okular')):
self.rmdoc = True
zipf = zipfile.ZipFile(filename, 'r')
zipf.extractall(TMPDIR)
# [ 'filename.pdf', 'content.xml', 'metadata.xml' ]
# becomes [ 'filename.pdf' ] which then becomes 'filename.pdf'
# then TMPDIR is added.
# Important! filename can have .okular extension!
self.docpath = os.path.join(TMPDIR,
[ fl for fl in zipf.namelist() if (
fl.rsplit('.')[1] != 'xml') ][0])
# Must insert try statement!
self.ui.documentWidget.load_document(self.docpath)
loaded = True
root = xml.parse(os.path.join(TMPDIR, 'metadata.xml')).getroot()
notes = parse_metadata(root)
for aux in ['content.xml', 'metadata.xml']:
os.remove(os.path.join(TMPDIR, aux))