--- a/src/pyams_utils/doctests/README.txt Tue May 10 16:44:27 2016 +0200
+++ b/src/pyams_utils/doctests/README.txt Thu May 12 10:41:22 2016 +0200
@@ -1,19 +1,18 @@
-==================
-ZTFY.utils package
-==================
+===================
+pyams_utils package
+===================
Introduction
------------
-This package is composed of a set of utility functions, which in complement with zope.app.zapi
-package can make Zope management easier.
+This package is composed of a set of utility functions, usable into any Pyramid application.
Unicode functions
-----------------
While working with extended characters sets containing accentuated characters, it's necessary to
-conversing strings to UTF8 so that they can be used without any conversion problem.
+convert strings to UTF8 so that they can be used without any conversion problem.
>>> from pyams_utils import unicode
@@ -128,7 +127,7 @@
Timezones handling
------------------
-Timezones handling game me headaches at first. I finally concluded that the best way (for me !) to handle
+Timezones handling gave me headaches at first. I finally concluded that the best way (for me !) to handle
TZ data was to store every datetime value in GMT timezone.
As far as I know, there is no easy way to know the user's timezone from his request settings. So you can:
- store this timezone in user's profile,
--- a/src/pyams_utils/list.py Tue May 10 16:44:27 2016 +0200
+++ b/src/pyams_utils/list.py Thu May 12 10:41:22 2016 +0200
@@ -23,10 +23,21 @@
def unique(seq, idfun=None):
"""Extract unique values from list, preserving order
+ Original list is not modified.
+
>>> from pyams_utils.list import unique
>>> mylist = [1, 2, 3, 2, 1]
>>> unique(mylist)
[1, 2, 3]
+
+ >>> mylist = [3, 2, 2, 1, 4, 2]
+ >>> unique(mylist)
+ [3, 2, 1, 4]
+
+ You can also set an 'id' function applied on each element:
+ >>> mylist = [1, 2, 3, '2', 4]
+ >>> unique(mylist, idfun=str)
+ [1, 2, 3, 4]
"""
if idfun is None:
def idfun(x): return x