本文整理汇总了Python中PyQt4.Qsci.QsciAPIs.isPrepared方法的典型用法代码示例。如果您正苦于以下问题:Python QsciAPIs.isPrepared方法的具体用法?Python QsciAPIs.isPrepared怎么用?Python QsciAPIs.isPrepared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qsci.QsciAPIs
的用法示例。
在下文中一共展示了QsciAPIs.isPrepared方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: APIs
# 需要导入模块: from PyQt4.Qsci import QsciAPIs [as 别名]
# 或者: from PyQt4.Qsci.QsciAPIs import isPrepared [as 别名]
class APIs(QObject):
"""
Class implementing an API storage entity.
@signal apiPreparationFinished() emitted after the API preparation has finished
@signal apiPreparationCancelled() emitted after the API preparation has been cancelled
@signal apiPreparationStarted() emitted after the API preparation has started
"""
def __init__(self, language, forPreparation = False, parent = None):
"""
Constructor
@param language language of the APIs object (string)
@param forPreparation flag indicating this object is just needed
for a preparation process (boolean)
@param parent reference to the parent object (QObject)
"""
QObject.__init__(self, parent)
self.setObjectName("APIs_%s" % language)
self.__inPreparation = False
self.__language = language
self.__forPreparation = forPreparation
self.__lexer = Lexers.getLexer(self.__language)
self.__apifiles = Preferences.getEditorAPI(self.__language)
self.__apifiles.sort()
if self.__lexer is None:
self.__apis = None
else:
self.__apis = QsciAPIs(self.__lexer)
self.connect(self.__apis, SIGNAL("apiPreparationFinished()"),
self.__apiPreparationFinished)
self.connect(self.__apis, SIGNAL("apiPreparationCancelled()"),
self.__apiPreparationCancelled)
self.connect(self.__apis, SIGNAL("apiPreparationStarted()"),
self.__apiPreparationStarted)
self.__loadAPIs()
def __loadAPIs(self):
"""
Private method to load the APIs.
"""
if self.__apis.isPrepared():
# load a prepared API file
if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"):
self.prepareAPIs()
self.__apis.loadPrepared()
else:
# load the raw files and prepare the API file
if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"):
self.prepareAPIs(ondemand = True)
def reloadAPIs(self):
"""
Public method to reload the API information.
"""
if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"):
self.prepareAPIs()
self.__loadAPIs()
def getQsciAPIs(self):
"""
Public method to get a reference to QsciAPIs object.
@return reference to the QsciAPIs object (QsciAPIs)
"""
if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"):
self.prepareAPIs()
return self.__apis
def __apiPreparationFinished(self):
"""
Private method called to save an API, after it has been prepared.
"""
res = self.__apis.savePrepared()
self.__inPreparation = False
self.emit(SIGNAL('apiPreparationFinished()'))
def __apiPreparationCancelled(self):
"""
Private method called, after the API preparation process has been cancelled.
"""
self.__inPreparation = False
self.emit(SIGNAL('apiPreparationCancelled()'))
def __apiPreparationStarted(self):
"""
Private method called, when the API preparation process started.
"""
self.__inPreparation = True
self.emit(SIGNAL('apiPreparationStarted()'))
def prepareAPIs(self, ondemand = False, rawList = None):
"""
Public method to prepare the APIs if necessary.
@keyparam ondemand flag indicating a requested preparation (boolean)
@keyparam rawList list of raw API files (QStringList)
"""
if self.__apis is None or self.__inPreparation:
#.........这里部分代码省略.........
示例2: QsciEditor
# 需要导入模块: from PyQt4.Qsci import QsciAPIs [as 别名]
# 或者: from PyQt4.Qsci.QsciAPIs import isPrepared [as 别名]
#.........这里部分代码省略.........
if code_folding:
# 0: Folding margin
self.setMarginWidth(2, 14)
self.setFolding(QsciScintilla.BoxedFoldStyle)
# Colors
fcol = CONF.get('scintilla', 'margins/foregroundcolor')
bcol = CONF.get('scintilla', 'margins/backgroundcolor')
if fcol:
self.setMarginsForegroundColor(QColor(fcol))
if bcol:
self.setMarginsBackgroundColor(QColor(bcol))
fcol = CONF.get('scintilla', 'foldmarginpattern/foregroundcolor')
bcol = CONF.get('scintilla', 'foldmarginpattern/backgroundcolor')
if fcol and bcol:
self.setFoldMarginColors(QColor(fcol), QColor(bcol))
def setup_api(self):
"""Load and prepare Python API"""
if self.lexer() is None:
return
self.api = QsciAPIs(self.lexer())
is_api_ready = False
api_path = CONF.get('editor', 'api')
if not osp.isfile(api_path):
from spyderlib.config import DATA_PATH
api_path = osp.join(DATA_PATH, 'python.api')
if osp.isfile(api_path):
CONF.set('editor', 'api', api_path)
else:
return False
api_size = CONF.get('editor', 'api_size', None)
current_api_size = os.stat(api_path).st_size
if api_size is not None and api_size == current_api_size:
if self.api.isPrepared():
is_api_ready = self.api.loadPrepared()
else:
CONF.set('editor', 'api_size', current_api_size)
if not is_api_ready:
if self.api.load(api_path):
self.api.prepare()
self.connect(self.api, SIGNAL("apiPreparationFinished()"),
self.api.savePrepared)
return is_api_ready
def set_eol_chars_visible(self, state):
"""Show/hide EOL characters"""
self.setEolVisibility(state)
def remove_trailing_spaces(self):
"""Remove trailing spaces"""
text_before = unicode(self.text())
text_after = sourcecode.remove_trailing_spaces(text_before)
if text_before != text_after:
self.setText(text_after)
def fix_indentation(self):
"""Replace tabs by spaces"""
text_before = unicode(self.text())
text_after = sourcecode.fix_indentation(text_before)
if text_before != text_after:
self.setText(text_after)
def set_eol_mode(self, text):
"""
Set QScintilla widget EOL mode based on *text* EOL characters
"""
示例3: QsciEditor
# 需要导入模块: from PyQt4.Qsci import QsciAPIs [as 别名]
# 或者: from PyQt4.Qsci.QsciAPIs import isPrepared [as 别名]
#.........这里部分代码省略.........
self.setMarginMarkerMask(0, mask)
self.setMarginWidth(0, 14)
self.connect(self,
SIGNAL('marginClicked(int,int,Qt::KeyboardModifiers)'),
self.__margin_clicked)
if code_folding:
# 0: Folding margin
self.setMarginWidth(2, 14)
self.setFolding(QsciScintilla.BoxedFoldStyle)
# Colors
fcol = CONF.get('scintilla', 'margins/foregroundcolor')
bcol = CONF.get('scintilla', 'margins/backgroundcolor')
if fcol:
self.setMarginsForegroundColor(QColor(fcol))
if bcol:
self.setMarginsBackgroundColor(QColor(bcol))
fcol = CONF.get('scintilla', 'foldmarginpattern/foregroundcolor')
bcol = CONF.get('scintilla', 'foldmarginpattern/backgroundcolor')
if fcol and bcol:
self.setFoldMarginColors(QColor(fcol), QColor(bcol))
def setup_api(self):
"""Load and prepare API"""
if self.lexer() is None:
return
self.api = QsciAPIs(self.lexer())
is_api_ready = False
api_path = CONF.get('editor', 'api')
if not os.path.isfile(api_path):
return False
api_stat = CONF.get('editor', 'api_stat', None)
current_api_stat = os.stat(api_path)
if (api_stat is not None) and (api_stat == current_api_stat):
if self.api.isPrepared():
is_api_ready = self.api.loadPrepared()
else:
CONF.set('editor', 'api_stat', current_api_stat)
if not is_api_ready:
if self.api.load(api_path):
self.api.prepare()
self.connect(self.api, SIGNAL("apiPreparationFinished()"),
self.api.savePrepared)
return is_api_ready
def set_whitespace_visible(self, state):
"""Show/hide whitespace"""
if state:
self.setWhitespaceVisibility(QsciScintilla.WsVisible)
else:
self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
def set_eol_chars_visible(self, state):
"""Show/hide EOL characters"""
self.setEolVisibility(state)
def convert_eol_chars(self):
"""Convert EOL characters to current mode"""
self.convertEols(self.eolMode())
def remove_trailing_spaces(self):
"""Remove trailing spaces"""
text_before = unicode(self.text())
text_after = sourcecode.remove_trailing_spaces(text_before)
if text_before != text_after:
self.setText(text_after)