本文整理汇总了Python中util.homify函数的典型用法代码示例。如果您正苦于以下问题:Python homify函数的具体用法?Python homify怎么用?Python homify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了homify函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populateRecentFilesMenu
def populateRecentFilesMenu(self):
self.menu_recent_files.clear()
for url in recentfiles.urls():
f = url.toLocalFile()
dirname, basename = os.path.split(f)
text = "{0} ({1})".format(basename, util.homify(dirname))
self.menu_recent_files.addAction(text).url = url
qutil.addAccelerators(self.menu_recent_files.actions())
示例2: action
def action(filename):
url = QUrl.fromLocalFile(filename)
a = QAction(menu)
a.setText(_("Open \"{url}\"").format(url=util.homify(filename)))
a.setIcon(icons.get('document-open'))
@a.triggered.connect
def open_doc():
d = mainwindow.openUrl(url)
mainwindow.setCurrentDocument(d)
return a
示例3: display
def display(self):
text = util.homify(self._info.command)
if self._info.version():
text += " ({0})".format(self._info.versionString())
self.setIcon(icons.get("lilypond-run"))
else:
self.setIcon(icons.get("dialog-error"))
if self._info.command == self.listWidget().parentWidget().parentWidget()._defaultCommand:
text += " [{0}]".format(_("default"))
self.setText(text)
示例4: menu_file_open_recent
def menu_file_open_recent(parent):
m = QMenu(parent)
m.setTitle(_("Open &Recent"))
m.triggered.connect(slot_file_open_recent_action)
import recentfiles
for url in recentfiles.urls():
f = url.toLocalFile()
dirname, basename = os.path.split(f)
text = "{0} ({1})".format(basename, util.homify(dirname))
m.addAction(text).url = url
qutil.addAccelerators(m.actions())
return m
示例5: path
def path(url):
"""Returns the path, as a string, of the url to group documents.
Returns None if the document is nameless.
"""
if url.isEmpty():
return None
elif url.toLocalFile():
return util.homify(os.path.dirname(url.toLocalFile()))
else:
return url.resolved(QUrl('.')).toString(QUrl.RemoveUserInfo)
示例6: prettyName
def prettyName(self):
"""Return a pretty-printable name for this LilyPond instance."""
command = self.abscommand() or ""
# strip unneeded cruft from the command name
outstrip='out/bin/lilypond'
if command.endswith(outstrip):
command=command[:-len(outstrip)]
macstrip='/Contents/Resources/bin/lilypond'
if sys.platform.startswith('darwin') and command.endswith('.app' + macstrip):
command=command[:-len(macstrip)]
return "{name} {version} ({command})".format(
name = self.name,
version = self.versionString(),
command = util.homify(command))
示例7: complete
def complete():
target = definition.target(node)
if target:
if target.document is node.document:
a.setText(_("&Jump to definition (line {num})").format(
num = node.document.index(node.document.block(target.position)) + 1))
else:
a.setText(_("&Jump to definition (in {filename})").format(
filename=util.homify(target.document.filename)))
@a.triggered.connect
def activate():
definition.goto_target(mainwindow, target)
else:
a.setText(_("&Jump to definition (unknown)"))
a.setEnabled(False)
示例8: updateWindowTitle
def updateWindowTitle(self):
doc = self.currentDocument()
name = []
if sessions.currentSession():
name.append(sessions.currentSession() + ":")
if doc:
if doc.url().isEmpty():
name.append(doc.documentName())
elif doc.url().toLocalFile():
name.append(util.homify(doc.url().toLocalFile()))
else:
name.append(doc.url().toString())
if doc.isModified():
# L10N: state of document in window titlebar
name.append(_("[modified]"))
self.setWindowTitle(app.caption(" ".join(name)))
示例9: setDocumentStatus
def setDocumentStatus(self, doc):
if doc in self.docs:
index = self.docs.index(doc)
self.setTabText(index, doc.documentName())
if doc.url().toLocalFile():
tooltip = util.homify(doc.url().toLocalFile())
elif not doc.url().isEmpty():
tooltip = doc.url().toString(QUrl.RemoveUserInfo)
else:
tooltip = None
self.setTabToolTip(index, tooltip)
# icon
if jobmanager.isRunning(doc):
icon = 'lilypond-run'
elif doc.isModified():
icon = 'document-save'
else:
icon = 'text-plain'
self.setTabIcon(index, icons.get(icon))
示例10: setDocumentStatus
def setDocumentStatus(self, doc):
if doc in self.docs:
index = self.docs.index(doc)
self.setTabText(index, doc.documentName().replace('&', '&&'))
if doc.url().toLocalFile():
tooltip = util.homify(doc.url().toLocalFile())
elif not doc.url().isEmpty():
tooltip = doc.url().toString(QUrl.RemoveUserInfo)
else:
tooltip = None
self.setTabToolTip(index, tooltip)
# icon
job = jobmanager.job(doc)
if job and job.is_running() and not jobattributes.get(job).hidden:
icon = 'lilypond-run'
elif doc.isModified():
icon = 'document-save'
else:
icon = 'text-plain'
self.setTabIcon(index, icons.get(icon))
示例11: setDocuments
def setDocuments(self, documents):
"""Display the specified documents in the list."""
# clear the treewidget
for d in self.tree.invisibleRootItem().takeChildren():
for i in d.takeChildren():
i.doc = None
# group the documents by directory
dirs = {}
for d in documents:
path = d.url().toLocalFile()
if path:
dirname, filename = os.path.split(path)
dirs.setdefault(dirname, []).append((filename, d))
for dirname in sorted(dirs, key=util.naturalsort):
diritem = QTreeWidgetItem()
diritem.setText(0, util.homify(dirname))
self.tree.addTopLevelItem(diritem)
diritem.setExpanded(True)
diritem.setFlags(Qt.ItemIsEnabled)
diritem.setIcon(0, icons.get('folder-open'))
for filename, document in sorted(dirs[dirname],
key=lambda item: util.naturalsort(item[0])):
fileitem = QTreeWidgetItem()
diritem.addChild(fileitem)
if documentwatcher.DocumentWatcher.instance(document).isdeleted():
itemtext = _("[deleted]")
icon = "dialog-error"
else:
itemtext = _("[modified]")
icon = "document-edit"
fileitem.setIcon(0, icons.get(icon))
fileitem.setText(0, filename)
fileitem.setText(1, itemtext)
fileitem.doc = document
# select the item if there is only one
if len(dirs) == 1 and len(dirs.values()[0]) == 1:
fileitem.setSelected(True)
self.tree.resizeColumnToContents(0)
self.tree.resizeColumnToContents(1)
self.updateButtons()
示例12: updateWindowTitle
def updateWindowTitle(self):
doc = self.currentDocument()
name = []
if sessions.currentSession():
name.append(sessions.currentSession() + ':')
if doc:
if doc.url().isEmpty():
name.append(doc.documentName())
elif doc.url().toLocalFile():
name.append(util.homify(doc.url().toLocalFile()))
else:
name.append(doc.url().toString())
if doc.isModified():
# L10N: state of document in window titlebar
name.append(_("[modified]"))
window_title = app.caption(" ".join(name))
if vcs.app_is_git_controlled():
window_title += " " + vcs.app_active_branch_window_title()
self.setWindowTitle(window_title)
示例13: displaycommand
def displaycommand(self):
"""The path to the command in a format pretty to display.
This removes the 'out/bin/lilypond' part of custom build LilyPond
versions, and on Mac OS X it removes the
'/Contents/Resources/bin/lilypond' part.
Finally it replaces the users home directory with '~'.
The empty string is returned if LilyPond is not installed on the users'
system.
"""
command = self.abscommand()
if command:
outstrip='out/bin/lilypond'
if command.endswith(outstrip):
command=command[:-len(outstrip)]
macstrip='/Contents/Resources/bin/lilypond'
if sys.platform.startswith('darwin') and command.endswith('.app' + macstrip):
command=command[:-len(macstrip)]
return util.homify(command)
else:
return self.command