Created
September 30, 2019 02:34
-
-
Save angww/9351d0727e07d7f637b06771edbb15a6 to your computer and use it in GitHub Desktop.
Small program to automate workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pip install premailer | |
import sys | |
from premailer import transform | |
if len(sys.argv) < 2: | |
print("Falta o agumento 1. Arquivo HTML de entrada.") | |
sys.exit(1) | |
file_in_name = str(sys.argv[1]) | |
file_extension = file_in_name.rsplit( ".", 1 ) | |
if len(file_extension) < 2 or file_extension[1] != "html": | |
print("O primeiro argumento precisa ser um aquivo .html. Exemplo: python cssinliner Relatorio.html") | |
sys.exit(1) | |
file_in = open(file_in_name, "r") | |
file_iniline = transform(file_in.read(), allow_network=False) | |
#print(file_iniline) | |
file_out_name = file_in_name.rsplit( ".", 1 )[0] + "_CSS_INLINE.html" | |
file = open(file_out_name, "w") | |
file.write(file_iniline) | |
file.close() | |
print("Convertido e salvo. Arquivo de saída: ", file_out_name) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment