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

Python ostools.file_exists函数代码示例

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

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



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

示例1: _needs_recompile

    def _needs_recompile(self, dependency_graph, source_file):
        """
        Returns True if the source_file needs to be recompiled
        given the dependency_graph, the file contents and the last modification time
        """
        content_hash = source_file.content_hash
        content_hash_file_name = self._hash_file_name_of(source_file)
        if not ostools.file_exists(content_hash_file_name):
            LOGGER.debug("%s has no vunit_hash file at %s and must be recompiled",
                         source_file.name, content_hash_file_name)
            return True

        old_content_hash = ostools.read_file(content_hash_file_name)
        if old_content_hash != content_hash:
            LOGGER.debug("%s has different hash than last time and must be recompiled",
                         source_file.name)
            return True

        for other_file in dependency_graph.get_direct_dependencies(source_file):
            other_content_hash_file_name = self._hash_file_name_of(other_file)

            if not ostools.file_exists(other_content_hash_file_name):
                continue

            if more_recent(other_content_hash_file_name, content_hash_file_name):
                LOGGER.debug("%s has dependency compiled earlier and must be recompiled",
                             source_file.name)
                return True

        LOGGER.debug("%s has same hash file and must not be recompiled",
                     source_file.name)

        return False
开发者ID:KevinKes,项目名称:vunit,代码行数:33,代码来源:project.py


示例2: create_library

    def create_library(self, library_name, path):

        if not file_exists(dirname(path)):
            os.makedirs(dirname(path))

        if not file_exists(path):
            proc = Process(['vlib', '-unix', path])
            proc.consume_output(callback=None)

        try:
            proc = Process(['vmap', '-modelsimini', self._modelsim_ini, library_name])
            proc.consume_output(callback=None)
        except Process.NonZeroExitCode:
            pass

        match = self._vmap_pattern.search(proc.output)
        if match:
            do_vmap = not file_exists(match.group('dir'))
        else:
            do_vmap = False

        if 'No mapping for library' in proc.output:
            do_vmap = True

        if do_vmap:
            proc = Process(['vmap','-modelsimini', self._modelsim_ini, library_name, path])
            proc.consume_output(callback=None)
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:27,代码来源:modelsim_interface.py


示例3: _create_modelsim_ini

    def _create_modelsim_ini(self):
        """
        Create the modelsim.ini file if it does not exist
        """
        if file_exists(self._modelsim_ini):
            return

        parent = dirname(self._modelsim_ini)
        if not file_exists(parent):
            os.makedirs(parent)

        with open(join(self._prefix, "..", "modelsim.ini"), 'rb') as fread:
            with open(self._modelsim_ini, 'wb') as fwrite:
                fwrite.write(fread.read())
开发者ID:suoto,项目名称:vunit,代码行数:14,代码来源:modelsim_interface.py


示例4: _preprocess

    def _preprocess(self, library_name, file_name, preprocessors):
        """
        Preprocess file_name within library_name using explicit preprocessors
        if preprocessors is None then use implicit globally defined processors
        """
        # @TODO dependency checking etc...

        if preprocessors is None:
            preprocessors = [self._location_preprocessor, self._check_preprocessor]
            preprocessors = [p for p in preprocessors if p is not None]
            preprocessors = self._external_preprocessors + preprocessors

        if len(preprocessors) == 0:
            return file_name

        code = ostools.read_file(file_name)
        for preprocessor in preprocessors:
            code = preprocessor.run(code, basename(file_name))

        pp_file_name = join(self._preprocessed_path, library_name, basename(file_name))

        idx = 1
        while ostools.file_exists(pp_file_name):
            LOGGER.debug("Preprocessed file exists '%s', adding prefix", pp_file_name)
            pp_file_name = join(self._preprocessed_path,
                                library_name, "%i_%s" % (idx, basename(file_name)))
            idx += 1

        ostools.write_file(pp_file_name, code)
        return pp_file_name
开发者ID:varunnagpaal,项目名称:vunit,代码行数:30,代码来源:ui.py


示例5: _create_modelsim_ini

 def _create_modelsim_ini(self):
     """
     Create the modelsim.ini file if it does not exist
     """
     if file_exists(self._modelsim_ini):
         return
     write_file(self._modelsim_ini, read_file(join(self._prefix, "..", "modelsim.ini")))
开发者ID:varunnagpaal,项目名称:vunit,代码行数:7,代码来源:modelsim_interface.py


示例6: add_source_file

    def add_source_file(self,    # pylint: disable=too-many-arguments
                        file_name, library_name, file_type='vhdl', include_dirs=None, defines=None,
                        vhdl_standard='2008',
                        no_parse=False):
        """
        Add a file_name as a source file in library_name with file_type

        :param no_parse: Do not parse file contents
        """
        if not ostools.file_exists(file_name):
            raise ValueError("File %r does not exist" % file_name)

        LOGGER.debug('Adding source file %s to library %s', file_name, library_name)
        self._validate_library_name(library_name)
        library = self._libraries[library_name]

        if file_type == "vhdl":
            assert include_dirs is None
            source_file = VHDLSourceFile(file_name, library,
                                         vhdl_parser=self._vhdl_parser,
                                         vhdl_standard=vhdl_standard,
                                         no_parse=no_parse)
            library.add_vhdl_design_units(source_file.design_units)
        elif file_type == "verilog":
            source_file = VerilogSourceFile(file_name, library, self._verilog_parser, include_dirs, defines, no_parse)
            library.add_verilog_design_units(source_file.design_units)
        else:
            raise ValueError(file_type)

        library.add_source_file(source_file)
        self._source_files_in_order.append(source_file)
        return source_file
开发者ID:KevinKes,项目名称:vunit,代码行数:32,代码来源:project.py


示例7: _determine_partial_pass

    def _determine_partial_pass(self, output_path):
        """
        In case of simulation failure determine which of the individual test cases failed.
        This is done by reading the test_runner_trace.csv file and checking for test case entry points.
        """
        log_file = join(output_path, "test_runner_trace.csv")

        retval = {}
        for name in self.test_cases:
            retval[name] = FAILED

        if not ostools.file_exists(log_file):
            return retval

        test_log = ostools.read_file(log_file)
        test_starts = []
        for test_name in self._test_cases:
            if "Test Runner,Test case: " + test_name in test_log:
                test_starts.append(test_name)

        for test_name in test_starts[:-1]:
            retval[self._full_name(test_name)] = PASSED

        for test_name in self._test_cases:
            if test_name not in test_starts:
                retval[self._full_name(test_name)] = SKIPPED
        return retval
开发者ID:varunnagpaal,项目名称:vunit,代码行数:27,代码来源:test_suites.py


示例8: _preprocess

    def _preprocess(self, library_name, file_name, preprocessors):
        # @TODO dependency checking etc...

        if preprocessors is None:
            preprocessors = [self._location_preprocessor, self._check_preprocessor]
            preprocessors = [p for p in preprocessors if not p is None]
            preprocessors = self._external_preprocessors + preprocessors

        if len(preprocessors) == 0:
            return file_name

        code = ostools.read_file(file_name)
        for p in preprocessors:
            code = p.run(code, basename(file_name))

        pp_file_name = join(self._preprocessed_path, library_name, basename(file_name))

        idx = 1
        while ostools.file_exists(pp_file_name):
            logger.debug("Preprocessed file exists '%s', adding prefix" % pp_file_name)
            pp_file_name = join(self._preprocessed_path,
                                library_name, "%i_%s" % (idx, basename(file_name)))
            idx += 1

        ostools.write_file(pp_file_name, code)
        return pp_file_name
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:26,代码来源:ui.py


示例9: create_library

    def create_library(self, library_name, library_path, mapped_libraries=None):
        """
        Create and map a library_name to library_path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(abspath(library_path)):
            os.makedirs(abspath(library_path))
        if not file_exists(abspath(library_path+"/64/")):
            os.makedirs(abspath(library_path+"/64/"))

        if library_name in mapped_libraries and mapped_libraries[library_name] == library_path:
            return

        vcs = SetupFile.parse(self._vcssetup)
        vcs[library_name] = library_path
        vcs.write(self._vcssetup)
开发者ID:cmarqu,项目名称:vunit,代码行数:17,代码来源:vcs_interface.py


示例10: create_library

    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), library_name, path], cwd=dirname(self._library_cfg))
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        proc = Process([join(self._prefix, 'vmap'), library_name, path], cwd=dirname(self._library_cfg))
        proc.consume_output(callback=None)
开发者ID:mark-newsam,项目名称:vunit,代码行数:18,代码来源:activehdl_interface.py


示例11: _create_library_cfg

    def _create_library_cfg(self):
        """
        Create the library.cfg file if it does not exist
        """
        if file_exists(self._library_cfg):
            return

        with open(self._library_cfg, "w") as ofile:
            ofile.write('$INCLUDE = "%s"\n' % join(self._prefix, "..", "vlib", "library.cfg"))
开发者ID:mark-newsam,项目名称:vunit,代码行数:9,代码来源:activehdl_interface.py


示例12: create_library

    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(path)):
            os.makedirs(dirname(path))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path])
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        proc = Process([join(self._prefix, 'vmap'), '-modelsimini', self._modelsim_ini, library_name, path])
        proc.consume_output(callback=None)
开发者ID:enzochiau,项目名称:vunit,代码行数:18,代码来源:modelsim_interface.py


示例13: create_library

    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path],
                           env=self.get_env())
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        cfg = parse_modelsimini(self._sim_cfg_file_name)
        cfg.set("Library", library_name, path)
        write_modelsimini(cfg, self._sim_cfg_file_name)
开发者ID:barri,项目名称:vunit,代码行数:20,代码来源:modelsim_interface.py


示例14: create_library

    def create_library(self, library_name, path, mapped_libraries=None):
        """
        Create and map a library_name to path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(path))):
            os.makedirs(dirname(abspath(path)))

        if not file_exists(path):
            proc = Process([join(self._prefix, 'vlib'), '-unix', path])
            proc.consume_output(callback=None)

        if library_name in mapped_libraries and mapped_libraries[library_name] == path:
            return

        cfg = RawConfigParser()
        cfg.read(self._modelsim_ini)
        cfg.set("Library", library_name, path)
        with open(self._modelsim_ini, "w") as optr:
            cfg.write(optr)
开发者ID:suoto,项目名称:vunit,代码行数:21,代码来源:modelsim_interface.py


示例15: _create_modelsim_ini

    def _create_modelsim_ini(self):
        """
        Create the modelsim.ini file
        """
        parent = dirname(self._sim_cfg_file_name)
        if not file_exists(parent):
            os.makedirs(parent)

        original_modelsim_ini = os.environ.get("VUNIT_MODELSIM_INI",
                                               join(self._prefix, "..", "modelsim.ini"))
        with open(original_modelsim_ini, 'rb') as fread:
            with open(self._sim_cfg_file_name, 'wb') as fwrite:
                fwrite.write(fread.read())
开发者ID:barri,项目名称:vunit,代码行数:13,代码来源:modelsim_interface.py


示例16: create_library

    def create_library(self, library_name, library_path, mapped_libraries=None):
        """
        Create and map a library_name to library_path
        """
        mapped_libraries = mapped_libraries if mapped_libraries is not None else {}

        if not file_exists(dirname(abspath(library_path))):
            os.makedirs(dirname(abspath(library_path)))

        if library_name in mapped_libraries and mapped_libraries[library_name] == library_path:
            return

        cds = CDSFile.parse(self._cdslib)
        cds[library_name] = library_path
        cds.write(self._cdslib)
开发者ID:barri,项目名称:vunit,代码行数:15,代码来源:incisive_interface.py


示例17: _create_modelsim_ini

 def _create_modelsim_ini(self):
     """
     Create the modelsim.ini file if it does not exist
     """
     if file_exists(self._modelsim_ini):
         return
     cwd = join(dirname(self._modelsim_ini))
     try:
         env = os.environ.copy()
         del env["MODELSIM"]
         output = subprocess.check_output([join(self._prefix, 'vmap'), '-c'],
                                          cwd=cwd, stderr=subprocess.PIPE, env=env)
     except subprocess.CalledProcessError as exc:
         LOGGER.error("Failed to create %s by running 'vmap -c' in %s exit code was %i",
                      self._modelsim_ini, cwd, exc.returncode)
         print("== Output of 'vmap -c' " + ("=" * 60))
         print(exc.output)
         print("=======================" + ("=" * 60))
         raise
开发者ID:enzochiau,项目名称:vunit,代码行数:19,代码来源:modelsim_interface.py


示例18: run

    def run(self, output_path):
        """
        Run the test case using the output_path
        """
        generics = {}

        if not call_pre_config(self._pre_config, output_path):
            return False

        if self._has_runner_cfg:
            runner_cfg = {
                "enabled_test_cases": encode_test_case(self._test_case),
                "output path": output_path.replace("\\", "/") + "/",
                "active python runner": True,
            }

            generics["runner_cfg"] = encode_dict(runner_cfg)

        sim_ok = self._test_bench.run(output_path, generics, elaborate_only=self._elaborate_only)

        if self._elaborate_only:
            return sim_ok

        vunit_results_file = join(output_path, "vunit_results")
        if not ostools.file_exists(vunit_results_file):
            return False
        test_results = ostools.read_file(vunit_results_file)

        expected_results = ""
        if self._test_case is not None:
            expected_results += "test_start:%s\n" % self._test_case
        expected_results += "test_suite_done\n"

        if not test_results == expected_results:
            return False

        if self._post_check is None:
            return True

        return self._post_check(output_path)
开发者ID:KevinKes,项目名称:vunit,代码行数:40,代码来源:test_suites.py


示例19: _read_test_results

    def _read_test_results(self, output_path):
        """
        Read test results from vunit_results file
        """
        vunit_results_file = join(output_path, "vunit_results")

        retval = {}
        for name in self.test_cases:
            retval[name] = FAILED

        if not ostools.file_exists(vunit_results_file):
            return retval

        test_results = ostools.read_file(vunit_results_file)
        test_starts = []
        test_suite_done = False

        for line in test_results.splitlines():

            if line.startswith("test_start:"):
                test_name = line[len("test_start:"):]
                test_starts.append(self._full_name(test_name))

            elif line.startswith("test_suite_done"):
                test_suite_done = True

        for idx, test_name in enumerate(test_starts):
            last_start = idx == len(test_starts) - 1

            if test_suite_done or not last_start:
                retval[test_name] = PASSED

        for test_name in self.test_cases:
            if test_name not in test_starts:
                retval[test_name] = SKIPPED

        return retval
开发者ID:KevinKes,项目名称:vunit,代码行数:37,代码来源:test_suites.py


示例20: post_process

    def post_process(self, output_path):
        """
        Merge coverage from all test cases,
        top hierarchy level is removed since it has different name in each test case
        """
        if self._coverage is None:
            return

        # Teardown to ensure ucdb file was written.
        self.teardown()

        merged_coverage_file = join(output_path, "merged_coverage.ucdb")
        vcover_cmd = [join(self._prefix, 'vcover'), 'merge', '-strip', '1', merged_coverage_file]

        for coverage_file in self._coverage_files:
            if file_exists(coverage_file):
                vcover_cmd.append(coverage_file)
            else:
                LOGGER.warning("Missing coverage ucdb file: %s", coverage_file)

        print("Merging coverage files into %s..." % merged_coverage_file)
        vcover_merge_process = Process(vcover_cmd)
        vcover_merge_process.consume_output()
        print("Done merging coverage files")
开发者ID:suoto,项目名称:vunit,代码行数:24,代码来源:modelsim_interface.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ostools.read_file函数代码示例发布时间:2022-05-26
下一篇:
Python incisive_interface.IncisiveInterface类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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