Skip to content

Commit

Permalink
#3 padronização de nomes, PEP-8 e organização dos arquivos
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Jan 17, 2019
1 parent 54f8fc0 commit 6bdeafb
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 82 deletions.
81 changes: 0 additions & 81 deletions app/auxiliar.py

This file was deleted.

14 changes: 14 additions & 0 deletions app/dict_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from json import loads


def read_json(json_file):
"""
Função que seleciona o arquivo json a ser lido.
:args:
json_file: Arquivo json com as informações para o resume
:return: um dicionario com as informações do json
"""
with open(json_file) as _file:
return loads(_file.read())
73 changes: 73 additions & 0 deletions app/languages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
keys = {
'k_name': 'name',
'k_function': 'function',
'k_phone': 'phone',
'k_email': 'email',
'k_address': 'address',
'k_education': 'education',
'k_experience': 'experience',
'k_skills': 'skills',
'k_languages': 'languages',
'k_contact': 'contact',
'k_portfolio': 'portfolio',
}

langs = {
'en': {
'name': 'Name',
'function': 'Function',
'phone': 'Phone',
'email': 'Email',
'address': 'Address',
'education': 'Education',
'experience': 'Experience',
'skills': 'Skills',
'languages': 'Languages',
'contact': 'Contact',
'portfolio': 'Portfolio',
},
'pt': {
'name': 'Nome',
'function': 'Cargo',
'phone': 'Telefone',
'email': 'E-mail',
'address': 'Endereço',
'education': 'Escolaridade',
'experience': 'Experiência',
'skills': 'Habilidades',
'languages': 'Línguas',
'contact': 'Contato',
'portfolio': 'Portfólio',
},
'es': {
'name': 'Nombre',
'function': 'Cargo',
'phone': 'Teléfono',
'email': 'E-mail',
'address': 'Dirección',
'education': 'Educacíon',
'experience': 'Experiencia',
'skills': 'Habildades',
'languages': 'Idiomas',
'contact': 'Contacto',
'portfolio': 'Portfolio',
},
}

templates = {
'basic': 'A very basic resume',
'red': 'A red template - by:magnvmOpvs',
'Simple': 'A simple template - by:magnvmOpvs',
}


def mount_i18n(lang: str) -> dict:
"""
Monta as chaves no jinja para o idioma escolhido.
:args:
lang: Linguagem selecionada
:return: Um dicionario monstado com a lingua escolida
"""
return {e: langs[lang][keys[e]] for e in keys}
3 changes: 2 additions & 1 deletion app/make.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from weasyprint import HTML
from app.mount_template import select_template
from app.auxiliar import read_json, mount_i18n
from app.languages import mount_i18n
from app.dict_tools import read_json


def create(lang, template, json_file, output):
Expand Down

0 comments on commit 6bdeafb

Please sign in to comment.