Skip to content

Commit

Permalink
Changed the internal root directory as it was not true after installa…
Browse files Browse the repository at this point in the history
…tion of the package. The Scripts have now another root than the rest which should be changed later
  • Loading branch information
ArJaVer committed Oct 15, 2024
1 parent 5136cc7 commit 4949077
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 39 deletions.
1 change: 1 addition & 0 deletions scripts/convert_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from PyQt6 import uic

# Define paths
# This is a different root than the one in the original script
root = pathlib.Path(__file__).resolve().parents[1]
ui_dir = root / 'src/evaluix/GUIs'
output_dir = ui_dir # Output directory is the same as the input directory
Expand Down
1 change: 1 addition & 0 deletions scripts/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import pathlib

# This is a different root than the one in the original script
root = pathlib.Path(__file__).resolve().parents[1]
version_file = root / 'src/evaluix' / '__version__.py'

Expand Down
10 changes: 5 additions & 5 deletions src/evaluix/GUIs/CustomWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@


#paths
root = pathlib.Path(__file__).resolve().parents[3]
root = pathlib.Path(__file__).resolve().parents[1]

QDir.addSearchPath('icons', str(root / 'src/evaluix/Icons'))
QDir.addSearchPath('icons', str(root / 'Icons'))

with open(root / 'src/evaluix/utils' / 'EvaluixConfig.yaml', 'r') as file:
with open(root / 'utils' / 'EvaluixConfig.yaml', 'r') as file:
config = yaml.safe_load(file)

with open(root / 'src/evaluix/utils' / 'Macros.yaml', 'r') as file:
with open(root / 'utils' / 'Macros.yaml', 'r') as file:
macros = yaml.safe_load(file)

class ClickableMenu(QMenu):
Expand Down Expand Up @@ -122,7 +122,7 @@ def paintEvent(self, event):
# Draw the info icon in the info region
def paintIcon(self):
painter = QPainter(self)
pixmap = QPixmap(str(root / "src/evaluix/Icons" / "icon_infosettings_cropped.png")) # Load the image
pixmap = QPixmap(str(root / "Icons" / "icon_infosettings_cropped.png")) # Load the image
painter.drawPixmap(self.info_rect, pixmap) # Draw the image in the info region

# Handle the mouse press event region dependently
Expand Down
13 changes: 7 additions & 6 deletions src/evaluix/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,18 @@
from .utils.EvaluationFunctions import *

#paths
own_path = pathlib.Path(__file__).resolve().parents[1]
root = pathlib.Path(__file__).resolve().parents[0]
print(root)

QDir.addSearchPath('icons', str(own_path / 'Icons'))
QDir.addSearchPath('icons', str(root / 'Icons'))


def load_config(path):
with open(path, 'r') as file:
return yaml.safe_load(file)

EvaluixConfig = load_config(own_path / 'evaluix/utils' / 'EvaluixConfig.yaml')
ProfileConfig = load_config(own_path / 'evaluix/utils' / 'DefaultProfile.yaml')
EvaluixConfig = load_config(root / 'utils' / 'EvaluixConfig.yaml')
ProfileConfig = load_config(root / 'utils' / 'DefaultProfile.yaml')


#TODO: Create just one update function for everything (table_metadata, table_datapkg, table_data, tabl
Expand Down Expand Up @@ -3081,7 +3082,7 @@ def load_profile(self):
# Update EvaluixConfig with the new profile file
EvaluixConfig['ProfileConfig'] = filename
# Save the updated EvaluixConfig to the config file
with open(own_path / 'EvaluixConfig.yaml', 'w') as file:
with open(root / 'utils' / 'EvaluixConfig.yaml', 'w') as file:
yaml.dump(EvaluixConfig, file)

# Load the new profile file
Expand Down Expand Up @@ -3466,7 +3467,7 @@ def main():
window.show()
app.exec()
except Exception as e:
with open(own_path / 'log.txt', 'a') as f:
with open(root / 'logs' / 'log.txt', 'a') as f:
f.write(str(e))
f.write(traceback.format_exc())
raise e
Expand Down
2 changes: 1 addition & 1 deletion src/evaluix/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.1.26"
__version__ = "0.9.1.27"
8 changes: 4 additions & 4 deletions src/evaluix/utils/CreateEvaluixConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def create_evaluix_config():
import pathlib

# Path to the __version__.py file
root = pathlib.Path(__file__).resolve().parents[3]
version_file = root / 'src/evaluix' / '__version__.py'
root = pathlib.Path(__file__).resolve().parents[1]
version_file = root / '__version__.py'

# Import the EvaluationFunctions module
try:
Expand Down Expand Up @@ -221,14 +221,14 @@ def get_function_info(func):
}

# Export to EvaluixConfig.yaml
with open(root / 'src/evaluix/utils' / 'EvaluixConfig.yaml', 'w') as file:
with open(root / 'utils' / 'EvaluixConfig.yaml', 'w') as file:
yaml.dump({'Version': AboutEvaluix['Version']}, file)
yaml.dump({'EvaluixConfig': AboutEvaluix['EvaluixConfig']}, file)
yaml.dump({'ProfileConfig': AboutEvaluix['ProfileConfig']}, file)
yaml.dump(conversion_factors, file)

# Export to DefaultProfile.yaml
with open(root / 'src/evaluix/utils' / 'DefaultProfile.yaml', 'w') as file:
with open(root / 'utils' / 'DefaultProfile.yaml', 'w') as file:
yaml.dump({'Autosave_status': AboutEvaluix['Autosave_status']}, file)
yaml.dump({'Macros': DefaultMacros}, file)
yaml.dump({'function_info': function_info}, file)
2 changes: 1 addition & 1 deletion src/evaluix/utils/EvaluixConfig.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version: '"0.9.1.24"'
Version: '"0.9.1.26"'
EvaluixConfig: EvaluixConfig.yaml
ProfileConfig: DefaultProfile.yaml
conversion_factors:
Expand Down
4 changes: 2 additions & 2 deletions src/evaluix/utils/FileLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
###########################################
# Define a logger for this module
###########################################
own_path = pathlib.Path(__file__).parent.absolute()
root = pathlib.Path(__file__).resolve.parents[1]
logger_name = __name__

# Create a logger for extensive file logging
Expand All @@ -49,7 +49,7 @@
date_str = datetime.date.today().strftime('%Y-%m-%d')

# Create a file handler and set its level to DEBUG
fh = logging.FileHandler(own_path / f'logger_{date_str}.log')
fh = logging.FileHandler(root / 'logs' / f'logger_{date_str}.log')
fh.setLevel(logging.DEBUG)

# Create a console handler and set its level to INFO
Expand Down
20 changes: 0 additions & 20 deletions src/evaluix/utils/logger_2024-10-15.log

This file was deleted.

0 comments on commit 4949077

Please sign in to comment.