diff options
author | Sylvain Thenault <sylvain.thenault@logilab.fr> | 2008-05-16 11:05:00 +0200 |
---|---|---|
committer | Sylvain Thenault <sylvain.thenault@logilab.fr> | 2008-05-16 11:05:00 +0200 |
commit | fdfda1ab165bbbd9e1d5c84bfca0271b7ce442e7 (patch) | |
tree | 990368f1ef80c3925a9b2300e733f080ce5c1692 | |
parent | 0d1b0ddfbadc1da55c4d1c4c66899a200f1e011a (diff) | |
parent | 37efb3f82b2bd93aeb1e177ede786865796953d7 (diff) | |
download | logilab-common-fdfda1ab165bbbd9e1d5c84bfca0271b7ce442e7.tar.gz |
merge
-rw-r--r-- | adbh.py | 13 | ||||
-rw-r--r-- | deprecation.py | 41 | ||||
-rw-r--r-- | textutils.py | 5 |
3 files changed, 29 insertions, 30 deletions
@@ -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 = { |