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_node_text(root): | |
text = "" | |
if root.text: | |
text = root.text.strip() | |
for child in root: | |
text += get_node_text(child) | |
if root.tail: |
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 dl_file(url, directory=os.path.dirname(__file__), user=None, password=None, filename=None): | |
""" | |
Download a file from a url to a directory | |
@param url: url of a file | |
@param directory: directory to save the file into | |
@return: True if file was downloaded successfully, False otherwise | |
""" | |
# Disable the proxy |
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 load_json_data(json_filename): | |
""" | |
Load a *.json file into a Python dictionary | |
@param json_filename: path to the json file | |
@return: a dictionary containing the data | |
""" | |
json_file = open(json_filename) | |
json_data = json_file.read() | |
test_data = json.loads(json_data) |
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
import xml.etree.ElementTree as ET | |
def CDATA(text=None): | |
element = ET.Element('![CDATA[') | |
element.text = text | |
return element | |
ET._original_serialize_xml = ET._serialize_xml |
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 indent(elem, level=0): | |
"""Add whitespace to xml document to increase readability | |
elem - root element to start the indention at | |
level - start level of indention | |
""" | |
i = "\n" + level*" " | |
if len(elem): | |
if not elem.text or not elem.text.strip(): | |
elem.text = i + " " |
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
text = re.sub(r'\.([a-zA-z])', r'. \1', text) |
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
%% start of file `template.tex'. | |
%% Copyright 2006-2013 Xavier Danaux ([email protected]). | |
% | |
% This work may be distributed and/or modified under the | |
% conditions of the LaTeX Project Public License version 1.3c, | |
% available at http://www.latex-project.org/lppl/. | |
\documentclass[11pt,a4paper,sans]{moderncv} % possible options include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') and font family ('sans' and 'roman') | |
\usepackage{tabularx} |
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 | |
import os | |
import sys | |
import string | |
import syslog | |
# Import the client module | |
from deluge.ui.client import client | |
# Import the reactor module from Twisted - this is for our mainloop |
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/env python | |
""" | |
Simple Python script that combines a folder of pdfs into a single | |
pdf. By default the pdfs are merged in alphabetical order and | |
only appear once. To change this create a "list.txt" file in the | |
directory with the pdfs to merge and list the order of the pdfs | |
to merge. | |
Ex list.txt: | |
doc2.pdf |
NewerOlder