# Path: nhlscrapi/_tools.py
# def exclude_from(l, containing = [], equal_to = []):
#     """Exclude elements in list l containing any elements from list ex.
#     Example:
#         >>> l = ['bob', 'r', 'rob\r', '\r\nrobert']
#         >>> containing = ['\n', '\r']
#         >>> equal_to = ['r']
#         >>> exclude_from(l, containing, equal_to)
#         ['bob']
#     """
#       
#     cont = lambda li: any(c in li for c in containing)
#     eq = lambda li: any(e == li for e in equal_to)
#     return [li for li in l if not (cont(li) or eq(li))]


from nhlscrapi._tools import exclude_from as ex_junk
  return num, name
    
def __make_dict(o):
  d = { }
  for oi in o:
    num, name = __num_name(oi)
    if num in d:
      num = max(d.keys())+1
        
    d[num] = name
        
  return d


def __format_out(refs, lines):
  offs = { 'refs': { }, 'linesman': { } }
  if refs:
    offs['refs'] = __make_dict(refs)
  
  if lines:
    offs['linesman'] = __make_dict(lines)
  
  return offs



# layout of officials seasons <= 2009
def official_parser_pre_09(lx_doc):
  off_row = lx_doc.xpath('//td[contains(text(),"Referee")]')[0].xpath('..')[0]
  

# Path: nhlscrapi/_tools.py
# def exclude_from(l, containing = [], equal_to = []):
#     """Exclude elements in list l containing any elements from list ex.
#     Example:
#         >>> l = ['bob', 'r', 'rob\r', '\r\nrobert']
#         >>> containing = ['\n', '\r']
#         >>> equal_to = ['r']
#         >>> exclude_from(l, containing, equal_to)
#         ['bob']
#     """
#       
#     cont = lambda li: any(c in li for c in containing)
#     eq = lambda li: any(e == li for e in equal_to)
#     return [li for li in l if not (cont(li) or eq(li))]


# Path: nhlscrapi/scrapr/officialsparser.py
from nhlscrapi._tools import exclude_from as ex_junk

  return num, name
    
def __make_dict(o):
  d = { }
  for oi in o:
    num, name = __num_name(oi)
    if num in d:
      num = max(d.keys())+1
        
    d[num] = name
        
  return d


def __format_out(refs, lines):
  offs = { 'refs': { }, 'linesman': { } }
  if refs:
    offs['refs'] = __make_dict(refs)
  
  if lines:
    offs['linesman'] = __make_dict(lines)
  
  return offs



# layout of officials seasons <= 2009
def official_parser_pre_09(lx_doc):
  off_row = lx_doc.xpath('//td[contains(text(),"Referee")]')[0].xpath('..')[0]
  

  refs = ex_junk(off_row[1].xpath('.//text()'))