'Check or update status flags
@param flag: the name of the status flag to return
@param default: the default value if the flag is not set
@param attr: key-value pairs for flags to set
@return: the value of the requested flag, or all flags
as dict if no flag was specified'

def __status(self, flag=None, default=None, **attr):

    flags = self.flags
    for (k, v) in attr.items():
        if (v is not None):
            flags[k] = v
        else:
            flags.pop(k, None)
    if (flag is not None):
        return flags.get(flag, default)
    return flags
