nodes: 0, module; 1, function_definition; 2, function_name:collect_backups; 3, parameters; 4, block; 5, identifier:self; 6, identifier:location; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, if_statement; 14, return_statement; 15, comment:"""
          Collect the backups at the given location.
  
          :param location: Any value accepted by :func:`coerce_location()`.
          :returns: A sorted :class:`list` of :class:`Backup` objects (the
                    backups are sorted by their date).
          :raises: :exc:`~exceptions.ValueError` when the given directory doesn't
                   exist or isn't readable.
          """; 16, assignment; 17, assignment; 18, call; 19, call; 20, identifier:entry; 21, call; 22, block; 23, identifier:backups; 24, block; 25, call; 26, identifier:backups; 27, list; 28, identifier:location; 29, call; 30, attribute; 31, argument_list; 32, attribute; 33, argument_list; 34, identifier:natsort; 35, argument_list; 36, expression_statement; 37, if_statement; 38, expression_statement; 39, identifier:sorted; 40, argument_list; 41, identifier:coerce_location; 42, argument_list; 43, identifier:logger; 44, identifier:info; 45, string:"Scanning %s for backups .."; 46, identifier:location; 47, identifier:location; 48, identifier:ensure_readable; 49, call; 50, assignment; 51, identifier:match; 52, block; 53, else_clause; 54, call; 55, identifier:backups; 56, identifier:location; 57, attribute; 58, argument_list; 59, identifier:match; 60, call; 61, if_statement; 62, block; 63, attribute; 64, argument_list; 65, attribute; 66, identifier:list_entries; 67, attribute; 68, attribute; 69, argument_list; 70, boolean_operator; 71, block; 72, elif_clause; 73, else_clause; 74, expression_statement; 75, identifier:logger; 76, identifier:info; 77, string:"Found %i timestamped backups in %s."; 78, call; 79, identifier:location; 80, identifier:location; 81, identifier:context; 82, identifier:location; 83, identifier:directory; 84, identifier:TIMESTAMP_PATTERN; 85, identifier:search; 86, identifier:entry; 87, attribute; 88, call; 89, expression_statement; 90, boolean_operator; 91, block; 92, block; 93, call; 94, identifier:len; 95, argument_list; 96, identifier:self; 97, identifier:exclude_list; 98, identifier:any; 99, generator_expression; 100, call; 101, attribute; 102, not_operator; 103, expression_statement; 104, try_statement; 105, attribute; 106, argument_list; 107, identifier:backups; 108, call; 109, for_in_clause; 110, attribute; 111, argument_list; 112, identifier:self; 113, identifier:include_list; 114, call; 115, call; 116, block; 117, except_clause; 118, identifier:logger; 119, identifier:debug; 120, string:"Failed to match time stamp in filename: %s"; 121, identifier:entry; 122, attribute; 123, argument_list; 124, identifier:p; 125, attribute; 126, identifier:logger; 127, identifier:verbose; 128, string:"Excluded %s (it matched the exclude list)."; 129, identifier:entry; 130, identifier:any; 131, generator_expression; 132, attribute; 133, argument_list; 134, expression_statement; 135, as_pattern; 136, block; 137, identifier:fnmatch; 138, identifier:fnmatch; 139, identifier:entry; 140, identifier:p; 141, identifier:self; 142, identifier:exclude_list; 143, call; 144, for_in_clause; 145, identifier:logger; 146, identifier:verbose; 147, string:"Excluded %s (it didn't match the include list)."; 148, identifier:entry; 149, call; 150, identifier:ValueError; 151, as_pattern_target; 152, expression_statement; 153, attribute; 154, argument_list; 155, identifier:p; 156, attribute; 157, attribute; 158, argument_list; 159, identifier:e; 160, call; 161, identifier:fnmatch; 162, identifier:fnmatch; 163, identifier:entry; 164, identifier:p; 165, identifier:self; 166, identifier:include_list; 167, identifier:backups; 168, identifier:append; 169, call; 170, attribute; 171, argument_list; 172, identifier:Backup; 173, argument_list; 174, identifier:logger; 175, identifier:notice; 176, string:"Ignoring %s due to invalid date (%s)."; 177, identifier:entry; 178, identifier:e; 179, keyword_argument; 180, keyword_argument; 181, identifier:pathname; 182, call; 183, identifier:timestamp; 184, call; 185, attribute; 186, argument_list; 187, attribute; 188, argument_list; 189, attribute; 190, identifier:join; 191, attribute; 192, identifier:entry; 193, identifier:datetime; 194, identifier:datetime; 195, list_splat; 196, identifier:os; 197, identifier:path; 198, identifier:location; 199, identifier:directory; 200, generator_expression; 201, call; 202, for_in_clause; 203, identifier:int; 204, argument_list; 205, identifier:group; 206, call; 207, identifier:group; 208, integer:10; 209, attribute; 210, argument_list; 211, identifier:match; 212, identifier:groups; 213, string; 214, string_content:0
code: def collect_backups(self, location):
          """
          Collect the backups at the given location.
  
          :param location: Any value accepted by :func:`coerce_location()`.
          :returns: A sorted :class:`list` of :class:`Backup` objects (the
                    backups are sorted by their date).
          :raises: :exc:`~exceptions.ValueError` when the given directory doesn't
                   exist or isn't readable.
          """
          backups = []
          location = coerce_location(location)
          logger.info("Scanning %s for backups ..", location)
          location.ensure_readable()
          for entry in natsort(location.context.list_entries(location.directory)):
              match = TIMESTAMP_PATTERN.search(entry)
              if match:
                  if self.exclude_list and any(fnmatch.fnmatch(entry, p) for p in self.exclude_list):
                      logger.verbose("Excluded %s (it matched the exclude list).", entry)
                  elif self.include_list and not any(fnmatch.fnmatch(entry, p) for p in self.include_list):
                      logger.verbose("Excluded %s (it didn't match the include list).", entry)
                  else:
                      try:
                          backups.append(Backup(
                              pathname=os.path.join(location.directory, entry),
                              timestamp=datetime.datetime(*(int(group, 10) for group in match.groups('0'))),
                          ))
                      except ValueError as e:
                          logger.notice("Ignoring %s due to invalid date (%s).", entry, e)
              else:
                  logger.debug("Failed to match time stamp in filename: %s", entry)
          if backups:
              logger.info("Found %i timestamped backups in %s.", len(backups), location)
          return sorted(backups)