nodes: 0, module; 1, function_definition; 2, function_name:from_dir; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:top; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:exts; 14, None; 15, identifier:exclude_dirs; 16, string:"_*"; 17, comment:"""
          Find all pseudos in the directory tree starting from top.
  
          Args:
              top: Top of the directory tree
              exts: List of files extensions. if exts == "all_files"
                      we try to open all files in top
              exclude_dirs: Wildcard used to exclude directories.
  
          return: :class:`PseudoTable` sorted by atomic number Z.
          """; 18, assignment; 19, comparison_operator:exts == "all_files"; 20, block; 21, else_clause; 22, call; 23, identifier:pseudos; 24, list; 25, identifier:exts; 26, string:"all_files"; 27, for_statement; 28, if_statement; 29, expression_statement; 30, block; 31, attribute; 32, argument_list; 33, identifier:f; 34, list_comprehension; 35, block; 36, not_operator; 37, block; 38, call; 39, if_statement; 40, for_statement; 41, call; 42, identifier:sort_by_z; 43, call; 44, for_in_clause; 45, if_statement; 46, identifier:pseudos; 47, expression_statement; 48, return_statement; 49, attribute; 50, argument_list; 51, comparison_operator:exts is None; 52, block; 53, identifier:p; 54, call; 55, block; 56, identifier:cls; 57, argument_list; 58, attribute; 59, argument_list; 60, identifier:fn; 61, call; 62, call; 63, block; 64, call; 65, None; 66, identifier:logger; 67, identifier:info; 68, binary_operator:'Creating PseudoTable with %i pseudopotentials' % len(pseudos); 69, identifier:exts; 70, None; 71, expression_statement; 72, identifier:find_exts; 73, argument_list; 74, try_statement; 75, identifier:pseudos; 76, attribute; 77, identifier:join; 78, identifier:top; 79, identifier:fn; 80, attribute; 81, argument_list; 82, attribute; 83, argument_list; 84, try_statement; 85, attribute; 86, argument_list; 87, string; 88, call; 89, assignment; 90, identifier:top; 91, identifier:exts; 92, keyword_argument; 93, block; 94, except_clause; 95, identifier:os; 96, identifier:path; 97, identifier:os; 98, identifier:listdir; 99, identifier:top; 100, attribute; 101, identifier:isfile; 102, identifier:f; 103, block; 104, except_clause; 105, identifier:logger; 106, identifier:warning; 107, binary_operator:'No pseudopotentials parsed from folder %s' % top; 108, string_content:Creating PseudoTable with %i pseudopotentials; 109, identifier:len; 110, argument_list; 111, identifier:exts; 112, tuple; 113, identifier:exclude_dirs; 114, identifier:exclude_dirs; 115, expression_statement; 116, as_pattern; 117, block; 118, identifier:os; 119, identifier:path; 120, expression_statement; 121, if_statement; 122, block; 123, string; 124, identifier:top; 125, identifier:pseudos; 126, string:"psp8"; 127, call; 128, identifier:Exception; 129, as_pattern_target; 130, expression_statement; 131, assignment; 132, identifier:p; 133, block; 134, else_clause; 135, expression_statement; 136, string_content:No pseudopotentials parsed from folder %s; 137, attribute; 138, argument_list; 139, identifier:exc; 140, call; 141, identifier:p; 142, call; 143, expression_statement; 144, block; 145, call; 146, identifier:pseudos; 147, identifier:append; 148, call; 149, attribute; 150, argument_list; 151, attribute; 152, argument_list; 153, call; 154, expression_statement; 155, attribute; 156, argument_list; 157, attribute; 158, argument_list; 159, identifier:logger; 160, identifier:critical; 161, binary_operator:"Error in %s:\n%s" % (p, exc); 162, identifier:Pseudo; 163, identifier:from_file; 164, identifier:f; 165, attribute; 166, argument_list; 167, call; 168, identifier:logger; 169, identifier:info; 170, binary_operator:'Skipping file %s' % f; 171, identifier:Pseudo; 172, identifier:from_file; 173, identifier:p; 174, string:"Error in %s:\n%s"; 175, tuple; 176, identifier:pseudos; 177, identifier:append; 178, identifier:p; 179, attribute; 180, argument_list; 181, string; 182, identifier:f; 183, identifier:p; 184, identifier:exc; 185, identifier:logger; 186, identifier:info; 187, binary_operator:'Skipping file %s' % f; 188, string_content:Skipping file %s; 189, string; 190, identifier:f; 191, string_content:Skipping file %s
code: def from_dir(cls, top, exts=None, exclude_dirs="_*"):
          """
          Find all pseudos in the directory tree starting from top.
  
          Args:
              top: Top of the directory tree
              exts: List of files extensions. if exts == "all_files"
                      we try to open all files in top
              exclude_dirs: Wildcard used to exclude directories.
  
          return: :class:`PseudoTable` sorted by atomic number Z.
          """
          pseudos = []
  
          if exts == "all_files":
              for f in [os.path.join(top, fn) for fn in os.listdir(top)]:
                  if os.path.isfile(f):
                      try:
                          p = Pseudo.from_file(f)
                          if p:
                              pseudos.append(p)
                          else:
                              logger.info('Skipping file %s' % f)
                      except:
                          logger.info('Skipping file %s' % f)
              if not pseudos:
                  logger.warning('No pseudopotentials parsed from folder %s' % top)
                  return None
              logger.info('Creating PseudoTable with %i pseudopotentials' % len(pseudos))
  
          else:
              if exts is None: exts=("psp8",)
  
              for p in find_exts(top, exts, exclude_dirs=exclude_dirs):
                  try:
                      pseudos.append(Pseudo.from_file(p))
                  except Exception as exc:
                      logger.critical("Error in %s:\n%s" % (p, exc))
  
          return cls(pseudos).sort_by_z()