def parse(self, value, check_files=True): """ File argument. :param value: The file path. :type value: str :keyword check_files: If it should verify the file path. :type check_files: bool :return: Argument ready string. :rtype: str """ if not path.isfile(encoding.native_type(value)): raise ArgumentParseError("File path \"{path}\" not valid.".format(path=value)) value = super(FilePath, self).parse(value) return value
def parse(self, value, check_files=True): """ File argument. :param value: The file path. :type value: str :keyword check_files: If it should verify the file path. :type check_files: bool :return: Argument ready string. :rtype: str """ if not path.isfile(encoding.native_type(value)): raise ArgumentParseError( "File path \"{path}\" not valid.".format(path=value)) value = super(FilePath, self).parse(value) return value
def downloaded_file(json, check_files=True): """ Checks that the download was successful. :param json: The json from the cli. :type json: DictObject :keyword check_files: If it should verify the file path. :type check_files: bool :return: The file path. :rtype: str """ if "event" not in json or not json.event: raise IllegalResponseException("Has no valid event attribute.") if json.event != u("download"): raise IllegalResponseException("Download event should be 'download'.") if "result" not in json or not json.result: raise IllegalResponseException("Has no valid result attribute.") if check_files and not path.isfile(encoding.native_type(json.result)): raise IllegalResponseException("File path \"{path}\" not valid.".format(path=json.result)) else: return json.result
def downloaded_file(json, check_files=True): """ Checks that the download was successful. :param json: The json from the cli. :type json: DictObject :keyword check_files: If it should verify the file path. :type check_files: bool :return: The file path. :rtype: str """ if "event" not in json or not json.event: raise IllegalResponseException("Has no valid event attribute.") if json.event != u("download"): raise IllegalResponseException("Download event should be 'download'.") if "result" not in json or not json.result: raise IllegalResponseException("Has no valid result attribute.") if check_files and not path.isfile(encoding.native_type(json.result)): raise IllegalResponseException( "File path \"{path}\" not valid.".format(path=json.result)) else: return json.result
def parse(self, value): if not path.isfile(encoding.native_type(value)): raise ArgumentParseError("File path \"{path}\" not valid.".format(path=value)) value = super(File, self).parse(value) return value
def parse(self, value): if not path.isfile(encoding.native_type(value)): raise ArgumentParseError( "File path \"{path}\" not valid.".format(path=value)) value = super(FilePath, self).parse(value) return value