Skip to content

Refactor SIGSET.__repr__() to call other methods #8

Description

@wdoekes
def __repr__(self):
    human_sigs = _get_human_signals()
    return '{%s}' % (', '.join(ret),)
def _get_human_signals(self):
        ret = []
        for i, bitmask in enumerate(self.val):
            if bitmask:
                ret.extend(self._get_XXX(mask2list, i, bitmask)
    return ret
def _get_XXX(...):
                if mask2list and i <= 1:  # 64 bits in the first two int32s
                    numbers = mask2list(bitmask)  # sorted from low to high
                    if i == 1:
                        numbers = [i << 1 for i in numbers]
                    for number in numbers:
                        ret.append(SIGNAMES.get(number, 'SIG%d' % (number,)))
                else:
                    strvalue = binrepr and binrepr(bitmask) or str(bitmask)
                    ret.append('%d: %s' % (i, strvalue))
    return ret

Or something..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions