def write(self, f_output="", f_data=""): """ writes the numpy file. :param f_output: <str> custom file output name. :param f_data: <str> data to write. :return: <bool> True for success. <bool> False for failure. """ Serializer.write(self, f_output=f_output, f_data=f_data) try: numpy.save(self.OUTPUT_PATH, self.INTERPRETED_INPUT_DATA) self.print_file_size() return True except ValueError: return False
def write(self, f_output="", f_data=""): """ writes the json file. :param f_output: <str> custom file output name. :param f_data: <str> data to write. :return: <bool> True for success. <bool> False for failure. """ Serializer.write(self, f_output=f_output, f_data=f_data) with open(self.OUTPUT_PATH, 'w') as json_data: try: json.dump(self.INTERPRETED_INPUT_DATA, json_data, ensure_ascii=False, indent=4) self.print_file_size() return True except ValueError: return False
def write(self, f_output="", f_data=""): """ writes the json file. :param f_output: <str> custom file output name. :param f_data: <str> data to write. :return: <bool> True for success. <bool> False for failure. """ Serializer.write(self, f_output=f_output, f_data=f_data) with open(self.OUTPUT_PATH, 'wb') as pickle_data: try: pickle.dump(self.INTERPRETED_INPUT_DATA, pickle_data) pickle_data.close() self.print_file_size() return True except ValueError: return False
def write(self, f_output="", f_data=""): """ writes the json file. :param f_output: <str> custom file output name. :param f_data: <str> data to write. :return: <bool> True for success. <bool> False for failure. """ Serializer.write(self, f_output=f_output, f_data=f_data) success = self.serialize_data_repr(self.INTERPRETED_INPUT_DATA) if not success: raise ValueError("[Serialization Error] :: File not serialized") with open(self.OUTPUT_PATH, 'w') as uni_file: try: uni_file.writelines(self.READ_DATA) self.print_file_size() return True except ValueError: return False
def write(self, f_output="", f_data=""): """ writes the json file. :param f_output: <str> custom file output name. :param f_data: <str> data to write. :return: <bool> True for success. <bool> False for failure. """ Serializer.write(self, f_output=f_output, f_data=f_data) if DEBUG: print("[Serializer Type] :: {}".format(self.SERIALIZER_TYPE)) print("[Serializer Output] :: {}".format(self.OUTPUT_PATH)) print("[Serializer Html Output] :: {}".format( self.OUTPUT_HTML_PATH)) with open(self.OUTPUT_PATH, 'w') as yaml_data: yaml.dump(self.INTERPRETED_INPUT_DATA, yaml_data) yaml_data.close() self.print_file_size() return True