Update the sources data and information for each source. Parameters ---------- sourcesdata : list The list of sources data that we are to update. sourcesparams : kwargs Dictionary providing additional parameters for updating the sources data. Currently,
(sourcesdata, **sourcesparams)
| 667 | |
| 668 | # Update Logic |
| 669 | def update_sources_data(sourcesdata, **sourcesparams): |
| 670 | """ |
| 671 | Update the sources data and information for each source. |
| 672 | |
| 673 | Parameters |
| 674 | ---------- |
| 675 | sourcesdata : list |
| 676 | The list of sources data that we are to update. |
| 677 | sourcesparams : kwargs |
| 678 | Dictionary providing additional parameters for updating the |
| 679 | sources data. Currently, those fields are: |
| 680 | |
| 681 | 1) datapath |
| 682 | 2) extensions |
| 683 | 3) extensionspath |
| 684 | 4) sourcedatafilename |
| 685 | 5) nounifiedhosts |
| 686 | |
| 687 | Returns |
| 688 | ------- |
| 689 | update_sources_data : list |
| 690 | The original source data list with new source data appended. |
| 691 | """ |
| 692 | |
| 693 | sourcedatafilename = sourcesparams["sourcedatafilename"] |
| 694 | |
| 695 | if not sourcesparams["nounifiedhosts"]: |
| 696 | for source in sort_sources( |
| 697 | recursive_glob(sourcesparams["datapath"], sourcedatafilename) |
| 698 | ): |
| 699 | updatefile = open(source, "r", encoding="UTF-8") |
| 700 | try: |
| 701 | updatedata = json.load(updatefile) |
| 702 | sourcesdata.append(updatedata) |
| 703 | finally: |
| 704 | updatefile.close() |
| 705 | |
| 706 | for source in sourcesparams["extensions"]: |
| 707 | sourcedir = path_join_robust(sourcesparams["extensionspath"], source) |
| 708 | for updatefile_path in sort_sources( |
| 709 | recursive_glob(sourcedir, sourcedatafilename) |
| 710 | ): |
| 711 | updatefile = open(updatefile_path, "r") |
| 712 | try: |
| 713 | updatedata = json.load(updatefile) |
| 714 | sourcesdata.append(updatedata) |
| 715 | finally: |
| 716 | updatefile.close() |
| 717 | |
| 718 | return sourcesdata |
| 719 | |
| 720 | |
| 721 | def jsonarray(json_array_string): |