Update the host and website information provided in the README JSON data. Parameters ---------- readme_file : str The name of the README file to update. readme_updates : kwargs Dictionary providing additional JSON fields to update before saving the data.
(readme_file, **readme_updates)
| 1355 | |
| 1356 | |
| 1357 | def update_readme_data(readme_file, **readme_updates): |
| 1358 | """ |
| 1359 | Update the host and website information provided in the README JSON data. |
| 1360 | |
| 1361 | Parameters |
| 1362 | ---------- |
| 1363 | readme_file : str |
| 1364 | The name of the README file to update. |
| 1365 | readme_updates : kwargs |
| 1366 | Dictionary providing additional JSON fields to update before |
| 1367 | saving the data. Currently, those fields are: |
| 1368 | |
| 1369 | 1) extensions |
| 1370 | 2) sourcesdata |
| 1371 | 3) numberofrules |
| 1372 | 4) outputsubfolder |
| 1373 | 5) nounifiedhosts |
| 1374 | """ |
| 1375 | |
| 1376 | extensions_key = "base" |
| 1377 | extensions = readme_updates["extensions"] |
| 1378 | nounifiedhosts = readme_updates["nounifiedhosts"] |
| 1379 | |
| 1380 | if extensions: |
| 1381 | extensions_key = "-".join(extensions) |
| 1382 | if nounifiedhosts: |
| 1383 | extensions_key = extensions_key + "-only" |
| 1384 | |
| 1385 | output_folder = readme_updates["outputsubfolder"] |
| 1386 | generation_data = { |
| 1387 | "location": path_join_robust(output_folder, ""), |
| 1388 | "nounifiedhosts": nounifiedhosts, |
| 1389 | "entries": readme_updates["numberofrules"], |
| 1390 | "sourcesdata": readme_updates["sourcesdata"], |
| 1391 | } |
| 1392 | |
| 1393 | with open(readme_file, "r") as f: |
| 1394 | readme_data = json.load(f) |
| 1395 | readme_data[extensions_key] = generation_data |
| 1396 | |
| 1397 | for denomination, data in readme_data.copy().items(): |
| 1398 | if "location" in data and data["location"] and "\\" in data["location"]: |
| 1399 | # Windows compatibility: #1166 |
| 1400 | readme_data[denomination]["location"] = data["location"].replace("\\", "/") |
| 1401 | |
| 1402 | with open(readme_file, "w") as f: |
| 1403 | json.dump(readme_data, f) |
| 1404 | |
| 1405 | |
| 1406 | def move_hosts_file_into_place(finalfile): |