pymensago/userprofile.py
def rename_profile(self, oldname, newname) -> RetVal:
		'''Renames a profile, leaving the profile ID unchanged.

		Parameters:
		  * oldname: the current name of the profile
		  * newname: the new name of the profile
		
		Returns:
		  * no additional fields
		
		Notes:
			As with create_profile(), capital letters will be squashed, care should be
			used with special characters, and `default` is reserved.
		'''
		
		if not oldname or not newname:
			return RetVal(ErrEmptyData, "BUG: profile names may not be empty")
		
		old_squashed = oldname.casefold()
		new_squashed = newname.casefold()

		if old_squashed == new_squashed:
			return RetVal()
		
		index = self._index_for_profile(old_squashed)
		if index < 0:
			return RetVal(ErrNotFound, f"{oldname} doesn't exist")

		if self._index_for_profile(new_squashed) >= 0:
			return RetVal(ErrExists, f"{newname} already exists")

		if index == self.active_index:
			self.profiles[index].deactivate()

		oldpath = pathlib.Path(self.profiles[index].path)
		newpath = oldpath.parent.joinpath(new_squashed)
		try:
			os.rename(oldpath, newpath)
		except Exception as e:
			if index == self.active_index:
				self.profiles[index].activate()
			return RetVal.wrap_exception(e)

		self.profiles[index].name = new_squashed
		self.profiles[index].path = newpath
		
		if index == self.active_index:
			self.profiles[index].activate()
		
		return RetVal()
Renames a profile, leaving the profile ID unchanged.

		Parameters:
		  * oldname: the current name of the profile
		  * newname: the new name of the profile
		
		Returns:
		  * no additional fields
		
		Notes:
			As with create_profile(), capital letters will be squashed, care should be
			used with special characters, and `default` is reserved.
		
Renames a profile, leaving the profile ID unchanged.
Renames a profile leaving the profile ID unchanged .
def rename_profile(self, oldname, newname) -> RetVal:
		if not oldname or not newname:
			return RetVal(ErrEmptyData, "BUG: profile names may not be empty")
		old_squashed = oldname.casefold()
		new_squashed = newname.casefold()
		if old_squashed == new_squashed:
			return RetVal()
		index = self._index_for_profile(old_squashed)
		if index < 0:
			return RetVal(ErrNotFound, f"{oldname} doesn't exist")
		if self._index_for_profile(new_squashed) >= 0:
			return RetVal(ErrExists, f"{newname} already exists")
		if index == self.active_index:
			self.profiles[index].deactivate()
		oldpath = pathlib.Path(self.profiles[index].path)
		newpath = oldpath.parent.joinpath(new_squashed)
		try:
			os.rename(oldpath, newpath)
		except Exception as e:
			if index == self.active_index:
				self.profiles[index].activate()
			return RetVal.wrap_exception(e)
		self.profiles[index].name = new_squashed
		self.profiles[index].path = newpath
		if index == self.active_index:
			self.profiles[index].activate()
		return RetVal()
def rename_profile ( self , oldname , newname ) -> RetVal : if not oldname or not newname : return RetVal ( ErrEmptyData , "BUG: profile names may not be empty" ) old_squashed = oldname . casefold ( ) new_squashed = newname . casefold ( ) if old_squashed == new_squashed : return RetVal ( ) index = self . _index_for_profile ( old_squashed ) if index < 0 : return RetVal ( ErrNotFound , f"{oldname} doesn't exist" ) if self . _index_for_profile ( new_squashed ) >= 0 : return RetVal ( ErrExists , f"{newname} already exists" ) if index == self . active_index : self . profiles [ index ] . deactivate ( ) oldpath = pathlib . Path ( self . profiles [ index ] . path ) newpath = oldpath . parent . joinpath ( new_squashed ) try : os . rename ( oldpath , newpath ) except Exception as e : if index == self . active_index : self . profiles [ index ] . activate ( ) return RetVal . wrap_exception ( e ) self . profiles [ index ] . name = new_squashed self . profiles [ index ] . path = newpath if index == self . active_index : self . profiles [ index ] . activate ( ) return RetVal ( )
Renames a profile, leaving the profile ID unchanged.
Renames a profile leaving the profile ID unchanged .
'''Renames a profile, leaving the profile ID unchanged.

		Parameters:
		  * oldname: the current name of the profile
		  * newname: the new name of the profile
		
		Returns:
		  * no additional fields
		
		Notes:
			As with create_profile(), capital letters will be squashed, care should be
			used with special characters, and `default` is reserved.
		'''
no additional fields
no additional fields
self
oldname
newname
* oldname
the current name of the profile
the current name of the profile
* newname
the new name of the profile
the new name of the profile