本文整理汇总了Python中spyderlib.widgets.comboboxes.PythonModulesComboBox.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python PythonModulesComboBox.is_valid方法的具体用法?Python PythonModulesComboBox.is_valid怎么用?Python PythonModulesComboBox.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.widgets.comboboxes.PythonModulesComboBox
的用法示例。
在下文中一共展示了PythonModulesComboBox.is_valid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProfilerWidget
# 需要导入模块: from spyderlib.widgets.comboboxes import PythonModulesComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PythonModulesComboBox import is_valid [as 别名]
#.........这里部分代码省略.........
title = _( "Save profiler result")
filename, _selfilter = getsavefilename(self, title,
getcwd(),
_("Profiler result")+" (*.Result)")
if filename:
self.datatree.save_data(filename)
def compare(self):
filename, _selfilter = getopenfilename(self, _("Select script to compare"),
getcwd(), _("Profiler result")+" (*.Result)")
if filename:
self.datatree.compare(filename)
self.show_data()
self.clear_button.setEnabled(True)
def clear(self):
self.datatree.compare(None)
self.datatree.hide_diff_cols(True)
self.show_data()
self.clear_button.setEnabled(False)
def analyze(self, filename, wdir=None, args=None, pythonpath=None):
if not is_profiler_installed():
return
self.kill_if_running()
#index, _data = self.get_data(filename)
index = None # FIXME: storing data is not implemented yet
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
if wdir is None:
wdir = osp.dirname(filename)
self.start(wdir, args, pythonpath)
def select_file(self):
self.redirect_stdio.emit(False)
filename, _selfilter = getopenfilename(self, _("Select Python script"),
getcwd(), _("Python scripts")+" (*.py ; *.pyw)")
self.redirect_stdio.emit(True)
if filename:
self.analyze(filename)
def show_log(self):
if self.output:
TextEditor(self.output, title=_("Profiler output"),
readonly=True, size=(700, 500)).exec_()
def show_errorlog(self):
if self.error_output:
TextEditor(self.error_output, title=_("Profiler output"),
readonly=True, size=(700, 500)).exec_()
def start(self, wdir=None, args=None, pythonpath=None):
filename = to_text_string(self.filecombo.currentText())
if wdir is None:
wdir = self._last_wdir
if wdir is None:
wdir = osp.basename(filename)
if args is None:
args = self._last_args
if args is None:
args = []
示例2: PylintWidget
# 需要导入模块: from spyderlib.widgets.comboboxes import PythonModulesComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PythonModulesComboBox import is_valid [as 别名]
#.........这里部分代码省略.........
self.process = None
self.set_running_state(False)
if PYLINT_PATH is None:
for widget in (self.treewidget, self.filecombo,
self.start_button, self.stop_button):
widget.setDisabled(True)
if os.name == 'nt' \
and programs.is_module_installed("pylint"):
# Pylint is installed but pylint script is not in PATH
# (AFAIK, could happen only on Windows)
text = _('Pylint script was not found. Please add "%s" to PATH.')
text = to_text_string(text) % osp.join(sys.prefix, "Scripts")
else:
text = _('Please install <b>pylint</b>:')
url = 'http://www.logilab.fr'
text += ' <a href=%s>%s</a>' % (url, url)
self.ratelabel.setText(text)
else:
self.show_data()
def analyze(self, filename):
if PYLINT_PATH is None:
return
filename = to_text_string(filename) # filename is a QString instance
self.kill_if_running()
index, _data = self.get_data(filename)
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
self.start()
def select_file(self):
self.redirect_stdio.emit(False)
filename, _selfilter = getopenfilename(self, _("Select Python file"),
getcwd(), _("Python files")+" (*.py ; *.pyw)")
self.redirect_stdio.emit(True)
if filename:
self.analyze(filename)
def remove_obsolete_items(self):
"""Removing obsolete items"""
self.rdata = [(filename, data) for filename, data in self.rdata
if is_module_or_package(filename)]
def get_filenames(self):
return [filename for filename, _data in self.rdata]
def get_data(self, filename):
filename = osp.abspath(filename)
for index, (fname, data) in enumerate(self.rdata):
if fname == filename:
return index, data
else:
return None, None
def set_data(self, filename, data):
filename = osp.abspath(filename)
index, _data = self.get_data(filename)
if index is not None:
self.rdata.pop(index)
self.rdata.insert(0, (filename, data))
示例3: PylintWidget
# 需要导入模块: from spyderlib.widgets.comboboxes import PythonModulesComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PythonModulesComboBox import is_valid [as 别名]
class PylintWidget(QWidget):
"""
Pylint widget
"""
DATAPATH = get_conf_path('.pylint.results')
VERSION = '1.0.2'
def __init__(self, parent, max_entries=100):
QWidget.__init__(self, parent)
self.output = None
self.error_output = None
self.max_entries = max_entries
self.data = [self.VERSION]
if osp.isfile(self.DATAPATH):
try:
data = cPickle.load(file(self.DATAPATH))
if data[0] == self.VERSION:
self.data = data
except EOFError:
pass
self.filecombo = PythonModulesComboBox(self)
if self.data:
self.remove_obsolete_items()
self.filecombo.addItems(self.get_filenames())
self.start_button = create_toolbutton(self, get_icon('run.png'),
translate('Pylint', "Analyze"),
tip=translate('Pylint', "Run analysis"),
triggered=self.start)
self.stop_button = create_toolbutton(self, get_icon('terminate.png'),
translate('Pylint', "Stop"),
tip=translate('Pylint',
"Stop current analysis"))
self.connect(self.filecombo, SIGNAL('valid(bool)'),
self.start_button.setEnabled)
self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data)
browse_button = create_toolbutton(self, get_icon('fileopen.png'),
tip=translate('Pylint', 'Select Python script'),
triggered=self.select_file)
self.ratelabel = QLabel()
self.datelabel = QLabel()
self.log_button = create_toolbutton(self, get_icon('log.png'),
translate('Pylint', "Output"),
tip=translate('Pylint',
"Complete Pylint output"),
triggered=self.show_log)
self.treewidget = ResultsTree(self)
hlayout1 = QHBoxLayout()
hlayout1.addWidget(self.filecombo)
hlayout1.addWidget(browse_button)
hlayout1.addWidget(self.start_button)
hlayout1.addWidget(self.stop_button)
hlayout2 = QHBoxLayout()
hlayout2.addWidget(self.ratelabel)
hlayout2.addStretch()
hlayout2.addWidget(self.datelabel)
hlayout2.addStretch()
hlayout2.addWidget(self.log_button)
layout = QVBoxLayout()
layout.addLayout(hlayout1)
layout.addLayout(hlayout2)
layout.addWidget(self.treewidget)
self.setLayout(layout)
self.process = None
self.set_running_state(False)
if not is_pylint_installed():
for widget in (self.treewidget, self.filecombo,
self.start_button, self.stop_button):
widget.setDisabled(True)
text = translate('Pylint', 'Please install <b>pylint</b>:')
url = 'http://www.logilab.fr'
text += ' <a href=%s>%s</a>' % (url, url)
self.ratelabel.setText(text)
else:
self.show_data()
def analyze(self, filename):
if not is_pylint_installed():
return
filename = unicode(filename) # filename is a QString instance
self.kill_if_running()
index, _data = self.get_data(filename)
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(index)
self.filecombo.selected()
if self.filecombo.is_valid():
self.start()
#.........这里部分代码省略.........
示例4: MemoryProfilerWidget
# 需要导入模块: from spyderlib.widgets.comboboxes import PythonModulesComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PythonModulesComboBox import is_valid [as 别名]
#.........这里部分代码省略.........
self.setLayout(layout)
self.process = None
self.set_running_state(False)
self.start_button.setEnabled(False)
if not is_memoryprofiler_installed():
for widget in (self.datatree, self.filecombo, self.log_button,
self.start_button, self.stop_button, browse_button,
self.collapse_button, self.expand_button):
widget.setDisabled(True)
text = _(
'<b>Please install the <a href="%s">memory_profiler module</a></b>'
) % WEBSITE_URL
self.datelabel.setText(text)
self.datelabel.setOpenExternalLinks(True)
else:
pass # self.show_data()
def analyze(self, filename, wdir=None, args=None, pythonpath=None,
use_colors=True):
self.use_colors = use_colors
if not is_memoryprofiler_installed():
return
self.kill_if_running()
#index, _data = self.get_data(filename)
index = None # FIXME: storing data is not implemented yet
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
if wdir is None:
wdir = osp.dirname(filename)
self.start(wdir, args, pythonpath)
def select_file(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
filename, _selfilter = getopenfilename(
self, _("Select Python script"), getcwd(),
_("Python scripts")+" (*.py ; *.pyw)")
self.emit(SIGNAL('redirect_stdio(bool)'), False)
if filename:
self.analyze(filename)
def show_log(self):
if self.output:
TextEditor(self.output, title=_("Memory profiler output"),
readonly=True, size=(700, 500)).exec_()
def show_errorlog(self):
if self.error_output:
TextEditor(self.error_output, title=_("Memory profiler output"),
readonly=True, size=(700, 500)).exec_()
def start(self, wdir=None, args=None, pythonpath=None):
filename = to_text_string(self.filecombo.currentText())
if wdir is None:
wdir = self._last_wdir
if wdir is None:
wdir = osp.basename(filename)
if args is None:
args = self._last_args
if args is None:
示例5: ProfilerWidget
# 需要导入模块: from spyderlib.widgets.comboboxes import PythonModulesComboBox [as 别名]
# 或者: from spyderlib.widgets.comboboxes.PythonModulesComboBox import is_valid [as 别名]
#.........这里部分代码省略.........
widget.setDisabled(True)
if os.name == 'nt' \
and programs.is_module_installed("profile"):
# The following is a comment from the pylint plugin:
# Module is installed but script is not in PATH
# (AFAIK, could happen only on Windows)
text = translate('Profiler',
'Profiler script was not found. Please add "%s" to PATH.')
text = unicode(text) % os.path.join(sys.prefix, "Scripts")
else:
text = translate('Profiler',
('Please install the modules '+
'<b>profile</b> and <b>pstats</b>:'))
# FIXME: need the actual website
url = 'http://www.python.org'
text += ' <a href=%s>%s</a>' % (url, url)
self.datelabel.setText(text)
else:
pass # self.show_data()
def analyze(self, filename):
if not is_profiler_installed():
return
filename = unicode(filename) # filename is a QString instance
self.kill_if_running()
#index, _data = self.get_data(filename)
index=None # FIXME: storing data is not implemented yet
if index is None:
self.filecombo.addItem(filename)
self.filecombo.setCurrentIndex(self.filecombo.count()-1)
else:
self.filecombo.setCurrentIndex(self.filecombo.findText(filename))
self.filecombo.selected()
if self.filecombo.is_valid():
self.start()
def select_file(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
filename = QFileDialog.getOpenFileName(self,
translate('Profiler', "Select Python script"), os.getcwdu(),
translate('Profiler', "Python scripts")+" (*.py ; *.pyw)")
self.emit(SIGNAL('redirect_stdio(bool)'), False)
if filename:
self.analyze(filename)
def show_log(self):
if self.output:
TextEditor(self.output, title=translate('Profiler', "Profiler output"),
readonly=True, size=(700, 500)).exec_()
def show_errorlog(self):
if self.error_output:
TextEditor(self.error_output, title=translate('Profiler', "Profiler output"),
readonly=True, size=(700, 500)).exec_()
def start(self):
self.datelabel.setText('Profiling, please wait...')
filename = unicode(self.filecombo.currentText())
self.process = QProcess(self)
self.process.setProcessChannelMode(QProcess.SeparateChannels)
self.process.setWorkingDirectory(os.path.dirname(filename))
self.connect(self.process, SIGNAL("readyReadStandardOutput()"),
self.read_output)
self.connect(self.process, SIGNAL("readyReadStandardError()"),
lambda: self.read_output(error=True))