\
        takes a list of image elements
        and filters out the ones with bad names
351628
def filter_bad_names(self, images):
        
        good_images = []
        for image in images:
            if self.is_valid_filename(image):
                good_images.append(image)
        return good_images if len(good_images) > 0 else None
293769
def trim_filter(filter, levels=1):
    ''''''
    trimmed = [f[levels:] for f in filter]
    return [f for f in trimmed if f]
1134709
function removeUnwantedCharacters(cleanedString, unwantedCharArray) {
    for (var x = 0; x < unwantedCharArray.length; x++) {
        var unwantedCharRegExp = new RegExp(unwantedCharArray[x], 'g');
        cleanedString = cleanedString.replace(unwantedCharRegExp, '');
    }
    return cleanedString;
}
242142
def _remove_dots(src):
    '''
    
    '''
    output = {}
    for key, val in six.iteritems(src):
        if isinstance(val, dict):
            val = _remove_dots(val)
        output[key.replace('.', '-')] = val
    return output
452109
def _filter_image(self, url):
        ""
        return reduce(lambda f, g: f and g(f), 
        [
            filters.AdblockURLFilter()(url),
            filters.NoImageFilter(),
            filters.SizeImageFilter(),
            filters.MonoImageFilter(),
            filters.FormatImageFilter(),
        ])
460608
def base_name_from_image(image):
    
    m = re.match("^(.+/)?([^:/]+)(:[^:]+)?$", image)
    algo_name = m.group(2) if m else image
    return algo_name
729904
def scrub(data):
    """"""
    # blanks, Nones, and empty strings can stay as is
    if not data:
        return data
    if isinstance(data, (int, float)):
        return data
    if isinstance(data, list):
        return [scrub(entry) for entry in data]
    if isinstance(data, dict):
        return {scrub(key): scrub(value) for key, value in data.items()}
    try:
        return json.encoder.encode_basestring(data)[1:-1]
    except TypeError as exc:
        raise ValidationError("Input '%s' is not a permitted type: %s" % (data,
                                                                          exc))
    except Exception as exc:
        raise ValidationError("Input '%s' not permitted: %s" % (data, exc))
1027881
function filterData(str, data) {
  data = data || [];
  var ctx = String(str || '').trim();
  var slashParts = ctx.split('/');
  ctx = slashParts.pop();
  var wordParts = String(ctx).trim().split(' ');
  var res = data.filter(function (item) {
    return (strip(item).slice(0, ctx.length) === ctx);
  });
  res = res.map(function (item) {
    var parts = String(item).trim().split(' ');
    if (parts.length > 1) {
      parts = parts.slice(wordParts.length);
      return parts.join(' ');
    }
    return item;
  });
  return res;
}
672191
def _clean_result(self, text):
        """"""
        text = re.sub('\s\s+', ' ', text)
        text = re.sub('\.\.+', '.', text)
        text = text.replace("'", "\\'")
        return text
613516
def remove_bg(img, th=(240, 255)):
    
    if img.size == 0:
        return img

    img = gray3(img)

    # delete rows with complete background color
    h, w = img.shape[:2]
    i = 0
    while i < h:
        mask = np.logical_or(img[i, :, :] < th[0], img[i, :, :] > th[1])
        if not mask.any():
            img = np.delete(img, i, axis=0)
            i -= 1
            h -= 1
        i += 1

    # if image is complete background only
    if img.size == 0:
        return img

    # delete columns with complete background color
    h, w = img.shape[:2]
    i = 0
    while i < w:
        mask = np.logical_or(img[:, i, :] < th[0], img[:, i, :] > th[1])
        if not mask.any():
            img = np.delete(img, i, axis=1)
            i -= 1
            w -= 1
        i += 1

    return img
378175
def scrubFilename(filename):
    '''
    
    '''
    global _PACKAGE_SCRUB_LIST
    for package in _PACKAGE_SCRUB_LIST:
        i = filename.rfind(package)
        if i > -1:
            return filename[i:]

    return filename
478605
def filter_dup(lst, lists):
    '''
    
    '''
    max_rank = len(lst) + 1
    dct = to_ranked_dict(lst)
    dicts = [to_ranked_dict(l) for l in lists]
    return [word for word in lst if all(dct[word] < dct2.get(word, max_rank) for dct2 in dicts)]
1339925
def filter_element(data)
      if @element_filter
        data, el_errors = @element_filter.filter(data)
        return [data, el_errors] if el_errors
      elsif options[:class]
        if !data.is_a?(options[:class])
          return [data, :class]
        end
      end

      [data, nil]
    end
992122
def parse_image_name(self, image):
        '''
             

        '''
        self._image = image
        self.uri = self.get_uri(image)
        self.image = self.remove_uri(image)
966957
def prettyMatcherList(things):
    """"""
    norm = []
    for x in makeSequence(things):
        if hasattr(x, 'pattern'):
            norm.append(x.pattern)
        else:
            norm.append(x)
    return "('%s')" % "', '".join(norm)
270861
def remove_part_images(filename):
    """"""
    dirname = '{0}_files'.format(os.path.splitext(filename)[0])
    if os.path.exists(dirname):
        shutil.rmtree(dirname)
930712
def normalize_names(names):
    """"""
    if isinstance(names, basestring):
        names = names.split(',')
    names = listify(names)
    return [str(name).strip() for name in names]