示例#1
0
 async def get_entities(self, entity: str):
     """
         This loads the entity from the saved manifest
     """
     json_io = JsonIO(cog_data_path(self) / f"{entity}.json")
     data = json_io._load_json()
     return data
示例#2
0
def list_instances():
    if not config_file.exists():
        print("No instances have been configured! Configure one "
              "using `redbot-setup` before trying to run the bot!")
        sys.exit(1)
    else:
        data = JsonIO(config_file)._load_json()
        text = "Configured Instances:\n\n"
        for instance_name in sorted(data.keys()):
            text += "{}\n".format(instance_name)
        print(text)
        sys.exit(0)
示例#3
0
def save_config(name, data, remove=False):
    config = load_existing_config()
    if remove and name in config:
        config.pop(name)
    else:
        if name in config:
            print("WARNING: An instance already exists with this name. "
                  "Continuing will overwrite the existing instance config.")
            if not confirm(
                    "Are you absolutely certain you want to continue (y/n)? "):
                print("Not continuing")
                sys.exit(0)
        config[name] = data
    JsonIO(config_file)._save_json(config)
示例#4
0
def load_existing_config():
    if not config_file.exists():
        return {}

    return JsonIO(config_file)._load_json()