当前位置: 首页>>代码示例>>Python>>正文


Python filetools.add_extension函数代码示例

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


在下文中一共展示了add_extension函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_file_path

def get_file_path(root, action='open'):
    dlg = FileDialog(action=action,
                     wildcard=FileDialog.create_wildcard('YAML', '*.yaml *.yml'),
                     default_directory=root)
    if dlg.open():
        if dlg.path:
            return add_extension(dlg.path, ext=('.yaml', '.yml'))
开发者ID:NMGRL,项目名称:pychron,代码行数:7,代码来源:conditionals_edit_view.py

示例2: dump

    def dump(self):
        p = os.path.join(paths.hidden_dir, add_extension('config', '.p'))
        with open(p, 'wb') as wfile:
            obj = {'name': self.active_name}
            pickle.dump(obj, wfile)

        self.dump_item(self.active_item)
开发者ID:NMGRL,项目名称:pychron,代码行数:7,代码来源:peak_center_config.py

示例3: _save_

    def _save_(self, type_='pic', path=None):
        """
        """
        if path is None:
            dlg = FileDialog(action='save as', default_directory=os.path.expanduser('~'))
            if dlg.open() == OK:
                path = dlg.path
                self.status_text = 'Image Saved: %s' % path

        if path is not None:
            if type_ == 'pdf' or path.endswith('.pdf'):
                self._render_to_pdf(filename=path)
            else:
                # auto add an extension to the filename if not present
                # extension is necessary for PIL compression
                # set default save type_ DEFAULT_IMAGE_EXT='.png'

                # see http://infohost.nmt.edu/tcc/help/pubs/pil/formats.html
                saved = False
                for ei in IMAGE_EXTENSIONS:
                    if path.endswith(ei):
                        self._render_to_pic(path)
                        saved = True
                        break

                if not saved:
                    self._render_to_pic(add_extension(path, DEFAULT_IMAGE_EXT))
开发者ID:kenlchen,项目名称:pychron,代码行数:27,代码来源:graph.py

示例4: get_production

 def get_production(self, pname, **kw):
     root = os.path.join(paths.meta_dir, 'productions')
     if not os.path.isdir(root):
         os.mkdir(root)
     p = os.path.join(root, add_extension(pname))
     ip = Production(p)
     return ip
开发者ID:OSUPychron,项目名称:pychron,代码行数:7,代码来源:meta_repo.py

示例5: _gain_path

    def _gain_path(self, name):
        root = os.path.join(paths.meta_dir, 'spectrometers')
        if not os.path.isdir(root):
            os.mkdir(root)

        p = os.path.join(root, add_extension('{}.gain'.format(name), '.json'))
        return p
开发者ID:OSUPychron,项目名称:pychron,代码行数:7,代码来源:meta_repo.py

示例6: save_csv

def save_csv(record_id, items):
    path = os.path.join(paths.data_det_ic_dir, add_extension(record_id, '.csv'))
    with open(path, 'w') as wfile:
        wrt = csv.writer(wfile, delimiter='\t')
        wrt.writerow(['#det', 'intensity', 'err'] + DETECTOR_ORDER)
        for i in items:
            wrt.writerow(i.to_row())
开发者ID:OSUPychron,项目名称:pychron,代码行数:7,代码来源:detector_ic.py

示例7: dump_item

 def dump_item(self, item):
     name = item.name
     p = os.path.join(self.root, add_extension(name, '.p'))
     print('dump itme')
     with open(p, 'wb') as wfile:
         pickle.dump(item, wfile)
         print('sdfasdf')
开发者ID:NMGRL,项目名称:pychron,代码行数:7,代码来源:peak_center_config.py

示例8: make_gosub

    def make_gosub(self):
        selection = self.control.code.textCursor().selectedText()
        dlg = FileDialog(action='save as',
                         default_directory=os.path.dirname(self.path))

        p = None
        # root = os.path.dirname(self.path)
        # p = os.path.join(root, 'common', 'test_gosub.py')
        if dlg.open():
            p = dlg.path

        if p:
            p = add_extension(p, '.py')
            # p='/Users/ross/Desktop/foosub.py'
            with open(p, 'w') as wfile:
                wfile.write('# Extracted Gosub\n')
                wfile.write('# Source: from {}\n'.format(self.path))
                wfile.write('# Date: {}\n'.format(datetime.now().strftime('%m-%d-%Y %H:%M')))
                wfile.write('def main():\n')
                for li in selection.split(u'\u2029'):
                    wfile.write(u'    {}\n'.format(li.lstrip()))

            p = remove_extension(p)
            rp = os.path.relpath(p, self.path)
            rp = rp.replace('/', ':')
            self.control.code.replace_selection("gosub('{}')".format(rp[3:]))
