diff --git a/setup.py b/setup.py index 969ac7b..02c85b2 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from setuptools import setup, find_packages from setuptools.command.test import test as test_command from sped import __version__ diff --git a/sped/arquivos.py b/sped/arquivos.py index 5242969..abe4982 100644 --- a/sped/arquivos.py +++ b/sped/arquivos.py @@ -41,17 +41,17 @@ def read_registro(self, line): bloco.add(registro) def write_to(self, buffer): - buffer.write(self._registro_abertura.as_line() + '\r\n') + buffer.write(self._registro_abertura.as_line() + u'\r\n') reg_count = 2 for key in self._blocos.keys(): bloco = self._blocos[key] reg_count += len(bloco.registros) for r in bloco.registros: - buffer.write(r.as_line() + '\r\n') + buffer.write(r.as_line() + u'\r\n') self._registro_fechamento[2] = reg_count - buffer.write(self._registro_fechamento.as_line() + '\r\n') + buffer.write(self._registro_fechamento.as_line() + u'\r\n') def getstring(self): buffer = StringIO() diff --git a/sped/campos.py b/sped/campos.py index dbb3aeb..fdebc83 100644 --- a/sped/campos.py +++ b/sped/campos.py @@ -83,7 +83,7 @@ class CampoFixo(Campo): '0000' """ def __init__(self, indice, nome, valor): - super().__init__(indice, nome, True) + super(CampoFixo, self).__init__(indice, nome, True) self._valor = valor @property @@ -99,7 +99,7 @@ def set(self, registro, valor): class CampoAlfanumerico(Campo): def __init__(self, indice, nome, obrigatorio=False, tamanho=255): - super().__init__(indice, nome, obrigatorio) + super(CampoAlfanumerico, self).__init__(indice, nome, obrigatorio) self._tamanho = tamanho @property @@ -109,12 +109,12 @@ def tamanho(self): def set(self, registro, valor): valor = valor or '' valor = valor[:self._tamanho] - super().set(registro, valor) + super(CampoAlfanumerico, self).set(registro, valor) class CampoNumerico(Campo): def __init__(self, indice, nome, obrigatorio=False, precisao=0, minimo=0, maximo=1000): - super().__init__(indice, nome, obrigatorio) + super(CampoNumerico, self).__init__(indice, nome, obrigatorio) self._precisao = precisao self._minimo = minimo self._maximo = maximo @@ -132,49 +132,49 @@ def maximo(self): return self._maximo def get(self, registro): - valor = super().get(registro) + valor = super(CampoNumerico, self).get(registro) if not valor: return None return Decimal(valor.replace(',', '.')) def set(self, registro, valor): if isinstance(valor, Decimal) or isinstance(valor, float): - super().set(registro, (('%.' + str(self._precisao) + 'f') % valor).replace('.', ',')) + super(CampoNumerico, self).set(registro, (('%.' + str(self._precisao) + 'f') % valor).replace('.', ',')) elif isinstance(valor, int): - super().set(registro, str(valor)) + super(CampoNumerico, self).set(registro, str(valor)) elif not valor: - super().set(registro, '0') + super(CampoNumerico, self).set(registro, '0') else: raise FormatoInvalidoError(registro, self.nome) class CampoData(Campo): def __init__(self, indice, nome, obrigatorio=False): - super().__init__(indice, nome, obrigatorio) + super(CampoData, self).__init__(indice, nome, obrigatorio) def get(self, registro): - valor = super().get(registro) + valor = super(CampoData, self).get(registro) if not valor: return None return datetime.strptime(valor, '%d%m%Y').date() def set(self, registro, valor): if isinstance(valor, date): - super().set(registro, valor.strftime('%d%m%Y')) + super(CampoData, self).set(registro, valor.strftime('%d%m%Y')) elif not valor: - super().set(registro, None) + super(CampoData, self).set(registro, None) else: raise FormatoInvalidoError(registro, self.nome) class CampoRegex(Campo): def __init__(self, indice, nome, obrigatorio=False, regex=None): - super().__init__(indice, nome, obrigatorio) + super(CampoRegex, self).__init__(indice, nome, obrigatorio) self._regex = re.compile('^' + regex + '$') def set(self, registro, valor): if not valor or self._regex.match(valor): - super().set(registro, valor) + super(CampoRegex, self).set(registro, valor) else: raise FormatoInvalidoError(registro, self.nome) diff --git a/sped/ecd/arquivos.py b/sped/ecd/arquivos.py index f88e7b3..05cd0aa 100644 --- a/sped/ecd/arquivos.py +++ b/sped/ecd/arquivos.py @@ -19,7 +19,7 @@ class ArquivoDigital(ArquivoDigital): blocos = blocos def __init__(self): - super().__init__() + super(ArquivoDigital, self).__init__() self._blocos['0'] = Bloco0() self._blocos['I'] = BlocoI() self._blocos['J'] = BlocoJ() diff --git a/sped/ecd/blocos.py b/sped/ecd/blocos.py index 8d67085..9f150fc 100644 --- a/sped/ecd/blocos.py +++ b/sped/ecd/blocos.py @@ -20,7 +20,7 @@ class Bloco0(Bloco): @property def fechamento(self): - registro = super().fechamento + registro = Bloco.fechamento.fget(self) registro[2] += 1 return registro @@ -50,6 +50,6 @@ class Bloco9(Bloco): @property def fechamento(self): - registro = super().fechamento + registro = super(Bloco9, self).fechamento registro[2] += 1 return registro diff --git a/sped/ecf/arquivos.py b/sped/ecf/arquivos.py index 492478b..a118a05 100644 --- a/sped/ecf/arquivos.py +++ b/sped/ecf/arquivos.py @@ -28,7 +28,7 @@ class ArquivoDigital(ArquivoDigital): blocos = blocos def __init__(self): - super().__init__() + super(ArquivoDigital, self).__init__() self._blocos['0'] = Bloco0() self._blocos['C'] = BlocoC() self._blocos['E'] = BlocoE() diff --git a/sped/efd/icms_ipi/arquivos.py b/sped/efd/icms_ipi/arquivos.py index fef9094..e9aba78 100644 --- a/sped/efd/icms_ipi/arquivos.py +++ b/sped/efd/icms_ipi/arquivos.py @@ -23,7 +23,7 @@ class ArquivoDigital(ArquivoDigital): blocos = blocos def __init__(self): - super().__init__() + super(ArquivoDigital, self).__init__() self._blocos['0'] = Bloco0() self._blocos['C'] = BlocoC() self._blocos['D'] = BlocoD() diff --git a/sped/efd/pis_cofins/arquivos.py b/sped/efd/pis_cofins/arquivos.py index aff5fc1..f68b064 100644 --- a/sped/efd/pis_cofins/arquivos.py +++ b/sped/efd/pis_cofins/arquivos.py @@ -24,7 +24,7 @@ class ArquivoDigital(ArquivoDigital): blocos = blocos def __init__(self): - super().__init__() + super(ArquivoDigital, self).__init__() self._blocos['0'] = Bloco0() self._blocos['A'] = BlocoA() self._blocos['C'] = BlocoC() diff --git a/sped/erros.py b/sped/erros.py index 9803026..1e3b3d0 100644 --- a/sped/erros.py +++ b/sped/erros.py @@ -6,16 +6,16 @@ def __init__(self, registro): self._registro = registro def __str__(self): - return '{0}'.format(self._registro) + return u'{0}'.format(self._registro) class CampoError(RegistroError): def __init__(self, registro, campo): - super().__init__(registro) + super(CampoError, self).__init__(registro) self._campo = campo def __str__(self): - return '{0} -> {1}'.format(self._registro.__class__.__name__, self._campo) + return u'{0} -> {1}'.format(self._registro.__class__.__name__, self._campo) class CampoFixoError(CampoError): diff --git a/sped/registros.py b/sped/registros.py index e88fbd7..b8074e4 100644 --- a/sped/registros.py +++ b/sped/registros.py @@ -113,4 +113,4 @@ def __setattr__(self, name, value): campo.set(self, value) def as_line(self): - return '|'.join(self._valores) + return u'|'.join(self._valores)