• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python py3compat.getcwd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spyderlib.py3compat.getcwd函数的典型用法代码示例。如果您正苦于以下问题:Python getcwd函数的具体用法?Python getcwd怎么用?Python getcwd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getcwd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:31,代码来源:namespacebrowser.py


示例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)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:7,代码来源:profilergui.py


示例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)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:7,代码来源:profilergui.py


示例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)
开发者ID:jromang,项目名称:spyderlib,代码行数:60,代码来源:explorer.py


示例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)
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:7,代码来源:pylintgui.py


示例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)
开发者ID:G-VAR,项目名称:spyder,代码行数:7,代码来源:workingdirectory.py


示例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)
开发者ID:G-VAR,项目名称:spyder,代码行数:7,代码来源:workingdirectory.py


示例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)
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:7,代码来源:findinfiles.py


示例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)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:8,代码来源:profilergui.py


示例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)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:8,代码来源:workingdirectory.py


示例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)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:17,代码来源:runconfig.py


示例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)
开发者ID:gyenney,项目名称:Tools,代码行数:9,代码来源:configdialog.py


示例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)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:9,代码来源:runconfig.py


示例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)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:18,代码来源:runconfig.py


示例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
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:10,代码来源:workingdirectory.py


示例16: refresh

 def refresh(self, new_path=None, force_current=False):
     """Refresh widget
     force=False: won't refresh widget if path has not changed"""
     if new_path is None:
         new_path = getcwd()
     if force_current:
         index = self.set_current_folder(new_path)
         self.expand(index)
         self.setCurrentIndex(index)
     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)
开发者ID:sonofeft,项目名称:spyder,代码行数:11,代码来源:explorer.py


示例17: select_file

 def select_file(self, edit, filters=None):
     """Select File"""
     basedir = osp.dirname(to_text_string(edit.text()))
     if not osp.isdir(basedir):
         basedir = getcwd()
     if filters is None:
         filters = _("All files (*)")
     title = _("Select file")
     filename, _selfilter = getopenfilename(self, title, basedir, filters)
     if filename:
         edit.setText(filename)
开发者ID:gyenney,项目名称:Tools,代码行数:11,代码来源:configdialog.py


示例18: get_pythonxy_plugindir

def get_pythonxy_plugindir(name):
    """Searching Python(x,y) plugin directory in current working directory"""
    for fname in os.listdir(getcwd()):
        path = osp.abspath(osp.join(fname, 'src', 'python', name))
        if osp.isdir(path):
            # Also create the binary directory if it does not exist yet:
            def create_dir(path):
                if not osp.isdir(path):
                    os.mkdir(path)
            create_dir(osp.join(fname, 'bin'))
            create_dir(osp.join(fname, 'bin', 'python'))
            return path
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:12,代码来源:clonebuild.py


示例19: __init__

    def __init__(self, parent=None, name_filters=['*.py', '*.pyw'],
                 show_all=False, show_cd_only=None, show_icontext=True):
        QWidget.__init__(self, parent)
        
        self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only)
        self.treewidget.setup(name_filters=name_filters, show_all=show_all)
        self.treewidget.chdir(getcwd())
        
        icontext_action = create_action(self, _("Show icons and text"),
                                        toggled=self.toggle_icontext)
        self.treewidget.common_actions += [None, icontext_action]
        
        # Setup toolbar
        self.toolbar = QToolBar(self)
        self.toolbar.setIconSize(QSize(16, 16))
        
        self.previous_action = create_action(self, text=_("Previous"),
                            icon=ima.icon('ArrowBack'),
                            triggered=self.treewidget.go_to_previous_directory)
        self.toolbar.addAction(self.previous_action)
        self.previous_action.setEnabled(False)
        self.treewidget.set_previous_enabled.connect(
                                               self.previous_action.setEnabled)
        
        self.next_action = create_action(self, text=_("Next"),
                            icon=ima.icon('ArrowForward'),
                            triggered=self.treewidget.go_to_next_directory)
        self.toolbar.addAction(self.next_action)
        self.next_action.setEnabled(False)
        self.treewidget.set_next_enabled.connect(self.next_action.setEnabled)
        
        parent_action = create_action(self, text=_("Parent"),
                            icon=ima.icon('ArrowUp'),
                            triggered=self.treewidget.go_to_parent_directory)
        self.toolbar.addAction(parent_action)
        self.toolbar.addSeparator()

        options_action = create_action(self, text='', tip=_('Options'),
                                       icon=ima.icon('tooloptions'))
        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)
            
        icontext_action.setChecked(show_icontext)
        self.toggle_icontext(show_icontext)     
        
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.toolbar)
        vlayout.addWidget(self.treewidget)
        self.setLayout(vlayout)
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:53,代码来源:explorer.py


示例20: save_dictionary

def save_dictionary(data, filename):
    """Save dictionary in a single file .spydata file"""
    filename = osp.abspath(filename)
    old_cwd = getcwd()
    os.chdir(osp.dirname(filename))
    error_message = None
    try:
        saved_arrays = {}
        if load_array is not None:
            # Saving numpy arrays with np.save
            arr_fname = osp.splitext(filename)[0]
            for name in list(data.keys()):
                if isinstance(data[name], np.ndarray) and data[name].size > 0:
                    # Saving arrays at data root
                    fname = __save_array(data[name], arr_fname,
                                       len(saved_arrays))
                    saved_arrays[(name, None)] = osp.basename(fname)
                    data.pop(name)
                elif isinstance(data[name], (list, dict)):
                    # Saving arrays nested in lists or dictionaries
                    if isinstance(data[name], list):
                        iterator = enumerate(data[name])
                    else:
                        iterator = iter(list(data[name].items()))
                    to_remove = []
                    for index, value in iterator:
                        if isinstance(value, np.ndarray) and value.size > 0:
                            fname = __save_array(value, arr_fname,
                                               len(saved_arrays))
                            saved_arrays[(name, index)] = osp.basename(fname)
                            to_remove.append(index)
                    for index in sorted(to_remove, reverse=True):
                        data[name].pop(index)
            if saved_arrays:
                data['__saved_arrays__'] = saved_arrays
        pickle_filename = osp.splitext(filename)[0]+'.pickle'
        with open(pickle_filename, 'wb') as fdesc:
            pickle.dump(data, fdesc, 2)
        tar = tarfile.open(filename, "w")
        for fname in [pickle_filename]+[fn for fn in list(saved_arrays.values())]:
            tar.add(osp.basename(fname))
            os.remove(fname)
        tar.close()
        if saved_arrays:
            data.pop('__saved_arrays__')
    except (RuntimeError, pickle.PicklingError, TypeError) as error:
        error_message = to_text_string(error)
    os.chdir(old_cwd)
    return error_message
开发者ID:JamesLinus,项目名称:spyder,代码行数:49,代码来源:iofuncs.py



注:本文中的spyderlib.py3compat.getcwd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python py3compat.is_text_string函数代码示例发布时间:2022-05-27
下一篇:
Python plugins.SpyderPluginWidget类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap