From 503a11739652038d9bee47ef6e091e6821176666 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Fri, 3 Jul 2020 18:05:49 +0200 Subject: [PATCH] Remove utils section Moved the last script in there to ESMValTool --- doc/gensidebar.py | 1 - doc/utils.rst | 12 --- esmvalcore/utils/__init__.py | 0 esmvalcore/utils/draft_release_notes.py | 99 ------------------------- 4 files changed, 112 deletions(-) delete mode 100644 doc/utils.rst delete mode 100644 esmvalcore/utils/__init__.py delete mode 100644 esmvalcore/utils/draft_release_notes.py diff --git a/doc/gensidebar.py b/doc/gensidebar.py index ac527f8da8..a076f9df59 100644 --- a/doc/gensidebar.py +++ b/doc/gensidebar.py @@ -76,7 +76,6 @@ def _header(project, text): _write("esmvalcore", "Diagnostic script interfaces", "interfaces") _write("esmvalcore", "Development", "develop/index") _write("esmvalcore", "Contributing", "contributing") - _write("esmvalcore", "Utilities", "utils") _write("esmvalcore", "ESMValCore API Reference", "api/esmvalcore") _write("esmvalcore", "Changelog", "changelog") _endl() diff --git a/doc/utils.rst b/doc/utils.rst deleted file mode 100644 index a27244e6cc..0000000000 --- a/doc/utils.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. _utils: - -Utilities -********* - -This section provides information on small tools that are available in the ``esmvalcore/utils`` directory. - - -draft_release_notes.py -====================== - -Script for drafting release notes based on the titles of the GitHub pull requests that have been merged since the previous release. diff --git a/esmvalcore/utils/__init__.py b/esmvalcore/utils/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/esmvalcore/utils/draft_release_notes.py b/esmvalcore/utils/draft_release_notes.py deleted file mode 100644 index ad3af567b4..0000000000 --- a/esmvalcore/utils/draft_release_notes.py +++ /dev/null @@ -1,99 +0,0 @@ -"""Draft release notes. - -To use this tool, follow these steps: -1) `pip install pygithub` -2) Create an access token and store it in the file ~/.github_api_key, see: -https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line -3) set PREVIOUS_RELEASE to the date/time of the previous release in code below - -""" -import datetime -from pathlib import Path - -try: - from github import Github -except ImportError: - print("Please `pip install pygithub`") - -try: - GITHUB_API_KEY = Path("~/.github_api_key").expanduser().read_text().strip() -except FileNotFoundError: - print("Please create an access token and store it in the file " - "~/.github_api_key, see:\nhttps://help.github.com/en/github/" - "authenticating-to-github/creating-a-personal-access-token-" - "for-the-command-line") - -from esmvalcore import __version__ - -VERSION = f"v{__version__}" -GITHUB_REPO = "ESMValGroup/ESMValCore" - -TITLES = { - 'bug': 'Bug fixes', - 'enhancement': 'Improvements', -} - - -def draft_notes_since(previous_release_date, labels): - """Draft release notes containing the merged pull requests. - - Arguments - --------- - previous_release_date: datetime.datetime - date of the previous release - labels: list - list of GitHub labels that deserve separate sections - """ - session = Github(GITHUB_API_KEY) - repo = session.get_repo(GITHUB_REPO) - pulls = repo.get_pulls( - state='closed', - sort='updated', - direction='desc', - ) - - lines = {} - for pull in pulls: - if pull.merged: - if pull.closed_at < previous_release_date: - break - pr_labels = {label.name for label in pull.labels} - for label in labels: - if label in pr_labels: - break - else: - label = 'enhancement' - - user = pull.user - username = user.login if user.name is None else user.name - line = ( - f"- {pull.title} (`#{pull.number} " - f"`__) " - f"`{username} `__") - if label not in lines: - lines[label] = [] - lines[label].append((pull.closed_at, line)) - - # Create sections - sections = [ - VERSION, - '-' * len(VERSION), - '', - "This release includes", - ] - for label in sorted(lines): - entries = sorted(lines[label]) # sort by merge time - label = TITLES.get(label, label) - sections.append('\n'.join(['', label, '~' * len(label), ''])) - sections.append('\n'.join(entry for _, entry in entries)) - notes = '\n'.join(sections) - - print(notes) - - -if __name__ == '__main__': - - PREVIOUS_RELEASE = datetime.datetime(2020, 3, 6) - LABELS = ('bug', 'fix for dataset') - - draft_notes_since(PREVIOUS_RELEASE, LABELS)