Zum Inhalt

repo_scanner

repo_scanner scans a journal's harvested XML files for mentions of GitHub repository links (via a regex match on github.\w+/\w+/\w+), and for every match, records which article(s) reference that repository (along with the article's DOI, title, publication year, and authors), into a single JSON file.

Note: It is not a data-processing step in the harvesting pipeline itself.

This is one of the simplest examples in the repo of a read-only analysis script (ie, it never modifies, moves, or deletes anything in the article folders it scans, it only reads and reports). If you need to write a one-off "scan everything and produce a report" script, this is a lighter-weight template than any of the pipeline modules.

Working

  • It walks every .xml file under a given journal directory (os.walk, fully recursive — not scoped to any particular module's output folder).
  • For each XML file containing at least one GitHub-link match, it opens the corresponding metadata-article.json (usually two directory levels up from the XML file) and extracts DOI, title, publication year, and authors, wrapping each field access in its own try/except so a missing field doesn't abort the whole article.
  • It builds a dict keyed by repository URL, with each value being a list of [xml_path, doi, title, year, authors, repo_links] entries for every article that mentioned that repository.
  • Finally, it writes the whole dict to a single JSON file at a fixed output path.