Changeset 52633

Show
Ignore:
Timestamp:
02/29/08 17:33:13 (2 years ago)
Author:
madarche
Message:

- Factorized the toLatin9 method in CPSUtil.text.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/products/CPSOOo/trunk/CHANGES

    r52050 r52633  
    77Bug fixes 
    88~~~~~~~~~ 
    9 - 
     9- Factorized the toLatin9 method in CPSUtil.text. 
    1010New internal features 
    1111~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSOOo/trunk/OOoDocbookDocument.py

    r51948 r52633  
    11# -*- coding: ISO-8859-15 -*- 
    2 # (C) Copyright 2004-2007 Nuxeo SAS <http://nuxeo.com> 
     2# (C) Copyright 2004-2008 Nuxeo SAS <http://nuxeo.com> 
    33# Authors: 
    44# M.-A. Darche (Nuxeo) 
     
    3939 
    4040from Products.CMFCore.permissions import View 
     41from Products.CPSUtil.text import toLatin9 
    4142from Products.CPSDocument.CPSDocument import CPSDocument 
    4243 
     
    5859 
    5960log_key = 'OOoDocbookDocument' 
    60  
    61 def toLatin9(s): 
    62     if s is None: 
    63         return None 
    64     else: 
    65         # Replace RIGHT SINGLE QUOTATION MARK (unicode only) 
    66         # bythe APOSTROPHE (ascii and latin1). 
    67         # cf. http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 
    68         s = s.replace(u'\u2019', u'\u0027') 
    69         #&#8217; 
    70         return s.encode('iso-8859-15', 'ignore') 
    7161 
    7262def toUnicode(s): 
  • CPS3/products/CPSRemoteController/trunk/CHANGES

    r52080 r52633  
    77Bug fixes 
    88~~~~~~~~~ 
    9 - 
     9- Factorized the toLatin9 method in CPSUtil.text. 
    1010New internal features 
    1111~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSRemoteController/trunk/RemoteControllerTool.py

    r51808 r52633  
    5050from Products.CPSUtil.id import generateFileName 
    5151from Products.CPSUtil.integration import getProductVersion 
    52 from Products.CPSUtil.xmlrpc import toLatin9 
     52from Products.CPSUtil.text import toLatin9 
    5353from Products.CPSUtil.xmlrpc import unMarshallDocument 
    5454 
  • CPS3/products/CPSRemoteController/trunk/tests/test_RemoteControllerClient.py

    r48944 r52633  
    3333from Products.CPSRemoteController.RemoteControllerClient import \ 
    3434    RequestDispatcher, RemoteControllerClient, CPSRemoteControllerClient 
    35 from Products.CPSRemoteController.RemoteControllerTool import toLatin9 
     35from Products.CPSUtil.text import toLatin9 
    3636 
    3737def randomText(max_len=10): 
  • CPS3/products/CPSUtil/trunk/CHANGES

    r52595 r52633  
    77Bug fixes 
    88~~~~~~~~~ 
    9 - 
     9- Factorized the toLatin9 method in CPSUtil.text. 
    1010New internal features 
    1111~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSUtil/trunk/text.py

    r51800 r52633  
    11# -*- coding: ISO-8859-15 -*- 
    2 # (C) Copyright 2005-2007 Nuxeo SAS <http://nuxeo.com> 
     2# (C) Copyright 2005-2008 Nuxeo SAS <http://nuxeo.com> 
    33# Authors: 
    44# M.-A. Darche <madarche@nuxeo.com> 
     
    5050    return s 
    5151 
     52# Allowing this method to be imported in restricted code 
     53ModuleSecurityInfo('Products.CPSUtil.text').declarePublic('toLatin9') 
     54def toLatin9(obj): 
     55    if isinstance(obj, dict): 
     56        for k, v in obj.items(): 
     57            if isinstance(v, unicode): 
     58                v = _unicodeToLatin9(v) 
     59                obj[k] = v 
     60    elif isinstance(obj, unicode): 
     61        obj = _unicodeToLatin9(obj) 
     62    return obj 
     63 
     64def _unicodeToLatin9(s): 
     65    if s is None: 
     66        return None 
     67    else: 
     68        # Replace RIGHT SINGLE QUOTATION MARK (unicode only) 
     69        # by the APOSTROPHE (ascii and latin1). 
     70        # cf. http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 
     71        s = s.replace(u'\u2019', u'\u0027') 
     72        #&#8217; 
     73        return s.encode('iso-8859-15', 'ignore') 
    5274 
    5375# Allowing this method to be imported in restricted code 
  • CPS3/products/CPSUtil/trunk/xmlrpc.py

    r48942 r52633  
    1 # (C) Copyright 2005 Nuxeo SARL <http://nuxeo.com> 
     1# (C) Copyright 2005-2008 Nuxeo SAS <http://nuxeo.com> 
    22# Authors: 
    33# Tarek Ziade <tziade@nuxeo.com> 
     
    150150    return element 
    151151 
    152 def toLatin9(obj): 
    153     if isinstance(obj, dict): 
    154         for k, v in obj.items(): 
    155             if isinstance(v, unicode): 
    156                 v = _stringToLatin9(v) 
    157                 obj[k] = v 
    158     elif isinstance(obj, unicode): 
    159         obj = _stringToLatin9(obj) 
    160     return obj 
    161  
    162 def _stringToLatin9(s): 
    163     if s is None: 
    164         return None 
    165     else: 
    166         # Replace RIGHT SINGLE QUOTATION MARK (unicode only) 
    167         # by the APOSTROPHE (ascii and latin1). 
    168         # cf. http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 
    169         s = s.replace(u'\u2019', u'\u0027') 
    170         #&#8217; 
    171         return s.encode('iso-8859-15', 'ignore')