Ejemplo n.º 1
0
class StyleFileAction(argparse.Action):
    def __call__(self, parser, namespace, values, option_string=None):
        if not isinstance(values, str):
            sys.exit("*** %s is not a string" % values)
        self.path = Path(values)
        self.path.assert_exists()
        self.path.assert_is_file()
        self.path.assert_mode(os.R_OK)
        namespace.style_file = str(self.path)
Ejemplo n.º 2
0
 def __init__(self, file_path):
     p = Path(file_path)
     p.assert_exists()
     p.assert_is_file()
     p.assert_mode(os.R_OK)
     self.file_path = file_path
     self.raw_contents = read_file(file_path)
     self.parameters = self._parse_parameters()
     self.rejected_parameters = {}
Ejemplo n.º 3
0
 def __init__(self, repository_base):
     super().__init__()
     json_file = os.path.join(repository_base, REPO_INFO_FILENAME)
     path = Path(json_file)
     if not path.exists():
         # If there is no .json file in the repo, it might be an old version
         # checked out. We can still do best-effort with a default file
         # that is located in this repo.
         json_file = self._failback_file()
         path = Path(json_file)
         if not path.exists():
             sys.exit("Could not find a .json repository info file to use.")
     path.assert_is_file()
     path.assert_mode(os.R_OK)
     content = read_file(json_file)
     self.update(json.loads(content))
Ejemplo n.º 4
0
 def _find_binaries(self, search_directories):
     binaries = {}
     for directory in search_directories:
         for binary in CLANG_BINARIES:
             path = Path(os.path.join(directory, binary))
             if not path.exists():
                 continue
             path.assert_is_file()
             path.assert_mode(os.R_OK | os.X_OK)
             if path.filename() not in binaries:
                 binaries[path.filename()] = []
             version = str(ClangVersion(str(path)))
             binaries[path.filename()].append({
                 'path': str(path),
                 'version': version
             })
     return binaries