m-aciek / python-docs-weblate

Python docs on Weblate POC
0 stars 0 forks source link

Programmatically clear out contributor agreement for components #11

Closed m-aciek closed 1 year ago

m-aciek commented 1 year ago

https://github.com/python/python-docs-pl/issues/21#issuecomment-1613130623

Manually clearing out the bugs component didn't clear out the field for the rest of them. There is more than 500 components, we need to programatically clear them out.

Related to https://github.com/WeblateOrg/weblate/issues/6152.

Potentially needs exposing contributor agreement in wlc Python API.

m-aciek commented 1 year ago

Done with following script:

from os import getenv

from tqdm import tqdm
from wlc import Weblate, Project

def _clear_agreements(weblate_key: str) -> None:
    weblate = Weblate(weblate_key, 'https://hosted.weblate.org/api/')
    project = Project(weblate, 'https://hosted.weblate.org/api/projects/python-docs/')
    for component in tqdm(project.list()):
        if component.agreement:
            component.patch(agreement='')

if __name__ == "__main__":
    _clear_agreements(weblate_key=getenv('KEY'))

And https://github.com/WeblateOrg/wlc/pull/479.