|
@@ -11,12 +11,11 @@ import os
|
|
import sys
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
+## Finds all JSON files in the given directory recursively and returns a list of those files in absolute paths.
|
|
|
|
+#
|
|
|
|
+# \param work_dir The directory to look for JSON files recursively.
|
|
|
|
+# \return A list of JSON files in absolute paths that are found in the given directory.
|
|
def find_json_files(work_dir: str) -> list:
|
|
def find_json_files(work_dir: str) -> list:
|
|
- """
|
|
|
|
- Finds all JSON files in the given directory recursively and returns a list of those files in absolute paths.
|
|
|
|
- :param work_dir: The directory to look for JSON files recursively.
|
|
|
|
- :return: A list of JSON files in absolute paths that are found in the given directory.
|
|
|
|
- """
|
|
|
|
json_file_list = []
|
|
json_file_list = []
|
|
for root, dir_names, file_names in os.walk(work_dir):
|
|
for root, dir_names, file_names in os.walk(work_dir):
|
|
for file_name in file_names:
|
|
for file_name in file_names:
|
|
@@ -25,13 +24,12 @@ def find_json_files(work_dir: str) -> list:
|
|
return json_file_list
|
|
return json_file_list
|
|
|
|
|
|
|
|
|
|
|
|
+## Removes the given entries from the given JSON file. The file will modified in-place.
|
|
|
|
+#
|
|
|
|
+# \param file_path The JSON file to modify.
|
|
|
|
+# \param entries A list of strings as entries to remove.
|
|
|
|
+# \return None
|
|
def remove_entries_from_json_file(file_path: str, entries: list) -> None:
|
|
def remove_entries_from_json_file(file_path: str, entries: list) -> None:
|
|
- """
|
|
|
|
- Removes the given entries from the given JSON file. The file will modified in-place.
|
|
|
|
- :param file_path: The JSON file to modify.
|
|
|
|
- :param entries: A list of strings as entries to remove.
|
|
|
|
- :return: None
|
|
|
|
- """
|
|
|
|
try:
|
|
try:
|
|
with open(file_path, "r", encoding = "utf-8") as f:
|
|
with open(file_path, "r", encoding = "utf-8") as f:
|
|
package_dict = json.load(f, object_hook = collections.OrderedDict)
|
|
package_dict = json.load(f, object_hook = collections.OrderedDict)
|