pymensago/keycard.py
def save(self, path: str, clobber: bool) -> RetVal:
		'''Saves a keycard to a file'''
		if not path:
			return RetVal(ErrBadValue, 'path may not be empty')
		
		if os.path.exists(path) and not clobber:
			return RetVal(ErrExists)
			
		try:
			with open(path, 'wb') as f:
				for entry in self.entries:
					f.write(b'----- BEGIN ENTRY -----\r\n')
					f.write(entry.make_bytestring(-1))
					f.write(b'----- END ENTRY -----\r\n')
			
		except Exception as e:
			return RetVal.wrap_exception(e)

		return RetVal()
Saves a keycard to a file
Saves a keycard to a file
Saves a keycard to a file
def save(self, path: str, clobber: bool) -> RetVal:
		if not path:
			return RetVal(ErrBadValue, 'path may not be empty')
		if os.path.exists(path) and not clobber:
			return RetVal(ErrExists)
		try:
			with open(path, 'wb') as f:
				for entry in self.entries:
					f.write(b'----- BEGIN ENTRY -----\r\n')
					f.write(entry.make_bytestring(-1))
					f.write(b'----- END ENTRY -----\r\n')
		except Exception as e:
			return RetVal.wrap_exception(e)
		return RetVal()
def save ( self , path : str , clobber : bool ) -> RetVal : if not path : return RetVal ( ErrBadValue , 'path may not be empty' ) if os . path . exists ( path ) and not clobber : return RetVal ( ErrExists ) try : with open ( path , 'wb' ) as f : for entry in self . entries : f . write ( b'----- BEGIN ENTRY -----\r\n' ) f . write ( entry . make_bytestring ( - 1 ) ) f . write ( b'----- END ENTRY -----\r\n' ) except Exception as e : return RetVal . wrap_exception ( e ) return RetVal ( )
Saves a keycard to a file
Saves a keycard to a file
'''Saves a keycard to a file'''
self
path
str
clobber
bool