Metadata-Version: 2.4
Name: bsyncpy
Version: 0.4.0
Summary: Tools to autogenerate a Python SDK for BuildingSync given an XSD
Author: Joel Bender
Author-email: joel@carrickbender.com
Requires-Python: >=3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: lxml (>=5.0)
Project-URL: Repository, https://github.com/BuildingSync/bsyncpy
Description-Content-Type: text/markdown

# bsyncpy

![Build Status](https://github.com/BuildingSync/bsyncpy/actions/workflows/ci.yml/badge.svg?branch=develop)

Current BuildingSync version: `2.7.0`.

Supported Python versions: 3.11, 3.12, 3.13, and 3.14.

## Installing

`pip install bsyncpy`

## Generating
- `poetry install`
- `poetry run pre-commit install`
- Download, copy, or curl a BuildingSync schema into `bsyncpy/bsyncpy`
  - `curl -L -o bsyncpy/BuildingSync-2.7.xsd https://github.com/BuildingSync/schema/releases/download/v2.7.0/BuildingSync.xsd`
- cd into `bsyncpy/bsyncpy`
- Run generator: `poetry run python bsyncpy_generator.py BuildingSync-2.7.xsd`
- Go back to the root `bsyncpy` and run tests: `poetry run pytest`
- Make sure formatting is good: `poetry run pre-commit run --all-files`
- On commit, pre-commit should run again

## Simple example

*Input*
```python
from lxml import etree
from bsyncpy import bsync

# Create a root and set the version attribute
root = bsync.BuildingSync()
root.set('version', '2.7.0')

# Valid element attributes can also be passed in as kwargs
f = bsync.Facilities(bsync.Facilities.Facility(ID='Facility-1'))

# Add the facilities.facility elements to the root
root += f

# write the document to disk
with open('output.xml', 'wb+') as f:
    output = etree.tostring(root.toxml(), pretty_print=True, doctype='<?xml version="1.0" encoding="UTF-8"?>')
    f.write(output)
```

*Output*
```xml
<?xml version="1.0" encoding="UTF-8"?>
<BuildingSync version="2.7.0">
  <Facilities>
    <Facility ID="Facility-1"/>
  </Facilities>
</BuildingSync>
```

## Comprehensive example

Check out the example Jupyter notebooks in the BuildingSync schema repository: [docs/notebooks](https://github.com/BuildingSync/schema/tree/develop-v2/docs/notebooks).


# Updating Version

* See the notes above on downloading and generating the new bsync.py file. 
* Bump version in `pyproject.toml` file
* Add/update CHANGELOG entry
* Add the new release to the generator matrix in `.github/workflows/ci.yml`
* Update this README with the latest version of testing.

## Releasing New Version

* Bump version using poetry by calling `poetry version X.Y.Z`
* Make sure CHANGELOG.md is up to date
* Create pull request to merge `develop` to `main`
* `git tag <version>`. Version in the form of vX.Y.Z.
* `git push --tags`.
* Go to GitHub and convert the tag to a release.
* `poetry build`
* `poetry publish`. Login via pypi account.

