-
Notifications
You must be signed in to change notification settings - Fork 0
(feat/5)Criação de funções e padronização de dados ao abrir config #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
É possível verificar com o getCnpj() se já tem os 14 caracteres, e deixar o botão habilitado ou desabilitado.
|
pages/config.py
Outdated
from helpers.utils import getCnpj | ||
|
||
def default_year(): | ||
with open("env.txt", "r") as configFile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Em helpers.utils já existe uma função que lê o arquivo e retorna o ano.
Então o adequado seria utilizar essa função que já supri a necessidade.
Razões:
- Eficiência e economia de tempo
- Manutenção simplificada
- Legibilidade e organização do código
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentei essa opção, mas não consegui fazer funcionar. Da forma como a função está lá em utils, não dá certo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foi corrigido conforme solicitado
|
||
|
||
def default_month(): | ||
with open("env.txt", "r") as configfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m helpers.utils já existe uma função que lê o arquivo e retorna o mês que está no arquivo.
Então o adequado seria utilizar essa função que já supri a necessidade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A função retorna um int mas precisamos de um string com o nome do mês
def getMonth():
with open("env.txt", "r") as configFile:
content = configFile.readlines()
monthInFile = [i for i in content if "month =" in i][0]
containsData = monthInFile[8:-1] != ''
if containsData and int(monthInFile[8:-1]) > 0:
return int(monthInFile[8:-1])
else:
return 0
Por isso o uso da nova função
def default_month():
with open("env.txt", "r") as configfile:
lines = configfile.readlines()
monthInFile = [i for i in lines if "month =" in i][0]
month_num = int(monthInFile.split('=')[1].strip())
months = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro',
'Novembro', 'Dezembro']
return months[month_num - 1]
Verificar uma forma de a função inicial servir para os dois propósitos?
Referente a este erro:
Altera para mim e deixa "return int(yearInFile[7:-1])", acredito que isto já vai resolver. |
O botão save estava ficando desabilitado apenas 1 vez. O programa não estava reconhecendo caso o usuário digitasse novamente um comprimento do CNPJ de 14 caracteres.
Depois:
A variável, repetida em default_month() e returnMonth(month=None) foi colocada no inicio do script config, sendo agora repetida apenas 1 vez. |
Foi necessário adicionar as seguintes funções
Obs: Ao clicar em configurações, só é possível desabilitar Salvar caso apagado um número e escrito novamente (caso número do cnpj venha automaticamente de env)
Obs: Generate Das está apresentando erro na função getYear()