Skip to content

Instantly share code, notes, and snippets.

@p3r7
Created February 24, 2023 11:37
Show Gist options
  • Save p3r7/85dcd732d5cb822ef93d5cfde2890a6e to your computer and use it in GitHub Desktop.
Save p3r7/85dcd732d5cb822ef93d5cfde2890a6e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
## ------------------------------------------------------------------------
## imports
import re
import json
from pprint import pprint
import requests
## ------------------------------------------------------------------------
## mode
M_DEBUG = 'DEBUG'
M_DIFF = 'DIFF'
M_REPLACE_TAGS = 'REPLACE_TAGS'
# MODE = M_REPLACE_TAGS
MODE = M_DIFF
## ------------------------------------------------------------------------
## helper fns
## ------------------------------------------------------------------------
## main
r = requests.get('https://raw.githubusercontent.com/monome/norns-community/main/community.json', headers={'Accept': 'application/json'})
r_wiki = requests.get('https://gist.githubusercontent.com/p3r7/2f61ec64954935ab60eae47e828d14ac/raw/62a3d5440d68be03f513456d38de295f5d62a60e/wiki_js_norns_community.json')
script_index = r.json()
script_index_wiki = r_wiki.json()
scripts_in_main_index = []
scripts_in_wiki = list(script_index_wiki.keys())
scripts_only_in_wiki = []
scripts_not_in_wiki = []
for script in script_index['entries']:
name = script['project_name']
scripts_in_main_index.append(name)
tags = []
if 'tags' in script:
tags = script['tags']
if not name in script_index_wiki:
scripts_not_in_wiki.append(name)
continue
script_wiki = script_index_wiki[name]
categories = script_wiki['types']
io_capabilities = script_wiki['features']
wiki_tags = categories + io_capabilities
if MODE == M_DEBUG:
print('-------------------------')
print(name)
print("old tags:")
pprint(tags)
print("new tags (from wiki):")
pprint(wiki_tags)
script['tags'] = wiki_tags
if MODE == M_REPLACE_TAGS:
print(json.dumps(script_index, indent=2))
if MODE == M_DIFF:
scripts_only_in_wiki = set(scripts_in_wiki) - set(scripts_in_main_index)
print("not in wiki: ")
pprint(scripts_not_in_wiki)
print("not in main index (only wiki): ")
pprint(scripts_only_in_wiki)
# pprint(script_index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment