Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ secrets/*
!secrets/.gitkeep
temp/
log/
.vscode

.vscode
.coverage
69 changes: 69 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,74 @@
# Updates

## 1.9.2 get to 90% update

### new things

- Suproting 100%

- Utility 99%
- collor 100%
- deltatime 98%
- UnitConverter 100%
- config manager 100%
- logger 100%
- debug 97%

- Data Prosesing 52%
- csv data pipeline 100%
- filter 96%
- map 91%
- PID 98%
- data swite will not be tested at this moment

- contol softwere
- State machine
- will not be tested at this moment

### bug Fix

- somthing

### changes

- somthing

### breaking changes

- somthing

## 1.9.1 location update

### new things

- Base Unit test
- 100% suporting

### breaking changes

- file structure

## 1.9.0 Test update

### new things

- Unit test
- UnitTestUtilities.py

### bug Fix

- somthing

### changes

- yamlWriter now suports mode=a the right way
- Exsamlpe files now change name to exsample and not test
- all suporting script tests uptated to use the test util

### breaking changes

- Exsample is no longer the main way of testing the code

## 1.8.2 csv update


Expand Down
4 changes: 2 additions & 2 deletions DataProsesing/DataRW.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from ..Suporting.jsonWriter import *
from ..Suporting.yamlWriter import *

#from ..Utility.Debug import Debug
from ..Utility.Debug import Debug


def write_data(file_path,data, **kwargs):

directory = os.path.dirname(file_path)
if directory and not os.path.exists(directory):
os.makedirs(directory, exist_ok=True)
#Debug.log(f"Dir did not exist, created it: {directory}", "Warning", group="WarningError")
Debug.log(f"Dir did not exist, created it: {directory}", "Warning", group="WarningError")

ext = os.path.splitext(file_path)[1].lower()

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ using "import GabesPythonToolBox as GTB" for all
or import "GabesPythonToolBox.Category.lib as (XX)"
That’s it. You're good to go.

### comands
#### unit test
'''
pytest UnitTest -v
'''
#### get filestucture
'''
tree /F /A > folder_tree.txt
'''

## Current Features

### ControllSoftwere
Expand Down
3 changes: 3 additions & 0 deletions Suporting/csvReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def read_csv(file_path, seperator_symbol: str = ',', float_symbol: str = '.', re
# Process each line using the helper
for line in lines:
values = process_line(line, seperator_symbol, float_symbol)
if not values:
Debug.log(f"emty row","Info",group="LIB_Debug")
continue # skip empty lines
row = {header[i]: values[i] for i in range(len(header))}
Debug.log(f"row:\n{row}\n\n","Info",group="LIB_Debug")
data.append(row)
Expand Down
2 changes: 1 addition & 1 deletion Suporting/csvWriterLogger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import copy
import csv

#TODO make it one file again
#this is a direct coppy of csvWriter and oly exsists sice circular import isues

def write_csv(
Expand Down
27 changes: 25 additions & 2 deletions Suporting/jsonWriter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
import json
def write_json(file_path,data,mode: str = 'w'):
import os

def write_json(file_path, data, mode: str = 'w'):
"""
Write a dictionary to a JSON file.
If mode='a', merge with existing JSON content if it is a dict.
"""
if mode == 'a' and os.path.exists(file_path):
# Load existing data
with open(file_path, "r", encoding="utf-8") as f:
try:
existing_data = json.load(f)
except json.JSONDecodeError:
raise ValueError("Existing JSON content is invalid")
if not isinstance(existing_data, dict):
raise TypeError("Existing JSON content is not a dict; cannot merge")

# Merge existing data with new data
existing_data.update(data)
data_to_write = existing_data
mode = 'w' # overwrite with merged content
else:
data_to_write = data

with open(file_path, mode=mode, encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
json.dump(data_to_write, f, indent=4, ensure_ascii=False)
26 changes: 23 additions & 3 deletions Suporting/yamlWriter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import yaml
def write_yaml(file_path,data,mode: str = 'w'):
with open(file_path,mode=mode, encoding="utf-8") as f:
yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True)
import os

def write_yaml(file_path, data, mode: str = 'w'):
"""
Write a dictionary to a YAML file.
If mode='a', merge with existing YAML content if it is a dict.
"""
if mode == 'a' and os.path.exists(file_path):
# Load existing data
with open(file_path, "r", encoding="utf-8") as f:
existing_data = yaml.safe_load(f) or {}
if not isinstance(existing_data, dict):
raise TypeError("Existing YAML content is not a dict; cannot merge")

# Merge existing data with new data
existing_data.update(data)
data_to_write = existing_data
mode = 'w' # Overwrite file with merged content
else:
data_to_write = data

with open(file_path, mode=mode, encoding="utf-8") as f:
yaml.safe_dump(data_to_write, f, sort_keys=False, allow_unicode=True)
Empty file added Tests/FallbackTest/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.ControllSoftwere.StateMachine.BaseState import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.ControllSoftwere.StateMachine.NoneState import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.ControllSoftwere.StateMachine.StateLoader import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.ControllSoftwere.StateMachine.StateManager import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.ControllSoftwere.StateMachine.StateSwitcher import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
9 changes: 9 additions & 0 deletions Tests/UnitTest/DataProsesing/test_DataConsolPrinter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from GabesPythonToolBox.DataProsesing import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True

#ingen ide hvordan teste disse
7 changes: 7 additions & 0 deletions Tests/UnitTest/DataProsesing/test_DataFormater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.DataProsesing import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
7 changes: 7 additions & 0 deletions Tests/UnitTest/DataProsesing/test_DataHelperFunctions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.DataProsesing import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
7 changes: 7 additions & 0 deletions Tests/UnitTest/DataProsesing/test_DataPrettifyer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.DataProsesing import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
7 changes: 7 additions & 0 deletions Tests/UnitTest/DataProsesing/test_DataRW.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
from GabesPythonToolBox.DataProsesing import *
from GabesPythonToolBox.Tests.UnitTestComon.UntTestUtility import Nothing
#TODO

def test_doc():
assert True
Loading
Loading