Metadata-Version: 2.4
Name: guilite
Version: 0.1.1
Summary: A lightweight, extensible Python library for simulation, reporting, and web-based input/output. Includes automatic web UI, report generation, and support for custom simulators.
Author: Kjell Kolsaker
License: MIT License
        
        Copyright (c) 2025 Kjell Kolsaker
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/kjelkols/guilite
Project-URL: Bug Tracker, https://github.com/kjelkols/guilite/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Flask
Requires-Dist: pydantic>=1.10
Requires-Dist: jinja2
Dynamic: license-file
Dynamic: requires-python


# guilite

Et lettvekts Python-bibliotek for simulering, rapportgenerering og webbasert input/output.

## Installasjon

Installer avhengigheter og biblioteket lokalt:

```bash
pip install .
```

## Grunnleggende bruk

Definer dine egne simulator-klasser ved å arve fra `SimulatorBase` og implementere `run` og `generate_report`.

Eksempel (se også `examples/mysimulator.py`):

```python
from typing import Type
from pydantic import BaseModel, Field
from reportgenerator.simulatorbase import SimulatorBase
from reportgenerator.engine import Engine

class MyInput(BaseModel):
	x: float = Field(1.0, title="X-verdi")
	y: float = Field(2.0, title="Y-verdi")

class MyResult(BaseModel):
	sum: float = Field(..., title="Sum")

class MySimulator(SimulatorBase):
	input_model = MyInput
	result_model = MyResult
	name = "Addisjon"

	@staticmethod
	def run(input_data: BaseModel) -> BaseModel:
		data = input_data if isinstance(input_data, MyInput) else MyInput(**input_data.model_dump())
		return MyResult(sum=data.x + data.y)

	@staticmethod
	def generate_report(input_data: BaseModel, result_data: BaseModel) -> str:
		eng = Engine()
		eng.write_header("Addisjon", level=2)
		eng.write_model(input_data)
		eng.write_model(result_data)
		return eng.get_html()
```

## Starte web-app med egne simulatorer

Se `examples/run_simulator_app.py`:

```python
from reportgenerator.simulatorapp import SimulatorApp
from examples.mysimulator import MySimulator1, MySimulator2

if __name__ == "__main__":
	simulators = {
		"add": MySimulator1,
		"mult": MySimulator2,
	}
	app = SimulatorApp(simulators=simulators)
	app.run(debug=True)
```

Kjør fra prosjektroten:
```bash
python -m examples.run_simulator_app
```

## Funksjoner
- Automatisk webgrensesnitt for input og rapport
- Støtte for flere simulatorer
- Input/rapport kan lastes opp/ned som JSON
- Brukeren trenger ikke forholde seg til Flask eller templates

## Demo og eksempler
Se `examples/`-mappen for komplette demoer.

## Lisens
MIT License. Se LICENSE.
