Orb/python/doxygen/filerenamer.py
author Michel Szarindar <Michel.Szarindar@Nokia.com>
Thu, 18 Mar 2010 18:26:18 +0000
changeset 1 82f11024044a
parent 0 42188c7ea2d9
permissions -rw-r--r--
Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     1
# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved.
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     2
# This component and the accompanying materials are made available under the terms of the License 
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     3
# "Eclipse Public License v1.0" which accompanies this distribution, 
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     4
# and is available at the URL "http://www.eclipse.org/legal/epl-v10.html".
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     5
#
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     6
# Initial Contributors:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     7
# Nokia Corporation - initial contribution.
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     8
#
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
     9
# Contributors:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    10
# System Documentation Tools
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    11
# Description:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    12
#
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    13
import os.path
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    14
import sys
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    15
import unittest
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    16
import xml
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    17
import stat
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    18
import logging
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    19
from cStringIO import StringIO
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    20
from xml.etree import ElementTree as etree
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    21
from lib import scan, main, XmlParser, StubXmlParser
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    22
from optparse import OptionParser
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    23
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    24
__version__ = '0.1'
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    25
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    26
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    27
UNSAFE_CHARS = ("\n", "\t", ":", "?", ",", "=", ".", "\\", "/", "[", "]", "|", "<", ">", "+", ";", '"', "-")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    28
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    29
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    30
class FileRenamer(object):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    31
    """
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    32
    Given an xml file this class returns a MODE compatable filename
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    33
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    34
    >>> fr = FileRenamer(xmlparser=StubXmlParser())
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    35
    >>> fr.rename(r"c:\\temp\\xml\\class_c_active_scheduler.xml")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    36
    'class_c_active_scheduler=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.reference'
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    37
    """
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    38
    def __init__(self, xmlparser=XmlParser(), publishing_target="mode"):
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    39
        self.parser = xmlparser
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    40
        self.publishing_target = publishing_target
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    41
    
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    42
    def _escape(self, filename):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    43
        for char in UNSAFE_CHARS:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    44
            filename = filename.replace(char, "")            
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    45
        filename = filename.encode('unicode-escape', 'ignore')
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    46
        filename = filename.replace(" ", "-")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    47
        return filename        
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    48
    
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    49
    def rename(self, xmlfile):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    50
        """
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    51
        Return DITA MODE compliant filename.
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    52
        Format of resultant filenames is:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    53
            title=identifier=version=language=resolution.extension    
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    54
        Examples:
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    55
            Test-Document=GUID-1234=1=en=.reference
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    56
        """
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    57
        id = self.parser.parse(xmlfile)
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    58
        filename = os.path.basename(xmlfile)
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    59
        filename, ext = os.path.splitext(filename)
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    60
        if self.publishing_target == "mode":
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    61
            filename = self._escape(filename) 
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    62
            newfilename = "=".join((filename, id, '1', 'en', ''))
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    63
            ext = ext if ext == ".ditamap" else ".reference"
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    64
        elif self.publishing_target == "ditaot":
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    65
            newfilename = id
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    66
            ext = ext = ext if ext == ".ditamap" else ".xml"
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    67
        return newfilename + ext
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    68
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    69
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    70
def rename(indir, publishing_target):
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    71
    fr = FileRenamer(publishing_target=publishing_target)
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    72
    for filepath in scan(indir):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    73
        newfilename = os.path.join(os.path.dirname(filepath), fr.rename(filepath))
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    74
        try:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    75
            os.chmod(filepath, stat.S_IWRITE)
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    76
        except Exception, e:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    77
            logging.error('Unable to make file \"%s\" writable, error was: %s' % (filepath, e))
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    78
            continue
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    79
        else:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    80
            logging.debug("Renaming %s to %s" % (filepath, newfilename))
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    81
            try:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    82
                os.rename(filepath, newfilename)
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    83
            except Exception, e:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    84
                logging.error('Unable to rename file \"%s\" to \"%s\", error was: %s' % (filepath, newfilename, e))
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
    85
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    86
def main():        
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    87
    usage = "usage: %prog <Path to the XML content> <publishing_target>\n"
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    88
    parser = OptionParser(usage, version='%prog ' + __version__)
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    89
    parser.add_option("-p", dest="publishing_target", type="choice", choices=["mode", "ditaot"], default="mode", 
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    90
                          help="Publishing Target: mode|ditaot, [default: %default]")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    91
    parser.add_option("-l", "--loglevel", type="int", default=30, help="Log Level (debug=10, info=20, warning=30, [error=40], critical=50)")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    92
    (options, args) = parser.parse_args()
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    93
    if len(args) < 1:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    94
        parser.print_help()
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    95
        parser.error("Please supply the path to the XML content")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    96
        
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    97
    if options.loglevel:
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    98
        logging.basicConfig(level=options.loglevel)
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
    99
    
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   100
    rename(args[0],options.publishing_target)
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   101
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   102
if __name__ == '__main__':
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   103
    sys.exit(main())
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   104
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   105
######################################
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   106
# Test code
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   107
######################################
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   108
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   109
class TestFileRenamer(unittest.TestCase):
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   110
    def test_i_can_return_a_files_new_mode_name(self):
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   111
        fr = FileRenamer(xmlparser=StubXmlParser(),publishing_target="mode")
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   112
        newfile = fr.rename("hello.xml")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   113
        self.assertTrue(newfile == "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.reference")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   114
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   115
    def test_i_can_return_a_ditamaps_new_mode_name(self,publishing_target="mode"):
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   116
        fr = FileRenamer(xmlparser=StubXmlParser())
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   117
        newfile = fr.rename("hello.ditamap")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   118
        self.assertTrue(newfile == "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.ditamap")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   119
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   120
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   121
    def test_i_can_return_a_files_new_name_if_passed_an_absolute_path(self):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   122
        fr = FileRenamer(xmlparser=StubXmlParser())
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   123
        newfile = fr.rename("c:\\temp\\xml\\hello.xml")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   124
        self.assertTrue(newfile == "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.reference")
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   125
        
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   126
    def test_i_can_remove_incompatable_characters_from_a_filename(self):
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   127
        fr = FileRenamer(xmlparser=StubXmlParser())
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   128
        newfile = fr.rename("hello:?,=..xml")
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   129
        self.assertTrue(newfile , "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.reference")        
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   130
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   131
    def test_i_can_return_a_files_new_ditaot_name(self):
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   132
        fr = FileRenamer(xmlparser=StubXmlParser(),publishing_target="ditaot")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   133
        newfile = fr.rename("hello.xml")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   134
        self.assertEquals(newfile, "GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F.xml")
0
42188c7ea2d9 Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff changeset
   135
1
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   136
    def test_i_can_return_a_ditamaps_new_ditaot_name(self):
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   137
        fr = FileRenamer(xmlparser=StubXmlParser(),publishing_target="ditaot")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   138
        newfile = fr.rename("hello.ditamap")
82f11024044a Contribution of a new version of ORB and CXX DITA plug-in bug 1461 bug 1621 bug 1962
Michel Szarindar <Michel.Szarindar@Nokia.com>
parents: 0
diff changeset
   139
        self.assertEquals(newfile, "GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F.ditamap")