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
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [main, master]
tags: ['v*']
pull_request:
branches: [main, master]

jobs:
test:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install package + dev extras
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Lint (ruff)
run: ruff check aspython tests
continue-on-error: true

- name: Run tests
run: pytest -q

build-exe:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install package + dev extras
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Build single-file executable
run: pyinstaller packaging/aspython.spec --noconfirm

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aspython-windows
path: dist/aspython.exe

- name: Attach to GitHub release
uses: softprops/action-gh-release@v2
with:
files: dist/aspython.exe
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
tests/AsProject/*
!tests/AsProject/package.json

# Translations
*.mo
Expand Down
43 changes: 10 additions & 33 deletions ASCncConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,20 @@
* File: ASCncConfig.py
* Copyright (c) 2023 Loupe
* https://loupe.team
*
*
* This file is part of ASPython, licensed under the MIT License.
'''
'''
AS Tools - Cnc Config

This package contains functions necessary to perform actions on
AS Cnc Configuration files outside of Automation Studio.

Requires lxml
'''
"""Backwards-compatibility shim — use ``aspython.cnc`` instead."""
import warnings as _warnings

import os.path
# import xml.etree.ElementTree as ET
import lxml.etree as ET
from aspython.cnc import listOfProcs # noqa: F401

__version__ = '0.0.0.1'

def listOfProcs(tree, include_comments=False):
procs = []
for node in tree.xpath('//BuiltInProcs'):
for child in node:
if child.tag is not ET.Comment:
if include_comments and child.getprevious() is not None and child.getprevious().tag is ET.Comment:
print("<!-- " + child.getprevious().text + "-->")
procs.append(child.getprevious())
print(child.tag)
procs.append(child)
return procs

def main():
tree = ET.parse('test/gmcipubr.cnc')

# print(ET.tostring(tree, pretty_print=True))
listOfProcs(tree, include_comments=True)


if __name__ == "__main__":
main()
_warnings.warn(
"Importing from 'ASCncConfig' is deprecated; use 'aspython.cnc' instead.",
DeprecationWarning,
stacklevel=2,
)

__all__ = ["listOfProcs"]
Loading
Loading