mirror of
https://github.com/Findus23/matomo-utils.git
synced 2024-09-19 15:13:44 +02:00
improve mass-edit.py
This commit is contained in:
parent
69201340fe
commit
485d3426b5
1 changed files with 42 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
||||||
from typing import Dict
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -38,6 +38,17 @@ def create_addon(component, name, configuration: Dict):
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
def get_addons(addons: List[str]) -> Tuple[Dict[str, int], Dict[str, Dict]]:
|
||||||
|
ids = {}
|
||||||
|
configs = {}
|
||||||
|
for addon in addons:
|
||||||
|
r = s.get(addon)
|
||||||
|
data = r.json()
|
||||||
|
ids[data["name"]] = data["id"]
|
||||||
|
configs[data["name"]] = data["configuration"]
|
||||||
|
return ids, configs
|
||||||
|
|
||||||
|
|
||||||
components = {}
|
components = {}
|
||||||
|
|
||||||
r = s.get(url + f"projects/{PROJECT}/components/")
|
r = s.get(url + f"projects/{PROJECT}/components/")
|
||||||
|
@ -65,32 +76,38 @@ core_repo_components = {slug: comp for slug, comp in components.items() if
|
||||||
"https://github.com/matomo-org/matomo/" == comp["repo"]}
|
"https://github.com/matomo-org/matomo/" == comp["repo"]}
|
||||||
|
|
||||||
non_core_repo_components = diff_dicts(phpcomponents, core_repo_components)
|
non_core_repo_components = diff_dicts(phpcomponents, core_repo_components)
|
||||||
|
non_core_repo_components = diff_dicts(non_core_repo_components, community_components)
|
||||||
|
|
||||||
|
for slug, comp in phpcomponents.items():
|
||||||
for slug, comp in community_components.items():
|
|
||||||
print(slug, comp["name"])
|
print(slug, comp["name"])
|
||||||
# print(comp["check_flags"])
|
addon_ids, addon_configs = get_addons(comp["addons"])
|
||||||
# license = comp["license"]
|
license = comp["license"]
|
||||||
# if license != "GPL-3.0-or-later":
|
if license != "GPL-3.0-or-later":
|
||||||
# print(license)
|
print(license)
|
||||||
update_setting(comp, {
|
# update_setting(comp, {
|
||||||
"check_flags": "php-format,safe-html,ignore-optional-plural",
|
# "check_flags": "php-format,safe-html,ignore-optional-plural",
|
||||||
# "license": "proprietary",
|
# # "license": "proprietary",
|
||||||
"manage_units": False, # Manage strings
|
# "manage_units": False, # Manage strings
|
||||||
"enforced_checks": [
|
# "edit_template": True,
|
||||||
"php_format"
|
# "enforced_checks": [
|
||||||
],
|
# "php_format"
|
||||||
})
|
# ],
|
||||||
if comp["addons"]:
|
# })
|
||||||
print("skipping")
|
# create_addon(comp, name="weblate.cleanup.blank", configuration={})
|
||||||
continue
|
# create_addon(comp, name="weblate.cleanup.generic", configuration={})
|
||||||
create_addon(comp, name="weblate.cleanup.blank", configuration={})
|
# create_addon(comp, name="weblate.json.customize", configuration={
|
||||||
create_addon(comp, name="weblate.cleanup.generic", configuration={})
|
# "sort_keys": True,
|
||||||
create_addon(comp, name="weblate.json.customize", configuration={
|
# "indent": 4,
|
||||||
"sort_keys": True,
|
# "style": "spaces"
|
||||||
"indent": 4,
|
# })
|
||||||
"style": "spaces"
|
if "weblate.git.squash" not in addon_ids.keys():
|
||||||
|
print("add addon")
|
||||||
|
create_addon(comp, name="weblate.git.squash", configuration={
|
||||||
|
"squash": "language",
|
||||||
|
"append_trailers": True,
|
||||||
|
"commit_message": ""
|
||||||
})
|
})
|
||||||
|
# input("done\n")
|
||||||
# lock_component(comp, unlock=True)
|
# lock_component(comp, unlock=True)
|
||||||
# print("locked")
|
# print("locked")
|
||||||
# exit()
|
# exit()
|
||||||
|
|
Loading…
Reference in a new issue