1 # -----------------------------------------------------------------------
2 # Copyright (C) 2007 Georgia Public Library Service
3 # Bill Erickson <billserickson@gmail.com>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # -----------------------------------------------------------------------
19 # -----------------------------------------------------------------------
20 # Grab-bag of general utility functions
21 # -----------------------------------------------------------------------
24 # -----------------------------------------------------------------------
25 # more succinct search/replace call
26 # -----------------------------------------------------------------------
27 def replace(str, pattern, replace):
28 return re.compile(pattern).sub(replace, str)
32 return (evt and isinstance(evt, dict) and evt.get('ilsevent') != None)
36 return evt['ilsevent']
41 return evt['textcode']
51 ''' Unique-ify a list. only works if list items are hashable '''