Skip to content

Commit f840c31

Browse files
committed
python prep package
1 parent 2eca8f9 commit f840c31

File tree

9 files changed

+64
-7
lines changed

9 files changed

+64
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.egg-info

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name="farm-dev"
33
version = "0.0.1"
44
dependencies = [
5+
"attrs"
56
]
67

78
[tool.ruff]

src/farm_tool/__init__.py

Whitespace-only changes.

src/farm_tool/__main__.py

Whitespace-only changes.

src/farm_tool/apps/api/__init__.py

Whitespace-only changes.

src/farm_tool/cli.py

Whitespace-only changes.

src/farm_tool/core/models/scenario.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import List
2+
3+
from attrs import define
4+
5+
from farm_tool.core.models.sensors import Sensor
6+
7+
8+
@define
9+
class InputStreamConfig:
10+
rotation: int
11+
fps: int
12+
13+
14+
@define
15+
class Scenario:
16+
name: str
17+
input_config: InputStreamConfig
18+
sensors: List[Sensor]

src/farm_tool/core/models/sensors.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import abc
2+
import enum
3+
4+
from typing import List
5+
6+
from attrs import define
7+
8+
9+
@define
10+
class Position:
11+
x: int
12+
y: int
13+
14+
15+
class SensorType(enum.Enum):
16+
time = enum.auto()
17+
speed = enum.auto()
18+
heatmap = enum.auto()
19+
counter = enum.auto()
20+
distance = enum.auto()
21+
movement = enum.auto()
22+
23+
24+
class BaseSensorProcessor(metaclass=abc.ABCMeta):
25+
@abc.abstractmethod
26+
def process(self, frame: List[Position], config: dict):
27+
pass
28+
29+
30+
@define
31+
class Sensor:
32+
name: str
33+
description: str
34+
position: Position
35+
type: SensorType
36+
activation: List[BaseSensorProcessor]

view-md.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44

55

66
def encode_text(data: str) -> str:
7-
return base64.urlsafe_b64encode(zlib.compress(data.encode('utf-8'), 9)).decode()
7+
return base64.urlsafe_b64encode(zlib.compress(data.encode("utf-8"), 9)).decode()
8+
89

910
LANG_DICT = {
1011
"plantuml": "https://kroki.io/c4plantuml/svg/{data}",
1112
"blockdiag": "https://kroki.io/blockdiag/svg/{data}",
1213
}
1314

14-
def process(input: Path):
1515

16+
def process(input: Path):
1617
encode_flag = False
1718
lang = ""
1819
data_collected = []
1920
for line in input.read_text().splitlines():
20-
21-
2221
if line.startswith("```") and not encode_flag:
2322
encode_flag = True
2423
lang = line[3:]
@@ -41,6 +40,8 @@ def process(input: Path):
4140
data_collected.append(line)
4241

4342

44-
Path(r"D:\dev\farm-dev\docs\discussions\001-requirements-analysis.proc.md").write_text("\n".join(
45-
process(Path(r"D:\dev\farm-dev\docs\discussions\001-requirements-analysis.md"))
46-
))
43+
Path(r"D:\dev\farm-dev\docs\discussions\001-requirements-analysis.proc.md").write_text(
44+
"\n".join(
45+
process(Path(r"D:\dev\farm-dev\docs\discussions\001-requirements-analysis.md"))
46+
)
47+
)

0 commit comments

Comments
 (0)