本文整理汇总了Python中spyder.py3compat.getcwd函数的典型用法代码示例。如果您正苦于以下问题:Python getcwd函数的具体用法?Python getcwd怎么用?Python getcwd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getcwd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open_project
def open_project(self, path=None, restart_consoles=True,
save_previous_files=True):
"""Open the project located in `path`"""
if path is None:
basedir = get_home_dir()
path = getexistingdirectory(parent=self,
caption=_("Open project"),
basedir=basedir)
if not self.is_valid_project(path):
if path:
QMessageBox.critical(self, _('Error'),
_("<b>%s</b> is not a Spyder project!") % path)
return
else:
self.add_to_recent(path)
# A project was not open before
if self.current_active_project is None:
if save_previous_files:
self.editor.save_open_files()
self.editor.set_option('last_working_dir', getcwd())
self.show_explorer()
else: # we are switching projects
self.set_project_filenames(self.editor.get_open_filenames())
self.current_active_project = EmptyProject(path)
self.latest_project = EmptyProject(path)
self.set_option('current_project_path', self.get_active_project_path())
self.setup_menu_actions()
self.sig_project_loaded.emit(path)
self.pythonpath_changed.emit()
if restart_consoles:
self.restart_consoles()
示例2: 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)
示例3: select_file
def select_file(self):
self.redirect_stdio.emit(False)
filename = getexistingdirectory(
self, _("Select directory"), getcwd())
self.redirect_stdio.emit(False)
if filename:
self.analyze(filename)
示例4: select_file
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)
示例5: 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)
示例6: 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()
error_message = self.shellwidget.save_namespace(self.filename)
self.shellwidget._kernel_reply = None
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)
示例7: open_interpreter
def open_interpreter(self, wdir=None):
"""Open interpreter"""
if not wdir:
wdir = getcwd()
self.visibility_changed(True)
self.start(fname=None, wdir=to_text_string(wdir), args='',
interact=True, debug=False, python=True)
示例8: 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)
示例9: 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)
示例10: 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)
示例11: 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)
示例12: run_script
def run_script(self):
"""Run a Python script"""
self.redirect_stdio.emit(False)
filename, _selfilter = getopenfilename(self, _("Run Python script"),
getcwd(), _("Python scripts")+" (*.py ; *.pyw ; *.ipy)")
self.redirect_stdio.emit(True)
if filename:
self.start(fname=filename, wdir=None, args='',
interact=False, debug=False)
示例13: select_directory
def select_directory(self):
"""Display dialog for user to select working directory."""
basedir = to_text_string(self.wdir_lineedit.text())
if not osp.isdir(basedir):
basedir = getcwd()
title = _("Select directory")
directory = getexistingdirectory(self, title, basedir)
if directory:
self.wdir_lineedit.setText(directory)
示例14: getcwd_or_home
def getcwd_or_home():
"""Safe version of getcwd that will fallback to home user dir.
This will catch the error raised when the current working directory
was removed for an external program.
"""
try:
return getcwd()
except OSError:
logger.debug("WARNING: Current working directory was deleted, "
"falling back to home dirertory")
return get_home_dir()
示例15: 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)