[rtems-central commit] items: Simplify code

Sebastian Huber sebh at rtems.org
Thu Jul 28 09:47:00 UTC 2022


Module:    rtems-central
Branch:    master
Commit:    bb633e29ea74428e0d278c865e098c6822d9c145
Changeset: http://git.rtems.org/rtems-central/commit/?id=bb633e29ea74428e0d278c865e098c6822d9c145

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jul 28 11:53:19 2022 +0200

items: Simplify code

---

 rtemsspec/items.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/rtemsspec/items.py b/rtemsspec/items.py
index 503a92c8..b8846d5a 100644
--- a/rtemsspec/items.py
+++ b/rtemsspec/items.py
@@ -742,9 +742,8 @@ class ItemCache:
             if name.endswith(".yml") and not name.startswith("."):
                 if not update_cache:
                     update_cache = mtime <= os.path.getmtime(path2)
-            else:
-                if stat.S_ISDIR(os.lstat(path2).st_mode):
-                    self._load_items_recursive(index, base, path2, cache_dir)
+            elif stat.S_ISDIR(os.lstat(path2).st_mode):
+                self._load_items_recursive(index, base, path2, cache_dir)
         self._load_items_in_dir(base, path, cache_file, update_cache)
 
     def _load_items(self, config: Any):
@@ -811,9 +810,8 @@ class JSONItemCache(ItemCache):
             if name.endswith(".json") and not name.startswith("."):
                 uid = "/" + os.path.relpath(path2, base).replace(".json", "")
                 self._add_item(uid, _load_json_data(path2, uid))
-            else:
-                if stat.S_ISDIR(os.lstat(path2).st_mode):
-                    self._load_json_items(base, path2)
+            elif stat.S_ISDIR(os.lstat(path2).st_mode):
+                self._load_json_items(base, path2)
 
     def _load_items(self, config: Any):
         for path in config["paths"]:



More information about the vc mailing list