本文整理汇总了Python中spyderlib.py3compat.getcwd函数的典型用法代码示例。如果您正苦于以下问题:Python getcwd函数的具体用法?Python getcwd怎么用?Python getcwd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getcwd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_data
def save_data(self, filename=None):
"""Save data"""
if filename is None:
filename = self.filename
if filename is None:
filename = getcwd()
filename, _selfilter = getsavefilename(self, _("Save data"),
filename,
iofunctions.save_filters)
if filename:
self.filename = filename
else:
return False
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
if self.is_internal_shell:
wsfilter = self.get_internal_shell_filter('picklable',
check_all=True)
namespace = wsfilter(self.shellwidget.interpreter.namespace).copy()
error_message = iofunctions.save(namespace, filename)
else:
settings = self.get_view_settings()
error_message = monitor_save_globals(self._get_sock(),
settings, filename)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, _("Save data"),
_("<b>Unable to save current workspace</b>"
"<br><br>Error message:<br>%s") % error_message)
self.save_button.setEnabled(self.filename is not None)
示例2: select_file
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)
示例3: compare
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)
示例4: __init__
def __init__(self, parent=None, name_filters=['*.py', '*.pyw'],
valid_types=('.py', '.pyw'), show_all=False,
show_cd_only=None, show_toolbar=True, show_icontext=True):
QWidget.__init__(self, parent)
self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only)
self.treewidget.setup(name_filters=name_filters,
valid_types=valid_types, show_all=show_all)
self.treewidget.chdir(getcwd())
toolbar_action = create_action(self, _("Show toolbar"),
toggled=self.toggle_toolbar)
icontext_action = create_action(self, _("Show icons and text"),
toggled=self.toggle_icontext)
self.treewidget.common_actions += [None,
toolbar_action, icontext_action]
# Setup toolbar
self.toolbar = QToolBar(self)
self.toolbar.setIconSize(QSize(16, 16))
self.previous_action = create_action(self, text=_("Previous"),
icon=get_icon('previous.png'),
triggered=self.treewidget.go_to_previous_directory)
self.toolbar.addAction(self.previous_action)
self.previous_action.setEnabled(False)
self.connect(self.treewidget, SIGNAL("set_previous_enabled(bool)"),
self.previous_action.setEnabled)
self.next_action = create_action(self, text=_("Next"),
icon=get_icon('next.png'),
triggered=self.treewidget.go_to_next_directory)
self.toolbar.addAction(self.next_action)
self.next_action.setEnabled(False)
self.connect(self.treewidget, SIGNAL("set_next_enabled(bool)"),
self.next_action.setEnabled)
parent_action = create_action(self, text=_("Parent"),
icon=get_icon('up.png'),
triggered=self.treewidget.go_to_parent_directory)
self.toolbar.addAction(parent_action)
options_action = create_action(self, text='', tip=_("Options"),
icon=get_icon('tooloptions.png'))
self.toolbar.addAction(options_action)
widget = self.toolbar.widgetForAction(options_action)
widget.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, self.treewidget.common_actions)
options_action.setMenu(menu)
toolbar_action.setChecked(show_toolbar)
self.toggle_toolbar(show_toolbar)
icontext_action.setChecked(show_icontext)
self.toggle_icontext(show_icontext)
vlayout = QVBoxLayout()
vlayout.addWidget(self.toolbar)
vlayout.addWidget(self.treewidget)
self.setLayout(vlayout)
示例5: select_file
def select_file(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
filename, _selfilter = getopenfilename(self, _("Select Python file"),
getcwd(), _("Python files")+" (*.py ; *.pyw)")
self.emit(SIGNAL('redirect_stdio(bool)'), False)
if filename:
self.analyze(filename)
示例6: select_directory
def select_directory(self):
"""Select directory"""
self.redirect_stdio.emit(False)
directory = getexistingdirectory(self.main, _("Select directory"), getcwd())
if directory:
self.chdir(directory)
self.redirect_stdio.emit(True)
示例7: refresh_plugin
def refresh_plugin(self):
"""Refresh widget"""
curdir = getcwd()
self.pathedit.add_text(curdir)
self.save_wdhistory()
self.set_previous_enabled.emit(self.histindex is not None and self.histindex > 0)
self.set_next_enabled.emit(self.histindex is not None and self.histindex < len(self.history) - 1)
示例8: detect_hg_repository
def detect_hg_repository(self, path=None):
if path is None:
path = getcwd()
hg_repository = is_hg_installed() and get_vcs_root(path) is not None
self.hg_manifest.setEnabled(hg_repository)
if not hg_repository and self.hg_manifest.isChecked():
self.custom_dir.setChecked(True)
示例9: save_data
def save_data(self):
"""Save data"""
title = _( "Save profiler result")
filename, _selfilter = getsavefilename(self, title,
getcwd(),
_("Profiler result")+" (*.Result)")
if filename:
self.datatree.save_data(filename)
示例10: select_directory
def select_directory(self):
"""Select directory"""
self.emit(SIGNAL('redirect_stdio(bool)'), False)
directory = getexistingdirectory(self.main, _("Select directory"),
getcwd())
if directory:
self.chdir(directory)
self.emit(SIGNAL('redirect_stdio(bool)'), True)
示例11: set
def set(self, options):
self.args = options.get("args", "")
self.args_enabled = options.get("args/enabled", False)
if CONF.get("run", WDIR_USE_FIXED_DIR_OPTION, False):
default_wdir = CONF.get("run", WDIR_FIXED_DIR_OPTION, getcwd())
self.wdir = options.get("workdir", default_wdir)
self.wdir_enabled = True
else:
self.wdir = options.get("workdir", getcwd())
self.wdir_enabled = options.get("workdir/enabled", False)
self.current = options.get("current", CONF.get("run", CURRENT_INTERPRETER_OPTION, True))
self.systerm = options.get("systerm", CONF.get("run", SYSTERM_INTERPRETER_OPTION, False))
self.interact = options.get("interact", CONF.get("run", "interact", False))
self.show_kill_warning = options.get("show_kill_warning", CONF.get("run", "show_kill_warning", False))
self.post_mortem = options.get("post_mortem", CONF.get("run", "post_mortem", False))
self.python_args = options.get("python_args", "")
self.python_args_enabled = options.get("python_args/enabled", False)
示例12: select_directory
def select_directory(self, edit):
"""Select directory"""
basedir = to_text_string(edit.text())
if not osp.isdir(basedir):
basedir = getcwd()
title = _("Select directory")
directory = getexistingdirectory(self, title, basedir)
if directory:
edit.setText(directory)
示例13: select_directory
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
self.wd_cb.setChecked(True)
示例14: set
def set(self, options):
self.args = options.get('args', '')
self.args_enabled = options.get('args/enabled', False)
if CONF.get('run', WDIR_USE_FIXED_DIR_OPTION, False):
default_wdir = CONF.get('run', WDIR_FIXED_DIR_OPTION, getcwd())
self.wdir = options.get('workdir', default_wdir)
self.wdir_enabled = True
else:
self.wdir = options.get('workdir', getcwd())
self.wdir_enabled = options.get('workdir/enabled', False)
self.current = options.get('current',
CONF.get('run', CURRENT_INTERPRETER_OPTION, True))
self.systerm = options.get('systerm',
CONF.get('run', SYSTERM_INTERPRETER_OPTION, False))
self.interact = options.get('interact', False)
self.show_kill_warning = options.get('show_kill_warning', True)
self.python_args = options.get('python_args', '')
self.python_args_enabled = options.get('python_args/enabled', False)
示例15: load_wdhistory
def load_wdhistory(self, workdir=None):
"""Load history from a text file in user home directory"""
if osp.isfile(self.LOG_PATH):
wdhistory, _ = encoding.readlines(self.LOG_PATH)
wdhistory = [name for name in wdhistory if os.path.isdir(name)]
else:
if workdir is None:
workdir = getcwd()
wdhistory = [ workdir ]
return wdhistory