diff --git a/.github/workflows/codacy-coverage.yml b/.github/workflows/codacy-coverage.yml
index 0df87960..1a872fb6 100644
--- a/.github/workflows/codacy-coverage.yml
+++ b/.github/workflows/codacy-coverage.yml
@@ -25,7 +25,7 @@ jobs:
- name: Build unit + integration coverage using pytest-cov
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1080x24 -ac +extension GLX
- pytest -s --cov=opencodeblocks --cov-report=xml:coverage.xml tests
+ pytest -s --cov=pyflow --cov-report=xml:coverage.xml tests
env:
DISPLAY: :99
- name: Run codacy-coverage-reporter
diff --git a/.github/workflows/python-coverage.yml b/.github/workflows/python-coverage.yml
index 70dca56b..984cf783 100644
--- a/.github/workflows/python-coverage.yml
+++ b/.github/workflows/python-coverage.yml
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
name: Python coverage
@@ -28,7 +28,7 @@ jobs:
- name: Build unit coverage using pytest-cov
run: |
- pytest --cov=opencodeblocks --cov-report=xml tests/unit
+ pytest --cov=pyflow --cov-report=xml tests/unit
score=$(python coverage_score.py --score)
color=$(python coverage_score.py --color)
echo "COVERAGE_UNIT_SCORE=$score"
@@ -40,7 +40,7 @@ jobs:
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 00ce73155619a4544884ca6d251954b3
- filename: opencodeblocks_unit_coverage_badge.json
+ filename: pyflow_unit_coverage_badge.json
label: Unit coverage
message: ${{ env.COVERAGE_UNIT_SCORE }}
color: ${{ env.COVERAGE_UNIT_COLOR }}
@@ -49,7 +49,7 @@ jobs:
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1080x24 -ac +extension GLX
- pytest -s --cov=opencodeblocks --cov-report=xml tests/integration
+ pytest -s --cov=pyflow --cov-report=xml tests/integration
score=$(python coverage_score.py --score)
color=$(python coverage_score.py --color)
echo "COVERAGE_INTEGRATION_SCORE=$score"
@@ -64,7 +64,7 @@ jobs:
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 00ce73155619a4544884ca6d251954b3
- filename: opencodeblocks_integration_coverage_badge.json
+ filename: pyflow_integration_coverage_badge.json
label: Integration coverage
message: ${{ env.COVERAGE_INTEGRATION_SCORE }}
color: ${{ env.COVERAGE_INTEGRATION_COLOR }}
diff --git a/.github/workflows/python-pylint.yml b/.github/workflows/python-pylint.yml
index 85f3b934..354e95a0 100644
--- a/.github/workflows/python-pylint.yml
+++ b/.github/workflows/python-pylint.yml
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
name: Pylint
@@ -32,7 +32,7 @@ jobs:
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 00ce73155619a4544884ca6d251954b3
- filename: opencodeblocks_pylint_badge.json
+ filename: pyflow_pylint_badge.json
label: Pylint
message: ${{ env.PYLINT_SCORE }}
color: ${{ env.PYLINT_COLOR }}
diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml
index a4a7db6d..abaee1c5 100644
--- a/.github/workflows/python-tests.yml
+++ b/.github/workflows/python-tests.yml
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
name: Pytest
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d8e8f557..90dc0fef 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,6 @@
# PyFlow - Contributing guide
-[![Pytest badge](https://github.com/Bycelium/OpenCodeBlocks/actions/workflows/python-tests.yml/badge.svg?branch=master)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-tests.yml) [![Pylint badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_pylint_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-pylint.yml) [![Unit coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_unit_coverage_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-coverage.yml) [![Integration coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_integration_coverage_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-coverage.yml)
+[![Pytest badge](https://github.com/Bycelium/Pyflow/actions/workflows/python-tests.yml/badge.svg?branch=master)](https://github.com/MathisFederico/Pyflow/actions/workflows/python-tests.yml) [![Pylint badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fpyflow_pylint_badge.json)](https://github.com/MathisFederico/Pyflow/actions/workflows/python-pylint.yml) [![Unit coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fpyflow_unit_coverage_badge.json)](https://github.com/MathisFederico/Pyflow/actions/workflows/python-coverage.yml) [![Integration coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fpyflow_integration_coverage_badge.json)](https://github.com/MathisFederico/Pyflow/actions/workflows/python-coverage.yml)
Whenever you encounter a :beetle: **bug** or have :tada: **feature request**,
report this via [GitHub issues](https://github.com/Bycelium/PyFlow/issues).
@@ -21,7 +21,7 @@ You can run the program with `python main.py`
Before doing your **pull request**, check using `pylint` and `pytest` that there were no code regressions.
```bash
-pylint .\opencodeblocks\
+pylint .\pyflow\
```
Some `pylint` issues can be fixed automatically using `black`, with the following command:
@@ -31,7 +31,7 @@ black .
```
```bash
-pytest --cov=opencodeblocks --cov-report=html tests/unit
+pytest --cov=pyflow --cov-report=html tests/unit
```
We want to keep the *Pylint* score above *9.0*.
@@ -43,26 +43,26 @@ The comments and docstrings should preferably follow [these](https://google.gith
Commits should start with a Capital letter and should be written in present tense (e.g. ``:tada: Add cool new feature`` instead of ``:tada: Added cool new feature``).
You should also start your commit message with one or two applicable emoji. This does not only look great but also makes you rethink what to add to a commit. Make many but small commits!
- Emoji | Description
------------------|-------------
-:tada: `:tada:` | When you add a cool new feature
-:beetle: `:beetle:` | When you fixed a bug
-:fire: `:fire:` | When you removed something
-:truck: `:truck:`| When you moved/renamed something
-:wrench: `:wrench:` | When you improved/refactored a small piece of code
-:hammer: `:hammer:` | When you improved/refactored a large piece of code
-:sparkles: `:sparkles:` | When you improved code quality (pylint, PEP, ...)
-:art: `:art:` | When you improved/added design assets
-:rocket: `:rocket:` | When you improved performance.
-:memo: `:memo:` | When you wrote documentation.
-:umbrella: `:umbrella:` | When you improved coverage
-:twisted_rightwards_arrows: `:twisted_rightwards_arrows:` | When you merge a branch
+ | Emoji | Description |
+ | --------------------------------------------------------- | -------------------------------------------------- |
+ | :tada: `:tada:` | When you add a cool new feature |
+ | :beetle: `:beetle:` | When you fixed a bug |
+ | :fire: `:fire:` | When you removed something |
+ | :truck: `:truck:` | When you moved/renamed something |
+ | :wrench: `:wrench:` | When you improved/refactored a small piece of code |
+ | :hammer: `:hammer:` | When you improved/refactored a large piece of code |
+ | :sparkles: `:sparkles:` | When you improved code quality (pylint, PEP, ...) |
+ | :art: `:art:` | When you improved/added design assets |
+ | :rocket: `:rocket:` | When you improved performance. |
+ | :memo: `:memo:` | When you wrote documentation. |
+ | :umbrella: `:umbrella:` | When you improved coverage |
+ | :twisted_rightwards_arrows: `:twisted_rightwards_arrows:` | When you merge a branch |
This section was inspired by [This repository](https://github.com/schneegans/dynamic-badges-action).
## Creating a new block type
-You can checkout [this commit](https://github.com/MathisFederico/OpenCodeBlocks/commits/2305e3c92d88d2fd32644e7eab4c4e40246675d3) which contains the minimal amount of code required to
+You can checkout [this commit](https://github.com/Bycelium/Pyflow/commits/2305e3c92d88d2fd32644e7eab4c4e40246675d3) which contains the minimal amount of code required to
create a new block type.
## Version Numbers
diff --git a/README.md b/README.md
index a9504856..09af31a5 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
# PyFlow
-[![Pytest badge](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-tests.yml/badge.svg?branch=master)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-tests.yml)
-[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ddd03302fd7c4849b452959753bc0939)](https://www.codacy.com/gh/MathisFederico/OpenCodeBlocks/dashboard?utm_source=github.com&utm_medium=referral&utm_content=MathisFederico/OpenCodeBlocks&utm_campaign=Badge_Grade)
-[![Pylint badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_pylint_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-pylint.yml)
-[![Total coverage Codacy Badge](https://app.codacy.com/project/badge/Coverage/ddd03302fd7c4849b452959753bc0939)](https://www.codacy.com/gh/MathisFederico/OpenCodeBlocks/dashboard?utm_source=github.com&utm_medium=referral&utm_content=MathisFederico/OpenCodeBlocks&utm_campaign=Badge_Coverage)
-[![Unit coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_unit_coverage_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-coverage.yml)
-[![Integration coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_integration_coverage_badge.json)](https://github.com/MathisFederico/OpenCodeBlocks/actions/workflows/python-coverage.yml)
+[![Pytest badge](https://github.com/MathisFederico/opencodeblocks/actions/workflows/python-tests.yml/badge.svg?branch=master)](https://github.com/MathisFederico/opencodeblocks/actions/workflows/python-tests.yml)
+[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ddd03302fd7c4849b452959753bc0939)](https://www.codacy.com/gh/MathisFederico/opencodeblocks/dashboard?utm_source=github.com&utm_medium=referral&utm_content=MathisFederico/opencodeblocks&utm_campaign=Badge_Grade)
+[![Pylint badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_pylint_badge.json)](https://github.com/MathisFederico/opencodeblocks/actions/workflows/python-pylint.yml)
+[![Total coverage Codacy Badge](https://app.codacy.com/project/badge/Coverage/ddd03302fd7c4849b452959753bc0939)](https://www.codacy.com/gh/MathisFederico/opencodeblocks/dashboard?utm_source=github.com&utm_medium=referral&utm_content=MathisFederico/opencodeblocks&utm_campaign=Badge_Coverage)
+[![Unit coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_unit_coverage_badge.json)](https://github.com/MathisFederico/opencodeblocks/actions/workflows/python-coverage.yml)
+[![Integration coverage badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FMathisFederico%2F00ce73155619a4544884ca6d251954b3%2Fraw%2Fopencodeblocks_integration_coverage_badge.json)](https://github.com/MathisFederico/opencodeblocks/actions/workflows/python-coverage.yml)
[![Licence - GPLv3](https://img.shields.io/github/license/MathisFederico/Crafting?style=plastic)](https://www.gnu.org/licenses/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
@@ -52,7 +52,7 @@ Make sure you have Python 3 installed. You can download it from [here](https://w
Clone the current repo:
```bash
-git clone https://github.com/MathisFederico/OpenCodeBlocks/
+git clone https://github.com/MathisFederico/Pyflow/
```
Install the dependencies
@@ -64,7 +64,7 @@ pip install -r requirements.txt
Run !
```bash
-python -m opencodeblocks
+python -m pyflow
```
## Contributing
diff --git a/blocks/cnn_model.ocbb b/blocks/cnn_model.ocbb
deleted file mode 100644
index 2e123482..00000000
--- a/blocks/cnn_model.ocbb
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "title": "CNN",
- "block_type": "OCBCodeBlock",
- "source": "input_size = 28\r\nclasses = 5\r\nmodel = Sequential()\r\nmodel.add(layers.Conv2D(input_size, kernel_size=(3,3), input_shape=(input_size,input_size,1)))\r\nmodel.add(layers.MaxPooling2D(pool_size=(2, 2)))\r\nmodel.add(layers.Flatten())\r\nmodel.add(layers.Dense(128, activation=tf.nn.relu))\r\nmodel.add(layers.Dropout(0.2))\r\nmodel.add(layers.Dense(classes,activation=tf.nn.softmax))\r\n\r\nmodel.compile(optimizer='adam', \r\n loss='sparse_categorical_crossentropy')",
- "stdout": "",
- "image": "",
- "splitter_pos": [80,50],
- "width": 600,
- "height": 400,
- "metadata": {
- "title_metadata": {
- "color": "white",
- "font": "Ubuntu",
- "size": 10,
- "padding": 4.0
- }
- }
-}
\ No newline at end of file
diff --git a/blocks/container.ocbb b/blocks/container.ocbb
deleted file mode 100644
index e543d0b6..00000000
--- a/blocks/container.ocbb
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "title": "Container",
- "block_type": "OCBContainerBlock",
- "source": "",
- "splitter_pos": [88,41],
- "width": 618,
- "height": 184,
- "metadata": {
- "title_metadata": {
- "color": "white",
- "font": "Ubuntu",
- "size": 10,
- "padding": 4.0
- }
- }
-}
\ No newline at end of file
diff --git a/blocks/drawing.ocbb b/blocks/drawing.ocbb
deleted file mode 100644
index 25503ea0..00000000
--- a/blocks/drawing.ocbb
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "title": "Drawing",
- "block_type": "OCBDrawingBlock",
- "image": "",
- "splitter_pos": [80,50],
- "width": 600,
- "height": 400,
- "metadata": {
- "title_metadata": {
- "color": "white",
- "font": "Ubuntu",
- "size": 10,
- "padding": 4.0
- }
- }
-}
\ No newline at end of file
diff --git a/blocks/empty.ocbb b/blocks/empty.pfb
similarity index 93%
rename from blocks/empty.ocbb
rename to blocks/empty.pfb
index f5435526..8469d16b 100644
--- a/blocks/empty.ocbb
+++ b/blocks/empty.pfb
@@ -1,5 +1,5 @@
{
- "title": "Empty",
+ "title": "Code",
"block_type": "OCBCodeBlock",
"source": "",
"stdout": "",
diff --git a/blocks/import_ml.ocbb b/blocks/import_ml.ocbb
deleted file mode 100644
index fdb57216..00000000
--- a/blocks/import_ml.ocbb
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "title": "Imports for ML",
- "block_type": "OCBCodeBlock",
- "source": "import tensorflow as tf\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\nfrom tensorflow.keras.models import Sequential",
- "stdout": "",
- "image": "",
- "splitter_pos": [80,50],
- "width": 600,
- "height": 400,
- "metadata": {
- "title_metadata": {
- "color": "white",
- "font": "Ubuntu",
- "size": 10,
- "padding": 4.0
- }
- }
-}
\ No newline at end of file
diff --git a/blocks/markdown.ocbb b/blocks/markdown.pfb
similarity index 100%
rename from blocks/markdown.ocbb
rename to blocks/markdown.pfb
diff --git a/blocks/slider.ocbb b/blocks/slider.ocbb
deleted file mode 100644
index c49a9362..00000000
--- a/blocks/slider.ocbb
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "title": "Slider",
- "block_type": "OCBSliderBlock",
- "source": "",
- "splitter_pos": [88,41],
- "width": 618,
- "height": 184,
- "metadata": {
- "title_metadata": {
- "color": "white",
- "font": "Ubuntu",
- "size": 10,
- "padding": 4.0
- }
- }
-}
\ No newline at end of file
diff --git a/coverage_score.py b/coverage_score.py
index abf9031b..d9ffc243 100644
--- a/coverage_score.py
+++ b/coverage_score.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module to get coverage score. """
diff --git a/media/placeholder_logo.png b/media/placeholder_logo.png
new file mode 100644
index 00000000..a63571a4
Binary files /dev/null and b/media/placeholder_logo.png differ
diff --git a/opencodeblocks/__init__.py b/opencodeblocks/__init__.py
deleted file mode 100644
index 8b299e47..00000000
--- a/opencodeblocks/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-# OpenCodeBlock an open-source tool for modular visual programing in python
-# Copyright (C) 2021 Mathïs FEDERICO
-
-""" OpenCodeBlocks: An open-source tool for modular visual programing in python """
-
-__appname__ = "OpenCodeBlocks"
-__author__ = "Mathïs Fédérico"
-__version__ = "0.0.1"
diff --git a/opencodeblocks/blocks/__init__.py b/opencodeblocks/blocks/__init__.py
deleted file mode 100644
index 3a2eca69..00000000
--- a/opencodeblocks/blocks/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
-# Copyright (C) 2021 Mathïs FEDERICO
-
-""" Module for the OCB Blocks of different types. """
-
-from opencodeblocks.blocks.sliderblock import OCBSliderBlock
-from opencodeblocks.blocks.codeblock import OCBCodeBlock
-from opencodeblocks.blocks.markdownblock import OCBMarkdownBlock
-from opencodeblocks.blocks.drawingblock import OCBDrawingBlock
-from opencodeblocks.blocks.containerblock import OCBContainerBlock
diff --git a/opencodeblocks/blocks/widgets/__init__.py b/opencodeblocks/blocks/widgets/__init__.py
deleted file mode 100644
index d62d3431..00000000
--- a/opencodeblocks/blocks/widgets/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
-# Copyright (C) 2021 Mathïs FEDERICO
-
-""" Module for the OCB Blocks Widgets. """
-
-from opencodeblocks.blocks.widgets.blocksplitter import OCBSplitter
-from opencodeblocks.blocks.widgets.blocktitle import OCBTitle
-from opencodeblocks.blocks.widgets.blocksizegrip import OCBSizeGrip
diff --git a/opencodeblocks/core/__init__.py b/opencodeblocks/core/__init__.py
deleted file mode 100644
index 58401fca..00000000
--- a/opencodeblocks/core/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
-# Copyright (C) 2021 Mathïs FEDERICO
diff --git a/opencodeblocks/graphics/__init__.py b/opencodeblocks/graphics/__init__.py
deleted file mode 100644
index 58401fca..00000000
--- a/opencodeblocks/graphics/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
-# Copyright (C) 2021 Mathïs FEDERICO
diff --git a/opencodeblocks/graphics/function_parsing.py b/opencodeblocks/graphics/function_parsing.py
deleted file mode 100644
index 4af206a1..00000000
--- a/opencodeblocks/graphics/function_parsing.py
+++ /dev/null
@@ -1,128 +0,0 @@
-""" Module for code parsing and code execution """
-
-from typing import List, Tuple
-from opencodeblocks.graphics.kernel import Kernel
-
-kernel = Kernel()
-
-
-def run_cell(cell: str) -> str:
- """
- Executes a piece of Python code in an ipython kernel, returns its last output
-
- Args:
- cell: String containing Python code
-
- Return:
- output in the last message sent by the kernel
- """
- return kernel.execute(cell)
-
-
-def get_function_name(code: str) -> str:
- """
- Parses a string of code and returns the first function name it finds
-
- Args:
- code: String containing Python code
-
- Return:
- Name of first defined function
- """
- def_index = code.find("def")
- if def_index == -1:
- raise ValueError("'def' not found in source code")
- start_of_name = def_index + 4
- parenthesis_index = code.find("(", start_of_name)
- if parenthesis_index == -1:
- raise ValueError("'(' not found in source code")
- end_of_name = parenthesis_index
- return code[start_of_name:end_of_name]
-
-
-def get_signature(code: str) -> str:
- """
- Returns the signature of a string of Python code defining a function
- For example: the signature of def hello(a,b,c=3) is "(a,b,c=3)"
-
- Args:
- code: String containing Python code
-
- Return:
- Signature of first defined function
-
- """
- name = get_function_name(code)
- run_cell(code)
- run_cell("from inspect import signature")
- return run_cell(f"print(signature({name}))")
-
-
-def find_kwarg_index(signature_couple: List[str]) -> int:
- """
- Returns the index delimiting the args and kwargs in a list of arguments
- Examples:
- find_kwwarg_index(['a','b','c=3']) -> 2
- find_kwwarg_index([]) -> None
-
- Args:
- list of Strings representing the arguments of a function
-
- Return:
- index delimiting the args and kwargs in a list of arguments
-
- """
- kwarg_index = len(signature_couple)
- for i, item in enumerate(signature_couple):
- if "=" in item:
- kwarg_index = i
- break
- return kwarg_index
-
-
-def extract_args(code: str) -> Tuple[List[str], List[str]]:
- """
- Returns the args and kwargs of a string of Python code defining a function
- Examples:
- get_signature(def hello(a,b,c=3)...) -> "(a,b,c=3)"
-
- Args:
- code: String containing Python code
-
- Return:
- (args, kwargs) of first defined function
-
- """
- signature_string = get_signature(code)
- # Remove parentheses
- signature_string = signature_string[1:-2]
- signature_string = signature_string.replace(" ", "")
- if signature_string == "":
- return ([], [])
- signature_list = signature_string.split(",")
- kwarg_index = find_kwarg_index(signature_list)
- return signature_list[:kwarg_index], signature_list[kwarg_index:]
-
-
-def execute_function(code: str, *args, **kwargs) -> str:
- """
- Executes the function defined in code in an IPython shell and runs it fed by args and kwargs.
- Other arguments than the first are passed to the function when executing it.
- Keyword arguments are passed to the function when executing it.
-
- Args:
- code: String representing the function code to execute.
-
- Return:
- String representing the output given by the IPython shell when executing the function.
-
- """
- function_name = get_function_name(code)
- execution_code = f"{function_name}("
- for arg in args:
- execution_code += f"{arg},"
- for name, value in kwargs.items():
- execution_code += f"{name}={value},"
-
- run_cell(code)
- return run_cell(execution_code + ")")
diff --git a/pyflow/__init__.py b/pyflow/__init__.py
new file mode 100644
index 00000000..8fdd529a
--- /dev/null
+++ b/pyflow/__init__.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# Pyflow an open-source tool for modular visual programing in python
+# Copyright (C) 2021 Mathïs FEDERICO
+
+""" Pyflow: An open-source tool for modular visual programing in python """
+
+__appname__ = "Pyflow"
+__author__ = "Mathïs Fédérico"
+__version__ = "0.0.1"
diff --git a/opencodeblocks/__main__.py b/pyflow/__main__.py
similarity index 73%
rename from opencodeblocks/__main__.py
rename to pyflow/__main__.py
index 957d8365..7d13e2c8 100644
--- a/opencodeblocks/__main__.py
+++ b/pyflow/__main__.py
@@ -1,7 +1,11 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
# pylint:disable=wrong-import-position
+"""
+Pyflow main module, run this to launch Pyflow
+"""
+
import os
import sys
import asyncio
@@ -10,7 +14,7 @@
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
from qtpy.QtWidgets import QApplication
-from opencodeblocks.graphics.window import OCBWindow
+from pyflow.graphics.window import OCBWindow
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
@@ -21,5 +25,7 @@
wnd = OCBWindow()
if len(sys.argv) > 1:
wnd.createNewMdiChild(sys.argv[1])
+
+ wnd.setWindowTitle("Pyflow Beta v0.1")
wnd.show()
sys.exit(app.exec_())
diff --git a/pyflow/blocks/__init__.py b/pyflow/blocks/__init__.py
new file mode 100644
index 00000000..a22024d9
--- /dev/null
+++ b/pyflow/blocks/__init__.py
@@ -0,0 +1,10 @@
+# Pyflow an open-source tool for modular visual programing in python
+# Copyright (C) 2021 Mathïs FEDERICO
+
+""" Module for the OCB Blocks of different types. """
+
+from pyflow.blocks.sliderblock import OCBSliderBlock
+from pyflow.blocks.codeblock import OCBCodeBlock
+from pyflow.blocks.markdownblock import OCBMarkdownBlock
+from pyflow.blocks.drawingblock import OCBDrawingBlock
+from pyflow.blocks.containerblock import OCBContainerBlock
diff --git a/opencodeblocks/blocks/block.py b/pyflow/blocks/block.py
similarity index 96%
rename from opencodeblocks/blocks/block.py
rename to pyflow/blocks/block.py
index 9aafddf7..917b0b4f 100644
--- a/opencodeblocks/blocks/block.py
+++ b/pyflow/blocks/block.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
# pylint:disable=unused-argument
@@ -16,19 +16,19 @@
QWidget,
)
-from opencodeblocks.core.serializable import Serializable
-from opencodeblocks.graphics.socket import OCBSocket
-from opencodeblocks.blocks.widgets import OCBSplitter, OCBSizeGrip, OCBTitle
+from pyflow.core.serializable import Serializable
+from pyflow.core.socket import OCBSocket
+from pyflow.blocks.widgets import OCBSplitter, OCBSizeGrip, OCBTitle
if TYPE_CHECKING:
- from opencodeblocks.scene.scene import OCBScene
+ from pyflow.scene.scene import OCBScene
BACKGROUND_COLOR = QColor("#E3212121")
class OCBBlock(QGraphicsItem, Serializable):
- """Base class for blocks in OpenCodeBlocks."""
+ """Base class for blocks in Pyflow."""
DEFAULT_DATA = {
"title": "New block",
@@ -52,7 +52,7 @@ def __init__(
title: Union[OCBTitle, str] = DEFAULT_DATA["title"],
parent: Optional["QGraphicsItem"] = None,
):
- """Base class for blocks in OpenCodeBlocks.
+ """Base class for blocks in Pyflow.
Args:
block_type: Block type.
diff --git a/opencodeblocks/blocks/codeblock.py b/pyflow/blocks/codeblock.py
similarity index 97%
rename from opencodeblocks/blocks/codeblock.py
rename to pyflow/blocks/codeblock.py
index ba312697..96b54de3 100644
--- a/opencodeblocks/blocks/codeblock.py
+++ b/pyflow/blocks/codeblock.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the base OCB Code Block. """
@@ -15,10 +15,10 @@
from ansi2html import Ansi2HTMLConverter
-from opencodeblocks.blocks.block import OCBBlock
+from pyflow.blocks.block import OCBBlock
-from opencodeblocks.blocks.executableblock import OCBExecutableBlock
-from opencodeblocks.graphics.pyeditor import PythonEditor
+from pyflow.blocks.executableblock import OCBExecutableBlock
+from pyflow.core.pyeditor import PythonEditor
conv = Ansi2HTMLConverter()
diff --git a/opencodeblocks/blocks/containerblock.py b/pyflow/blocks/containerblock.py
similarity index 84%
rename from opencodeblocks/blocks/containerblock.py
rename to pyflow/blocks/containerblock.py
index df00a483..b2aec37b 100644
--- a/opencodeblocks/blocks/containerblock.py
+++ b/pyflow/blocks/containerblock.py
@@ -3,7 +3,7 @@
"""
from PyQt5.QtWidgets import QVBoxLayout
-from opencodeblocks.blocks.block import OCBBlock
+from pyflow.blocks.block import OCBBlock
class OCBContainerBlock(OCBBlock):
@@ -18,10 +18,10 @@ def __init__(self, **kwargs):
# Due to the overall structure of the code, this cannot be removed, as the
# scene should be able to serialize blocks.
# This is not due to bad code design and should not be removed.
- from opencodeblocks.graphics.view import (
+ from pyflow.graphics.view import (
OCBView,
) # pylint: disable=cyclic-import
- from opencodeblocks.scene.scene import OCBScene # pylint: disable=cyclic-import
+ from pyflow.scene.scene import OCBScene # pylint: disable=cyclic-import
self.layout = QVBoxLayout(self.root)
self.layout.setContentsMargins(
diff --git a/opencodeblocks/blocks/drawingblock.py b/pyflow/blocks/drawingblock.py
similarity index 97%
rename from opencodeblocks/blocks/drawingblock.py
rename to pyflow/blocks/drawingblock.py
index e4ec7a46..7a7b3a64 100644
--- a/opencodeblocks/blocks/drawingblock.py
+++ b/pyflow/blocks/drawingblock.py
@@ -1,5 +1,7 @@
# pylint:disable=unused-argument
+""" Module for the base OCB Drawing Block. """
+
from math import floor
import json
from typing import OrderedDict
@@ -7,7 +9,7 @@
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QColor, QMouseEvent, QPaintEvent, QPainter
from PyQt5.QtWidgets import QPushButton, QWidget
-from opencodeblocks.blocks.executableblock import OCBExecutableBlock
+from pyflow.blocks.executableblock import OCBExecutableBlock
eps = 1
diff --git a/opencodeblocks/blocks/executableblock.py b/pyflow/blocks/executableblock.py
similarity index 98%
rename from opencodeblocks/blocks/executableblock.py
rename to pyflow/blocks/executableblock.py
index 5539741a..590a0e0b 100644
--- a/opencodeblocks/blocks/executableblock.py
+++ b/pyflow/blocks/executableblock.py
@@ -5,10 +5,8 @@
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication
-from networkx.algorithms.traversal.breadth_first_search import bfs_edges
-
-from opencodeblocks.blocks.block import OCBBlock
-from opencodeblocks.graphics.socket import OCBSocket
+from pyflow.blocks.block import OCBBlock
+from pyflow.core.socket import OCBSocket
class OCBExecutableBlock(OCBBlock):
diff --git a/opencodeblocks/blocks/markdownblock.py b/pyflow/blocks/markdownblock.py
similarity index 96%
rename from opencodeblocks/blocks/markdownblock.py
rename to pyflow/blocks/markdownblock.py
index 7c953b00..d184030c 100644
--- a/opencodeblocks/blocks/markdownblock.py
+++ b/pyflow/blocks/markdownblock.py
@@ -9,8 +9,8 @@
from PyQt5.Qsci import QsciLexerMarkdown, QsciScintilla
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QFont
-from opencodeblocks.blocks.block import OCBBlock
-from opencodeblocks.graphics.theme_manager import theme_manager
+from pyflow.blocks.block import OCBBlock
+from pyflow.graphics.theme_manager import theme_manager
class OCBMarkdownBlock(OCBBlock):
diff --git a/opencodeblocks/blocks/sliderblock.py b/pyflow/blocks/sliderblock.py
similarity index 95%
rename from opencodeblocks/blocks/sliderblock.py
rename to pyflow/blocks/sliderblock.py
index 0fa580b2..e64615fe 100644
--- a/opencodeblocks/blocks/sliderblock.py
+++ b/pyflow/blocks/sliderblock.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
"""
Exports OCBSliderBlock.
@@ -7,7 +7,7 @@
from typing import OrderedDict
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QLineEdit, QSlider, QVBoxLayout
-from opencodeblocks.blocks.executableblock import OCBExecutableBlock
+from pyflow.blocks.executableblock import OCBExecutableBlock
class OCBSliderBlock(OCBExecutableBlock):
diff --git a/pyflow/blocks/widgets/__init__.py b/pyflow/blocks/widgets/__init__.py
new file mode 100644
index 00000000..bcbaef76
--- /dev/null
+++ b/pyflow/blocks/widgets/__init__.py
@@ -0,0 +1,8 @@
+# Pyflow an open-source tool for modular visual programing in python
+# Copyright (C) 2021 Mathïs FEDERICO
+
+""" Module for the OCB Blocks Widgets. """
+
+from pyflow.blocks.widgets.blocksplitter import OCBSplitter
+from pyflow.blocks.widgets.blocktitle import OCBTitle
+from pyflow.blocks.widgets.blocksizegrip import OCBSizeGrip
diff --git a/opencodeblocks/blocks/widgets/blocksizegrip.py b/pyflow/blocks/widgets/blocksizegrip.py
similarity index 100%
rename from opencodeblocks/blocks/widgets/blocksizegrip.py
rename to pyflow/blocks/widgets/blocksizegrip.py
diff --git a/opencodeblocks/blocks/widgets/blocksplitter.py b/pyflow/blocks/widgets/blocksplitter.py
similarity index 100%
rename from opencodeblocks/blocks/widgets/blocksplitter.py
rename to pyflow/blocks/widgets/blocksplitter.py
diff --git a/opencodeblocks/blocks/widgets/blocktitle.py b/pyflow/blocks/widgets/blocktitle.py
similarity index 98%
rename from opencodeblocks/blocks/widgets/blocktitle.py
rename to pyflow/blocks/widgets/blocktitle.py
index f9a50e18..de187992 100644
--- a/opencodeblocks/blocks/widgets/blocktitle.py
+++ b/pyflow/blocks/widgets/blocktitle.py
@@ -10,7 +10,7 @@
from PyQt5.QtGui import QFocusEvent, QFont, QMouseEvent
from PyQt5.QtWidgets import QLineEdit, QWidget
-from opencodeblocks.core.serializable import Serializable
+from pyflow.core.serializable import Serializable
class OCBTitle(QLineEdit, Serializable):
diff --git a/pyflow/core/__init__.py b/pyflow/core/__init__.py
new file mode 100644
index 00000000..a474fac2
--- /dev/null
+++ b/pyflow/core/__init__.py
@@ -0,0 +1,2 @@
+# Pyflow an open-source tool for modular visual programing in python
+# Copyright (C) 2021 Mathïs FEDERICO
diff --git a/opencodeblocks/graphics/edge.py b/pyflow/core/edge.py
similarity index 96%
rename from opencodeblocks/graphics/edge.py
rename to pyflow/core/edge.py
index b0a683f4..7f1b297e 100644
--- a/opencodeblocks/graphics/edge.py
+++ b/pyflow/core/edge.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCB Edge. """
@@ -15,13 +15,13 @@
QWidget,
)
-from opencodeblocks.core.serializable import Serializable
-from opencodeblocks.graphics.socket import OCBSocket
+from pyflow.core.serializable import Serializable
+from pyflow.core.socket import OCBSocket
class OCBEdge(QGraphicsPathItem, Serializable):
- """Base class for directed edges in OpenCodeBlocks."""
+ """Base class for directed edges in Pyflow."""
DEFAULT_DATA = {"path_type": "bezier"}
MANDATORY_FIELDS = {"source", "destination"}
@@ -39,7 +39,7 @@ def __init__(
source_socket: OCBSocket = None,
destination_socket: OCBSocket = None,
):
- """Base class for edges in OpenCodeBlocks.
+ """Base class for edges in Pyflow.
Args:
edge_width: Width of the edge.
diff --git a/opencodeblocks/graphics/kernel.py b/pyflow/core/kernel.py
similarity index 98%
rename from opencodeblocks/graphics/kernel.py
rename to pyflow/core/kernel.py
index 6cea732d..e4348466 100644
--- a/opencodeblocks/graphics/kernel.py
+++ b/pyflow/core/kernel.py
@@ -4,7 +4,7 @@
from typing import Tuple
from jupyter_client.manager import start_new_kernel
-from opencodeblocks.graphics.worker import Worker
+from pyflow.core.worker import Worker
class Kernel:
diff --git a/opencodeblocks/graphics/pyeditor.py b/pyflow/core/pyeditor.py
similarity index 91%
rename from opencodeblocks/graphics/pyeditor.py
rename to pyflow/core/pyeditor.py
index 19b02c82..ce65dfa8 100644
--- a/opencodeblocks/graphics/pyeditor.py
+++ b/pyflow/core/pyeditor.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for OCB in block python editor. """
@@ -14,22 +14,22 @@
QWheelEvent,
)
from PyQt5.Qsci import QsciScintilla, QsciLexerPython
-from opencodeblocks.graphics.theme_manager import theme_manager
+from pyflow.graphics.theme_manager import theme_manager
-from opencodeblocks.blocks.block import OCBBlock
+from pyflow.blocks.block import OCBBlock
if TYPE_CHECKING:
- from opencodeblocks.graphics.view import OCBView
+ from pyflow.graphics.view import OCBView
POINT_SIZE = 11
class PythonEditor(QsciScintilla):
- """In-block python editor for OpenCodeBlocks."""
+ """In-block python editor for Pyflow."""
def __init__(self, block: OCBBlock):
- """In-block python editor for OpenCodeBlocks.
+ """In-block python editor for Pyflow.
Args:
block: Block in which to add the python editor widget.
diff --git a/opencodeblocks/core/serializable.py b/pyflow/core/serializable.py
similarity index 94%
rename from opencodeblocks/core/serializable.py
rename to pyflow/core/serializable.py
index 4ed6505d..de75c58e 100644
--- a/opencodeblocks/core/serializable.py
+++ b/pyflow/core/serializable.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the Serializable base class """
diff --git a/opencodeblocks/graphics/socket.py b/pyflow/core/socket.py
similarity index 93%
rename from opencodeblocks/graphics/socket.py
rename to pyflow/core/socket.py
index 366b1f29..866ef168 100644
--- a/opencodeblocks/graphics/socket.py
+++ b/pyflow/core/socket.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for OCB Sockets """
@@ -11,16 +11,16 @@
from PyQt5.QtGui import QBrush, QColor, QPainter, QPen, QPolygon
from PyQt5.QtWidgets import QGraphicsItem, QStyleOptionGraphicsItem, QWidget
-from opencodeblocks.core.serializable import Serializable
+from pyflow.core.serializable import Serializable
if TYPE_CHECKING:
- from opencodeblocks.graphics.edge import OCBEdge
- from opencodeblocks.blocks.block import OCBBlock
+ from pyflow.core.edge import OCBEdge
+ from pyflow.blocks.block import OCBBlock
class OCBSocket(QGraphicsItem, Serializable):
- """Base class for sockets in OpenCodeBlocks."""
+ """Base class for sockets in Pyflow."""
DEFAULT_DATA = {
"type": "undefined",
@@ -43,7 +43,7 @@ def __init__(
linewidth: float = DEFAULT_DATA["metadata"]["linewidth"],
linecolor: str = DEFAULT_DATA["metadata"]["linecolor"],
):
- """Base class for sockets in OpenCodeBlocks.
+ """Base class for sockets in Pyflow.
Args:
block: Block containing the socket.
diff --git a/opencodeblocks/graphics/worker.py b/pyflow/core/worker.py
similarity index 95%
rename from opencodeblocks/graphics/worker.py
rename to pyflow/core/worker.py
index ea339952..f87ba6cc 100644
--- a/opencodeblocks/graphics/worker.py
+++ b/pyflow/core/worker.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module to create and manage multi-threading workers """
diff --git a/pyflow/graphics/__init__.py b/pyflow/graphics/__init__.py
new file mode 100644
index 00000000..a474fac2
--- /dev/null
+++ b/pyflow/graphics/__init__.py
@@ -0,0 +1,2 @@
+# Pyflow an open-source tool for modular visual programing in python
+# Copyright (C) 2021 Mathïs FEDERICO
diff --git a/opencodeblocks/graphics/theme.py b/pyflow/graphics/theme.py
similarity index 100%
rename from opencodeblocks/graphics/theme.py
rename to pyflow/graphics/theme.py
diff --git a/opencodeblocks/graphics/theme_manager.py b/pyflow/graphics/theme_manager.py
similarity index 96%
rename from opencodeblocks/graphics/theme_manager.py
rename to pyflow/graphics/theme_manager.py
index f1a7f89d..d967a76f 100644
--- a/opencodeblocks/graphics/theme_manager.py
+++ b/pyflow/graphics/theme_manager.py
@@ -11,7 +11,7 @@
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtCore import pyqtSignal, QObject
-from opencodeblocks.graphics.theme import Theme
+from pyflow.graphics.theme import Theme
class ThemeManager(QObject):
@@ -45,6 +45,7 @@ def __init__(self, parent=None):
@property
def selected_theme_index(self):
+ """Return the index of the selected theme"""
return self._selected_theme_index
@selected_theme_index.setter
diff --git a/opencodeblocks/graphics/view.py b/pyflow/graphics/view.py
similarity index 98%
rename from opencodeblocks/graphics/view.py
rename to pyflow/graphics/view.py
index 152f192c..d706644e 100644
--- a/opencodeblocks/graphics/view.py
+++ b/pyflow/graphics/view.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCB View """
@@ -13,11 +13,11 @@
from PyQt5.sip import isdeleted
-from opencodeblocks.scene import OCBScene
-from opencodeblocks.graphics.socket import OCBSocket
-from opencodeblocks.graphics.edge import OCBEdge
-from opencodeblocks.blocks.block import OCBBlock
-from opencodeblocks.blocks.codeblock import OCBCodeBlock
+from pyflow.scene import OCBScene
+from pyflow.core.socket import OCBSocket
+from pyflow.core.edge import OCBEdge
+from pyflow.blocks.block import OCBBlock
+from pyflow.blocks.codeblock import OCBCodeBlock
EPS: float = 1e-10 # To check if blocks are of size 0
diff --git a/opencodeblocks/graphics/widget.py b/pyflow/graphics/widget.py
similarity index 87%
rename from opencodeblocks/graphics/widget.py
rename to pyflow/graphics/widget.py
index 5399ba28..db89e000 100644
--- a/opencodeblocks/graphics/widget.py
+++ b/pyflow/graphics/widget.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCB Widget """
@@ -8,8 +8,8 @@
from PyQt5.QtWidgets import QVBoxLayout, QWidget
from PyQt5.QtCore import Qt
-from opencodeblocks.scene import OCBScene
-from opencodeblocks.graphics.view import OCBView
+from pyflow.scene import OCBScene
+from pyflow.graphics.view import OCBView
class OCBWidget(QWidget):
@@ -59,13 +59,15 @@ def savepath(self, value: str):
self.updateTitle()
def save(self):
+ """Save the current graph to the current save path."""
self.scene.save(self.savepath)
- def saveAsJupyter(self, filepath:str):
+ def saveAsJupyter(self, filepath: str):
"""Save the current graph notebook as a regular python notebook"""
self.scene.save_to_ipynb(filepath)
def load(self, filepath: str):
+ """Load a graph from a file."""
self.scene.load(filepath)
self.savepath = filepath
diff --git a/opencodeblocks/graphics/window.py b/pyflow/graphics/window.py
similarity index 92%
rename from opencodeblocks/graphics/window.py
rename to pyflow/graphics/window.py
index 1678fbb6..9ca5559d 100644
--- a/opencodeblocks/graphics/window.py
+++ b/pyflow/graphics/window.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
# pylint:disable=too-many-instance-attributes
@@ -9,8 +9,6 @@
from PyQt5.QtGui import QCloseEvent, QKeySequence
from PyQt5.QtWidgets import (
- QDockWidget,
- QListWidget,
QWidget,
QAction,
QFileDialog,
@@ -19,15 +17,15 @@
QMdiArea,
)
-from opencodeblocks.graphics.widget import OCBWidget
-from opencodeblocks.graphics.theme_manager import theme_manager
+from pyflow.graphics.widget import OCBWidget
+from pyflow.graphics.theme_manager import theme_manager
-from opencodeblocks.qss import loadStylesheets
+from pyflow.qss import loadStylesheets
class OCBWindow(QMainWindow):
- """Main window of the OpenCodeBlocks Qt-based application."""
+ """Main window of the Pyflow Qt-based application."""
def __init__(self):
super().__init__()
@@ -63,9 +61,6 @@ def __init__(self):
self.createMenus()
self.createToolBars()
- # BlocksDock
- self.createBlocksDock()
-
# StatusBar
self.statusbar = self.statusBar()
@@ -76,28 +71,10 @@ def __init__(self):
self.show()
def createToolBars(self):
- pass
-
- def createBlocksDock(self):
- self.block_list = QListWidget()
- self.block_list.addItem("Data loading")
- self.block_list.addItem("Data normalization")
- self.block_list.addItem("Data visualisation")
- self.block_list.addItem("Data preprocessing")
- self.block_list.addItem("Data reshape")
- self.block_list.addItem("Model definition")
- self.block_list.addItem("Model training")
- self.block_list.addItem("Model prediction")
- self.block_list.addItem("Model evaluation")
-
- self.items = QDockWidget("Blocks")
- self.items.setWidget(self.block_list)
- self.items.setFloating(False)
-
- self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.items)
+ """Does nothing, but is required by the QMainWindow interface."""
def updateMenus(self):
- pass
+ """Does nothing, but is required by the QMainWindow interface."""
def createActions(self):
"""Create all menu actions."""
@@ -260,6 +237,7 @@ def createMenus(self):
self.menuBar().addSeparator()
def updateThemeMenu(self):
+ """Update the theme selection menu."""
self.thememenu.clear()
theme_names = theme_manager().list_themes()
for i, theme in enumerate(theme_names):
@@ -270,6 +248,7 @@ def updateThemeMenu(self):
self.themeMapper.setMapping(action, i)
def updateWindowMenu(self):
+ """Update the window menu."""
self.windowMenu.clear()
self.windowMenu.addAction(self._actClose)
self.windowMenu.addAction(self._actCloseAll)
@@ -480,7 +459,8 @@ def activeMdiChild(self) -> OCBWidget:
return None
def readSettings(self):
- settings = QSettings("AutopIA", "OpenCodeBlocks")
+ """Read the settings from the config file."""
+ settings = QSettings("AutopIA", "Pyflow")
pos = settings.value("pos", QPoint(200, 200))
size = settings.value("size", QSize(400, 400))
self.move(pos)
@@ -489,12 +469,14 @@ def readSettings(self):
self.showMaximized()
def writeSettings(self):
- settings = QSettings("AutopIA", "OpenCodeBlocks")
+ """Write the settings to the config file."""
+ settings = QSettings("AutopIA", "Pyflow")
settings.setValue("pos", self.pos())
settings.setValue("size", self.size())
settings.setValue("isMaximized", self.isMaximized())
def setActiveSubWindow(self, window):
+ """Set the active subwindow to the given window."""
if window:
self.mdiArea.setActiveSubWindow(window)
@@ -508,4 +490,5 @@ def onMoveToItems(self):
current_window.moveToItems()
def setTheme(self, theme_index):
+ """Set the theme of the application."""
theme_manager().selected_theme_index = theme_index
diff --git a/opencodeblocks/qss/__init__.py b/pyflow/qss/__init__.py
similarity index 76%
rename from opencodeblocks/qss/__init__.py
rename to pyflow/qss/__init__.py
index 208e3fc4..8b1d3ea3 100644
--- a/opencodeblocks/qss/__init__.py
+++ b/pyflow/qss/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCB qss and styles. """
@@ -8,10 +8,11 @@
from PyQt5.QtCore import QFile
from PyQt5.QtWidgets import QApplication
-from opencodeblocks.qss import dark_resources
+from pyflow.qss import dark_resources
def loadStylesheets(filenames: List[str]):
+ """Load the stylesheets from the given filenames."""
styles = ""
for filename in filenames:
file = QFile(filename)
diff --git a/opencodeblocks/qss/dark_resources.py b/pyflow/qss/dark_resources.py
similarity index 99%
rename from opencodeblocks/qss/dark_resources.py
rename to pyflow/qss/dark_resources.py
index 1c2aad50..9a1f60f9 100644
--- a/opencodeblocks/qss/dark_resources.py
+++ b/pyflow/qss/dark_resources.py
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
-# Resource object code
-#
-# Created by: The Resource Compiler for PyQt5 (Qt v5.11.2)
-#
-# WARNING! All changes made in this file will be lost!
+"""
+Resource object code
+
+Created by: The Resource Compiler for PyQt5 (Qt v5.11.2)
+
+WARNING! All changes made in this file will be lost!
+"""
from qtpy import QtCore
@@ -502,12 +504,14 @@
def qInitResources():
+ """Initialize the qt resources."""
QtCore.qRegisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)
def qCleanupResources():
+ """Cleanup the qt resources."""
QtCore.qUnregisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)
diff --git a/opencodeblocks/qss/ocb.qss b/pyflow/qss/ocb.qss
similarity index 100%
rename from opencodeblocks/qss/ocb.qss
rename to pyflow/qss/ocb.qss
diff --git a/opencodeblocks/qss/ocb_dark.qss b/pyflow/qss/ocb_dark.qss
similarity index 100%
rename from opencodeblocks/qss/ocb_dark.qss
rename to pyflow/qss/ocb_dark.qss
diff --git a/opencodeblocks/scene/__init__.py b/pyflow/scene/__init__.py
similarity index 51%
rename from opencodeblocks/scene/__init__.py
rename to pyflow/scene/__init__.py
index 5da0fc6b..593113ba 100644
--- a/opencodeblocks/scene/__init__.py
+++ b/pyflow/scene/__init__.py
@@ -1,6 +1,6 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCBScene creation and manipulations. """
-from opencodeblocks.scene.scene import OCBScene
+from pyflow.scene.scene import OCBScene
diff --git a/opencodeblocks/scene/clipboard.py b/pyflow/scene/clipboard.py
similarity index 94%
rename from opencodeblocks/scene/clipboard.py
rename to pyflow/scene/clipboard.py
index c7fd021c..85bfb210 100644
--- a/opencodeblocks/scene/clipboard.py
+++ b/pyflow/scene/clipboard.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the handling an OCBScene clipboard operations. """
@@ -9,11 +9,11 @@
import json
from PyQt5.QtWidgets import QApplication
-from opencodeblocks.graphics.edge import OCBEdge
+from pyflow.core.edge import OCBEdge
if TYPE_CHECKING:
- from opencodeblocks.scene import OCBScene
- from opencodeblocks.graphics.view import OCBView
+ from pyflow.scene import OCBScene
+ from pyflow.graphics.view import OCBView
class SceneClipboard:
diff --git a/opencodeblocks/scene/from_ipynb_conversion.py b/pyflow/scene/from_ipynb_conversion.py
similarity index 97%
rename from opencodeblocks/scene/from_ipynb_conversion.py
rename to pyflow/scene/from_ipynb_conversion.py
index aaefbfd9..3f918056 100644
--- a/opencodeblocks/scene/from_ipynb_conversion.py
+++ b/pyflow/scene/from_ipynb_conversion.py
@@ -4,9 +4,9 @@
from PyQt5.QtGui import QFontMetrics, QFont
-from opencodeblocks.scene.ipynb_conversion_constants import *
-from opencodeblocks.graphics.theme_manager import theme_manager
-from opencodeblocks.graphics.pyeditor import POINT_SIZE
+from pyflow.scene.ipynb_conversion_constants import *
+from pyflow.graphics.theme_manager import theme_manager
+from pyflow.core.pyeditor import POINT_SIZE
def ipynb_to_ipyg(data: OrderedDict, use_theme_font: bool = True) -> OrderedDict:
diff --git a/opencodeblocks/scene/history.py b/pyflow/scene/history.py
similarity index 95%
rename from opencodeblocks/scene/history.py
rename to pyflow/scene/history.py
index 945079fe..676c3cd1 100644
--- a/opencodeblocks/scene/history.py
+++ b/pyflow/scene/history.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the handling an OCBScene history. """
@@ -6,7 +6,7 @@
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
- from opencodeblocks.scene import OCBScene
+ from pyflow.scene import OCBScene
class SceneHistory:
diff --git a/opencodeblocks/scene/ipynb_conversion_constants.py b/pyflow/scene/ipynb_conversion_constants.py
similarity index 100%
rename from opencodeblocks/scene/ipynb_conversion_constants.py
rename to pyflow/scene/ipynb_conversion_constants.py
diff --git a/opencodeblocks/scene/scene.py b/pyflow/scene/scene.py
similarity index 94%
rename from opencodeblocks/scene/scene.py
rename to pyflow/scene/scene.py
index 60b86814..9ee8fe6d 100644
--- a/opencodeblocks/scene/scene.py
+++ b/pyflow/scene/scene.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for the OCB Scene """
@@ -13,15 +13,15 @@
from PyQt5.QtGui import QColor, QPainter, QPen
from PyQt5.QtWidgets import QGraphicsScene
-from opencodeblocks.core.serializable import Serializable
-from opencodeblocks.blocks.block import OCBBlock
-from opencodeblocks.graphics.edge import OCBEdge
-from opencodeblocks.scene.clipboard import SceneClipboard
-from opencodeblocks.scene.history import SceneHistory
-from opencodeblocks.graphics.kernel import Kernel
-from opencodeblocks.scene.from_ipynb_conversion import ipynb_to_ipyg
-from opencodeblocks.scene.to_ipynb_conversion import ipyg_to_ipynb
-from opencodeblocks import blocks
+from pyflow.core.serializable import Serializable
+from pyflow.blocks.block import OCBBlock
+from pyflow.core.edge import OCBEdge
+from pyflow.scene.clipboard import SceneClipboard
+from pyflow.scene.history import SceneHistory
+from pyflow.core.kernel import Kernel
+from pyflow.scene.from_ipynb_conversion import ipynb_to_ipyg
+from pyflow.scene.to_ipynb_conversion import ipyg_to_ipynb
+from pyflow import blocks
class OCBScene(QGraphicsScene, Serializable):
diff --git a/opencodeblocks/scene/to_ipynb_conversion.py b/pyflow/scene/to_ipynb_conversion.py
similarity index 96%
rename from opencodeblocks/scene/to_ipynb_conversion.py
rename to pyflow/scene/to_ipynb_conversion.py
index 98e78878..a079cf99 100644
--- a/opencodeblocks/scene/to_ipynb_conversion.py
+++ b/pyflow/scene/to_ipynb_conversion.py
@@ -4,7 +4,7 @@
import copy
-from opencodeblocks.scene.ipynb_conversion_constants import *
+from pyflow.scene.ipynb_conversion_constants import *
def ipyg_to_ipynb(data: OrderedDict) -> OrderedDict:
diff --git a/pylint_score.py b/pylint_score.py
index cf64757e..b983c8e9 100644
--- a/pylint_score.py
+++ b/pylint_score.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module to get pylint score. """
@@ -54,7 +54,7 @@ def register(linter):
if __name__ == "__main__":
- options = ["opencodeblocks", "--output-format=pylint_score.MyReporterClass"]
+ options = ["pyflow", "--output-format=pylint_score.MyReporterClass"]
results = Run(options, exit=False)
score = results.linter.stats.global_note
score_min = 8.0
diff --git a/tests/__init__.py b/tests/__init__.py
index c7144c9a..fc97eed2 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
-""" Tests for the opencodeblocks package. """
+""" Tests for the pyflow package. """
diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py
index 59a9200d..419e85cc 100644
--- a/tests/integration/__init__.py
+++ b/tests/integration/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
diff --git a/tests/integration/blocks/__init__.py b/tests/integration/blocks/__init__.py
index da40e082..e0d043db 100644
--- a/tests/integration/blocks/__init__.py
+++ b/tests/integration/blocks/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
diff --git a/tests/integration/blocks/test_block.py b/tests/integration/blocks/test_block.py
index 93d42bce..39ab970d 100644
--- a/tests/integration/blocks/test_block.py
+++ b/tests/integration/blocks/test_block.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
@@ -11,7 +11,7 @@
from PyQt5.QtCore import QPointF
-from opencodeblocks.blocks.block import OCBBlock
+from pyflow.blocks.block import OCBBlock
from tests.integration.utils import apply_function_inapp, CheckingQueue, start_app
diff --git a/tests/integration/blocks/test_codeblock.py b/tests/integration/blocks/test_codeblock.py
index 3c304a0a..9418caf4 100644
--- a/tests/integration/blocks/test_codeblock.py
+++ b/tests/integration/blocks/test_codeblock.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
@@ -12,7 +12,7 @@
from PyQt5.QtCore import QPointF
-from opencodeblocks.blocks.codeblock import OCBCodeBlock
+from pyflow.blocks.codeblock import OCBCodeBlock
from tests.integration.utils import apply_function_inapp, CheckingQueue, start_app
diff --git a/tests/integration/blocks/test_flow.py b/tests/integration/blocks/test_flow.py
index 4bd3747e..ac864559 100644
--- a/tests/integration/blocks/test_flow.py
+++ b/tests/integration/blocks/test_flow.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
@@ -8,7 +8,7 @@
import pytest
import time
-from opencodeblocks.blocks.codeblock import OCBCodeBlock
+from pyflow.blocks.codeblock import OCBCodeBlock
from tests.integration.utils import apply_function_inapp, CheckingQueue, start_app
diff --git a/tests/integration/test_window.py b/tests/integration/test_window.py
index 06a084bd..62cf5fd2 100644
--- a/tests/integration/test_window.py
+++ b/tests/integration/test_window.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
@@ -9,7 +9,7 @@
import pytest
from pytest_mock import MockerFixture
-from opencodeblocks.graphics.window import OCBWindow
+from pyflow.graphics.window import OCBWindow
class TestWindow:
diff --git a/tests/integration/utils.py b/tests/integration/utils.py
index 53a5ab1c..d34d8b9d 100644
--- a/tests/integration/utils.py
+++ b/tests/integration/utils.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
"""
@@ -16,9 +16,9 @@
from qtpy.QtWidgets import QApplication
import pytest_check as check
import warnings
-from opencodeblocks.graphics.widget import OCBWidget
+from pyflow.graphics.widget import OCBWidget
-from opencodeblocks.graphics.window import OCBWindow
+from pyflow.graphics.window import OCBWindow
STOP_MSG = "stop"
CHECK_MSG = "check"
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index e7bad5eb..2e33fcf8 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
-""" Unit tests for the opencodeblocks package. """
+""" Unit tests for the pyflow package. """
diff --git a/tests/unit/scene/__init__.py b/tests/unit/scene/__init__.py
index d3971bdf..47614f0e 100644
--- a/tests/unit/scene/__init__.py
+++ b/tests/unit/scene/__init__.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
-""" Unit tests for the opencodeblocks scene module. """
+""" Unit tests for the pyflow scene module. """
diff --git a/tests/unit/scene/test_clipboard.py b/tests/unit/scene/test_clipboard.py
index d28b2087..cdf77d64 100644
--- a/tests/unit/scene/test_clipboard.py
+++ b/tests/unit/scene/test_clipboard.py
@@ -1,13 +1,13 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
-""" Unit tests for the opencodeblocks history module. """
+""" Unit tests for the pyflow history module. """
import pytest
from pytest_mock import MockerFixture
import pytest_check as check
-from opencodeblocks.scene.clipboard import SceneClipboard
+from pyflow.scene.clipboard import SceneClipboard
class TestSerializeSelected:
diff --git a/tests/unit/scene/test_function_parsing.py b/tests/unit/scene/test_function_parsing.py
deleted file mode 100644
index ec862ce4..00000000
--- a/tests/unit/scene/test_function_parsing.py
+++ /dev/null
@@ -1,118 +0,0 @@
-""" Unit tests for the opencodeblocks function parsing module. """
-
-import pytest
-from pytest_mock import MockerFixture
-import pytest_check as check
-
-from opencodeblocks.graphics.function_parsing import (
- find_kwarg_index,
- run_cell,
- get_function_name,
- get_signature,
- extract_args,
- execute_function,
- find_kwarg_index,
-)
-
-
-class TestFunctionParsing:
-
- """Testing function_parsing functions"""
-
- def test_run_cell(self, mocker: MockerFixture):
- """Test run_cell"""
- check.equal(run_cell("print(10)"), "10\n")
-
- def test_get_function_name(self, mocker: MockerFixture):
- """Test get_function_name"""
- check.equal(get_function_name("def function():\n return 'Hello'"), "function")
- check.equal(
- get_function_name("#Hello\ndef function():\n return 'Hello'\na = 10"),
- "function",
- )
- check.equal(
- get_function_name(
- "#Hello\ndef function(a,b=10):\n return 'Hello'\na = 10"
- ),
- "function",
- )
-
- def test_get_function_name_error(self, mocker: MockerFixture):
- """Return ValueError if get_function_name has wrong input"""
- with pytest.raises(ValueError):
- get_function_name("")
- get_function_name("#Hello")
- get_function_name("def function")
-
- def test_get_signature(self, mocker: MockerFixture):
- """Test get_signature"""
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.run_cell",
- return_value="(a, b, c=10)\n",
- )
- check.equal(
- get_signature("def function(a,b, c=10):\n return None"), "(a, b, c=10)\n"
- )
-
- def test_find_kwarg_index(self, mocker: MockerFixture):
- """Test find_kwarg_index"""
- check.equal(find_kwarg_index(["a", "b", "c=10"]), 2)
- check.equal(find_kwarg_index([]), 0)
-
- def test_extract_args(self, mocker: MockerFixture):
- """Test extract_args"""
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.get_signature",
- return_value="()\n",
- )
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.find_kwarg_index", return_value=0
- )
- check.equal(extract_args("def function():\n return 'Hello'"), ([], []))
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.get_signature",
- return_value="(a,b,c = 10)\n",
- )
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.find_kwarg_index", return_value=2
- )
- check.equal(
- extract_args("def function(a,b,c = 10):\n return 'Hello'"),
- (["a", "b"], ["c=10"]),
- )
-
- def test_extract_args_empty(self, mocker: MockerFixture):
- """Return a couple of empty lists if signature is empty"""
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.get_signature",
- return_value="()\n",
- )
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.find_kwarg_index",
- return_value=None,
- )
- check.equal(extract_args("def function( ):\n return 'Hello'"), ([], []))
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.get_signature",
- return_value="()\n",
- )
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.find_kwarg_index",
- return_value=None,
- )
- check.equal(extract_args("def function():\n return 'Hello'"), ([], []))
-
- def test_execute_function(self, mocker: MockerFixture):
- """Test execute_function"""
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.get_function_name",
- return_value="function",
- )
- mocker.patch(
- "opencodeblocks.graphics.function_parsing.run_cell",
- return_value="Out[1]: 25\n",
- )
- check.equal(
- execute_function("def function(a,b,c=10):\n return a+b+c", 10, 5),
- "Out[1]: 25\n",
- )
diff --git a/tests/unit/scene/test_history.py b/tests/unit/scene/test_history.py
index 30fe0964..bd2dd8a6 100644
--- a/tests/unit/scene/test_history.py
+++ b/tests/unit/scene/test_history.py
@@ -1,13 +1,13 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
-""" Unit tests for the opencodeblocks history module. """
+""" Unit tests for the pyflow history module. """
import pytest
from pytest_mock import MockerFixture
import pytest_check as check
-from opencodeblocks.scene.history import SceneHistory
+from pyflow.scene.history import SceneHistory
class TestUndo:
@@ -23,7 +23,7 @@ def setup(self, mocker: MockerFixture):
def test_undo(self, mocker: MockerFixture):
"""should allow for undo without breaking the history stack."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
check.equal(self.history.history_stack, ["A", "B", "C", "D"])
check.equal(self.history.history_stack[self.history.current], "D")
@@ -36,7 +36,7 @@ def test_undo(self, mocker: MockerFixture):
def test_undo_nostack(self, mocker: MockerFixture):
"""should allow to undo without any change if the history stack is empty."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
self.history.history_stack = []
self.history.current = -1
@@ -49,7 +49,7 @@ def test_undo_nostack(self, mocker: MockerFixture):
def test_undo_end_of_stack(self, mocker: MockerFixture):
"""should allow to undo without any change if at the end of the history stack."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
self.history.current = 0
check.equal(self.history.history_stack, ["A", "B", "C", "D"])
@@ -75,7 +75,7 @@ def setup(self, mocker: MockerFixture):
def test_redo(self, mocker: MockerFixture):
"""should allow for redo without changing the history stack."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
check.equal(self.history.history_stack, ["A", "B", "C", "D"])
check.equal(self.history.history_stack[self.history.current], "B")
@@ -88,7 +88,7 @@ def test_redo(self, mocker: MockerFixture):
def test_redo_nostack(self, mocker: MockerFixture):
"""should allow to redo without any change if the history stack is empty."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
self.history.history_stack = []
self.history.current = -1
@@ -101,7 +101,7 @@ def test_redo_nostack(self, mocker: MockerFixture):
def test_redo_end_of_stack(self, mocker: MockerFixture):
"""should allow to redo without any change if at the beggining of the history stack."""
- mocker.patch("opencodeblocks.scene.history.SceneHistory.restore")
+ mocker.patch("pyflow.scene.history.SceneHistory.restore")
self.history.current = 3
check.equal(self.history.history_stack, ["A", "B", "C", "D"])
diff --git a/tests/unit/scene/test_ipynb_conversion.py b/tests/unit/scene/test_ipynb_conversion.py
index 88d1a4cf..9376644b 100644
--- a/tests/unit/scene/test_ipynb_conversion.py
+++ b/tests/unit/scene/test_ipynb_conversion.py
@@ -5,8 +5,8 @@
import pytest_check as check
import json
-from opencodeblocks.scene.from_ipynb_conversion import ipynb_to_ipyg, is_title
-from opencodeblocks.scene.ipynb_conversion_constants import BLOCK_TYPE_TO_NAME
+from pyflow.scene.from_ipynb_conversion import ipynb_to_ipyg, is_title
+from pyflow.scene.ipynb_conversion_constants import BLOCK_TYPE_TO_NAME
class TestIpynbConversion:
diff --git a/utils.py b/utils.py
index aef55d62..59141d56 100644
--- a/utils.py
+++ b/utils.py
@@ -1,4 +1,4 @@
-# OpenCodeBlock an open-source tool for modular visual programing in python
+# Pyflow an open-source tool for modular visual programing in python
# Copyright (C) 2021 Mathïs FEDERICO
""" Module for badges colors """
@@ -7,10 +7,12 @@
def interpolate(weight, x, y):
+ """Linear interpolation between x and y, given a weight."""
return x * weight + (1 - weight) * y
def score_to_rgb_color(score, score_min, score_max):
+ """Convert a score to a color."""
normalized_score = max(0, (score - score_min) / (score_max - score_min))
hsv_color = (interpolate(normalized_score, 0.33, 0), 1, 1)
rgb_color = hsv_to_rgb(*hsv_color)