From: dbs Date: Sat, 19 Mar 2011 05:00:42 +0000 (+0000) Subject: Provide a top-level docstring for oils/utils/utils.py X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9f36c1bb74b5ba5fc77a2458c8a1415463046f15;p=contrib%2FConifer.git Provide a top-level docstring for oils/utils/utils.py Also, standardize on triple-double-quoted docstrings, per PEP257. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19819 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/python/oils/utils/utils.py b/Open-ILS/src/python/oils/utils/utils.py index 3f83c293e5..6a72aa7756 100644 --- a/Open-ILS/src/python/oils/utils/utils.py +++ b/Open-ILS/src/python/oils/utils/utils.py @@ -1,3 +1,7 @@ +""" +Grab-bag of general utility functions +""" + # ----------------------------------------------------------------------- # Copyright (C) 2007 Georgia Public Library Service # Bill Erickson @@ -16,25 +20,30 @@ import hashlib import osrf.ses -# ----------------------------------------------------------------------- -# Grab-bag of general utility functions -# ----------------------------------------------------------------------- - def md5sum(string): - """Return an MD5 message digest for a given input string""" + """ + Return an MD5 message digest for a given input string + """ + md5 = hashlib.md5() md5.update(string) return md5.hexdigest() def unique(arr): - ''' Unique-ify a list. only works if list items are hashable ''' + """ + Unique-ify a list. only works if list items are hashable + """ + o = {} for x in arr: o[x] = 1 return o.keys() def is_db_true(data): - ''' Returns true if the data provided matches what the database considers a true value ''' + """ + Returns PostgreSQL's definition of "truth" for the supplied data, roughly. + """ + if not data or data == 'f' or str(data) == '0': return False return True