Ejemplo n.º 1
0
 def __call__(self, parser, namespace, value, option_string=None):
     current = getattr(namespace, self.dest)
     if not isinstance(current, list) and current is not None:
         raise argparse.ArgumentError(
             self, ' already provided: %s, have %s' % (value, current))
     if not path.isfile(value):
         raise argparse.ArgumentError(self,
                                      'is not a valid file: %s' % (value))
     if not path.isreadable(value):
         raise argparse.ArgumentError(self, 'is not readable: %s' % (value))
     if current is not None:
         value = current + [value]
     setattr(namespace, self.dest, value)
Ejemplo n.º 2
0
 def __call__(self, parser, namespace, values, option_string=None):
     if type(values) is not list:
         values = [values]
     for value in values:
         if not path.isdir(value):
             raise argparse.ArgumentError(
                 self, 'is not a valid directory: %s' % (value))
         if not path.isreadable(value):
             raise argparse.ArgumentError(self,
                                          'is not readable: %s' % (value))
         if not path.iswritable(value):
             raise argparse.ArgumentError(self,
                                          'is not writeable: %s' % (value))
         setattr(namespace, self.dest, value)
Ejemplo n.º 3
0
 def create_path(self, where, recreate=True, cleanup=True):
     if path.exists(where):
         log.output('remove: %s' % (where))
         path.removeall(where)
     try:
         log.output('make: %s' % (where))
         path.mkdir(where)
     except:
         raise error.general('cannot create build path: %s' % (where))
     if not path.isreadable(where):
         raise error.general('build path is not readable: %s' % (where))
     if not path.iswritable(where):
         raise error.general('build path is not writeable: %s' % (where))
     if cleanup:
         self.remove_paths += [where]
Ejemplo n.º 4
0
 def __call__(self, parser, namespace, value, option_string=None):
     current = getattr(namespace, self.dest)
     if current is None:
         current = []
     if isinstance(value, list):
         values = value
     else:
         values = [values]
     for value in values:
         if not path.isfile(value) and not path.isdir(value):
             err = 'is not a valid file or directory: %s' % (value)
             raise argparse.ArgumentError(self, err)
         if not path.isreadable(value):
             raise argparse.ArgumentError(self,
                                          'is not readable: %s' % (value))
         current += [value]
     setattr(namespace, self.dest, current)