daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. random_dict = {
  3.     # "image":{
  4.     #     "repository": "nextcloud",
  5.     #         "tag": "15.0.2-apache",
  6.     #         "pullPolicy": "IfNotPresent"
  7.     # },
  8.     # "nameOverride": "",
  9.     # "fullnameOverride": "",
  10.     # "replicatCount": 1,
  11.     # "ingress":{
  12.     #     "enabled": "true",
  13.     #     "annotations": {}
  14.     # },
  15.     "nextcloud":{
  16.         "host": "nextcloud.corp.justin-tech.com",
  17.         "username": "admin",
  18.         "password": "changeme"
  19.     },
  20.     # "internalDatabase":{
  21.     #     "enabled": "true",
  22.     #     "name": "nextcloud"
  23.     # },
  24.     # "externalDatabase":{
  25.     #     "enabled": "false",
  26.     #     "host": "",
  27.     #     "user": "nextcloud",
  28.     #     "password": "",
  29.     #     "database": "nextcloud"
  30.     # },
  31.     "mariadb":{
  32.         "enabled": "true",
  33.         "db":{
  34.             "name": "nextcloud",
  35.             "user": "nextcloud",
  36.             "password": "changeme"
  37.         },
  38.         "persistence":{
  39.             "enabled": "true",
  40.             "storageClass": "nfs-client",
  41.             "accessMode": "changeme",
  42.             "size": "8Gi"
  43.         },
  44.     # },
  45.     # "service":{
  46.     #     "type": "ClusterIP",
  47.     #     "port": "8080",
  48.     #     "loadBalancerIP": "nil"
  49.     # },
  50.     # "persistence":{
  51.     #     "enabled": "true",
  52.     #     "storageClass": "nfs-client",
  53.     #     "accessMode": "ReadWriteOnce",
  54.     #     "size": "8gi"
  55.     }
  56. }
  57.  
  58.  
  59. def recurse(data, pat, item_map, result_dict):
  60.     if isinstance(data, dict):
  61.         for key in data.keys():
  62.             if data[key] == pat:
  63.                 cur_path = item_map + key
  64.                 data[key] = input("Input a dict value: ")
  65.                 # set in here so you can use it later in program with "fully qualified string key"
  66.                 result_dict[cur_path] = data[key]  
  67.             elif type(data[key]) == dict:
  68.                 # prep for going deeper
  69.                 item_map += key+'/'
  70.                 # and pass through
  71.                 recurse(data[key], pat, item_map, result_dict)
  72.             else:
  73.                 recurse(data[key], pat, item_map, result_dict)
  74.  
  75. result_dict = {}
  76. for item in random_dict.keys():
  77.     result_dict[item] ={}
  78.     recurse(random_dict[item], 'changeme','', result_dict[item])
  79.  
  80. print(result_dict)
  81. print(json.dumps(random_dict, indent=4))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top