Skip to content

Commit 82a6ab1

Browse files
committed
pypi
Prepare repository for pip upload
1 parent 5afc163 commit 82a6ab1

29 files changed

+125
-91
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include automatabpp *.py

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Each graph is called a machine, and each execution is called a state. (Yes, ther
2626

2727
To get a better idea of what's going on here's a quick example. Using a [__yEd Graph Editor__][4] Create a .graphml graph like this one and store it in the _graphs/_ folder of your project as _first.graphml_ .
2828

29-
![](./README/images/first.png)
29+
![](./docs/images/first.png)
3030

3131
Run the next code: (don't forget to clone the repository into your project folder)
3232

@@ -87,20 +87,20 @@ I also recommend using **Python 3.4+** although I haven't even tried it yet on t
8787

8888
### Directories
8989

90-
* **./automatabpp** - our module source code. This directory contains the python code for this project.
91-
* **./graphs** - yEd graphs are stored in this directory by default
92-
* **./README** - I've really took my time to write all of this so I would appreciate you checking it out
90+
* **./automatabpp/** - our module source code. This directory contains the python code for this project.
91+
* **./docs/** - I've really took my time to write all of this so I would appreciate you checking it out
92+
* **./graphs/** - yEd graphs are stored in this directory by default
9393

9494
### Additional Links
9595

9696
Here are some other .md links for You to read about this project.
97-
* [A list of available functions](README/FSM.md)
98-
* [Tutorial](README/tutorial.md) - make a _"Hello, World!"_ type of application (sort of). Also some more insight on what happens in the code itself.
99-
* [Example 1](README/examples/example1.md) - a simple e-mail validation machine
100-
* [Example 2](README/examples/example2.md) - an example for developing with multiple machines
101-
* [Example 3](README/examples/example3.md) - an example showcasing Base64 encode with this paradigm
102-
* [Example 4](README/examples/example4.md) - developing your embedded application with _complex_ behaviour
103-
* [Other](README/other.md)
97+
* [A list of available functions](docs/FSM.md)
98+
* [Tutorial](docs/tutorial.md) - make a _"Hello, World!"_ type of application (sort of). Also some more insight on what happens in the code itself.
99+
* [Example 1](docs/examples/example1.md) - a simple e-mail validation machine
100+
* [Example 2](docs/examples/example2.md) - an example for developing with multiple machines
101+
* [Example 3](docs/examples/example3.md) - an example showcasing Base64 encode with this paradigm
102+
* [Example 4](docs/examples/example4.md) - developing your embedded application with _complex_ behaviour
103+
* [Other](docs/other.md)
104104

105105

106106
[1]: https://en.wikipedia.org/wiki/Automata-based_programming "Automata-based programming"

automatabpp/__init__.py

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,5 @@
1-
__all__ = ["BEHAVIOUR", "EXECUTION", "OPERATION", "INTERFACE", "COMPARISONS"]
1+
from automatabpp.automatabpp import *
22

3-
import logging
4-
automata_bpp_logger = logging.getLogger(__name__)
5-
6-
from . machines.machines import Machines
7-
from . xml.xmlread import read_graphml
8-
from . commandqueue.commandqueue import CommandQueue
9-
from . constants import GRAPHS_DIRECTORY, START_COMMAND_NAME, STOP_COMMAND_NAME
10-
from . comparisons.comparisons import COMPARISONS
11-
12-
from functools import wraps
3+
__version__ = "1.0.0"
134

145
__doc__ = """ docfile """
15-
16-
17-
class BEHAVIOUR:
18-
19-
@staticmethod
20-
def set_default_graph_directory(new_path: str):
21-
global GRAPHS_DIRECTORY
22-
GRAPHS_DIRECTORY = new_path
23-
24-
@staticmethod
25-
def load_behaviour_from_graph(graph_file_path: str, machine_name: str):
26-
if graph_file_path[-8:] == ".graphml":
27-
read_graphml("{}/{}".format(GRAPHS_DIRECTORY, graph_file_path), machine_name)
28-
else:
29-
automata_bpp_logger.warning("Unknown format for reading the graph file: {}".format(graph_file_path))
30-
31-
32-
class EXECUTION:
33-
34-
@staticmethod
35-
def state(func):
36-
current_machine = Machines().GetCurrentDefinedMachine()
37-
if current_machine is not None:
38-
current_machine.SetExecuteStateFunction(func.__name__, func)
39-
return func
40-
41-
42-
class OPERATION:
43-
44-
@staticmethod
45-
def start_fsm():
46-
Machines().ExecuteCommand(START_COMMAND_NAME)
47-
48-
@staticmethod
49-
def stop_fsm():
50-
Machines().ExecuteCommand(STOP_COMMAND_NAME)
51-
Machines().ReturnToStart()
52-
CommandQueue().EmptyAllCommands()
53-
54-
@staticmethod
55-
def reset_fsm():
56-
OPERATION.stop_fsm()
57-
OPERATION.start_fsm()
58-
59-
@staticmethod
60-
def run_fsm(cmd=None):
61-
if cmd is None:
62-
Machines().ExecuteAllCommands()
63-
else:
64-
Machines().ExecuteCommand(cmd)
65-
66-
67-
class INTERFACE:
68-
69-
@staticmethod
70-
def run_command_if_lambda_on_result_true(lambda_func: callable, command: str):
71-
def wrapper_out(func):
72-
@wraps(func)
73-
def wrapper_in(*args, **kwargs):
74-
result = func(*args, **kwargs)
75-
if lambda_func(result):
76-
Machines().ExecuteCommand(command)
77-
return result
78-
return wrapper_in
79-
return wrapper_out

automatabpp/automatabpp.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
__all__ = ["BEHAVIOUR", "EXECUTION", "OPERATION", "INTERFACE", "COMPARISONS"]
2+
3+
import logging
4+
automata_bpp_logger = logging.getLogger(__name__)
5+
6+
from . machines.machines import Machines
7+
from . xml.xmlread import read_graphml
8+
from . commandqueue.commandqueue import CommandQueue
9+
from . constants import GRAPHS_DIRECTORY, START_COMMAND_NAME, STOP_COMMAND_NAME
10+
from . comparisons.comparisons import COMPARISONS
11+
12+
from functools import wraps
13+
14+
15+
class BEHAVIOUR:
16+
17+
@staticmethod
18+
def set_default_graph_directory(new_path: str):
19+
global GRAPHS_DIRECTORY
20+
GRAPHS_DIRECTORY = new_path
21+
22+
@staticmethod
23+
def load_behaviour_from_graph(graph_file_path: str, machine_name: str):
24+
if graph_file_path[-8:] == ".graphml":
25+
read_graphml("{}/{}".format(GRAPHS_DIRECTORY, graph_file_path), machine_name)
26+
else:
27+
automata_bpp_logger.warning("Unknown format for reading the graph file: {}".format(graph_file_path))
28+
29+
30+
class EXECUTION:
31+
32+
@staticmethod
33+
def state(func):
34+
current_machine = Machines().GetCurrentDefinedMachine()
35+
if current_machine is not None:
36+
current_machine.SetExecuteStateFunction(func.__name__, func)
37+
return func
38+
39+
40+
class OPERATION:
41+
42+
@staticmethod
43+
def start_fsm():
44+
Machines().ExecuteCommand(START_COMMAND_NAME)
45+
46+
@staticmethod
47+
def stop_fsm():
48+
Machines().ExecuteCommand(STOP_COMMAND_NAME)
49+
Machines().ReturnToStart()
50+
CommandQueue().EmptyAllCommands()
51+
52+
@staticmethod
53+
def reset_fsm():
54+
OPERATION.stop_fsm()
55+
OPERATION.start_fsm()
56+
57+
@staticmethod
58+
def run_fsm(cmd=None):
59+
if cmd is None:
60+
Machines().ExecuteAllCommands()
61+
else:
62+
Machines().ExecuteCommand(cmd)
63+
64+
65+
class INTERFACE:
66+
67+
@staticmethod
68+
def run_command_if_lambda_on_result_true(lambda_func: callable, command: str):
69+
def wrapper_out(func):
70+
@wraps(func)
71+
def wrapper_in(*args, **kwargs):
72+
result = func(*args, **kwargs)
73+
if lambda_func(result):
74+
Machines().ExecuteCommand(command)
75+
return result
76+
return wrapper_in
77+
return wrapper_out

automatabpp/commandqueue/commandqueue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from automatabpp import automata_bpp_logger
1+
from automatabpp.automatabpp import automata_bpp_logger
22
from automatabpp.metaclasses.singleton import Singleton
33

44

automatabpp/machine/machine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from automatabpp import automata_bpp_logger
1+
from automatabpp.automatabpp import automata_bpp_logger
22
from automatabpp.state.state import State
33
from automatabpp.constants import START_STATE_NAME
44

automatabpp/machines/machines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from automatabpp import automata_bpp_logger
1+
from automatabpp.automatabpp import automata_bpp_logger
22
from automatabpp.metaclasses.singleton import Singleton
33
from automatabpp.machine.machine import Machine
44
from automatabpp.commandqueue.commandqueue import CommandQueue

automatabpp/state/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from automatabpp import automata_bpp_logger
1+
from automatabpp.automatabpp import automata_bpp_logger
22
from automatabpp.commandqueue.commandqueue import CommandQueue
33

44

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)