예제 #1
0
 def validate(self, value):
     """ Make sure that the file can be written """
     value = StringOption.validate(self, value)
     value = StringOption.validate(self, value)
     name = self.name
     # Check for special code for STDOUT
     if value == '-':
         pass
     elif os.path.isdir(value):
         raise InvalidOptionError(name, value,
                                  "Argument is a directory, not a file")
     elif os.path.isfile(value):
         if not os.access(value, os.W_OK):
             raise InvalidOptionError(
                 name, value,
                 "File is not writable, please check the permissions")
     elif not os.path.dirname(value):
         pass
     elif not os.path.isdir(os.path.dirname(value)):
         try:
             os.makedirs(os.path.dirname(value), 0755)
         except OSError:
             raise InvalidOptionError(
                 name, value, "Could not create output directory for file")
     return value
예제 #2
0
 def validate(self, value):
    """ Make sure that the directory exists and is readable """
    value = StringOption.validate(self, value)
    name = self.name
    if self.actual: name = self.actual
    if not os.path.isdir(value):
       raise InvalidOptionError(name, value,
                                "Directory does not exist")
    elif not os.access(value, os.R_OK):
       raise InvalidOptionError(name, value,
             "Directory is not readable, please check permissions")
    return value
예제 #3
0
 def validate(self, value):
     """ Make sure that the directory exists and is readable """
     value = StringOption.validate(self, value)
     name = self.name
     if self.actual: name = self.actual
     if not os.path.isdir(value):
         raise InvalidOptionError(name, value, "Directory does not exist")
     elif not os.access(value, os.R_OK):
         raise InvalidOptionError(
             name, value,
             "Directory is not readable, please check permissions")
     return value
예제 #4
0
 def validate(self, value):
     """ Make sure that the file exists and is readable """
     value = StringOption.validate(self, value)
     name = self.name
     if self.actual: name = self.actual
     # Check for special code for STDIN
     if value == '-':
         pass
     elif not os.path.isfile(value):
         raise InvalidOptionError(name, value, "File does not exist")
     elif not os.access(value, os.R_OK):
         raise InvalidOptionError(
             name, value, "File is not readable, please check permissions")
     return value
예제 #5
0
 def validate(self, value):
    """ Make sure that the file exists and is readable """
    value = StringOption.validate(self, value)
    name = self.name
    if self.actual: name = self.actual
    # Check for special code for STDIN
    if value == '-':
       pass
    elif not os.path.isfile(value):
       raise InvalidOptionError(name, value, "File does not exist")
    elif not os.access(value, os.R_OK):
       raise InvalidOptionError(name, value,
             "File is not readable, please check permissions")
    return value
예제 #6
0
 def validate(self, value):
    """ Make sure that the file can be written """
    value = StringOption.validate(self, value)
    value = StringOption.validate(self, value)
    name = self.name
    # Check for special code for STDOUT
    if value == '-':
       pass
    elif os.path.isdir(value):
       raise InvalidOptionError(name, value,
                                "Argument is a directory, not a file")
    elif os.path.isfile(value):
       if not os.access(value, os.W_OK):
          raise InvalidOptionError(name, value,
                "File is not writable, please check the permissions")
    elif not os.path.dirname(value):
       pass
    elif not os.path.isdir(os.path.dirname(value)):
       try: os.makedirs(os.path.dirname(value), 0755)
       except OSError:
          raise InvalidOptionError(name, value,
                "Could not create output directory for file")
    return value
예제 #7
0
 def validate(self, value):
    """ Make sure that the directory can be written """
    value = StringOption.validate(self, value)
    name = self.name
    if self.actual: name = self.actual
    if os.path.isfile(value):
       raise InvalidOptionError(name, value,
                                "Argument is a file, not a directory")
    elif os.path.isdir(value):
       if not os.access(value, os.W_OK):
          raise InvalidOptionError(name, value,
                "Directory is not writable, please check the permissions")
    elif not os.path.isdir(value):
       try: os.makedirs(value, 0755)
       except OSError:
          raise InvalidOptionError(name, value,
                "Could not create output directory")
    return value
예제 #8
0
 def validate(self, value):
     """ Make sure that the directory can be written """
     value = StringOption.validate(self, value)
     name = self.name
     if self.actual: name = self.actual
     if os.path.isfile(value):
         raise InvalidOptionError(name, value,
                                  "Argument is a file, not a directory")
     elif os.path.isdir(value):
         if not os.access(value, os.W_OK):
             raise InvalidOptionError(
                 name, value,
                 "Directory is not writable, please check the permissions")
     elif not os.path.isdir(value):
         try:
             os.makedirs(value, 0755)
         except OSError:
             raise InvalidOptionError(name, value,
                                      "Could not create output directory")
     return value