summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thenault <sylvain.thenault@logilab.fr>2008-05-16 11:05:00 +0200
committerSylvain Thenault <sylvain.thenault@logilab.fr>2008-05-16 11:05:00 +0200
commitfdfda1ab165bbbd9e1d5c84bfca0271b7ce442e7 (patch)
tree990368f1ef80c3925a9b2300e733f080ce5c1692
parent0d1b0ddfbadc1da55c4d1c4c66899a200f1e011a (diff)
parent37efb3f82b2bd93aeb1e177ede786865796953d7 (diff)
downloadlogilab-common-fdfda1ab165bbbd9e1d5c84bfca0271b7ce442e7.tar.gz
merge
-rw-r--r--adbh.py13
-rw-r--r--deprecation.py41
-rw-r--r--textutils.py5
3 files changed, 29 insertions, 30 deletions
diff --git a/adbh.py b/adbh.py
index 1e3b1b1..1e0535c 100644
--- a/adbh.py
+++ b/adbh.py
@@ -80,6 +80,9 @@ class IN(FunctionDescr):
class LENGTH(FunctionDescr):
rtype = 'Int'
+class DATE(FunctionDescr):
+ rtype = 'Date'
+
class _GenericAdvFuncHelper:
"""Generic helper, trying to provide generic way to implement
specific functionnalities from others DBMS
@@ -103,6 +106,7 @@ class _GenericAdvFuncHelper:
# transformation functions
'UPPER': UPPER, 'LOWER': LOWER,
'LENGTH': LENGTH,
+ 'DATE': DATE,
# keyword function
'IN': IN
}
@@ -118,15 +122,6 @@ class _GenericAdvFuncHelper:
'Interval' : 'interval',
'Password' : 'bytea',
'Bytes' : 'bytea',
- # FIXME: still there for use from erudi, should be moved out
- # XXX think it can be safely removed now
- 'COUNT' : 'integer',
- 'MIN' : 'integer',
- 'MAX' : 'integer',
- 'SUM' : 'integer',
- 'LOWER' : 'text',
- 'UPPER' : 'text',
- 'LENGTH' :'integer',
}
diff --git a/deprecation.py b/deprecation.py
index 48f5402..804aeb8 100644
--- a/deprecation.py
+++ b/deprecation.py
@@ -21,8 +21,6 @@ __docformat__ = "restructuredtext en"
import sys
from warnings import warn
-from logilab.common.modutils import LazyObject, load_module_from_name
-
class deprecated(type):
"""metaclass to print a warning on instantiation of a deprecated class"""
@@ -105,31 +103,34 @@ def moved(modpath, objname):
instead (which has no lazy import feature though).
"""
def callnew(*args, **kwargs):
+ from logilab.common.modutils import load_module_from_name
message = "object %s has been moved to module %s" % (objname, modpath)
warn(message, DeprecationWarning, stacklevel=2)
m = load_module_from_name(modpath)
return getattr(m, objname)(*args, **kwargs)
return callnew
+# from logilab.common.modutils import LazyObject
+
+# class WarnLazyObject(LazyObject):
+# def __init__(self, oldname, newname):
+# # XXX doesn't work if module isn't in a package
+# package, module = newname.rsplit('.', 1)
+# super(WarnLazyObject, self).__init__(package, module)
+# self.oldname = oldname
+# self.newname = newname
+# print 'hop', oldname, newname
+# sys.modules[oldname] = self
+
+# def __getobj(self):
+# if self._imported is None:
+# message = "module %s has moved, it's now %s" % (
+# self.oldname, self.newname)
+# warn(message, DeprecationWarning, stacklevel=2)
+# return super(WarnLazyObject, self).__getobj()
+
-class WarnLazyObject(LazyObject):
- def __init__(self, oldname, newname):
- # XXX doesn't work if module isn't in a package
- package, module = newname.rsplit('.', 1)
- super(WarnLazyObject, self).__init__(package, module)
- self.oldname = oldname
- self.newname = newname
- print 'hop', oldname, newname
- sys.modules[oldname] = self
-
- def __getobj(self):
- if self._imported is None:
- message = "module %s has moved, it's now %s" % (
- self.oldname, self.newname)
- warn(message, DeprecationWarning, stacklevel=2)
- return super(WarnLazyObject, self).__getobj()
-
-module_moved = WarnLazyObject
+# module_moved = WarnLazyObject
def obsolete(reason="This function is obsolete"):
"""this function is an alternative to `deprecated_function`
diff --git a/textutils.py b/textutils.py
index 7114f68..1582e3e 100644
--- a/textutils.py
+++ b/textutils.py
@@ -46,7 +46,10 @@ __docformat__ = "restructuredtext en"
import re
from unicodedata import normalize as _uninormalize
-from os import linesep
+try:
+ from os import linesep
+except ImportError:
+ linesep = '\n' # gae
MANUAL_UNICODE_MAP = {