10.3. Name Manager

import inspect
from viper_toolkit import Dissect
from viper_toolkit import NameManager
lines = inspect.getsource(NameManager)
class NameManager(object):
    """Creates a NameManager class object which is used to standardize
    the names for a node or a process, and is linked to other 
    Viper toolkit modules, such as the logger. It includes rules for 
    automatically setting the name if a name isn't provided in order
    to standardize log messages, parameters, etc.
    Keyword arguments:
    abv -- the abreviated name for the object
    name -- the full name for the object
    def __init__(self, name: str = None, abv: str = None):
        # Sets the name of this module for the sake of logging.
        self._code = "NMG"
        # Retrieves the name of the module and sets to self._pkg_name
        self._name = name
        self._abv = abv
    def name(self):
        return self._name
    def name(self, name: str = None):
        if name == None:
                self._name = f'{rospy.get_name()}'[1:]
                self._name = "ERROR"
            self._name = name
        rospy.logdebug(f'[{self._code}] Name set to %s', self.name)
        #setattr(self, name, self._name)
    def abv(self):
        return self._abv
    def abv(self, code = None):
        if code == None:
            self._abv = self._autoabv()
            self._abv = self.codeformatter(code)
        rospy.set_param(f'/{self.name}/abv', self.abv)
        rospy.logdebug(f'[{self._code}] ABV set')
    def codeformatter(self, code: str):
        abv = code[:3].upper()
        abv = abv.ljust(3)
        return abv
    def _autoabv(self):
        if rospy.has_param(f'{self.name}/abv'):
            abv = rospy.get_param(f'/{self.name}/abv')
            return self.codeformatter(abv)
            return self.codeformatter(f'{self.name}')