1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/GeneralSupport.py Sat Sep 29 16:58:57 2012 +0200
1.3 @@ -0,0 +1,28 @@
1.4 +# -*- coding: iso-8859-1 -*-
1.5 +"""
1.6 + MoinMoin - GeneralSupport library
1.7 +
1.8 + @copyright: 2008, 2009, 2010, 2011, 2012 by Paul Boddie <paul@boddie.org.uk>
1.9 + @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.10 +"""
1.11 +
1.12 +# General utility functions.
1.13 +
1.14 +def int_or_none(x):
1.15 + if x is None:
1.16 + return x
1.17 + else:
1.18 + return int(x)
1.19 +
1.20 +def to_list(s, sep):
1.21 + return [x.strip() for x in s.split(sep) if x.strip()]
1.22 +
1.23 +def sort_none_first(x, y):
1.24 + if x is None:
1.25 + return -1
1.26 + elif y is None:
1.27 + return 1
1.28 + else:
1.29 + return cmp(x, y)
1.30 +
1.31 +# vim: tabstop=4 expandtab shiftwidth=4