Returns an iterator over the named bitfields in the structure as
        2-tuples of (key, value).  Uses a clone so as to only read from
        the underlying data once.
182257
def items(self):
        
        temp = self.clone()
        return [(f, getattr(temp, f)) for f in iter(self)]
811020
def get_hash(node,fields = None,exclude = ['pk','_id'],target = 'pk'):
    

    hasher = Hasher()

    def add_to_hash(value):

        if isinstance(value,dict):
            if target in value:
                add_to_hash(value[target])
            else:
                attribute_list = []
                for key,v in sorted(value.items(),key = lambda x: x[0]):

                    if (fields is not None and key not in fields) \
                        or (exclude is not None and key in exclude):
                        continue
                    add_to_hash(key)
                    add_to_hash(v)
        elif isinstance(value,(tuple,list)) and value and isinstance(value[0],(dict,node_class)):
            for i,v in enumerate(value):
                hasher.add(i)
                add_to_hash(v)
        else:
            hasher.add(value)

    add_to_hash(node)

    return hasher.digest.hexdigest()
1067946
def itersplit_to_fields(self, _str):
        
        if self.preparse:
            _str = self.preparse(_str)

        _fields = itersplit(_str, self.fsep)

        try:
            values = (
                t[1] for t in izip_longest(self._tuple._fields, _fields))
            return self._tuple(*values)
        except Exception as e:
            log.error(self._tuple)
            log.error(_fields)
            log.exception(e)
            raise
1107014
def copyFrom(bitfield)
      raise "Source bitfield is too small (#{bitfield.length} < #{length})" if bitfield.length < length
      (@data.length).times do |i|
        @data[i] = bitfield.data[i]
      end
    end
568436
def copy(self):
    
    if self._iters:
      a, b = it.tee(self._iters[0])
      self._iters[0] = a
      return Stream(b)
    iter(self)
1211854
def read(self, keyed=False, extended=False, cast=True, relations=False, limit=None):
        
        result = []
        rows = self.iter(keyed=keyed, extended=extended, cast=cast, relations=relations)
        for count, row in enumerate(rows, start=1):
            result.append(row)
            if count == limit:
                break
        return result
983890
def _restore(name, fields, value):
    
    k = (name, fields)
    cls = __cls.get(k)
    if cls is None:
        cls = collections.namedtuple(name, fields)
        __cls[k] = cls
    return cls(*value)
1359135
def dict_to_serializable_repr(x):
    
    # list of JSON representations of hashable objects which were
    # used as keys in this dictionary
    serialized_key_list = []
    serialized_keys_to_names = {}
    # use the class of x rather just dict since we might want to convert
    # derived classes such as OrderedDict
    result = type(x)()
    for (k, v) in x.items():
        if not isinstance(k, string_types):
            # JSON does not support using complex types such as tuples
            # or user-defined objects with implementations of __hash__ as
            # keys in a dictionary so we must keep the serialized
            # representations of such values in a list and refer to indices
            # in that list
            serialized_key_repr = to_json(k)
            if serialized_key_repr in serialized_keys_to_names:
                k = serialized_keys_to_names[serialized_key_repr]
            else:
                k = index_to_serialized_key_name(len(serialized_key_list))
                serialized_keys_to_names[serialized_key_repr] = k
                serialized_key_list.append(serialized_key_repr)
        result[k] = to_serializable_repr(v)
    if len(serialized_key_list) > 0:
        # only include this list of serialized keys if we had any non-string
        # keys
        result[SERIALIZED_DICTIONARY_KEYS_FIELD] = serialized_key_list
    return result
1138962
def iter_schemas(self, schema: Schema) -> Iterable[Tuple[str, Any]]:
        
        if not schema:
            return

        yield self.to_tuple(schema)

        for name, field in self.iter_fields(schema):
            if isinstance(field, Nested):
                yield self.to_tuple(field.schema)
                yield from self.iter_schemas(field.schema)

            if isinstance(field, List) and isinstance(field.container, Nested):
                yield self.to_tuple(field.container.schema)
                yield from self.iter_schemas(field.container.schema)
390918
function iterateOverKeys(getFn, obj, fn, hidden) {
  var keys = getFn(obj), desc;
  for (var i = 0, key; key = keys[i]; i++) {
    desc = getOwnPropertyDescriptor(obj, key);
    if (desc.enumerable || hidden) {
      fn(obj[key], key);
    }
  }
}
941088
def enum(**enums):
    
    # Enum values must be hashable to support reverse lookup.
    if not all(isinstance(val, collections.Hashable) for val in _values(enums)):
        raise EnumConstructionException('All enum values must be hashable.')

    # Cheating by maintaining a copy of original dict for iteration b/c iterators are hard.
    # It must be a deepcopy because new.classobj() modifies the original.
    en = copy.deepcopy(enums)
    e = type('Enum', (_EnumMethods,), dict((k, v) for k, v in _items(en)))

    try:
        e.choices = [(v, k) for k, v in sorted(_items(enums), key=itemgetter(1))]  # DEPRECATED
    except TypeError:
        pass
    e.get_id_by_label = e.__dict__.get
    e.get_label_by_id = dict((v, k) for (k, v) in _items(enums)).get

    return e
1095771
def get_value(self, attributes,key = None):
        

        value = attributes
        if key is None:
            key = self._splitted_key

        # A splitted key like 'a.b.c' goes into nested properties
        # and the value is retrieved recursively
        for i,elem in enumerate(key):
            if isinstance(value, (list,tuple)):
                #if this is a list, we return all matching values for the given list items
                return [self.get_value(v,key[i:]) for v in value]
            else:
                value = value[elem]

        return value
1207384
def get(self, key, index=None):
        
        records = self.get_multi([key], index=index)

        try:
            return records[0][1]  # return the value from the key/value tuple
        except IndexError:
            return None
587148
def iter_parsed_values(self, field: Field) -> Iterable[Tuple[str, Any]]:
        
        for key, func in self.parsers.items():
            value = func(field)
            if not value:
                continue
            yield key, value
826765
def iterate_over_fields(cls):
        """"""
        for attr in dir(cls):
            clsattr = getattr(cls, attr)
            if isinstance(clsattr, BaseField):
                yield attr, clsattr
651892
def fromkeys(cls, iterable, value, **kwargs):
        
        return cls(((k, value) for k in iterable), **kwargs)
905970
def unique(iterable, key=None):
    
    ensure_iterable(iterable)
    key = hash if key is None else ensure_callable(key)

    def generator():
        seen = set()
        for elem in iterable:
            k = key(elem)
            if k not in seen:
                seen.add(k)
                yield elem

    return generator()