(args)
| 107 | |
| 108 | |
| 109 | def new_main(args): |
| 110 | config_path = get_config_path() |
| 111 | template_path = os.path.join(config_path, "template") |
| 112 | if not os.path.isdir(template_path): |
| 113 | raise IOError("Can't find template configuration directory. Did you install GraphVite correctly?") |
| 114 | |
| 115 | config = "_".join(args.application) + ".yaml" |
| 116 | template = os.path.join(template_path, config) |
| 117 | if args.file: |
| 118 | config = args.file |
| 119 | if os.path.isfile(template): |
| 120 | if os.path.exists(config): |
| 121 | answer = None |
| 122 | while answer not in ["y", "n"]: |
| 123 | answer = input("File `%s` exists. Overwrite? (y/n)" % config) |
| 124 | if answer == "n": |
| 125 | return |
| 126 | shutil.copyfile(template, config) |
| 127 | print("A configuration template has been written into `%s`." % config) |
| 128 | else: |
| 129 | templates = glob.glob(os.path.join(template_path, "*.yaml")) |
| 130 | templates = sorted(templates) |
| 131 | applications = [""] |
| 132 | for template in templates: |
| 133 | application = os.path.splitext(os.path.basename(template))[0] |
| 134 | application = application.replace("_", " ") |
| 135 | applications.append(application) |
| 136 | raise ValueError("Can't find a configuration template for `%s`. Available applications are %s" |
| 137 | % (" ".join(args.application), "\n ".join(applications))) |
| 138 | |
| 139 | |
| 140 | def run_main(args): |
nothing calls this directly
no test coverage detected