2013-03-10 | Paul Boddie | file changeset files shortlog | Added macro argument parsing from MoinForms and a function to find parsers by content type. Changed the item storage API to use path tuples instead of strings when specifying directories. Introduced support for reverse iteration over stored items. Updated the release notes and version number. |
paul@25 | 1 | # -*- coding: iso-8859-1 -*- |
paul@25 | 2 | """ |
paul@25 | 3 | MoinMoin - GeneralSupport library |
paul@25 | 4 | |
paul@25 | 5 | @copyright: 2008, 2009, 2010, 2011, 2012 by Paul Boddie <paul@boddie.org.uk> |
paul@25 | 6 | @license: GNU GPL (v2 or later), see COPYING.txt for details. |
paul@25 | 7 | """ |
paul@25 | 8 | |
paul@25 | 9 | # General utility functions. |
paul@25 | 10 | |
paul@25 | 11 | def int_or_none(x): |
paul@25 | 12 | if x is None: |
paul@25 | 13 | return x |
paul@25 | 14 | else: |
paul@25 | 15 | return int(x) |
paul@25 | 16 | |
paul@25 | 17 | def to_list(s, sep): |
paul@25 | 18 | return [x.strip() for x in s.split(sep) if x.strip()] |
paul@25 | 19 | |
paul@25 | 20 | def sort_none_first(x, y): |
paul@25 | 21 | if x is None: |
paul@25 | 22 | return -1 |
paul@25 | 23 | elif y is None: |
paul@25 | 24 | return 1 |
paul@25 | 25 | else: |
paul@25 | 26 | return cmp(x, y) |
paul@25 | 27 | |
paul@25 | 28 | # vim: tabstop=4 expandtab shiftwidth=4 |