(self, arg, strip=True)
Returns the contents inside a pair of balanced {} braces. This
        is required when parsing various RTF artifacts as the braces delimit
        content associated with a specific tag.
Returns the contents inside a pair of balanced {} braces. This
        is required when parsing various RTF artifacts as the braces delimit
        content associated with a specific tag.
Returns the contents inside a pair of balanced {} braces . This is required when parsing various RTF artifacts as the braces delimit content associated with a specific tag .
def balanced_braces(self, arg, strip=True):
        """Returns the contents inside a pair of balanced {} braces. This
        is required when parsing various RTF artifacts as the braces delimit
        content associated with a specific tag."""
        if b'{' not in arg:
            return
        chars = []
        n = 0
        for c in arg:
            if c == 0x7b:
                if n > 0:
                    chars.append(c)
                n += 1
            elif c == 0x7d:
                n -= 1
                if n > 0:
                    chars.append(c)
                elif n == 0:
                    if strip:
                        return bytearray(chars).strip()
                    else:
                        return bytearray(chars)
                    chars = []
            elif n > 0:
                chars.append(c)
def balanced_braces ( self , arg , strip = True ) : if b'{' not in arg : return chars = [ ] n = 0 for c in arg : if c == 0x7b : if n > 0 : chars . append ( c ) n += 1 elif c == 0x7d : n -= 1 if n > 0 : chars . append ( c ) elif n == 0 : if strip : return bytearray ( chars ) . strip ( ) else : return bytearray ( chars ) chars = [ ] elif n > 0 : chars . append ( c )