本文整理汇总了Python中editxt.project.Project.path方法的典型用法代码示例。如果您正苦于以下问题:Python Project.path方法的具体用法?Python Project.path怎么用?Python Project.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.project.Project
的用法示例。
在下文中一共展示了Project.path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import path [as 别名]
def test(proj_has_path, is_changed):
m = Mocker()
window = m.mock(Window)
proj = Project(window)
#save_with_path = m.method(proj.save_with_path)
reset_cache = m.method(proj.reset_serial_cache)
m.method(proj.serialize)() >> "<serial>"
if proj_has_path:
proj.path = "test/proj.tmp"
if is_changed:
app = window.app >> m.mock(Application)
proj.serial_cache = "<invalid-cache>"
#if proj_has_path:
# save_with_path(proj.path)
app.save_window_states()
reset_cache()
else:
proj.serial_cache = "<serial>"
with m:
proj.save()
示例2: _setup
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import path [as 别名]
def _setup(self, app):
from editxt.editor import Editor
from editxt.project import Project
from editxt.window import Window
state = self.init_state
docs_by_name = {}
items = self.items
if state is None:
return
window = project = None
for i, state_item in enumerate(self.split(state)):
match = self.editor_re.match(state_item)
assert match, "unknown state item: {}".format(state_item)
collapsed, item, name, current = match.groups()
has_ext_name = name and ":" in name
assert item == "project" or (not collapsed and not has_ext_name), \
"unknown state item: {}".format(state_item)
if not name:
name = "<{}>".format(i)
if item == "window" or window is None:
window = Window(app)
project = None
app.windows.append(window)
if item == "window":
items[window] = "window" + name
continue
else:
items[window] = "window<{}>".format(i)
if item == "project" or project is None:
project = Project(window)
if has_ext_name:
name_offset = name.index(":") + 1
project.name = name[1:name_offset - 1]
else:
name_offset = 1
if "/" in name:
project.path = self.temp_path(name[name_offset:-1])
if collapsed:
project.expanded = False
window.projects.append(project)
if item == "project":
items[project] = "project" + name
if current:
if not window.selected_items:
window.current_editor = project
else:
window.selected_items.append(project)
continue
else:
items[project] = "project<{}>".format(i)
document = docs_by_name.get(name)
if document is None:
document = self.document_with_path(name[1:-1])
docs_by_name[name] = document
editor = Editor(project, document=document)
items[editor] = "editor" + name
items[document] = "document" + name
project.editors.append(editor)
if current:
if not window.selected_items:
window.current_editor = editor
else:
window.selected_items.append(editor)
示例3: test_can_rename
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import path [as 别名]
def test_can_rename():
proj = Project(None)
eq_(proj.path, None)
assert proj.can_rename()
proj.path = "<path>"
assert proj.can_rename()