Remove empty entries in a list
170335
def _remove_empty_entries(entries):
    """"""
    valid_entries = []
    for entry in set(entries):
        if entry:
            valid_entries.append(entry)
    return sorted(valid_entries)
411495
def drop_empty(arr):
    
    return [x for x in arr if not isinstance(x, list) or len(x) > 0]
1103636
def _prune_entries(self, num):
        ""
        while num > 0:
            self.access_log_lock.acquire()
            p = self.access_log.pop()
            self.access_log_lock.release()

            if not p.is_valid:
                continue # Invalidated entry, skip

            dict.pop(self, p.key, None)
            self.access_lookup.pop(p.key, None)
            num -= 1
446692
public static function ClearList(){
            $oThis = self::CreateInstanceIfNotExists();
            
            if(preg_match('/{list\:(.*?)}/', $oThis->sBuffer, $aMatches) == 1){
                $sListName = $aMatches[1]; 

                $iStart = strpos($oThis->sBuffer, "{list:{$sListName}}");

                if($iStart > 0)
                    $iEnd = strpos($oThis->sBuffer, "{end}", $iStart);

                if($iStart > 0 && $iEnd > 0)
                    $sList = substr($oThis->sBuffer, $iStart, $iEnd-$iStart)."{end}";

                $oThis->sBuffer = str_replace($sList, "", $oThis->sBuffer);
            }
        }
1241082
public static int listFindNoCaseIgnoreEmpty(String list, String value, char delimiter) {
	if (list == null) return -1;
	int len = list.length();
	if (len == 0) return -1;
	int last = 0;
	int count = 0;

	for (int i = 0; i < len; i++) {
	    if (list.charAt(i) == delimiter) {
		if (last < i) {
		    if (list.substring(last, i).equalsIgnoreCase(value)) return count;
		    count++;
		}
		last = i + 1;
	    }
	}
	if (last < len) {
	    if (list.substring(last).equalsIgnoreCase(value)) return count;
	}
	return -1;
    }
289792
private static List<String> maskNull(List<String> pTypes) {
        return (pTypes == null) ? Collections.<String>emptyList() : pTypes;
    }
820765
def emptyArray(key, add_label=None):
    """"""

    result = {
        'key': key,
        'startEmpty': True
    }
    if add_label is not None:
        result['add'] = add_label
        result['style'] = {'add': 'btn-success'}
    return result
561148
def filter_not_empty_values(value):
    """"""
    if not value:
        return None
    data = [x for x in value if x]
    if not data:
        return None
    return data
401074
protected List<String> trim(List<String> list) {
        if (list == null || list.size() == 0)
            return list;

        List<String> result = new ArrayList<String>();
        for (String s : list) {
            s = trim(s);

            if (s == null || s.length() == 0)
                continue;

            result.add(s);
        }

        return result;
    }
675695
def _drop_empty_props(self, item):
        
        if isinstance(item, list):
            return [self._drop_empty_props(i) for i in item]
        if isinstance(item, dict):
            return {
                k: self._drop_empty_props(v)
                for k, v in item.items() if v != ''
            }
        return item
932851
def clean_item_no_list(i):
    
    itype = type(i)
    if itype == dict:
        return clean_dict(i, clean_item_no_list)
    elif itype == list:
        return clean_tuple(i, clean_item_no_list)
    elif itype == tuple:
        return clean_tuple(i, clean_item_no_list)
    elif itype == numpy.float32:
        return float(i)
    elif itype == numpy.float64:
        return float(i)
    elif itype == numpy.int16:
        return int(i)
    elif itype == numpy.uint16:
        return int(i)
    elif itype == numpy.int32:
        return int(i)
    elif itype == numpy.uint32:
        return int(i)
    elif itype == float:
        return i
    elif itype == str:
        return i
    elif itype == int:
        return i
    elif itype == bool:
        return i
    elif itype == type(None):
        return i
    logging.info("[2] Unable to handle type %s", itype)
    return None
684214
def emptyElement(self, name, attrs):
        """"""
        attr = ' '.join('%s=%s' % (n, quoteattr(scientificformat(v)))
                        for n, v in sorted(attrs.items()))
        self._write('<%s %s/>' % (name, attr))
88999
def remove_empty_cols(records):
    """"""
    # In case it's a generator, turn it into a list
    records = list(records)
    seqstrs = [str(rec.seq) for rec in records]
    clean_cols = [col
                  for col in zip(*seqstrs)
                  if not all(c == '-' for c in col)]
    clean_seqs = [''.join(row)
                  for row in zip(*clean_cols)]
    for rec, clean_seq in zip(records, clean_seqs):
        yield SeqRecord(Seq(clean_seq, rec.seq.alphabet), id=rec.id,
                        name=rec.name, description=rec.description,
                        dbxrefs=rec.dbxrefs, features=rec.features,
                        annotations=rec.annotations,
                        letter_annotations=rec.letter_annotations)
457919
def strip_empty_values(obj):
    """"""
    if isinstance(obj, dict):
        new_obj = {}
        for key, val in obj.items():
            new_val = strip_empty_values(val)
            if new_val is not None:
                new_obj[key] = new_val
        return new_obj or None
    elif isinstance(obj, (list, tuple, set)):
        new_obj = []
        for val in obj:
            new_val = strip_empty_values(val)
            if new_val is not None:
                new_obj.append(new_val)
        return type(obj)(new_obj) or None
    elif obj or obj is False or obj == 0:
        return obj
    else:
        return None
277549
def list_remove_by_index(l, index):
    ''''''
    if index < 0 or index >= len(l):
        raise ValueError('index out of range')
    if index == (len(l) - 1):
        l.pop()
    elif index == 0:
        l = l[1:]
    else:
        l = l[0:index] + l[index+1:]

    return l
282486
def _render_list(self, items, empty='<pre>&lt;empty&gt;</pre>'):
    
    if not items or len(items) == 0:
      self._segments.append(empty)
      return
    self._segments.append('<ul>')
    for o in items:
      self._segments.append('<li>')
      self._segments.append(str(o))
      self._segments.append('</li>')
    self._segments.append('</ul>')
1161530
def clean_list(l0, clean_item_fn=None):
    
    clean_item_fn = clean_item_fn if clean_item_fn else clean_item
    l = list()
    for index, item in enumerate(l0):
        cleaned_item = clean_item_fn(item)
        l.append(cleaned_item)
    return l