本文整理汇总了Python中document.Document.save方法的典型用法代码示例。如果您正苦于以下问题:Python Document.save方法的具体用法?Python Document.save怎么用?Python Document.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.Document
的用法示例。
在下文中一共展示了Document.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDocument
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import save [as 别名]
class TestDocument(unittest.TestCase):
def setUp(self):
self.d = Document()
self.d.insert("a")
def test_cursor(self):
self.assertEqual(self.d.cursor.position, 1)
self.d.save("tst")
try:
remove("tst")
except OSError:
pass
self.d.cursor.back()
self.d.delete()
self.assertEqual(self.d.cursor.position, 0)
def test_multiple_chars_and_escape(self):
self.d.cursor.home()
self.d.delete()
string = ["h", "e", "l", "l", "o", "\n", "w", "o", "r", "l", "d", "!"]
for i in string:
self.d.insert(i)
self.assertEqual(self.d.string, "hello\nworld!")
def test_string_property(self):
self.assertEqual(self.d.string, "a")
示例2: do_save
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import save [as 别名]
def do_save(self):
doc = Document(size=self.size, pos=self.plane.pos, scale=self.plane.scale, rotation=self.plane.rotation)
for obj in reversed(self.plane.all_children):
attrs = [("pos", obj.pos), ("size", obj.size), ("rotation", obj.rotation), ("scale", obj.scale)]
if isinstance(obj, TextPlaneObject):
attrs += [(attr, getattr(obj, attr)) for attr in TextObject.__attrs__]
doc.create_text(**dict(attrs))
elif isinstance(obj, ImagePlaneObject):
attrs += [(attr, getattr(obj, attr)) for attr in ImageObject.__attrs__]
doc.create_image(**dict(attrs))
elif isinstance(obj, VideoPlaneObject):
attrs += [(attr, getattr(obj, attr)) for attr in VideoObject.__attrs__]
doc.create_video(**dict(attrs))
for obj in reversed(self.tb_slides.children):
obj.download_thumb()
doc.add_slide(obj.slide_pos, obj.slide_rotation, obj.slide_scale, obj.thumb)
ws = self.app.config.get("paths", "workspace")
if not self.filename:
project_dir = join(ws, "project_%d" % time())
makedirs(project_dir)
self._filename = join(project_dir, "project.json")
doc.save(self.filename)
self.is_dirty = False
示例3: enumerate
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import save [as 别名]
import download_cvs
import csv_reader
from datetime import datetime
from document import Document
import time
download_cvs.get()
data = csv_reader.reader()
# print category names
for i, cat in enumerate(data.next()):
print i, cat
for line in data:
doc = Document(meta={'id': line[0]},
title=line[1],
area=line[6],
description=line[8],
categories=line[11],
languages=line[27],
timestamp=datetime.now(),
releasedate=line[31],
entrydate=line[32])
doc.save()
time.sleep(1)
示例4: RegularUser
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import save [as 别名]
from document import Document
from Tkinter import *
verbose = False
###########################################################################
# TH0 = Setup
###########################################################################
# Create an instance of the User class for the newly created user, when the
# admin accepts an application, the user is automatically created.
ash = RegularUser(username='Ash')
# Create a document at the root directory.
ash.create_new_document('TH0.txt', 1, verbose=verbose)
# Get the 'id' of the newly created document.
pikaid = ash.manage.manage_DB.get_info('document', where={
'name': 'TH0.txt', 'parent_dir': 1}, verbose=verbose)[0]['id']
# Create an instance of the User class for the newly created document.
pikachu = Document(pikaid)
# Save new content to the document.
pikachu.save("Good Morning!\nGood Morning to you!\nHow do you do?\nFine thank you, yourself?\nI am well.\nGoodbye.\nGoodbye.", ash.info['id'], verbose=verbose)
# Save new content to the document.
pikachu.save("Good Morning!\nHow do you do?\nI am well.\nGoodbye.", ash.info['id'], verbose=verbose)
###########################################################################
# TH1 = Revision
###########################################################################
# Create the GUI.
root = Tk()
hui = HistoryUI(root, root, pikachu)
mainloop()
示例5: save
# 需要导入模块: from document import Document [as 别名]
# 或者: from document.Document import save [as 别名]
def save(self, jsonDictionary):
from document import Document
doc = Document(documentID=jsonDictionary['_id'], text=jsonDictionary['text'])
doc.save()