本文整理汇总了Python中variables.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: event
def event(self, ev):
"""General event handler.
This is reimplemented to:
- prevent inserting the hard line separator, which makes no sense in
plain text
- prevent handling Undo and Redo, they work better via the menu actions
- handle Tab and Backtab to change the indent
"""
if ev in (
# avoid the line separator, makes no sense in plain text
QKeySequence.InsertLineSeparator,
# those can better be called via the menu actions, then they
# work better
QKeySequence.Undo,
QKeySequence.Redo,
):
return False
# handle Tab and Backtab
if ev.type() == QEvent.KeyPress:
cursor = self.textCursor()
if ev.key() == Qt.Key_Tab and ev.modifiers() == Qt.NoModifier:
# tab pressed, insert a tab when no selection and in text,
# else increase the indent
if not cursor.hasSelection():
block = cursor.block()
text = block.text()[:cursor.position() - block.position()]
if text and not text.isspace():
if variables.get(self.document(), 'document-tabs', True):
cursor.insertText('\t')
else:
tabwidth = variables.get(self.document(), 'tab-width', 8)
spaces = tabwidth - len(text.expandtabs(tabwidth)) % tabwidth
cursor.insertText(' ' * spaces)
self.setTextCursor(cursor)
return True
import indent
indent.increase_indent(cursor)
if not cursor.hasSelection():
cursortools.strip_indent(cursor)
self.setTextCursor(cursor)
return True
elif ev.key() == Qt.Key_Backtab and ev.modifiers() == Qt.ShiftModifier:
# shift-tab pressed, decrease the indent
import indent
indent.decrease_indent(cursor)
if not cursor.hasSelection():
cursortools.strip_indent(cursor)
self.setTextCursor(cursor)
return True
return super(View, self).event(ev)
开发者ID:oleastre,项目名称:frescobaldi,代码行数:55,代码来源:view.py
示例2: basenames
def basenames(self):
"""Returns a list of basenames that our document is expected to create.
The list is created based on include files and the define output-suffix and
\bookOutputName and \bookOutputSuffix commands.
You should add '.ext' and/or '-[0-9]+.ext' to find created files.
"""
# if the file defines an 'output' variable, it is used instead
output = variables.get(self.document(), 'output')
filename = self.jobinfo()[0]
if output:
dirname = os.path.dirname(filename)
return [os.path.join(dirname, name.strip())
for name in output.split(',')]
mode = self.mode()
if mode == "lilypond":
return fileinfo.basenames(self.lydocinfo(), self.includefiles(), filename)
elif mode == "html":
pass
elif mode == "texinfo":
pass
elif mode == "latex":
pass
elif mode == "docbook":
pass
return []
开发者ID:brownian,项目名称:frescobaldi,代码行数:34,代码来源:documentinfo.py
示例3: version
def version(self):
"""Returns the LilyPond version if set in the document, as a tuple of ints.
First the functions searches inside LilyPond syntax.
Then it looks at the 'version' document variable.
Then, if the document is not a LilyPond document, it simply searches for a
\\version command string, possibly embedded in a comment.
The version is cached until the documents contents change.
"""
mkver = lambda strings: tuple(map(int, strings))
version = ly.parse.version(tokeniter.all_tokens(self.document()))
if version:
return mkver(re.findall(r"\d+", version))
# look at document variables
version = variables.get(self.document(), "version")
if version:
return mkver(re.findall(r"\d+", version))
# parse whole document for non-lilypond documents
if self.mode() != "lilypond":
m = re.search(r'\\version\s*"(\d+\.\d+(\.\d+)*)"', self.document().toPlainText())
if m:
return mkver(m.group(1).split('.'))
开发者ID:aspiers,项目名称:frescobaldi,代码行数:25,代码来源:documentinfo.py
示例4: master
def master(self):
"""Returns the master filename for the document, if it exists."""
filename = self.document().url().toLocalFile()
redir = variables.get(self.document(), "master")
if filename and redir:
path = os.path.normpath(os.path.join(os.path.dirname(filename), redir))
if os.path.exists(path) and path != filename:
return path
开发者ID:aspiers,项目名称:frescobaldi,代码行数:8,代码来源:documentinfo.py
示例5: document
def document(self):
"""Return the Document that should be engraved."""
doc = self.stickyDocument()
if not doc:
doc = self.mainwindow().currentDocument()
if not doc.url().isEmpty():
master = variables.get(doc, "master")
if master:
url = doc.url().resolved(QUrl(master))
doc = app.openUrl(url)
return doc
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:11,代码来源:__init__.py
示例6: mode
def mode(self, guess=True):
"""Returns the type of document ('lilypond, 'html', etc.).
The mode can be set using the "mode" document variable.
If guess is True (default), the mode is auto-recognized based on the contents
if not set explicitly using the "mode" variable. In this case, this function
always returns an existing mode.
If guess is False, auto-recognizing is not done and the function returns None
if the mode wasn't set explicitly.
"""
mode = variables.get(self.document(), "mode")
if mode in ly.lex.modes:
return mode
if guess:
return self.lydocinfo().mode()
开发者ID:brownian,项目名称:frescobaldi,代码行数:17,代码来源:documentinfo.py
示例7: setTabWidth
def setTabWidth(self):
"""(Internal) Reads the tab-width variable and the font settings to set the tabStopWidth."""
tabwidth = QSettings().value("indent/tab_width", 8, int)
tabwidth = self.fontMetrics().width(" ") * variables.get(self.document(), 'tab-width', tabwidth)
self.setTabStopWidth(tabwidth)
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:5,代码来源:view.py
示例8: encoding
def encoding(self):
return variables.get(self, "coding") or self._encoding
开发者ID:mamoch,项目名称:frescobaldi,代码行数:2,代码来源:document.py
注:本文中的variables.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论