Skip to content

Commit

Permalink
Merge 018ad3d into 58ace07
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Jun 24, 2019
2 parents 58ace07 + 018ad3d commit 5258050
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- '3.5'
- '3.6'
install:
- pip install six
Expand Down
3 changes: 2 additions & 1 deletion sped/blocos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def __init__(self, nome=''):
self._registros = []

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}({self._nome})>'
return '<%s.%s(%s)>' % (self.__class__.__module__,
self.__class__.__name__, self._nome)

@property
def abertura(self):
Expand Down
8 changes: 5 additions & 3 deletions sped/campos.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(self, indice, nome, obrigatorio=False):
self._obrigatorio = obrigatorio

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}({self._indice}, {self._nome})>'
return '<%s.%s(%s, %s)>' % (self.__class__.__module__,
self.__class__.__name__,
self._indice, self._nome)

@property
def indice(self):
Expand Down Expand Up @@ -207,8 +209,8 @@ def set(self, registro, valor):
else:
raise FormatoInvalidoError(registro, str(self))

def __repr__(self):
return f'{self.__class__.__name__}({self.indice}, {self.nome}, {self._obrigatorio}, {self._regex})'
# def __repr__(self):
# return '' f'{self.__class__.__name__}({self.indice}, {self.nome}, {self._obrigatorio}, {self._regex})'


class CampoCNPJ(Campo):
Expand Down
15 changes: 10 additions & 5 deletions sped/escrituracao.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def __init__(self, tipo: str, ano_calendario: int):
self._add_registro(self._registro_escrituracao)

sped_path = Path(__file__).parent
leiaute_ecd = Path(sped_path / 'leiautes' / f'{self._tipo}_{self._ano_calendario}.json')

leiaute_path = '%s/leiautes/%s_%s.json' % (sped_path, self._tipo,
self._ano_calendario)
leiaute_ecd = Path(leiaute_path)

with leiaute_ecd.open(encoding='utf-8', newline='\n') as f:
p = json.load(f)
Expand Down Expand Up @@ -226,19 +229,21 @@ def prepare(self):
self.registro_encerramento[2] = reg_count

def write_to(self, buff):
buff.write(f'{self.registro_abertura}\r\n')
buff.write('%s\r\n' % self.registro_abertura)
reg_count = 2
for bloco in self._blocos.values():
reg_count += len(bloco.registros)
for registro in bloco.registros:
buff.write(f'{registro}\r\n')
buff.write('%s\r\n' % registro)

self.registro_encerramento[2] = reg_count

buff.write(f'{self.registro_encerramento}\r\n')
buff.write('%s\r\n' % self.registro_encerramento)

def add(self, registro: Registro):
pass

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}({self._tipo}, {self._ano_calendario})>'
return '<%s.%s(%s, %s)>' % (self.__class__.__module__,
self.__class__.__name__,
self._tipo, self._ano_calendario)
10 changes: 5 additions & 5 deletions sped/leiaute.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, nome, descricao):
self.descricao = descricao

def __repr__(self):
return f'<Bloco({self.nome}, {self.descricao})>'
return '<Bloco(%s, %s)>' % (self.nome, self.descricao)


class Registro(object):
Expand All @@ -58,7 +58,7 @@ def __init__(self, codigo, nome, regras, nivel, ocorrencia, campos_chave):
self.campos = []

def __repr__(self):
return f'<Registro({self.codigo}, {self.nome})>'
return '<Registro(%s, %s)>' % (self.codigo, self.nome)


class Campo(object):
Expand All @@ -70,12 +70,12 @@ def __init__(self, indice, nome, descricao, tipo, tamanho, decimal, valores, obr
self.nome = nome
self.descricao = descricao
self.tipo = tipo

try:
self.tamanho = int(tamanho)
except:
self.tamanho = None

try:
self.decimal = int(decimal)
except:
Expand All @@ -86,4 +86,4 @@ def __init__(self, indice, nome, descricao, tipo, tamanho, decimal, valores, obr
self.regras = regras

def __repr__(self):
return f'<Campo({self.indice}, {self.nome})>'
return '<Campo(%s, %s)>' % (self.indice, self.nome)
2 changes: 1 addition & 1 deletion sped/registros.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __str__(self):
return '|'.join(self._valores)

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}>'
return '<%s.%s>' % (self.__class__.__module__, self.__class__.__name__)


class RegistroIndefinido(Registro):
Expand Down

0 comments on commit 5258050

Please sign in to comment.