示例#1
0
def is_visible_text(bs_elt) :
  if is_text(bs_elt) :
    s = te.clean_spaces(bs_elt.string)
    if len(s) == 0 :
      return False
    return True
  return False
示例#2
0
def contain_visible_text(bs_elt) :
  if is_text(bs_elt) :
    return len(te.clean_spaces(bs_elt.string))
  elif is_cdata(bs_elt) :
    return 0
  elif is_declaration(bs_elt) :
    return 0
  elif is_processing_instruction(bs_elt) :
    return 0
  l = 0
  for e in bs_elt.descendants :
    if e.string == None :
      continue
    su  = te.clean_spaces(e.string)
    if len(su) == 0 :
      continue
    l += len(su)
  return l
示例#3
0
def add_bloc(tree, res_cut_bloc) :
  for son in res_cut_bloc :
    if son[0] == 'str' :
      if len(te.clean_spaces(son[1])) > 0 :
        tree[1].append(son)
    elif son[0] == 'comment' :
      continue
    elif son[0]['name'] == 'script' :
      continue
    else :
      tree[1].append(son)
  return tree