Skip to content

Commit 1ca4fce

Browse files
authored
Merge pull request #18 from csgoh/dev-processpiper
Dev processpiper
2 parents 3d6d790 + c5d062e commit 1ca4fce

32 files changed

+582
-308
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ dotted*
133133
font_demo*
134134
test01.png
135135
pizza*.png
136-
.vscode/
136+
.vscode/
137+
*.txt

README.md

+45-62
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,22 @@
1111
[![Twitter Follow](https://img.shields.io/twitter/follow/CSGohNZ?style=social)](https://twitter.com/CSGohNZ)
1212

1313
# ProcessPiper (Business Process Diagram as Code)
14-
A python library to generate business process diagram using code.
14+
ProcessPiper is an open source python library to generate business process diagram using python code or [PiperFlow](https://github.com/csgoh/processpiper/wiki/Usage-Documentation#syntax) syntax.
1515

16-
## Why ProcessPiper?
17-
1. Generate professional business process diagrams with Python code, eliminating the need for manual drawing and complex tools.
18-
2. Improve teamwork by utilising source code repositories for change monitoring, collaboration, and diagram history.
19-
3. Enhance precision by generating diagrams with code, sharing/exporting them in PNG format, and integrating them with Python tools.
16+
<h3 align="center">
17+
<b><a href="https://github.com/csgoh/processpiper/wiki/installation">Installation</a></b>
18+
19+
<b><a href="https://github.com/csgoh/processpiper/wiki/Usage-Documentation">Usage Guide</a></b>
20+
21+
<b><a href="https://github.com/csgoh/processpiper/wiki/Change-Logs">Changelogs</a></b>
22+
</h3>
2023

21-
22-
# Features
23-
* Generate business process diagrams with Python code
24-
* Alternatively business process diagram can be generated by using plain text
25-
* Business process diagrams contains
26-
* Diagram title
27-
* Pool(s)
28-
* Lane(s)
29-
* Elements:
30-
* Event: Start, End, Timer, Intermediate, Message, Signal, Conditional and Link
31-
* Activity: Task, Subprocess
32-
* Gateway: Inclusive, Exclusive, Parallel, Event
33-
* Support for different colour themes
34-
* Default
35-
* GREYWOOF
36-
* BLUEMOUNTAIN
37-
* ORANGEPEEL
38-
* GREENTURTLE
39-
* Save diagram as PNG file
40-
41-
## Change Logs
42-
Refer to this [Change Logs](https://github.com/csgoh/processpiper/wiki/Change-Logs) page for the latest updates.
43-
44-
45-
46-
## Installation
47-
### Install from PyPI
48-
```bash
49-
pip install processpiper
50-
```
51-
<br>
52-
53-
## Frontend Application
54-
Two frontend applications have been developed to showcase ProcessPiper capability.
55-
* [Piperoni](https://github.com/csgoh/Piperoni) - A desktop application
56-
* [Piperita](https://piperita.streamlit.app/) - A Streamlit web application
5724
<br>
5825

59-
### Python version requirements:
60-
* Python 3.10, 3.11
61-
62-
### Library Dependencies
63-
* Pillow 9.5.0
64-
65-
### Supported Platforms
66-
* Windows
67-
* Ubuntu
68-
* MacOS
6926

70-
## Documentation
71-
Please refer to [Processpiper Wiki](https://github.com/csgoh/processpiper/wiki) for more information on how to use this library.
7227

73-
## Examples
74-
### (Method 1) Generate diagram using English like PiperFlow syntax
75-
This is a sample code to generate a business process diagram using PiperFlow syntax.
28+
## Method 1: Generate business process diagram using English like PiperFlow syntax
29+
This is a sample code to generate a business process diagram using [PiperFlow](https://github.com/csgoh/processpiper/wiki/Usage-Documentation#syntax) syntax.
7630
```python
7731
from processpiper.text2diagram import render
7832

@@ -103,7 +57,7 @@ render(input_syntax, "my_process_map.png")
10357

10458
```
10559

106-
### (Method 2) Generate diagram using Python code
60+
### Method 2: Generate business process diagram using Python code
10761
This is a sample code to generate a business process diagram using Python code. The code is self-explanatory. The diagram is generated using the default colour theme.
10862

10963
```python
@@ -144,16 +98,45 @@ with ProcessMap(
14498
The generated diagram is as follows:
14599
![Process Map](https://github.com/csgoh/processpiper/blob/main/images/test/test_auto_case1.png)
146100

101+
# Features
102+
* Generate business process diagrams with Python code
103+
* Alternatively business process diagram can be generated by using PiperFlow
104+
* Business process diagrams contains
105+
* Diagram title
106+
* Pool(s)
107+
* Lane(s)
108+
* Elements:
109+
* Event: Start, End, Timer, Intermediate, Message, Signal, Conditional and Link
110+
* Activity: Task, Subprocess
111+
* Gateway: Inclusive, Exclusive, Parallel, Event
112+
* Support for different colour themes
113+
* Default
114+
* GREYWOOF
115+
* BLUEMOUNTAIN
116+
* ORANGEPEEL
117+
* GREENTURTLE
118+
* Save diagram as PNG file
119+
120+
121+
## Frontend Application
122+
Two frontend applications have been developed to showcase ProcessPiper capability.
123+
* [Piperoni](https://github.com/csgoh/Piperoni) - A desktop application
124+
* [Piperita](https://piperita.streamlit.app/) - A Streamlit web application
147125

148-
## Development Status
149-
Initial first release would only cover the following basic business process elements. Other element types will be introduced in subsequence releases.
126+
## Support and Community
150127

151-
* Event: Start, End, Timer, Intermediate, Message, Signal, Conditional, Link
152-
* Activity: Task, Subprocess
153-
* Gateway: Inclusive, Exclusive, Parallel, Event
128+
If you have any problem, I will try my best to resolve it.<br>
129+
130+
* 📄 Find a solution in our [Wiki](https://github.com/csgoh/processpiper/wiki)
131+
* ⚠️ Open an issue right here on [GitHub](https://github.com/csgoh/processpiper/issues)<br>
154132

155133
Any ideas or suggestions, please send it to me via [GitHub Discussions](https://github.com/csgoh/processmapper/discussions).
156134

135+
## How to Contribute
136+
137+
If you'd like to contribute, start by reading our [Contribution Guide](https://github.com/csgoh/processpiper/tree/main/contributions/CONTRIBUTING.md).<br>
138+
139+
Lets build great software together.
157140

158141

159142

contributions/CONTRIBUTING.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing to ProcessPiper
2+
3+
Thank you for your interest in ProcessPiper and for taking the time to contribute to this project. 🙌
4+
ProcessPiper is a project by developers for developers and there are a lot of ways you can contribute.
5+
If you don't know where to start contributing, drop me a DM on [Twitter](https://twitter.com/CSGohNZ).
6+
7+
8+
## How can I contribute?
9+
10+
There are many ways in which you can contribute to ProcessPiper.
11+
12+
#### 🐛 Report a bug
13+
Report all issues through GitHub Issues. To help resolve your issue as quickly as possible, please provide the following information:
14+
* Your Operating System
15+
* Your code to reproduce the error
16+
17+
#### 🛠 File a feature request
18+
We welcome all feature requests, whether it's to add new functionality to an existing extension or to offer an idea for a brand new extension. File your feature request through ideas under [GitHub Discussion](https://github.com/csgoh/processpiper/discussions/categories/ideas) page.
19+
20+
21+
#### ⚙️ Close a Bug / Feature issue
22+
We welcome contributions that help make ProcessPiper bug free & improve the experience of our users. You can also find [open issues](https://github.com/csgoh/processpiper/issues). Check out our [Code Contribution Guide](contributions/CodeContributionsGuidelines.md) to begin.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Contributing code
2+
3+
### Getting Started
4+
5+
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
6+
Before raising a pull request, ensure you have raised a corresponding issue and discussed a possible solution with a maintainer. This gives your pull request the highest chance of getting merged quickly.
7+
8+
### Good First Issues
9+
10+
Looking for issues to contribute? Check out the [GitHub Issue](https://github.com/csgoh/processpiper/issues) page.
11+
12+
### 🍴 Git Workflow
13+
14+
We use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through pull requests.
15+
16+
1. Fork the repo and create a new branch from the `main` branch.
17+
2. Branches are named as `fix/fix-name` or `feature/feature-name`
18+
3. Please add tests for your changes.
19+
4. Once you are confident in your code changes, create a pull request in your fork to the release branch in the appsmithorg/appsmith base repository.
20+
5. If you've changed any functions, please call this out in the pull request and ensure backward compatibility.
21+
6. Link the issue of the base repository in your Pull request description. [Guide](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue)
22+
7. When you raise a pull request, we automatically run tests on our CI. Please ensure that all the tests are passing for your code change. We will not be able to accept your change if the test suite doesn't pass.
23+

images/test/piper_20230722_211046.png

38.2 KB
Loading

images/test/test_auto_case1.png

15 Bytes
Loading
34 Bytes
Loading

images/test/test_case10-DEFAULT.png

-22 Bytes
Loading
-32 Bytes
Loading

images/test/test_case10-GREYWOOF.png

-50 Bytes
Loading
-39 Bytes
Loading

images/test/test_case11.png

-33 Bytes
Loading

images/test/test_case17.png

10 Bytes
Loading

images/test/test_case2.png

9 Bytes
Loading

images/test/test_case3.png

-22 Bytes
Loading

images/test/test_case4.png

20 Bytes
Loading

images/test/test_case5.png

15 Bytes
Loading

images/test/test_case8.png

13 Bytes
Loading

images/test/test_diagram.png

27.9 KB
Loading

images/test/test_diagramX.png

35.7 KB
Loading

images/test/test_sample02.png

17.5 KB
Loading

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ classifiers = [
1414
"License :: OSI Approved :: MIT License",
1515
"Operating System :: OS Independent",
1616
]
17-
dependencies = ['Pillow>=9.5.0']
17+
dependencies = ['Pillow>=9.5.0', 'rich>=13.4.2']
1818

1919
[project.urls]
2020
"Homepage" = "https://github.com/csgoh/processpiper"

requirements.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
Pillow==9.5.0
2-
pytest==7.3.2
1+
Pillow>=9.5.0
2+
pytest>=7.3.2
3+
rich>=13.4.2
4+
build>=0.10.0
5+
twine>=4.0.2

src/processpiper/helper.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222
import logging
23+
from rich.console import Console
24+
from rich.panel import Panel
2325

2426

2527
class Helper:
@@ -28,13 +30,18 @@ class Helper:
2830
show_x_position = False
2931
show_y_position = False
3032
show_draw_position = False
31-
show_draw_connection = False
3233
show_draw = False
34+
show_draw_connection = False
3335
show_general = False
3436

3537
@staticmethod
3638
def printc(
37-
message: str, color: str = "30", end: str = "\n", show_level: str = "general"
39+
message: str,
40+
color: str = "30",
41+
reverse: bool = False,
42+
end: str = "\n",
43+
rich_type: str = "text",
44+
show_level: str = "general",
3845
):
3946
"""Print text in color"""
4047

@@ -50,7 +57,12 @@ def printc(
5057
or (show_level == "draw" and Helper.show_draw)
5158
or (show_level == "general" and Helper.show_general)
5259
):
53-
print(f"\033[1;{color}m{message}\033[0m", end=end)
60+
console = Console()
61+
if rich_type == "text":
62+
style_attribute = "reverse" if reverse else ""
63+
console.print(message, end=end, style=style_attribute)
64+
elif rich_type == "panel":
65+
console.print(Panel(message), style="blue")
5466

5567
@staticmethod
5668
def print_info(message: str, color: str = "30", end: str = "\n"):
@@ -59,7 +71,8 @@ def print_info(message: str, color: str = "30", end: str = "\n"):
5971
root_logger = logging.getLogger()
6072

6173
if root_logger.getEffectiveLevel() == logging.INFO:
62-
print(f"\033[1;{color}m{message}\033[0m", end=end)
74+
console = Console()
75+
console.print(f"\033[1;{color}m{message}\033[0m", end=end)
6376

6477
@staticmethod
6578
def debug_log(message: str):

src/processpiper/lane.py

+24-17
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,6 @@ def add_element(
130130
fill_colour: str = "",
131131
text_alignment: str = "",
132132
) -> Shape:
133-
"""Add an element to the lane"""
134-
# if font == "":
135-
# font = self.painter.element_font
136-
# if font_size == 0:
137-
# font_size = self.painter.element_font_size
138-
# if font_colour == "":
139-
# font_colour = self.painter.element_font_colour
140-
# if fill_colour == "":
141-
# fill_colour = self.painter.element_fill_colour
142-
# if text_alignment == "":
143-
# text_alignment = self.painter.element_text_alignment
144-
145133
font = font or self.painter.element_font
146134
font_size = font_size or self.painter.element_font_size
147135
font_colour = font_colour or self.painter.element_font_colour
@@ -209,22 +197,41 @@ def draw_shape(self) -> None:
209197
if self.shapes:
210198
for shape in self.shapes:
211199
Helper.printc(
212-
f" Drawing shape: {shape.name}, x={shape.x}, y={shape.y}, w={shape.width}, h={shape.height}",
200+
f" Drawing shape: [bold][red]\[{shape.name}][/red][/bold], x={shape.x}, y={shape.y}, w={shape.width}, h={shape.height}",
201+
rich_type="text",
213202
show_level="draw",
214203
)
204+
215205
shape.draw(self.painter)
216206

207+
# def _find_start_shape(self) -> Shape:
208+
# """Find the start shape in the process map"""
209+
# if self.shapes:
210+
# for pool in self._pools:
211+
# for lane in pool.lanes:
212+
# for shape in lane.shapes:
213+
# ### If the shape has no connection_from, it is the start shape
214+
# Helper.printc(
215+
# f"{shape.name} - {len(shape.connection_from)}",
216+
# show_level="layout_grid",
217+
# )
218+
# if len(shape.connection_from) == 0:
219+
# return shape
220+
# return None
221+
217222
def draw_connection(self, all_shapes: list) -> None:
218223
"""Draw the connections in the lane"""
224+
225+
Helper.printc(
226+
f"Lane: {self.name}", show_level="draw_connection", rich_type="panel"
227+
)
219228
if self.shapes:
220-
for shape in self.shapes:
221-
shape.draw_connection(self.painter, all_shapes)
229+
shape = self.shapes[0]
230+
shape.draw_connection(self.painter, all_shapes)
222231

223232
def set_draw_position(self, x: int, y: int, layout_grid: Grid) -> None:
224233
"""Set the draw position of the lane"""
225234

226-
# self.painter = painter
227-
228235
### Determine the number of rows for the lane
229236
lane_row_count = layout_grid.get_lane_row_count(self.id)
230237

0 commit comments

Comments
 (0)