from html2image import HTML2Image
with HTML2Image('<html><strong>Fooo</strong></html>', width='300') as html:
image = html.render()
This file contains hidden or 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
# Imports | |
import xml.etree.ElementTree as py_etree | |
import xml.etree.cElementTree as c_etree | |
text = "<foo>&fucking;</foo>" | |
# Exception | |
py_etree.fromstring(text) | |
""" | |
Traceback (most recent call last): |
This file contains hidden or 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
for i in range(rec.last_mail_id + 1, int(msg_count[0]) + 1): | |
if rec.rec_headers_den_mail: | |
typ, msg = serv.fetch(str(i), '(FLAGS BODY.PEEK[HEADER])') | |
method = getattr(self, 'save_header') | |
else: | |
typ, msg = serv.fetch(str(i), '(FLAGS RFC822)') | |
method = getattr(self, 'save_fullmail') | |
for mails in msg: | |
if type(mails) == type(('tuple', 'type')): | |
mail = email.message_from_string(mails[1]) |
This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import optparse | |
import csv | |
import time | |
parser = optparse.OptionParser(version="[GISCE ERP] Migrations") |
This file contains hidden or 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
from collections import namedtuple | |
import json | |
class Model(object): | |
fields = [ | |
'id', | |
'cini', | |
'origen', | |
'desti' | |
] |
This file contains hidden or 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
get_caller_stack(): | |
import inspect | |
for stack in inspect.stack(): | |
print "{0}:{1}".format(stack[1], stack[2]) |
This file contains hidden or 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
from datetime import datetime | |
from dateutil.relativedelta import relativedelta | |
d = datetime(2015, 1, 1) | |
d + relativedelta(month=2) | |
# fuck you typo in singular | |
# i like smelling my farts | |
# result is datetime.datetime(2015, 2, 1, 0, 0) |
This file contains hidden or 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
class TempFile(object): | |
def __init__(self, *args, **kwargs): | |
self.file = open(*args, **kwargs) | |
def __enter__(self): | |
return self.file | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
self.file.close() | |
os.remove(self.file.name) |
This file contains hidden or 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
from erppeek import Client | |
import sys | |
import base64 | |
from subprocess import call | |
import time | |
report = 'xml_report_name' | |
ids = [object_id] | |
This file contains hidden or 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
def get_version(): | |
import os | |
import subprocess | |
try: | |
try: | |
version = subprocess.check_output([ | |
'git', 'describe', '--tags' | |
]).strip() | |
except subprocess.CalledProcessError: | |
version = __import__('pkg_resources') \ |