本文整理汇总了Python中editxt.project.Project.create_with_serial方法的典型用法代码示例。如果您正苦于以下问题:Python Project.create_with_serial方法的具体用法?Python Project.create_with_serial怎么用?Python Project.create_with_serial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.project.Project
的用法示例。
在下文中一共展示了Project.create_with_serial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_with_serial
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import create_with_serial [as 别名]
def test_create_with_serial():
m = Mocker()
serial = {"path": "/temp/non-existent/project.edxt"}
assert not os.path.exists(serial["path"])
with m:
result = Project.create_with_serial(serial)
try:
eq_(result.path, serial["path"])
finally:
result.close()
示例2: deserialize
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import create_with_serial [as 别名]
def deserialize(self, data):
if data:
for serial in data.get("project_serials", []):
proj = Project.create_with_serial(serial)
self.projects.append(proj)
for proj_index, doc_index in data.get("recent_items", []):
if proj_index < len(self.projects):
proj = self.projects[proj_index]
if doc_index == "<project>":
self.recent.push(proj.id)
elif doc_index < len(proj.documents()):
doc = proj.documents()[doc_index]
self.recent.push(doc.id)
self.discard_and_focus_recent(None)
示例3: _setstate
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import create_with_serial [as 别名]
def _setstate(self, state):
if state:
for serial in state.get("project_serials", []):
proj = Project.create_with_serial(serial)
self.projects.append(proj)
for proj_index, doc_index in state.get("recent_items", []):
if proj_index < len(self.projects):
proj = self.projects[proj_index]
if doc_index == "<project>":
self.recent.push(proj.id)
elif doc_index < len(proj.documents()):
doc = proj.documents()[doc_index]
self.recent.push(doc.id)
if 'window_settings' in state:
self.window_settings = state['window_settings']
self.discard_and_focus_recent(None)