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
# http://pypi.python.org/pypi/chardet | |
import chardet | |
# List of your preferred charsets, or detect those available automatically (see below) | |
CHARSETS = ['ascii', 'latin_1', 'utf_8'] | |
def get_charset(string): | |
"""Given a string or unicode object, returns the simplest available |
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
[buildout] | |
eggs = ... | |
parts = ... | |
pastescript | |
[pastescript] | |
recipe = zc.recipe.egg | |
eggs = PasteScript # required to generate the specific paster script if not already in eggs list | |
${buildout:eggs} | |
extra-paths = path/to/pastescriptpatches.py |
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 is_ie(request, min_version=None, max_version=None): | |
user_agent = request.environ.get('HTTP_USER_AGENT', '') | |
ie = user_agent.find('MSIE') | |
if ie==-1: | |
return False | |
if not min_version and not max_version: | |
return True | |
version_match = re.match('[\d\.]*', user_agent[ie+5:]) |
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 f in `find ./ -type l`; do | |
lpath=`readlink $f` | |
echo $lpath | egrep "^/home/dev/python-buildout/src/parts/opt/include/python2.4" > /dev/null | |
if [ "$?" = "0" ]; then | |
newpath=`echo $lpath | sed -e 's:/home/dev/python-buildout/src/parts/opt/include/python2.4:/Users/richard/Documents/Projects/collective.buildout.python/python-2.4/lib/python2.4:g'` | |
rm $f | |
ln -s $newpath $f | |
fi | |
done |
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
<configure | |
xmlns="http://namespaces.zope.org/zope"> | |
<adapter | |
factory=".datamanager.PersistentDictionaryField" /> | |
</configure> |
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 AccessControl.SecurityManagement import newSecurityManager | |
from Testing.makerequest import makerequest | |
from zope.component.hooks import setSite | |
def get_manager(app): | |
for uid in app.acl_users.users.listUserIds(): | |
user = app.acl_users.users.getUser(uid) | |
if 'Manager' in user.getRoles(): | |
return user |
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
<html> | |
<head> | |
<title>HTML & CSS tree</title> | |
<!-- tree --> | |
<style type="text/css"> | |
ul.tree { | |
overflow-x: auto; | |
white-space: nowrap; | |
} |
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 flatten(iterable): | |
if not isinstance(iterable, (list, tuple)): | |
yield iterable | |
else: | |
for i in iterable: | |
if isinstance(i, (list, tuple)): | |
for j in flatten(i): | |
yield j | |
else: | |
yield 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
def wrap_text(text, limit): | |
#s = map(str.split, text.split('\n')) | |
#i = 0 | |
#for n in range(len(s)): | |
# while i < len(s[n]) - 1: | |
# if (len(s[n][i]) + len(s[n][i+1])) <= limit: | |
# s[n][i] += ' ' + s[n][i+1] | |
# s[n] = s[n][:i+1] + s[n][i+2:] | |
# elif len(s[n][i+1]) > limit: | |
# i += 1 |