本文整理汇总了Python中editxt.project.Project.expanded方法的典型用法代码示例。如果您正苦于以下问题:Python Project.expanded方法的具体用法?Python Project.expanded怎么用?Python Project.expanded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类editxt.project.Project
的用法示例。
在下文中一共展示了Project.expanded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import expanded [as 别名]
def test(c):
def objcstr(value):
value = ak.NSString.alloc().initWithString_(value)
isinstance(value, objc.pyobjc_unicode), (type(value), value)
return value
def check(flag, key, serial, value=None):
if flag:
assert key in serial, (key, serial)
if value is not None:
eq_(serial[key], value)
else:
assert key not in serial, key
proj = Project(None)
recent = [objcstr("/file.txt"), objcstr("/doc.xml")]
if c.recent:
proj.recent.extend(Recent(p) for p in recent)
if c.name:
proj.name = objcstr("<name>")
if c.docs:
proj.editors = [MockDoc(1)]
proj.expanded = c.expn
serial = proj.serialize()
check(False, "path", serial, proj.path)
check(c.name, "name", serial, proj.name)
check(c.docs, "documents", serial)
check(True, "expanded", serial, c.expn)
check(c.recent, "recent", serial, recent)
dump_yaml(serial) # verify that it does not crash
示例2: _setup
# 需要导入模块: from editxt.project import Project [as 别名]
# 或者: from editxt.project.Project import expanded [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)