Commit 2c89a570 authored by sylvain.thenault@logilab.fr's avatar sylvain.thenault@logilab.fr
Browse files

avoid dependency to common

--HG--
branch : tls-sprint
parent b4728112625f
......@@ -13,6 +13,7 @@ from simplejson import dumps
from logilab.common.decorators import classproperty
from logilab.common.deprecation import obsolete
from logilab.mtconverter import html_escape
from rql.nodes import VariableRef, SubQuery
from rql.stmts import Union, Select
......@@ -20,8 +21,7 @@ from rql.stmts import Union, Select
from cubicweb import Unauthorized
from cubicweb.vregistry import VObject
from cubicweb.selectors import yes
from cubicweb.utils import UStringIO
from cubicweb.common.uilib import html_escape, ustrftime
from cubicweb.utils import UStringIO, ustrftime
from cubicweb.common.registerers import yes_registerer, priority_registerer
......
......@@ -11,7 +11,6 @@ __docformat__ = "restructuredtext en"
import csv
import decimal
import locale
import re
from urllib import quote as urlquote
from cStringIO import StringIO
......@@ -23,16 +22,7 @@ from mx.DateTime import DateTimeType, DateTimeDeltaType
from logilab.common.textutils import unormalize
from logilab.mtconverter import html_escape, html_unescape
def ustrftime(date, fmt='%Y-%m-%d'):
"""like strftime, but returns a unicode string instead of an encoded
string which may be problematic with localized date.
encoding is guessed by locale.getpreferredencoding()
"""
# date format may depend on the locale
encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8'
return unicode(date.strftime(fmt), encoding)
from cubicweb.utils import ustrftime
def rql_for_eid(eid):
"""return the rql query necessary to fetch entity with the given eid. This
......
......@@ -9,7 +9,7 @@ __docformat__ = "restructuredtext en"
from logilab.common import interface
from logilab.common.compat import all
from logilab.common.decorators import cached
from logilab.mtconverter import TransformData, TransformError
from logilab.mtconverter import TransformData, TransformError, html_escape
from rql.utils import rqlvar_maker
......@@ -18,11 +18,16 @@ from cubicweb.vregistry import autoselectors
from cubicweb.rset import ResultSet
from cubicweb.selectors import yes
from cubicweb.appobject import AppRsetObject
from cubicweb.common.registerers import id_registerer
from cubicweb.common.uilib import printable_value, html_escape, soup2xhtml
from cubicweb.common.mixins import MI_REL_TRIGGERS
from cubicweb.common.mttransforms import ENGINE
from cubicweb.schema import RQLVocabularyConstraint, RQLConstraint, bw_normalize_etype
from cubicweb.common.registerers import id_registerer
try:
from cubicweb.common.uilib import printable_value, soup2xhtml
from cubicweb.common.mixins import MI_REL_TRIGGERS
from cubicweb.common.mttransforms import ENGINE
except ImportError:
# missing -common
MI_REL_TRIGGERS = {}
_marker = object()
......
......@@ -6,6 +6,7 @@
"""
__docformat__ = "restructuredtext en"
import locale
from md5 import md5
from time import time
from random import randint, seed
......@@ -42,6 +43,16 @@ def date_range(begin, end, incr=1, include=None):
yield date
date += incr
def ustrftime(date, fmt='%Y-%m-%d'):
"""like strftime, but returns a unicode string instead of an encoded
string which may be problematic with localized date.
encoding is guessed by locale.getpreferredencoding()
"""
# date format may depend on the locale
encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8'
return unicode(date.strftime(fmt), encoding)
def dump_class(cls, clsname):
"""create copy of a class by creating an empty class inheriting
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment