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


Python hashing.hash_string函数代码示例

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


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

示例1: __init__

 def __init__(self, name, library, verilog_parser, include_dirs=None, defines=None):
     SourceFile.__init__(self, name, library, 'verilog')
     self.package_dependencies = []
     self.module_dependencies = []
     self.include_dirs = include_dirs if include_dirs is not None else []
     self.defines = defines.copy() if defines is not None else {}
     code = ostools.read_file(self.name, encoding=HDL_FILE_ENCODING)
     self._content_hash = hash_string(code)
     for key, value in self.defines.items():
         self._content_hash = hash_string(self._content_hash + hash_string(key))
         self._content_hash = hash_string(self._content_hash + hash_string(value))
     self.parse(code, verilog_parser, include_dirs)
开发者ID:cmarqu,项目名称:vunit,代码行数:12,代码来源:project.py

示例2: _create_test_mapping_file

    def _create_test_mapping_file(self, test_suites):
        """
        Create a file mapping test name to test output folder.
        This is to allow the user to find the test output folder when it is hashed
        """
        mapping_file_name = join(self._output_path, "test_name_to_path_mapping.txt")

        # Load old mapping to remember non-deleted test folders as well
        # even when re-running only a single test case
        if exists(mapping_file_name):
            with open(mapping_file_name, "r") as fptr:
                mapping = set(fptr.read().splitlines())
        else:
            mapping = set()

        for test_suite in test_suites:
            name_hash = hash_string(test_suite.name)
            HASH_TO_TEST_NAME[name_hash] = test_suite.name
            mapping.add("%s %s" % (name_hash, test_suite.name))

        # Sort by everything except hash
        mapping = sorted(mapping, key=lambda value: value[value.index(" "):])

        with open(mapping_file_name, "w") as fptr:
            for value in mapping:
                fptr.write(value + "\n")
开发者ID:KevinKes,项目名称:vunit,代码行数:26,代码来源:test_runner.py

示例3: __init__

 def __init__(self, name, library, vhdl_parser):
     SourceFile.__init__(self, name, library, 'vhdl')
     self.dependencies = []
     self.depending_components = []
     code = ostools.read_file(self.name)
     self._content_hash = hash_string(code)
     self.parse(code, vhdl_parser)
开发者ID:enzochiau,项目名称:vunit,代码行数:7,代码来源:project.py

示例4: _hash_file_name_of

 def _hash_file_name_of(self, source_file):
     """
     Returns the name of the hash file associated with the source_file
     """
     library = self.get_library(source_file.library.name)
     prefix = hash_string(dirname(source_file.name))
     return join(library.directory, prefix, basename(source_file.name) + ".vunit_hash")
开发者ID:KevinKes,项目名称:vunit,代码行数:7,代码来源:project.py

示例5: _compile_options_hash

    def _compile_options_hash(self):
        """
        Compute hash of compile options

        Needs to be updated if there are nested dictionaries
        """
        return hash_string(repr(sorted(self._compile_options.items())))
开发者ID:KevinKes,项目名称:vunit,代码行数:7,代码来源:project.py

示例6: parse

    def parse(self, code, parser, include_dirs):
        """
        Parse Verilog code and adding dependencies and design units
        """
        try:
            design_file = parser.parse(code, self.name, include_dirs, self.defines)
            for included_file_name in design_file.included_files:
                self._content_hash = hash_string(self._content_hash +
                                                 ostools.read_file(included_file_name, encoding=HDL_FILE_ENCODING))
            for module in design_file.modules:
                self.design_units.append(ModuleDesignUnit(module.name, self, module.parameters))

            for package in design_file.packages:
                self.design_units.append(VerilogDesignUnit(package.name, self, "package"))

            for package_name in design_file.imports:
                self.package_dependencies.append(package_name)

            for package_name in design_file.package_references:
                self.package_dependencies.append(package_name)

            for instance_name in design_file.instances:
                self.module_dependencies.append(instance_name)

        except KeyboardInterrupt:
            raise
        except:  # pylint: disable=bare-except
            traceback.print_exc()
            LOGGER.error("Failed to parse %s", self.name)
开发者ID:KevinKes,项目名称:vunit,代码行数:29,代码来源:project.py

示例7: create_output_path

def create_output_path(output_file, test_suite_name):
    """
    Create the full output path of a test case.
    Ensure no bad characters and no long path names.
    """
    hash_name = hash_string(test_suite_name)
    return join(output_file, hash_name)
开发者ID:KevinKes,项目名称:vunit,代码行数:7,代码来源:test_runner.py

示例8: _content_hash

 def _content_hash(self, file_name):
     """
     Hash the contents of the file
     """
     if file_name is None or not exists(file_name):
         return None
     if file_name not in self._content_cache:
         self._content_cache[file_name] = "sha1:" + hash_string(read_file(file_name))
     return self._content_cache[file_name]
开发者ID:KevinKes,项目名称:vunit,代码行数:9,代码来源:parser.py

示例9: parse

    def parse(self, code, file_name, content_hash=None):
        """
        Parse the VHDL code and return a VHDLDesignFile parse result
        parse result is re-used if content hash found in database
        """
        file_name = abspath(file_name)

        if content_hash is None:
            content_hash = "sha1:" + hash_string(code)
        key = ("CachedVHDLParser.parse(%s)" % file_name).encode()

        if key in self._database:
            design_file, old_content_hash = self._database[key]
            if content_hash == old_content_hash:
                LOGGER.debug("Re-using cached VHDL parse results for %s with content_hash=%s",
                             file_name, content_hash)
                return design_file

        design_file = VHDLDesignFile.parse(code)
        self._database[key] = design_file, content_hash
        return design_file
开发者ID:chiggs,项目名称:vunit,代码行数:21,代码来源:vhdl_parser.py

示例10: content_hash

 def content_hash(self):
     """
     Compute hash of contents and compile options
     """
     return hash_string(self._content_hash + self._compile_options_hash() + hash_string(self._vhdl_standard))
开发者ID:KevinKes,项目名称:vunit,代码行数:5,代码来源:project.py


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