Browse Source

Merge bd816f569a into 7ac595d6f5

pull/110/merge
Christian Clauss 4 years ago
committed by GitHub
parent
commit
c91a96d1f2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      .github/workflows/lint_python.yml
  2. 4
      pynfe/processamento/serializacao.py
  3. 7
      pynfe/utils/__init__.py
  4. 1
      pynfe/utils/bar_code_128.py
  5. 4
      run_fake_soap_server.py
  6. 5
      run_tests.py

20
.github/workflows/lint_python.yml

@ -0,0 +1,20 @@
name: lint_python
on: [pull_request, push]
jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install bandit black flake8 isort mypy pytest pyupgrade safety
- run: bandit --recursive --skip B101 . || true # B101 is assert statements
- run: black --check . || true
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- run: isort --check-only --profile black . || true
- run: pip install sphinx_rtd_theme tornado -r requirements.txt -r requirements-nfse.txt
- run: python ./test.py || true
- run: mypy --ignore-missing-imports . || true
- run: pytest . || true
- run: pytest --doctest-modules . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check

4
pynfe/processamento/serializacao.py

@ -460,7 +460,7 @@ class SerializacaoXML(Serializacao):
etree.SubElement(pis_item, 'CST').text = produto_servico.pis_modalidade
etree.SubElement(pis_item, 'vBC').text = '{:.2f}'.format(produto_servico.pis_valor_base_calculo or 0)
etree.SubElement(pis_item, 'pPIS').text = '{:.2f}'.format(produto_servico.pis_aliquota_percentual or 0)
if produto_servico.pis_modalidade is not '99':
if produto_servico.pis_modalidade != '99':
etree.SubElement(pis_item, 'qBCProd').text = '{:.4f}'.format(produto_servico.quantidade_comercial)
etree.SubElement(pis_item, 'vAliqProd').text = '{:.4f}'.format(produto_servico.pis_aliquota_percentual or 0)
etree.SubElement(pis_item, 'vPIS').text = '{:.2f}'.format(produto_servico.pis_valor_base_calculo or 0)
@ -496,7 +496,7 @@ class SerializacaoXML(Serializacao):
etree.SubElement(cofins_item, 'CST').text = produto_servico.cofins_modalidade
etree.SubElement(cofins_item, 'vBC').text = '{:.2f}'.format(produto_servico.cofins_valor_base_calculo or 0)
etree.SubElement(cofins_item, 'pCOFINS').text = '{:.2f}'.format(produto_servico.cofins_aliquota_percentual or 0)
if produto_servico.cofins_modalidade is not '99':
if produto_servico.cofins_modalidade != '99':
etree.SubElement(cofins_item, 'vAliqProd').text = '{:.4f}'.format(produto_servico.cofins_aliquota_percentual or 0)
etree.SubElement(cofins_item, 'vCOFINS').text = '{:.2f}'.format(produto_servico.cofins_valor or 0)

7
pynfe/utils/__init__.py

@ -16,6 +16,13 @@ try:
except ImportError:
raise Exception('Falhou ao importar flags')
try:
basestring
unicode
except NameError:
basestring = str
unicode = str
# @memoize
def so_numeros(texto):

1
pynfe/utils/bar_code_128.py

@ -162,6 +162,7 @@ class Code128:
current_charset = None
pos=sum=0
skip=False
strCode=""
for c in range(len(code)):
if skip:
skip=False

4
run_fake_soap_server.py

@ -2,6 +2,7 @@
"""Este script deve ser executado com Python 2.6+ e OpenSSL"""
from __future__ import print_function
import os, datetime
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
@ -39,7 +40,7 @@ class HandlerStatusServico(tornado.web.RequestHandler):
tag = extrair_tag(raiz.getroot().getchildren()[0].getchildren()[0])
# Chama o método respectivo para a tag
print 'Metodo:', tag
print('Metodo:', tag)
getattr(self, tag)(raiz)
def nfeStatusServicoNF2(self, raiz):
@ -92,4 +93,3 @@ if __name__ == '__main__':
http_server = tornado.httpserver.HTTPServer(application, ssl_options=ssl_options)
http_server.listen(porta)
tornado.ioloop.IOLoop.instance().start()

5
run_tests.py

@ -23,8 +23,7 @@ if __name__ == '__main__':
# Run the tests
for fname in test_files:
print 'Running "%s"...'%(os.path.splitext(os.path.split(fname)[-1])[0])
print('Running "%s"...'%(os.path.splitext(os.path.split(fname)[-1])[0]))
doctest.testfile(fname)
print 'Finished!'
print('Finished!')
Loading…
Cancel
Save