-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
42 lines (28 loc) · 1.13 KB
/
__init__.py
File metadata and controls
42 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from .registro import Register
from . import errors
class FWDataFile(object):
_separator = ""
def __init__(self, specs_dirpath: str, separator: str="" ):
self._lines = []
self._separator = separator
self._specs_dirpath = specs_dirpath
self._registers = Register(self._specs_dirpath)
@property
def specs_dirpath(self):
return self._specs_dirpath
@specs_dirpath.setter
def specs_dirpath(self, value):
self._specs_dirpath = value
self._registers = Register(self._specs_dirpath)
def __str__(self):
if not self._lines:
raise errors.EmptyFileError()
result = []
result.extend(str(line) + self._separator for line in self._lines)
result.append('')
return '\r\n'.join(result)
def append_line(self, register, **kwargs):
# registro = list(self._registers.__dict__)[0]
if not bool(kwargs.get("separator",False)):
kwargs['separator'] = self._separator
self._lines.append(getattr(self._registers,register)(**kwargs))