src/lsi/utils/hosts.py
def _get_attrib(self, attr, convert_to_str=False):
        """
        Given an attribute name, looks it up on the entry. Names that
        start with ``tags.`` are looked up in the ``tags`` dictionary.

        :param attr: Name of attribute to look up.
        :type attr: ``str``
        :param convert_to_str: Convert result to a string.
        :type convert_to_str: ``bool``

        :rtype: ``object``
        """
        if attr.startswith('tags.'):
            tag = attr[len('tags.'):]
            if tag in self.tags and self.tags[tag] != '':
                return self.tags[tag]
            elif convert_to_str is True:
                return '<not set>'
            else:
                return self.tags.get(tag)
        elif not hasattr(self, attr):
            raise AttributeError('Invalid attribute: {0}. Perhaps you meant '
                                 '{1}?'.format(red(attr),
                                               green('tags.' + attr)))
        else:
            result = getattr(self, attr)
            if convert_to_str is True and not result:
                return '<none>'
            elif convert_to_str is True and isinstance(result, list):
                return ', '.join(result)
            elif convert_to_str is True:
                return str(result)
            else:
                return result
def _get_attrib(self, attr, convert_to_str=False):
        if attr.startswith('tags.'):
            tag = attr[len('tags.'):]
            if tag in self.tags and self.tags[tag] != '':
                return self.tags[tag]
            elif convert_to_str is True:
                return '<not set>'
            else:
                return self.tags.get(tag)
        elif not hasattr(self, attr):
            raise AttributeError('Invalid attribute: {0}. Perhaps you meant '
                                 '{1}?'.format(red(attr),
                                               green('tags.' + attr)))
        else:
            result = getattr(self, attr)
            if convert_to_str is True and not result:
                return '<none>'
            elif convert_to_str is True and isinstance(result, list):
                return ', '.join(result)
            elif convert_to_str is True:
                return str(result)
            else:
                return result
def _get_attrib ( self , attr , convert_to_str = False ) : if attr . startswith ( 'tags.' ) : tag = attr [ len ( 'tags.' ) : ] if tag in self . tags and self . tags [ tag ] != '' : return self . tags [ tag ] elif convert_to_str is True : return '<not set>' else : return self . tags . get ( tag ) elif not hasattr ( self , attr ) : raise AttributeError ( 'Invalid attribute: {0}. Perhaps you meant ' '{1}?' . format ( red ( attr ) , green ( 'tags.' + attr ) ) ) else : result = getattr ( self , attr ) if convert_to_str is True and not result : return '<none>' elif convert_to_str is True and isinstance ( result , list ) : return ', ' . join ( result ) elif convert_to_str is True : return str ( result ) else : return result
Given an attribute name, looks it up on the entry. Names that
        start with ``tags.`` are looked up in the ``tags`` dictionary.

        :param attr: Name of attribute to look up.
        :type attr: ``str``
        :param convert_to_str: Convert result to a string.
        :type convert_to_str: ``bool``

        :rtype: ``object``
Given an attribute name looks it up on the entry . Names that start with tags . are looked up in the tags dictionary .