summarylogtreecommitdiffstats
path: root/patch.py
diff options
context:
space:
mode:
Diffstat (limited to 'patch.py')
-rwxr-xr-xpatch.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/patch.py b/patch.py
index 8e0cb7665ee8..b4710b46f633 100755
--- a/patch.py
+++ b/patch.py
@@ -11,10 +11,27 @@ product_path = "/usr/lib/code/product.json"
patch_path = "/usr/share/%s/patch.json" % pkt_name
cache_path = "/usr/share/%s/cache.json" % pkt_name
+
+class term_colors:
+ WARNING = "\033[93m"
+ ENDC = "\033[0m"
+
+
+if not os.path.exists(product_path):
+ print(
+ term_colors.WARNING
+ + "WARN: "
+ + term_colors.ENDC
+ + product_path
+ + " does not exist. You need to install extra/code in the official repository to use this package. Skipping..."
+ )
+ exit(0)
+
if not os.path.exists(cache_path):
- with open(cache_path, 'w') as file:
+ with open(cache_path, "w") as file:
file.write("{}")
+
def patch():
with open(product_path, "r") as product_file:
product_data = json.load(product_file)
@@ -26,9 +43,10 @@ def patch():
cache_data[key] = product_data[key]
product_data[key] = patch_data[key]
with open(product_path, "w") as product_file:
- json.dump(product_data, product_file, indent='\t')
+ json.dump(product_data, product_file, indent="\t")
with open(cache_path, "w") as cache_file:
- json.dump(cache_data, cache_file, indent='\t')
+ json.dump(cache_data, cache_file, indent="\t")
+
def restore():
with open(product_path, "r") as product_file:
@@ -43,7 +61,8 @@ def restore():
for key in cache_data.keys():
product_data[key] = cache_data[key]
with open(product_path, "w") as product_file:
- json.dump(product_data, product_file, indent='\t')
+ json.dump(product_data, product_file, indent="\t")
+
if operation == "patch":
patch()