mirror of
https://github.com/infeeeee/dyn2py
synced 2025-12-16 22:16:18 +01:00
Basic support for running as a module
This commit is contained in:
59
README.md
59
README.md
@@ -2,6 +2,11 @@
|
||||
|
||||
Extract python nodes from Dynamo graphs
|
||||
|
||||
Use cases:
|
||||
|
||||
- Track changes in python nodes in source control systems like git
|
||||
- Work on python code in your favorite code editor outside Dynamo. `dyn2py` can also update Dynamo graphs from the previously exported python files.
|
||||
|
||||
## Installation
|
||||
|
||||
*TODO*
|
||||
@@ -17,6 +22,8 @@ Extract python nodes from Dynamo graphs
|
||||
|
||||
## Usage
|
||||
|
||||
### As a standalone command line program
|
||||
|
||||
```
|
||||
> dyn2py --help
|
||||
usage: dyn2py [-h] [-l LOGLEVEL] [-n] [-F] [-b] [-f {py,dyn}] [-u] [-p path/to/folder] source
|
||||
@@ -45,6 +52,41 @@ The script by default overwrites older files with newer files.
|
||||
Do not move the source Dynamo graphs, or update won't work with them later.
|
||||
```
|
||||
|
||||
### As a python module
|
||||
|
||||
API documentation available here: *TODO*
|
||||
|
||||
Most basic example to extract all nodes next to a dynamo file:
|
||||
|
||||
```python
|
||||
import dyn2py
|
||||
|
||||
dynamo_file = dyn2py.DynamoFile("path/to/dynamofile.dyn")
|
||||
dynamo_file.extract_python()
|
||||
```
|
||||
|
||||
Change options like with the command line switches with the `Options` class:
|
||||
|
||||
```python
|
||||
import dyn2py
|
||||
|
||||
# Create a backup on overwrite, read python files from a different folder:
|
||||
options = dyn2py.Options(
|
||||
backup=True,
|
||||
python_folder="path/to/pythonfiles")
|
||||
|
||||
dynamo_file = dyn2py.DynamoFile("path/to/dynamofile")
|
||||
python_files = dynamo_file.get_related_python_files(options)
|
||||
|
||||
# Read python files and update the graph:
|
||||
if python_files:
|
||||
for python_file in python_files:
|
||||
python_file.update_dynamo(options)
|
||||
|
||||
# Don't forget to save at the end:
|
||||
dynamo_file.write(options)
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Installation
|
||||
@@ -54,7 +96,7 @@ Requirements: git, pip
|
||||
```
|
||||
git clone https://github.com/infeeeee/dyn2py
|
||||
cd dyn2py
|
||||
py -m pip install -e .
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
With venv:
|
||||
@@ -62,14 +104,21 @@ With venv:
|
||||
```
|
||||
git clone https://github.com/infeeeee/dyn2py
|
||||
cd dyn2py
|
||||
py -m venv .venv
|
||||
venv .venv
|
||||
. ./.venv/bin/activate
|
||||
py -m pip install -e .
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
Build:
|
||||
### Build
|
||||
|
||||
```shell
|
||||
```
|
||||
pip install -e .[build]
|
||||
pyinstaller dyn2py.spec
|
||||
```
|
||||
|
||||
### Generate module documentation
|
||||
|
||||
```
|
||||
pip install -e .[doc]
|
||||
pdoc -d google -o docs dyn2py
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user