original_docstring: Loads top level domain resource for URLs etc.
      Example input file: data/top-level-domain-codes.txt
docstring: Loads top level domain resource for URLs etc.
docstring_tokens: Loads top level domain resource for URLs etc .
code: def load_top_level_domains(filename: Path) -> (List[str], List[str], List[str]):
      """Loads top level domain resource for URLs etc.
      Example input file: data/top-level-domain-codes.txt"""
      top_level_domain_names_with_low_reliability = []
      top_level_domain_names_with_normal_reliability = []
      top_level_domain_names_with_high_reliability = []
      try:
          with open(filename) as f_in:
              line_number = 0
              n_warnings = 0
              n_entries = 0
              for orig_line in f_in:
                  line_number += 1
                  line = ResourceDict.line_without_comment(orig_line)
                  if line.strip() == '':
                      continue
                  if re.match(r'^\uFEFF?\s*(?:#.*)?$', line):  # ignore empty or comment line
                      continue
                  # Check whether cost file line is well-formed. Following call will output specific warnings.
                  valid = double_colon_del_list_validation(line, str(line_number), str(filename),
                                                           valid_slots=['code',
                                                                        'comment',
                                                                        'country-name',
                                                                        'example',
                                                                        'reliability'],
                                                           required_slot_dict={'code': []})
                  if not valid:
                      n_warnings += 1
                      continue
                  if code := slot_value_in_double_colon_del_list(line, 'code'):
                      # country_code = slot_value_in_double_colon_del_list(line, 'country-code')
                      reliability = slot_value_in_double_colon_del_list(line, 'reliability')
                      if reliability == 'low':
                          top_level_domain_names_with_low_reliability.append(code.lower())
                      elif reliability == 'high':
                          top_level_domain_names_with_high_reliability.append(code.lower())
                      else:
                          top_level_domain_names_with_normal_reliability.append(code.lower())
                      n_entries += 1
                  else:
                      log.warning(f'Could not process line {line_number} in {filename}')
              # log.info(f'Loaded {n_entries} entries from {line_number} lines in {filename}')
              top_level_domain_names_with_low_reliability.sort()
              top_level_domain_names_with_normal_reliability.sort()
              top_level_domain_names_with_high_reliability.sort()
      except OSError:
          log.warning(f'Could not open top-level-domain file {filename}')
      return (top_level_domain_names_with_low_reliability,
              top_level_domain_names_with_normal_reliability,
              top_level_domain_names_with_high_reliability)
code_tokens: def load_top_level_domains ( filename : Path ) -> ( List [ str ] , List [ str ] , List [ str ] ) : top_level_domain_names_with_low_reliability = [ ] top_level_domain_names_with_normal_reliability = [ ] top_level_domain_names_with_high_reliability = [ ] try : with open ( filename ) as f_in : line_number = 0 n_warnings = 0 n_entries = 0 for orig_line in f_in : line_number += 1 line = ResourceDict . line_without_comment ( orig_line ) if line . strip ( ) == '' : continue if re . match ( r'^\uFEFF?\s*(?:#.*)?$' , line ) : continue valid = double_colon_del_list_validation ( line , str ( line_number ) , str ( filename ) , valid_slots = [ 'code' , 'comment' , 'country-name' , 'example' , 'reliability' ] , required_slot_dict = { 'code' : [ ] } ) if not valid : n_warnings += 1 continue if code := slot_value_in_double_colon_del_list ( line , 'code' ) : reliability = slot_value_in_double_colon_del_list ( line , 'reliability' ) if reliability == 'low' : top_level_domain_names_with_low_reliability . append ( code . lower ( ) ) elif reliability == 'high' : top_level_domain_names_with_high_reliability . append ( code . lower ( ) ) else : top_level_domain_names_with_normal_reliability . append ( code . lower ( ) ) n_entries += 1 else : log . warning ( f'Could not process line {line_number} in {filename}' ) top_level_domain_names_with_low_reliability . sort ( ) top_level_domain_names_with_normal_reliability . sort ( ) top_level_domain_names_with_high_reliability . sort ( ) except OSError : log . warning ( f'Could not open top-level-domain file {filename}' ) return ( top_level_domain_names_with_low_reliability , top_level_domain_names_with_normal_reliability , top_level_domain_names_with_high_reliability )
short_docstring: Loads top level domain resource for URLs etc.
short_docstring_tokens: Loads top level domain resource for URLs etc .
comment: """Loads top level domain resource for URLs etc.
      Example input file: data/top-level-domain-codes.txt"""$SEP$# ignore empty or comment line$SEP$# Check whether cost file line is well-formed. Following call will output specific warnings.$SEP$# country_code = slot_value_in_double_colon_del_list(line, 'country-code')$SEP$# log.info(f'Loaded {n_entries} entries from {line_number} lines in {filename}')