Turn loops into "objects" that can be processed normally
18142
def promote_loops( loops, index, shared ):
    """"""
    for loop in loops:
        loop = list(loop)
        members = [index[addr] for addr in loop]
        external_parents = list(set([
            addr for addr in sum([shared.get(addr,[]) for addr in loop],[])
            if addr not in loop 
        ]))
        if external_parents:
            if len(external_parents) == 1:
                # potentially a loop that's been looped...
                parent = index.get( external_parents[0] )
                if parent['type'] == LOOP_TYPE:
                    continue 
            # we haven't already been looped...
            loop_addr = new_address( index )
            shared[loop_addr] = external_parents
            loop_record = index[loop_addr] = {
                'address': loop_addr,
                'refs': loop,
                'parents': external_parents,
                'type': LOOP_TYPE,
                'size': 0,
            }
            for member in members:
                # member's references must *not* point to loop...
                member['refs'] = [
                    ref for ref in member['refs']
                    if ref not in loop 
                ]
                # member's parents are *just* the loop
                member['parents'][:] = [loop_addr]
            # each referent to loop holds a single reference to the loop rather than many to children
            for parent in external_parents:
                parent = index[parent]
                for member in members:
                    rewrite_references( parent['refs'], member['address'], None )
                parent['refs'].append( loop_addr )
1077140
def object_to_items(data_structure):
    """"""
    items = []
    # Get all items from dict
    try:
        items = list(data_structure.__dict__.items())
    except:
        pass
    # Get all slots
    hierarchy = [data_structure]
    try:
        hierarchy += inspect.getmro(data_structure)
    except:
        pass
    slots = []
    try:
        for b in hierarchy:
            try:
                slots += b.__slots__
            except:  # pragma: no cover
                pass
    except:  # pragma: no cover
        pass
    # Get attrs from slots
    for x in slots:
        items.append((x, getattr(data_structure, x)))
    return items
671623
def _process_transform(self, data, transform, step_size):
    '''
    
    '''
    if isinstance(transform, (list,tuple,set)):
      return { t : self._transform(data,t,step_size) for t in transform }
    elif isinstance(transform, dict):
      return { tn : self._transform(data,tf,step_size) for tn,tf in transform.items() }
    return self._transform(data,transform,step_size)
233637
def _normalize(obj):
    
    if isinstance(obj, list):
        return [_normalize(item) for item in obj]
    elif isinstance(obj, dict):
        return {k: _normalize(v) for k, v in obj.items() if v is not None}
    elif hasattr(obj, 'to_python'):
        return obj.to_python()
    return obj
735346
def create_opengl_object(gl_gen_function, n=1):
    """"""
    handle = gl.GLuint(1)
    gl_gen_function(n, byref(handle))  # Create n Empty Objects
    if n > 1:
        return [handle.value + el for el in range(n)]  # Return list of handle values
    else:
        return handle.value
254767
function strArrayToObj (array) {
  return array && array.reduce(function(o, v) {
      o[v] = true;
      return o;
    }, {});
}
1252889
function ( obj ) {
		var result = [];

		result = obj.reduce( function ( a, b ) {
			return a.concat( b );
		}, result );

		return result;
	}
1353353
function arrayToObject(array) {
  return array.reduce((obj, [prop1, prop2]) => {
    obj[prop1] = prop2
    obj[prop2] = prop1
    return obj
  }, {})
}
866910
def process_lists(self):
        """"""
        for l1_idx, obj1 in enumerate(self.l1):
            for l2_idx, obj2 in enumerate(self.l2):
                if self.equal(obj1, obj2):
                    self.matches.add((l1_idx, l2_idx))
830917
def juggle_types(data):
    """"""
    # Data is a list of lists (2D) and not a single column table (1D)
    if isinstance(data[0], list):
        return [[force_int(col) for col in row] for row in data]

    # Data is 1D
    elif isinstance(data, list):
        return [force_int(i) for i in data]
    else:
        return data
703678
function normalizeProperties(input) {
  if (!input) return;

  if (Array.isArray(input)) {
    return flatten(input).reduce(function (acc, o) {
      return Object.assign(acc, o);
    }, {});
  }

  return clone(input);
}
921896
def process(self):
        """"""
        if WINDOWS:
            select_inputs = []
            for i in self.inputs:
                if not isinstance(i, SelectableObject):
                    warning("Unknown ignored object type: %s", type(i))
                elif i.__selectable_force_select__:
                    # Then use select.select
                    select_inputs.append(i)
                elif not self.remain and i.check_recv():
                    self.results.append(i)
                else:
                    i.wait_return(self._exit_door)
            if select_inputs:
                # Use default select function
                self.results.extend(select(select_inputs, [], [], self.remain)[0])  # noqa: E501
            if not self.remain:
                return self.results

            threading.Thread(target=self._timeout_thread, args=(self.remain,)).start()  # noqa: E501
            if not self._ended:
                self.available_lock.acquire()
            return self.results
        else:
            r, _, _ = select(self.inputs, [], [], self.remain)
            return r
488385
def nodes_to_object(self, node, object):
        ""

        for n in list(node):
            self.node_to_object(n, object)
575997
def to_regular_array(self, A):
        
        # this could be a static method, but we choose to be consistent with
        # from_regular_array
        return A.view((int, len(A.dtype.names))).reshape(A.shape + (-1,))
1274813
def cli(obj):
    """"""
    for k, v in obj.items():
        if isinstance(v, list):
            v = ', '.join(v)
        click.echo('{:20}: {}'.format(k, v))
630773
def _process_items(cls, vals):
        ""
        if type(vals) is cls:
            return vals.data
        elif not isinstance(vals, (list, tuple)):
            vals = [vals]
        items = []
        counts = defaultdict(lambda: 1)
        cls._unpack_paths(vals, items, counts)
        items = cls._deduplicate_items(items)
        return items
1184768
def process_generic(self, kind, context):
		""""""
		
		result = None
		
		while True:
			chunk = yield result
			
			if chunk is None:
				return
			
			result = chunk.clone(line='_' + kind + '(' + chunk.line + ')')