Pyflowchart

Latest version: v0.3.1

Safety actively analyzes 682229 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.4.0alpha.4

Support match-case with Python 3.10+

0.3.1

- fix a backward compatibility bug introduced in v0.3.0: 26
- code format & docs cleanup

0.3.0

🎉 Supports outputting HTML. Thanks to ddfault.


Python Code --> Flowchart --> HTML


**CLI**: ouput the generated flowchart.js DSL into an html by adding the parameter -o output.html where you specify an output filename ending in `.html` or `.htm`.

**Python**: `from pyflowchart import output_html ` and call `output_html(output_name: str, field_name: str, flowchart: str) -> None`

Opening the `output.html` in a browser to visualize the diagrams. Click run to update the diagram. Click links to download the flowchart as a `.svg` or `.png` image.

---

See README for more usage. See discussions in 24 for design & implementation details.

Goto https://pypi.org/project/pyflowchart/0.3.0/ for installing or upgrading.

---

0.2.3r

0.2.3

0.2.2

Improve the flowchart of *consecutive If statements* converted from python code with the new feature of `v0.2.0`:

python
example-conds-align.py
if cond1:
op1
if cond2:
op2
if cond3:
op3
op_end


It works fine in `v0.1.4` with the default `simplify` feature:

sh
python3 -m pyflowchart example.py




flow
cond3=>operation: op1 if cond1
cond14=>operation: op2 if cond2
cond25=>operation: op3 if cond3
op35=>operation: op_end

cond3->cond14
cond14->cond25
cond25->op35


![result-simplify](https://tva1.sinaimg.cn/large/008i3skNgy1gzcuv9rm3wj30we0ns3yx.jpg)

But if we run it with ` --no-simplify`:

sh
python3 -m pyflowchart --no-simplify example-condsalign.py


flow
cond3=>condition: if cond1
op7=>operation: op1
cond13=>condition: if cond2
op17=>operation: op2
cond23=>condition: if cond3
op27=>operation: op3
op32=>operation: op_end

cond3(yes)->op7
op7->cond13
cond13(yes)->op17
op17->cond23
cond23(yes)->op27
op27->op32
cond23(no)->op32
cond13(no)->cond23
cond3(no)->cond13


![result-old](https://tva1.sinaimg.cn/large/008i3skNgy1gzcuvb2nzbj30u00vjaap.jpg)

Ugly, right? No more~! This version offers a new `--conds-align` flag to beautify these *consecutive If statements*.

sh
python3 -m pyflowchart --no-simplify --conds-align example.py


or in python:

python
import pyflowchart
with open('example.py') as f:
code = f.read()

fc = pyflowchart.Flowchart.from_code(code, simplify=False, conds_align=True)
print(fc.flowchart())


Outputs:

flow
cond3(align-next=no)=>condition: if cond1
op7=>operation: op1
cond13(align-next=no)=>condition: if cond2
op17=>operation: op2
cond23=>condition: if cond3
op27=>operation: op3
op32=>operation: op_end

cond3(yes, right)->op7
op7->cond13
cond13(yes, right)->op17
op17->cond23
cond23(yes, right)->op27
op27->op32
cond23(no)->op32
cond13(no)->cond23
cond3(no)->cond13


![result-conds-align](https://tva1.sinaimg.cn/large/008i3skNgy1gzcuv8rg7kj30p40nqdgk.jpg)

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.