Structure Python package.

This commit is contained in:
Josh Lucas
2026-04-17 15:25:29 -05:00
parent e829d331da
commit 6dbf963691
17 changed files with 87 additions and 44 deletions

8
AuDaGe.code-workspace Normal file
View File

@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

30
pyproject.toml Normal file
View File

@@ -0,0 +1,30 @@
[build-system]
requires = ["uv_build >= 0.11.6"]
build-backend = "uv_build"
[project]
name = "AuDaGe"
version = "0.0.1"
dependencies = [
"pandas",
]
authors = [
{ name="Joshua Lucas", email="j.lucas@prime-controls.com" },
]
description = "A small example package"
readme = "readme.md"
requires-python = ">=3.12"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
license = "LicenseRef-Proprietary"
license-files = ["licen[cs]e*"]
[project.urls]
Homepage = "https://github.com/jlucas-primecontrols/AuDaGe"
Issues = "https://github.com/jlucas-primecontrols/AuDaGe/issues"
[tool.setuptools.packages.find]
where = ["src"]
# namespaces = false

0
src/AuDaGe/AuDaGe.py Normal file
View File

0
src/AuDaGe/__init__.py Normal file
View File

View File

View File

@@ -1,11 +1,13 @@
import os import os
import pandas as pd
import sys import sys
from collections.abc import Sequence
from collections.abc import Iterable import pandas as pd
from iec import datatypes, ElementaryVariable, UDT
from pandas import DataFrame from pandas import DataFrame
import AuDaGe
from AuDaGe.iec import datatypes, ElementaryVariable, UDT
class XSY(): class XSY():
"""Schneider Electric EcoStruxure Control Expert variable exchange file """Schneider Electric EcoStruxure Control Expert variable exchange file
(XSY). (XSY).
@@ -32,7 +34,7 @@ class XSY():
self, self,
xsy_path: os.path, xsy_path: os.path,
dir_path: os.path = '', dir_path: os.path = '',
def_paths: Iterable[os.path] = [], def_paths: Sequence[os.path] = [],
db_ss_path: os.path = 'flatten_datablock.xslt', db_ss_path: os.path = 'flatten_datablock.xslt',
ddt_ss_path: os.path = 'flatten_ddtsource.xslt', ddt_ss_path: os.path = 'flatten_ddtsource.xslt',
) -> None: ) -> None:
@@ -103,44 +105,44 @@ class XSY():
pass pass
# Run this module as a script to test. # Run this module as a script to test.
if __name__ == '__main__': # if __name__ == '__main__':
# Argument 1: path to XSY # # Argument 1: path to XSY
try: # try:
xsy_path = sys.argv[1] # xsy_path = sys.argv[1]
except: # except:
xsy_path = 'test/hsps.xsy' # xsy_path = 'test/hsps.xsy'
# Argument 2: path to dataBlock stylesheet. # # Argument 2: path to dataBlock stylesheet.
try: # try:
db_ss_path = sys.argv[2] # db_ss_path = sys.argv[2]
except: # except:
db_ss_path = 'flatten_datablock.xslt' # db_ss_path = 'flatten_datablock.xslt'
# Argument 3: path to DDTSource stylesheet. # # Argument 3: path to DDTSource stylesheet.
try: # try:
ddt_ss_path = sys.argv[3] # ddt_ss_path = sys.argv[3]
except: # except:
ddt_ss_path = 'flatten_ddtsource.xslt' # ddt_ss_path = 'flatten_ddtsource.xslt'
# Argument 4: path to other definition files # # Argument 4: path to other definition files
try: # try:
def_paths = [sys.argv[3].split(',')] # def_paths = [sys.argv[3].split(',')]
except: # except:
def_paths = ['builtins.xsy'] # def_paths = ['builtins.xsy']
# Argument 5: path to output file. # # Argument 5: path to output file.
try: # try:
out_path = sys.argv[5] # out_path = sys.argv[5]
except: # except:
out_path = 'test/test' # out_path = 'test/test'
dir_path: os.path = ('D:/OneDrive - Prime Controls/Repositories' # dir_path: os.path = ('D:/OneDrive - Prime Controls/Repositories'
'/AuDaGe/formats/controlexpert/') # '/AuDaGe/formats/controlexpert/')
xsy = XSY( # xsy = XSY(
xsy_path, # xsy_path,
dir_path, # dir_path,
def_paths = def_paths, # def_paths = def_paths,
db_ss_path = db_ss_path, # db_ss_path = db_ss_path,
ddt_ss_path = ddt_ss_path, # ddt_ss_path = ddt_ss_path,
) # )
xsy.read_datablock() # xsy.read_datablock()
xsy.read_defs() # xsy.read_defs()
xsy.expand_datablock() # xsy.expand_datablock()
xsy.datablock.to_csv(out_path + '_db.csv', index=False) # xsy.datablock.to_csv(out_path + '_db.csv', index=False)
xsy.defs.to_csv(out_path + '_ddt.csv', index=False) # xsy.defs.to_csv(out_path + '_ddt.csv', index=False)

View File

3
tests/xsy/xsy.py Normal file
View File

@@ -0,0 +1,3 @@
from AuDaGe.formats.controlexpert.xsy import XSY
print(XSY("hsps.xsy"))