View bootstrap_alert.py
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
from pymdownx.blocks import BlocksExtension | |
from pymdownx.blocks.block import Block, type_html_attribute_dict, type_html_identifier, type_string_in, \ | |
type_boolean, type_string, , type_multi | |
import xml.etree.ElementTree as etree | |
import uuid | |
class BsAlertBlock(Block): | |
NAME = 'alert' | |
ARGUMENT = None |
View rename_ical.py
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
import icalendar | |
def rename_events(infile, outfile, names=None): | |
''' | |
Given a path to a ics file, rename each event and write to outfile. | |
names should be a list of strings where each item is the new name | |
to assign to each event in the ics file. If an insuffient number | |
of names are provided, then an error will occur. | |
View print_label.py
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
from PIL import Image, ImageDraw, ImageFont | |
from brother_ql.devicedependent import label_type_specs | |
from brother_ql import BrotherQLRaster, create_label | |
from brother_ql.backends.helpers import send | |
PRINTER = { | |
'model': 'QL-800', | |
'address': 'usb://0x04f9:0x209b' | |
} |
View text2img.py
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
from PIL import Image, ImageDraw, ImageFont | |
def create_image(text, size, fp, format=None): | |
img = Image.new('L', size, 'white') | |
draw = ImageDraw.Draw(img) | |
# Find largest font size which fits within image size | |
fontsize = 20 | |
margin = 10 |
View peewee_monthfield.py
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
from peewee import _BaseFormattedField, format_date_time, _date_part | |
import datetime | |
class MonthField(_BaseFormattedField): | |
field_type = 'DATE' | |
formats = [ | |
'%Y-%m', | |
'%Y-%m-%d', | |
'%Y-%m-%d %H:%M:%S', |
View md2wpdf.py
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
import markdown | |
import re | |
import yaml | |
from yaml import SafeLoader | |
from wp2pdf import html2pdf | |
BLOCK_RE = re.compile(r'^-{3}[ \t]*\n(.*?\n)(?:\.{3}|-{3})[ \t]*\n', re.UNICODE|re.DOTALL) | |
View wp2pdf.py
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
from weasyprint import HTML, CSS | |
HTML_TEMPLATE = """ | |
<html> | |
<head> | |
</head> | |
<body> | |
{body} | |
</body> | |
</html> |
View pdf_columns.py
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
from weasyprint import HTML | |
CONTENT = """ | |
<html> | |
<head> | |
<style> | |
h1 { | |
padding: .5em 0; | |
background-color: lightskyblue; | |
} |
View textfield.py
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
from reportlab.platypus import SimpleDocTemplate, Flowable, Paragraph | |
from reportlab.lib.styles import getSampleStyleSheet | |
style = getSampleStyleSheet()['BodyText'] | |
class TextField(Flowable): | |
def __init__(self, **options): | |
Flowable.__init__(self) |
View md2pdf.py
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
import markdown | |
from xhtml2pdf import pisa | |
from datetime import date | |
TEMPLATE = """ | |
<html> | |
<head> | |
<style> | |
@page {{ | |
size: letter portrait; |
NewerOlder