Cleanup unregistered flags from all module -> [flags] dictionaries.

    If flag_obj is registered under either its long name or short name, it
    won't be removed from the dictionaries.

    Args:
      flag_obj: A flag object.
559605
def _CleanupUnregisteredFlagFromModuleDicts(self, flag_obj):
    
    if self._FlagIsRegistered(flag_obj):
      return
    for flags_by_module_dict in (self.FlagsByModuleDict(),
                                 self.FlagsByModuleIdDict(),
                                 self.KeyFlagsByModuleDict()):
      for flags_in_module in six.itervalues(flags_by_module_dict):
        # While (as opposed to if) takes care of multiple occurrences of a
        # flag in the list for the same module.
        while flag_obj in flags_in_module:
          flags_in_module.remove(flag_obj)
156
def unique_bits(flags_class):
    
    flags_class = unique(flags_class)
    other_bits = 0
    for name, member in flags_class.__members_without_aliases__.items():
        bits = int(member)
        if other_bits & bits:
            for other_name, other_member in flags_class.__members_without_aliases__.items():
                if int(other_member) & bits:
                    raise ValueError("%r: '%s' and '%s' have overlapping bits" % (flags_class, other_name, name))
        else:
            other_bits |= bits
1239313
def _name_with_flags(self, include_restricted, title=None):
        """"""
        name = "Special: " if self.special else ""
        name += self.name
        if title:
            name += " - {}".format(title)
        if include_restricted and self.restricted:
            name += " (R)"
        name += " (BB)" if self.both_blocks else ""
        name += " (A)" if self.administrative else ""
        name += " (S)" if self.sticky else ""
        name += " (Deleted)" if self.deleted else ""
        return name
1193062
def _clean_flags(args, caller):
    '''
    
    '''
    flags = ''
    if args is None:
        return flags
    allowed = ('a', 'B', 'h', 'H', 'i', 'k', 'l', 'P', 't', 'T', 'x', 'v')
    for flag in args:
        if flag in allowed:
            flags += flag
        else:
            raise CommandExecutionError(
                'Invalid flag passed to {0}'.format(caller)
            )
    return flags
531541
def _merge_flags(new_flags, old_flags=None, conf='any'):
    '''
    
    '''
    if not old_flags:
        old_flags = []
    args = [old_flags, new_flags]
    if conf == 'accept_keywords':
        tmp = new_flags + \
            [i for i in old_flags if _check_accept_keywords(new_flags, i)]
    else:
        tmp = portage.flatten(args)
    flags = {}
    for flag in tmp:
        if flag[0] == '-':
            flags[flag[1:]] = False
        else:
            flags[flag] = True
    tmp = []
    for key, val in six.iteritems(flags):
        if val:
            tmp.append(key)
        else:
            tmp.append('-' + key)

    # Next sort is just aesthetic, can be commented for a small performance
    # boost
    tmp.sort(key=lambda x: x.lstrip('-'))
    return tmp
1220751
def _default_objc(self):
        
        objc = ctypes.cdll.LoadLibrary(find_library('objc'))
        objc.objc_getClass.restype = ctypes.c_void_p
        objc.sel_registerName.restype = ctypes.c_void_p
        objc.objc_msgSend.restype = ctypes.c_void_p
        objc.objc_msgSend.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
        return objc
500934
def remove_pickle_problems(obj):
    
    if hasattr(obj, "doc_loader"):
        obj.doc_loader = None
    if hasattr(obj, "embedded_tool"):
        obj.embedded_tool = remove_pickle_problems(obj.embedded_tool)
    if hasattr(obj, "steps"):
        obj.steps = [remove_pickle_problems(s) for s in obj.steps]
    return obj
1131705
def is_flagged(self, user=None, status=None):
        
        filter_kwargs = {
            'content_type': ContentType.objects.get_for_model(self),
            'object_id': self.id,
        }
        update_filter_dict(filter_kwargs, user, status)
        return self.flags.filter(**filter_kwargs).count()
1366689
def _unregister_lookup(cls, lookup, lookup_name=None):
        
        if lookup_name is None:
            lookup_name = lookup.lookup_name
        del cls.class_lookups[lookup_name]
302482
def flags_as_args():
  """"""
  if hasattr(FLAGS, "flag_values_dict"):
    args_dict = FLAGS.flag_values_dict()
  else:
    args_dict = dict(FLAGS.__dict__["__flags"])
  del args_dict["cloud_mlengine"]
  # Configured later
  del args_dict["t2t_usr_dir"]
  args_dict.pop("h", None)
  args_dict.pop("helpfull", None)
  args_dict.pop("helpshort", None)
  args_dict.pop("help", None)
  args = []
  for name, val in args_dict.items():
    if val is None:
      continue
    if name.startswith("autotune"):
      continue
    args.extend(["--%s=%s" % (name, str(val))])
  return args
1180246
public Message clearFlag(Flag ... flags) {
        if(flags != null) {
            short tmp=this.flags;
            for(Flag flag : flags)
                if(flag != null)
                    tmp&=~flag.value();
            this.flags=tmp;
        }
        return this;
    }
1028435
def editflags(fd, add_flags=0, remove_flags=0):
    

    if add_flags & remove_flags != 0:
        raise ValueError(
            'Added and removed flags shouldn\'t overlap',
            add_flags, remove_flags)

    # The ext2progs code uses int or unsigned long,
    # the kernel uses an implicit int,
    # let's be explicit here.
    flags_ptr = ffi.new('uint64_t*')
    flags_buf = ffi.buffer(flags_ptr)
    fcntl.ioctl(fd, lib.FS_IOC_GETFLAGS, flags_buf)
    prev_flags = flags_ptr[0]
    flags_ptr[0] |= add_flags
    # Python represents negative numbers with an infinite number of
    # ones in bitops, so this will work correctly.
    flags_ptr[0] &= ~remove_flags
    fcntl.ioctl(fd, lib.FS_IOC_SETFLAGS, flags_buf)
    return prev_flags & (add_flags | remove_flags)
1169448
def flags_from_dict(kw):
    

    if len(kw) == 0:
        return ''

    flags = ''
    for (k, v) in kw.items():
        if v:
            flags += ' ' + str(k)
    # note that we want the leading space if there's at least one
    # flag.
    return flags
916643
def _set_flags(self, **flags):
        '''
        
        '''
        self._flags = enum.IntEnum('_flags', flags)
        self.__dict__.update(self._flags.__members__)
        self._patch_flag_doc()
518812
def _render_our_module_flags(self, module, output_lines, prefix=''):
    """"""
    flags = self._get_flags_defined_by_module(module)
    if flags:
      self._render_module_flags(module, flags, output_lines, prefix)
355197
def flag(name=None):
    

    if name is None:
        name = 'Flag Field'

    # Basic field
    field = pp.Regex('[YNU]')

    # Name
    field.setName(name)

    field.leaveWhitespace()

    return field
313926
def Flags(*params)
      if params.size==1 && params.first.kind_of?(Flags)
        params.first
      else
        Flags.new(*params)
      end
    end