if type(d) is dict:
        return dict((k, public_dict(v)) for k, v in d.items() if not k.startswith('_'))
    elif type(d) is list:
        return [public_dict(v) for v in d]
    else:
        return d
506090
def public_dict(d):
    

    if isinstance(d, dict):
        safe_dict = dict((key, public_dict(value)) for key, value in d.items() if not key.startswith('_'))
        if '_cls' in d:
            safe_dict['type'] = d['_cls']
        return safe_dict
    if isinstance(d, list):
        return [public_dict(l) for l in d]

    return d
258498
def get_by_type(self, _type):
        
        r = {}
        for k, v in self.items():
            if get_component_type(k) is _type:
                r[k] = v
        return r
1338656
def prefix_dict_keys(d: Dict[str, Any], prefix: str) -> Dict[str, Any]:
    
    result = {}  # type: Dict[str, Any]
    for k, v in d.items():
        result[prefix + k] = v
    return result
960776
def qdict_get_list(qdict, k):
    
    pks = qdict.getlist(k)
    return [e for e in pks if e]
214218
def get_name_type_dict(self):
        
        attrs = self.get_attributes()
        types = self.get_types()
        d = dict()
        for i,a in enumerate(attrs):
            d[a] = types[i]

        return d
403732
def dict_to_numpy_array(d):
    
    return fromarrays(d.values(), np.dtype([(str(k), v.dtype) for k, v in d.items()]))
422499
def DictKeyColumns(d):
    ''
    return [ColumnItem(k, k, type=deduceType(d[k])) for k in d.keys()]
749026
def _invert_dictionary(self, d):
        
        inv_dict = {}

        for k, v in d.items():
            inv_dict[v] = inv_dict.get(v, [])
            inv_dict[v] += [k]

        return inv_dict
1039678
def simple_dict() -> Callable:
    

    def parse(dict_str: str):

        def _parse(value: str):
            if value == "True":
                return True
            if value == "False":
                return False
            if "." in value:
                return float(value)
            return int(value)

        _dict = dict()
        try:
            for entry in dict_str.split(","):
                key, value = entry.split(":")
                _dict[key] = _parse(value)
        except ValueError:
            raise argparse.ArgumentTypeError("Specify argument dictionary as key1:value1,key2:value2,..."
                                             " Supported types: bool, int, float.")
        return _dict

    return parse
216491
def filter_dict(iterable, keys):
  
  if type(keys) is not list:
    keys = [keys]
  for i in iterable:
    try:
      d = {}
      for a in keys:
        try:
          d[a] = i[a]
        except KeyError:
          pass
      if d != {}:
        yield d
    except Exception:
      pass
897441
def is_dict(self, key):
        """"""
        data = self.model.get_data()
        return isinstance(data[key], dict)
409985
def todict(self, dict_type=dict, index_key=0, index_value=-1):
        ''''''
        if len(self):
            return dict_type(self.items([index_key, index_value]))
        else:  # empty
            return dict_type()
307457
def _list_dict(l: Iterator[str], case_insensitive: bool = False):
    
    if case_insensitive:
        raise NotImplementedError()
        d = tldap.dict.CaseInsensitiveDict()
    else:
        d = {}
    for i in l:
        d[i] = None
    return d
162866
def clean_empty(self, d=DEFAULT):
        
        if d is DEFAULT:
            d = self
        if isinstance(d, list):
            return [v for v in (self.clean_empty(v) for v in d) if v or v == 0]
        elif isinstance(d, type(self)):
            return type(self)({k: v for k, v in ((k, self.clean_empty(v)) for k, v in d.items()) if v or v == 0})
        elif isinstance(d, dict):
            return {k: v for k, v in ((k, self.clean_empty(v)) for k, v in d.items()) if v or v == 0}
        return d
907216
def from_dict(d):
        
        i = Tags()
        for k, v in d.items():
            if k not in ("@module", "@class"):
                i[k] = v
        return i
160322
def of(d):
    
    return {k: v for k, v in iteritems(d) if v != unset}
959227
def primitive(self):
        """"""
        dict = {}
        for key, value in self.__dict__.items():
            if not key.startswith('_'):
                dict[key] = copy(value)

        for key in dict:
            if isinstance(dict[key], (set)):
                dict[key] = sorted(list(dict[key]))

        return dict