text: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  import re
  import sys
  
  from common import find_mapping, load_mapping
  
  filename = find_mapping()
  
  
  error = False
  with open(filename) as handle:
      for line in handle.readlines():
          if not re.match('^"\^[^"]*\$",[0-9a-z/_-]*,(.*)?$', line):
              print("Line does not match defined format: %r." % line, file=sys.stderr)
              error = True
  if error:
      sys.exit(1)
  
  expressions = [line[:2] for line in load_mapping(filename)]
  
  error = False
  for _, family in expressions:
      family_match = False
      for expression, other_family in expressions:
          try:
              if re.match(expression, family):
                  if family != other_family:
                      print('Malware family %r matches to another family %r.' % (family, other_family))
                      error = True
                  else:
                      family_match = True
          except re.error as exc:
              print('Error parsing expression %r: %r' % (expression, exc))
  
      if not family_match:
          print('Family %r is not matched to itself.' % family)
          error = True
  if error:
      sys.exit(1)
  