Ejemplo n.º 1
0
 def __call__(self, parser, namespace, values, option_string=None):
     if not isinstance(values, str):
         sys.exit("*** %s is not a single string" % values)
     p = Path(values)
     p.assert_exists()
     p.assert_is_directory()
     p.assert_mode(os.R_OK | os.W_OK)
Ejemplo n.º 2
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.º 3
0
 def __init__(self, invocation_dir, output_file):
     path = Path(output_file)
     containing_directory = Path(path.containing_directory())
     if not os.path.exists(str(containing_directory)):
         os.makedirs(str(containing_directory))
     containing_directory.assert_exists()
     containing_directory.assert_mode(os.R_OK | os.W_OK)
     self.invocation_dir = invocation_dir
     self.output_file = str(path)
Ejemplo n.º 4
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.º 5
0
 def _parameter_directory(self, path_arg_str):
     p = Path(path_arg_str)
     p.assert_exists()
     # Tarball-download versions of clang put binaries in a bin/
     # subdirectory. For convenience, tolerate a parameter of either:
     # <unpacked_tarball>, <unpacked tarball>/bin or
     # <unpacked_tarball>/bin/<specific_binary>
     if p.is_file():
         return p.directory()
     bin_subdir = os.path.join(str(p), "bin/")
     if os.path.exists(bin_subdir):
         return bin_subdir
     return str(p)
Ejemplo n.º 6
0
 def __init__(self, directory):
     path = Path(directory)
     path.assert_exists()
     path.assert_is_directory()
     path.assert_mode(os.R_OK)
     self.directory = directory