-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharquivo.py
63 lines (50 loc) · 1.65 KB
/
arquivo.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Arquivo:
def __init__(self, caminho=None, cod=None):
self.caminho = caminho
self.cod = cod
def _get_caminho(self):
try:
return self._caminho
except AttributeError:
return None
def _set_caminho(self, caminho):
if type(caminho) != str and caminho is not None:
raise ValueError()
self._caminho = caminho
caminho = property(_get_caminho, _set_caminho)
def _get_cod(self):
try:
return self._cod
except AttributeError:
return None
def _set_cod(self, cod):
if type(cod) != int and cod is not None:
raise ValueError()
self._cod = cod
cod = property(_get_cod, _set_cod)
class ArquivoBinario(Arquivo):
def __init__(self, cod=None, data=None, extension=None):
super(ArquivoBinario, self).__init__(cod=cod)
self.data = data
self.extension = extension
def _get_data(self):
try:
return self._data
except AttributeError:
return None
def _set_data(self, data):
print(type(data))
if type(data) != bytes and data is not None:
raise ValueError()
self._data = data
data = property(_get_data, _set_data)
def _get_extension(self):
try:
return self._extension
except AttributeError:
return None
def _set_extension(self, extension):
if type(extension) != str and extension is not None:
raise ValueError()
self._extension = extension
extension = property(_get_extension, _set_extension)