Skip to content

Commit

Permalink
Add rtd module with support for enabling pr builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 3, 2023
1 parent 0ef2bcb commit 8553b77
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions jaraco/develop/rtd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import functools

import keyring
from requests_toolbelt import sessions


url = 'https://api.readthedocs.org/'


@functools.lru_cache()
def session():
auth = 'Token ' + keyring.get_password(url, 'token')
session = sessions.BaseUrlSession(url + 'api/v3/')
session.headers = dict(Authorization=auth)
return session


def enable_pr_build(project):
slug = project.replace('.', '').replace('_', '-')
session().patch(f'projects/{slug}/', data=dict(external_builds_enabled=True))

0 comments on commit 8553b77

Please sign in to comment.