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
# --- [middleware helper to serve static resources] --- | |
# Placed in public domain | |
import os | |
import mimetypes | |
# directory with static resources (default: 'static' in current dir) | |
STATIC_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), 'static')) | |
def appstatic(app, environ, start_response): |
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
#!/usr/bin/env python | |
""" | |
WSGI script that shows mainenance notice to web site visitors. | |
Features Z-Type and elapsed time counter based on timestamp | |
of this file. | |
You may safely copy-paste this code into your own scripts. | |
Public domain work by anatoly techtonik <[email protected]> | |
""" |
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
#!/usr/bin/env python | |
""" | |
Calculate length of Haiku Package file format header | |
http://dev.haiku-os.org/wiki/PackageManagement/FileFormat | |
""" | |
# needs python-cffi | |
from cffi import FFI |
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
def extract_zip(zippath, subdir, target): | |
'''extract entries from `subdir` of `zipfile` into `target`/ directory''' | |
from os.path import join, exists | |
import shutil | |
import zipfile | |
zf = zipfile.ZipFile(zippath) | |
for entry in zf.namelist(): | |
if subdir: | |
if not entry.startswith(subdir + '/'): |
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
# locally recipe that downloads patch and applies it | |
# --- bootstrap .locally --- | |
# | |
# this creates .locally/ subdirectory in the script's dir | |
# and sets a few global variables for convenience: | |
# | |
# ROOT - absolute path to bootstrap.py dir, ends with / | |
# LOOT - absolute path to the .locally/ subdir | |
# LIB - path to downloaded helper libs added to sys.path |
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
# locally recipe that checks out Rietveld sources | |
# sources go into subdir, because hg is unable to | |
# checkout into dirty dir. no custom move logic | |
# is done also | |
# [ ] check rietveld checkout into given dir | |
# [ ] check dir/ | |
# [ ] check dir/.hg/ | |
# [ ] check dir/codereview/ | |
# [ ] clone |
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
# Black magic to use Python logic for setting Makefile variables | |
# Real world example that is detecting AppEngine SDK with Python | |
# Helper code to detect SDK location | |
define DETECT_SDK | |
import os | |
locations = [ | |
"../google_appengine", | |
"/usr/local/google_appengine", | |
"../.locally/google_appengine", |
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
# snippet is placed into public domain by | |
# anatoly techtonik <[email protected]> | |
# http://stackoverflow.com/questions/8151300/ignore-case-in-glob-on-linux | |
import fnmatch | |
import os | |
import re | |
def findfiles(which, where='.'): |
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
""" | |
Build recursive hash of files in directory tree in hashdeep format. | |
Hashdeep format description: | |
http://md5deep.sourceforge.net/start-hashdeep.html | |
hashdeep.py differences from original hashdeep: | |
- if called without arguments, automatically starts to build |
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 re | |
# tested with BitBucket | |
TRACKER = 'http://bitbucket.org/tarek/distribute' | |
# return contents of reStructureText file with linked issue references | |
def _linkified(rstfile): | |
revision = re.compile(r'\b(issue\s*#?\d+)\b', re.M | re.I) | |
rstext = open(rstfile).read() |