mirror of
https://github.com/Findus23/matomo-utils.git
synced 2024-09-19 15:13:44 +02:00
extend mass-edit.py
This commit is contained in:
parent
851f07f9c7
commit
69201340fe
1 changed files with 43 additions and 10 deletions
|
@ -7,6 +7,12 @@ from config import *
|
|||
s = requests.Session()
|
||||
s.headers.update({"Authorization": "Token " + token})
|
||||
|
||||
PROJECT = "matomo" # "matomo-premium-plugins"
|
||||
|
||||
|
||||
def diff_dicts(dict1, dict2):
|
||||
return {key: dict1[key] for key in set(dict1) - set(dict2)}
|
||||
|
||||
|
||||
def lock_component(component, unlock=False):
|
||||
lock = not unlock
|
||||
|
@ -18,7 +24,15 @@ def lock_component(component, unlock=False):
|
|||
|
||||
def update_setting(component, settings: Dict):
|
||||
component_url = component["url"]
|
||||
r = s.patch(component_url, data=settings)
|
||||
r = s.patch(component_url, json=settings)
|
||||
if r.status_code > 200:
|
||||
print(r.json())
|
||||
r.raise_for_status()
|
||||
|
||||
|
||||
def create_addon(component, name, configuration: Dict):
|
||||
component_url = component["url"]
|
||||
r = s.post(component_url + "addons/", json={"name": name, "configuration": configuration})
|
||||
if r.status_code > 200:
|
||||
print(r.json())
|
||||
r.raise_for_status()
|
||||
|
@ -26,7 +40,7 @@ def update_setting(component, settings: Dict):
|
|||
|
||||
components = {}
|
||||
|
||||
r = s.get(url + "projects/matomo/components/")
|
||||
r = s.get(url + f"projects/{PROJECT}/components/")
|
||||
|
||||
data = r.json()
|
||||
count = data["count"]
|
||||
|
@ -45,19 +59,38 @@ phpcomponents = {slug: comp for slug, comp in components.items() if not comp["is
|
|||
|
||||
community_components = {slug: comp for slug, comp in components.items() if "Community" in comp["name"]}
|
||||
|
||||
official_components = {slug: components[slug] for slug in set(phpcomponents) - set(community_components)}
|
||||
official_components = diff_dicts(phpcomponents, community_components)
|
||||
|
||||
core_repo_components = {slug: comp for slug, comp in components.items() if
|
||||
"https://github.com/matomo-org/matomo/" == comp["repo"]}
|
||||
|
||||
for slug, comp in phpcomponents.items():
|
||||
non_core_repo_components = diff_dicts(phpcomponents, core_repo_components)
|
||||
|
||||
|
||||
for slug, comp in community_components.items():
|
||||
print(slug, comp["name"])
|
||||
print(comp["check_flags"])
|
||||
license = comp["license"]
|
||||
if license != "GPL-3.0-or-later":
|
||||
print(license)
|
||||
# print(comp["check_flags"])
|
||||
# license = comp["license"]
|
||||
# if license != "GPL-3.0-or-later":
|
||||
# print(license)
|
||||
update_setting(comp, {
|
||||
"check_flags": "php-format,ignore-optional-plural"
|
||||
"check_flags": "php-format,safe-html,ignore-optional-plural",
|
||||
# "license": "proprietary",
|
||||
"manage_units": False, # Manage strings
|
||||
"enforced_checks": [
|
||||
"php_format"
|
||||
],
|
||||
})
|
||||
# lock_component(comp)
|
||||
if comp["addons"]:
|
||||
print("skipping")
|
||||
continue
|
||||
create_addon(comp, name="weblate.cleanup.blank", configuration={})
|
||||
create_addon(comp, name="weblate.cleanup.generic", configuration={})
|
||||
create_addon(comp, name="weblate.json.customize", configuration={
|
||||
"sort_keys": True,
|
||||
"indent": 4,
|
||||
"style": "spaces"
|
||||
})
|
||||
# lock_component(comp, unlock=True)
|
||||
# print("locked")
|
||||
# exit()
|
||||
|
|
Loading…
Reference in a new issue