开发者ID:NMGRL,项目名称:pychron,代码行数:26,代码来源:pyscript_editor.py

示例9: _execute_extraction

    def _execute_extraction(self, name, root, kind, new_thread=True,
                            delay_start=0,
                            on_completion=None,
                            context=None):
        from pychron.pyscripts.extraction_line_pyscript import ExtractionPyScript

        klass = ExtractionPyScript
        if kind == 'Laser':
            from pychron.pyscripts.laser_pyscript import LaserPyScript

            klass = LaserPyScript

        script = klass(application=self.application,
                       root=root,
                       name=add_extension(name, '.py'),
                       runner=self._runner)

        if script.bootstrap():
            if context:
                script.setup_context(**context)
            else:
                script.set_default_context()
            try:
                script.test()
            except Exception, e:
                return
            self._current_script = script
            script.setup_context(extract_device='fusions_diode')
            if self.use_trace:
                self.active_editor.trace_delay = self.trace_delay

            ret = script.execute(trace=self.use_trace, new_thread=new_thread, delay_start=delay_start,
                                 on_completion=on_completion)
            return not script.is_canceled() and ret
开发者ID:UManPychron,项目名称:pychron,代码行数:34,代码来源:pyscript_task.py

示例10: _get_save_path

    def _get_save_path(self, path, ext='.pdf'):
        if path is None:
            dlg = FileDialog(action='save as', default_directory=paths.processed_dir)
            if dlg.open():
                if dlg.path:
                    path = add_extension(dlg.path, ext)

        return path
开发者ID:OSUPychron,项目名称:pychron,代码行数:8,代码来源:base_table_editor.py

示例11: load_spectrometer_parameters

 def load_spectrometer_parameters(self, spec_sha):
     if spec_sha:
         name = add_extension(spec_sha, '.json')
         p = repository_path(self.repository_identifier, name)
         sd = get_spec_sha(p)
         self.source_parameters = sd['spectrometer']
         self.gains = sd['gains']
         self.deflections = sd['deflections']
开发者ID:NMGRL,项目名称:pychron,代码行数:8,代码来源:dvc_analysis.py

示例12: _prepare

 def _prepare(self, extraction_script):
     extraction_script = add_extension(extraction_script)
     task = self.pyscript_task
     root, name = os.path.split(extraction_script)
     ctx = {'analysis_type': 'blank' if 'blank' in name else 'unknown'}
     ret = task.execute_script(name, root, new_thread=False, context=ctx)
     self.info('Extraction script {} {}'.format(name, 'completed successfully' if ret else 'failed'))
     return ret
开发者ID:NMGRL,项目名称:pychron,代码行数:8,代码来源:auto_mftable.py

示例13: save_as

 def save_as(self):
     if self._validate_sequence():
         dialog = FileDialog(action='save as', default_directory=paths.hops_dir)
         if dialog.open() == OK:
             p = dialog.path
             p = add_extension(p, '.txt')
             self._save_file(p)
             self.path = p
开发者ID:UManPychron,项目名称:pychron,代码行数:8,代码来源:hops_editor.py

示例14: get

    def get(self, name):
        p = os.path.join(paths.peak_center_config_dir, add_extension(name, '.p'))
        if os.path.isfile(p):
            with open(p, 'rb') as rfile:
                obj = pickle.load(rfile)
        else:
            obj = self.item_klass()

        return obj
开发者ID:kenlchen,项目名称:pychron,代码行数:9,代码来源:peak_center_config.py

示例15: _get_gosub_text

 def _get_gosub_text(self, gosub):
     root = os.path.dirname(self.path)
     new = gosub.replace('/', ':')
     new = add_extension(new, '.py')
     paths = new.split(':')
     p = os.path.join(root, *paths)
     if os.path.isfile(p):
         with open(p, 'r') as rfile:
             return rfile.read()
开发者ID:NMGRL,项目名称:pychron,代码行数:9,代码来源:pyscript_editor.py


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