summaryrefslogtreecommitdiffstats
path: root/aoc/__init__.py
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2022-12-01 09:36:18 +0100
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2022-12-01 09:36:18 +0100
commit469092002b7f1e1657468941bd86ccd3738baac3 (patch)
treef61cbeefd0bb3e30944165caa6dc5302725f8966 /aoc/__init__.py
parentf57d4d02c5b8050694784e948086271a7f4e49e5 (diff)
download2022-469092002b7f1e1657468941bd86ccd3738baac3.tar.gz
2022-469092002b7f1e1657468941bd86ccd3738baac3.tar.bz2
2022-469092002b7f1e1657468941bd86ccd3738baac3.zip
Added pre-commit
Diffstat (limited to 'aoc/__init__.py')
-rw-r--r--aoc/__init__.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/aoc/__init__.py b/aoc/__init__.py
index b13489c..5fce415 100644
--- a/aoc/__init__.py
+++ b/aoc/__init__.py
@@ -1,3 +1,4 @@
1# -*- coding: utf-8 -*-
1import os 2import os
2from abc import ABC 3from abc import ABC
3from typing import Generator, Any, Iterator 4from typing import Generator, Any, Iterator
@@ -5,23 +6,24 @@ from typing import Generator, Any, Iterator
5 6
6class BaseAssignment(ABC): 7class BaseAssignment(ABC):
7 example_result = NotImplemented 8 example_result = NotImplemented
9
8 def __init__(self, path): 10 def __init__(self, path):
9 self.path = path 11 self.path = path
10 12
11 def __str__(self): 13 def __str__(self):
12 return f'{self.__module__}.{self.__class__.__name__}' 14 return f"{self.__module__}.{self.__class__.__name__}"
13 15
14 def parse_item(self, item: str) -> Any: 16 def parse_item(self, item: str) -> Any:
15 return item 17 return item
16 18
17 def read_input(self, example = False) -> Generator: 19 def read_input(self, example=False) -> Generator:
18 file = f'{self.path}/input.txt' 20 file = f"{self.path}/input.txt"
19 if example or not os.path.isfile(file): 21 if example or not os.path.isfile(file):
20 file = f'{self.path}/example.txt' 22 file = f"{self.path}/example.txt"
21 23
22 with open(file, 'r') as input_file: 24 with open(file, "r") as input_file:
23 for line in input_file.readlines(): 25 for line in input_file.readlines():
24 yield self.parse_item(line.strip()) 26 yield self.parse_item(line.strip())
25 27
26 def run(self, input: Iterator) -> Any: 28 def run(self, input: Iterator) -> Any:
27 raise NotImplementedError('Please implement run') \ No newline at end of file 29 raise NotImplementedError("Please implement run")