def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: """ :throws Exception: """ return list_special_comments(path)
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, Any]: attributes: Dict[str, Any] = special_comments.list_special_comments( path.resolve()) or _get_csx_pragmas(path.resolve()) attributes.setdefault('links', []) attributes['links'].extend(special_comments.list_embedded_urls(path)) return attributes
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, Any]: """ :throws Exception: """ attributes: Dict[str, Any] = special_comments.list_special_comments(path) attributes.setdefault('links', []) attributes['links'].extend(special_comments.list_embedded_urls(path)) return attributes
def is_verification_file(self, path: pathlib.Path, *, basedir: pathlib.Path) -> bool: path = basedir / path metadata = _cargo_metadata(cwd=path.parent) package_and_target = _find_target(metadata, path) if not package_and_target: return False _, target = package_and_target return _is_bin_or_example_bin( target) and 'PROBLEM' in special_comments.list_special_comments( path)
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: if 'list_attributes' not in self.config: return list_special_comments(path) logger.warning( '"languages.*.list_attributes" field in .verify-helper/config.toml is now obsoleted' ) command = self.config['list_attributes'].format(path=str(path), basedir=str(basedir)) text = subprocess.check_output(shlex.split(command)) attributes = {} for line in text.splitlines(): key, _, value = line.decode().partition(' ') attributes[key] = value return attributes
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, Any]: attributes: Dict[str, Any] = {} attributes.update( special_comments.list_doxygen_annotations(path.resolve())) comments = special_comments.list_special_comments(path.resolve()) if comments: attributes.update(comments) elif super().is_verification_file(path, basedir=basedir): # use old-style if special comments not found # #define PROBLEM "https://..." の形式は複数 environments との相性がよくない。あと遅い attributes[_NOT_SPECIAL_COMMENTS] = '' all_ignored = True for env in self._list_environments(): joined_CXXFLAGS = ' '.join( map(shlex.quote, [*env.CXXFLAGS, '-I', str(basedir)])) macros = _cplusplus_list_defined_macros( path.resolve(), CXX=env.CXX, joined_CXXFLAGS=joined_CXXFLAGS) # convert macros to attributes if _IGNORE not in macros: for key in [_PROBLEM, _ERROR]: if all_ignored: # the first non-ignored environment if key in macros: attributes[key] = macros[key] else: assert attributes.get(key) == macros.get(key) all_ignored = False else: if env._is_gcc(): attributes[_IGNORE_IF_GCC] = '' elif env._is_clang(): attributes[_IGNORE_IF_CLANG] = '' else: attributes[_IGNORE] = '' if all_ignored: attributes[_IGNORE] = '' attributes.setdefault('links', []) attributes['links'].extend(special_comments.list_embedded_urls(path)) return attributes
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: special_comments = list_special_comments(path.resolve()) if special_comments: return special_comments else: # use old-style if special comments not found # #define PROBLEM "https://..." の形式は複数 environments との相性がよくない。あと遅い attributes: Dict[str, str] = { _NOT_SPECIAL_COMMENTS: '', } all_ignored = True for env in self._list_environments(): joined_CXXFLAGS = ' '.join( map(shlex.quote, [*env.CXXFLAGS, '-I', str(basedir)])) macros = _cplusplus_list_defined_macros( path.resolve(), CXX=env.CXX, joined_CXXFLAGS=joined_CXXFLAGS) # convert macros to attributes if _IGNORE not in macros: for key in [_PROBLEM, _ERROR]: if all_ignored: # the first non-ignored environment if key in macros: attributes[key] = macros[key] else: assert attributes.get(key) == macros.get(key) all_ignored = False else: if env._is_gcc(): attributes[_IGNORE_IF_GCC] = '' elif env._is_clang(): attributes[_IGNORE_IF_CLANG] = '' else: attributes[_IGNORE] = '' if all_ignored: attributes[_IGNORE] = '' return attributes
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: return list_special_comments( path.resolve()) or list_doxygen_annotations(path.resolve())
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: return list_special_comments(path.resolve()) or _get_csx_pragmas(path.resolve())
def list_attributes(self, path: pathlib.Path, *, basedir: pathlib.Path) -> Dict[str, str]: return list_special_comments(path)