Skip to content

Commit

Permalink
Updates to cache to try to fix some dumb ass shit
Browse files Browse the repository at this point in the history
  • Loading branch information
LyamBRS committed May 11, 2023
1 parent 7175365 commit f16344c
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Libraries/BRS_Python_Libraries
29 changes: 22 additions & 7 deletions Programs/Local/FileHandler/Cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,26 @@ def Load() -> bool:
Cache.jsonData = JSONdata("Cache", path)
if(Cache.jsonData.jsonData == None):
Debug.Error("FAILED TO LOAD EXISTING JSON CACHE")
Cache.loaded = False
Debug.End()
return True
else:
Debug.Log("JSONdata loaded from existing cache")
Cache.SetDate("Open")

# Cache has been loaded. External cache values may be loaded from now on.
Cache.loaded = True
else:
Debug.Log("No JSON files were found.")
Debug.Log("Creating Cache.json")
Cache.CreateNew()

# Cache has been loaded. External cache values may be loaded from now on.
Cache.loaded = True
if(Cache.CreateNew()):
Debug.Error("FILE COULD NOT BE CREATED")
Cache.loaded = False
Debug.End()
return True
else:
Debug.Log("A new cache file was created and loaded.")
Cache.loaded = True

# Load cached theme
if(Cache.LoadTheme()):
Expand All @@ -123,7 +131,7 @@ def Load() -> bool:
Debug.Log("Cached language loaded")
Debug.End()
#-----------------------------------------------------------------
def CreateNew():
def CreateNew() -> bool:
"""
CreateNew:
----------
Expand All @@ -133,6 +141,11 @@ def CreateNew():
It will attempt to create it no matter what happens, potentially crashing the application in the event
where it absolutely cannot be created at all.
Returns:
--------
- `True`: Error occured
- `False` : Worked.
"""
Debug.Start("Cache: CreateNew")
Cache.jsonData = JSONdata("Cache",AppendPath(os.getcwd(), "/Local/Cache/"))
Expand All @@ -142,10 +155,12 @@ def CreateNew():
Debug.Log("File created successfully")
Cache.SetDate("Creation")
Cache.SetDate("Open")
Debug.End()
return False
else:
Debug.Error("FAILED TO CREATE JSON FILE")
Debug.End()
pass
Debug.End()
return True
#-----------------------------------------------------------------
def SaveFile():
"""
Expand Down
Binary file modified Programs/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
127 changes: 84 additions & 43 deletions Test2.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,87 @@
from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.button import MDFloatingActionButton

KV = '''
MDScreen:
md_bg_color: "#f7f2fa"
MDBoxLayout:
id: box
spacing: "56dp"
adaptive_size: True
pos_hint: {"center_x": .5, "center_y": .5}
'''


class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Orange"
self.theme_cls.material_style = "M3"
return Builder.load_string(KV)

def on_start(self):
data = {
"standard": {"md_bg_color": "#fefbff", "text_color": "#6851a5"},
"small": {"md_bg_color": "#e9dff7", "text_color": "#211c29"},
"large": {"md_bg_color": "#f8d7e3", "text_color": "#311021"},
}
for type_button in data.keys():
self.root.ids.box.add_widget(
MDFloatingActionButton(
icon="pencil",
type=type_button,
theme_icon_color="Custom",
md_bg_color=data[type_button]["md_bg_color"],
icon_color=data[type_button]["text_color"],
)
)


Example().run()
import os
import ast

directory = os.getcwd()
used_libraries = set()

def check_file_for_libraries(file_path):
with open(file_path, "r") as file:
tree = ast.parse(file.read())

for node in ast.walk(tree):
if isinstance(node, ast.Import):
for name in node.names:
if name.name == "git":
used_libraries.add("gitpython")
if name.name == "github":
used_libraries.add("PyGitHub")

# Recursive iteration through files in the directory
for root, _, files in os.walk(directory):
for file_name in files:
print(f"CHECKING >>> {file_name}")
if file_name.endswith(".py"): # Process only Python files
file_path = os.path.join(root, file_name)
check_file_for_libraries(file_path)

print("\n")
print(used_libraries)













# from kivy.lang import Builder
#
# from kivymd.app import MDApp
# from kivymd.uix.button import MDFloatingActionButton
#
# KV = '''
# MDScreen:
# md_bg_color: "#f7f2fa"
#
# MDBoxLayout:
# id: box
# spacing: "56dp"
# adaptive_size: True
# pos_hint: {"center_x": .5, "center_y": .5}
# '''
#
#
# class Example(MDApp):
# def build(self):
# self.theme_cls.theme_style = "Dark"
# self.theme_cls.primary_palette = "Orange"
# self.theme_cls.material_style = "M3"
# return Builder.load_string(KV)
#
# def on_start(self):
# data = {
# "standard": {"md_bg_color": "#fefbff", "text_color": "#6851a5"},
# "small": {"md_bg_color": "#e9dff7", "text_color": "#211c29"},
# "large": {"md_bg_color": "#f8d7e3", "text_color": "#311021"},
# }
# for type_button in data.keys():
# self.root.ids.box.add_widget(
# MDFloatingActionButton(
# icon="pencil",
# type=type_button,
# theme_icon_color="Custom",
# md_bg_color=data[type_button]["md_bg_color"],
# icon_color=data[type_button]["text_color"],
# )
# )
#
#
# Example().run()

#fakeNetwork = """
#Interface name : Wi-Fi
Expand Down

0 comments on commit f16344c

Please sign in to comment.