fix for name when module is directory

This commit is contained in:
foamyguy 2024-03-02 11:56:25 -06:00
parent ac578b852a
commit 84e048e0ee

View file

@ -275,11 +275,51 @@ class Module:
print(url)
print(url.scheme)
print(f"url.path: {url.path}")
if url.path.endswith("/"):
self.file = None
self.name = url.path.split("/")[-2]
else:
self.file = os.path.basename(url.path)
self.name = os.path.basename(url.path).replace(".py", "").replace(".mpy", "")
#print(f"opb: {os.path.basename(url.path)}")
self.file = os.path.basename(url.path)
self.name = self.file.replace(".py", "").replace(".mpy", "")
print(f"file: {self.file}")
print(f"name: {self.name}")
# if str(url.scheme).lower() in ("http", "https"):
# if url.path.endswith(".py") or url.path.endswith(".mpy"):
# print("isfile")
# self.file = os.path.basename(url.path)
# self.name = (
# os.path.basename(url.path).replace(".py", "").replace(".mpy", "")
# )
# else:
# print("directory")
# self.file = None
# self.name = os.path.basename(
# url.path if url.path[:-1] == "/" else url.path[:-1]
# )
# print(f"file: {self.file}")
# print(f"name: {self.name}")
# else:
#
# print(f"parse: {self.file.parse()}")
# print(f"path b4: {self.path}")
# if os.path.isfile(self.path):
# print("isfile")
# # Single file module.
# self.file = os.path.basename(self.path)
# self.name = self.file.replace(".py", "").replace(".mpy", "")
# else:
# print("directory")
# # Directory based module.
# self.file = None
# self.path = os.path.join(backend.library_path, name, "")
# print(f"file: {self.file}")
# print(f"name: {self.name}")
self.repo = repo
self.device_version = device_version