From 38aa08c5fd23e3f6534e44b6dee110196a70081f Mon Sep 17 00:00:00 2001
From: Lilac <lilac@noreply.bgme.me>
Date: Sat, 2 Mar 2024 05:01:50 +0000
Subject: [PATCH] code-marketplace: auto updated to 1.87.0-2

---
 repo/code-marketplace/PKGBUILD |  4 ++--
 repo/code-marketplace/patch.py | 27 +++++++++++++++++++++++----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/repo/code-marketplace/PKGBUILD b/repo/code-marketplace/PKGBUILD
index 45f1599..e3df5d2 100644
--- a/repo/code-marketplace/PKGBUILD
+++ b/repo/code-marketplace/PKGBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Sainnhe Park <sainnhe@gmail.com>
 pkgname=code-marketplace
 pkgver=1.87.0
-pkgrel=1
+pkgrel=2
 pkgdesc='Enable vscode marketplace in Code OSS'
 arch=('any')
 url='https://marketplace.visualstudio.com/vscode'
@@ -13,7 +13,7 @@ source=('code-marketplace.hook'
         'patch.py'
         'patch.json')
 md5sums=('ce502275aa945985182b51420fc6037c'
-         'f11f7ccd925de0398ef2e28b127bb063'
+         '9ed6f3972479ab6d3d053e7c47ead55a'
          '9c508868efde1d84dccd98dc679c95f9')
 
 package() {
diff --git a/repo/code-marketplace/patch.py b/repo/code-marketplace/patch.py
index 8e0cb76..b4710b4 100755
--- a/repo/code-marketplace/patch.py
+++ b/repo/code-marketplace/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()