1   
 2   
 3  from translate.storage import oo 
 4  from translate.misc import wStringIO 
 5  import warnings 
 6   
 9          warnings.resetwarnings() 
 10   
12          warnings.resetwarnings() 
 13   
19   
21          """helper that converts oo source to oofile object and back""" 
22          return str(self.ooparse(oosource)) 
 23   
25          """checks that a simple oo entry is parsed correctly""" 
26          oosource = r'svx        source\dialog\numpages.src      0       string  RID_SVXPAGE_NUM_OPTIONS STR_BULLET                      0       en-US   Character                               20050924 09:13:58' 
27          oofile = self.ooparse(oosource) 
28          assert len(oofile.units) == 1 
29          oe = oofile.units[0] 
30          assert oe.languages.keys() == ["en-US"] 
31          ol = oofile.oolines[0] 
32          assert ol.getkey() == ('svx', r'source\dialog\numpages.src', 'string', 'RID_SVXPAGE_NUM_OPTIONS', 'STR_BULLET', '') 
33          assert ol.text == 'Character' 
34          assert str(ol) == oosource 
 35   
37          """checks that a simple entry with quickhelptext is parsed correctly""" 
38          oosource = r'sd source\ui\dlg\sdobjpal.src      0       imagebutton     FLTWIN_SDOBJPALETTE     BTN_SYMSIZE                     16      en-US   -               Toggle Symbol Size              20051017 21:40:56' 
39          oofile = self.ooparse(oosource) 
40          assert len(oofile.units) == 1 
41          oe = oofile.units[0] 
42          assert oe.languages.keys() == ["en-US"] 
43          ol = oofile.oolines[0] 
44          assert ol.getkey() == ('sd', r'source\ui\dlg\sdobjpal.src', 'imagebutton', 'FLTWIN_SDOBJPALETTE', 'BTN_SYMSIZE', '') 
45          assert ol.quickhelptext == 'Toggle Symbol Size' 
46          assert str(ol) == oosource 
 47   
49          """checks that a simple entry with title text is parsed correctly""" 
50          oosource = r'dbaccess   source\ui\dlg\indexdialog.src   0       querybox        QUERY_SAVE_CURRENT_INDEX                                0       en-US   Do you want to save the changes made to the current index?                      Exit Index Design       20051017 21:40:56' 
51          oofile = self.ooparse(oosource) 
52          assert len(oofile.units) == 1 
53          oe = oofile.units[0] 
54          assert oe.languages.keys() == ["en-US"] 
55          ol = oofile.oolines[0] 
56          assert ol.getkey() == ('dbaccess', r'source\ui\dlg\indexdialog.src', 'querybox', 'QUERY_SAVE_CURRENT_INDEX', '', '') 
57          assert ol.title == 'Exit Index Design' 
58          assert str(ol) == oosource 
 59   
61          """checks that a blank line is parsed correctly""" 
62          oosource = '\n' 
63          warnings.simplefilter("error") 
64          oofile = self.ooparse(oosource) 
65          assert len(oofile.units) == 0 
 66   
68          """checks that we process the length field correctly""" 
69           
70          oosource = r'sd source\ui\dlg\sdobjpal.src      0       imagebutton     FLTWIN_SDOBJPALETTE     BTN_SYMSIZE                     16      en-US   -               Toggle Symbol Size              20051017 21:40:56' 
71          oofile = self.ooparse(oosource) 
72          assert len(oofile.units) == 1 
73          oe = oofile.units[0] 
74          assert oe.languages.keys() == ["en-US"] 
75          ol = oofile.oolines[0] 
76          assert int(ol.width) == 16 
 77   
79          """checks that we escape properly""" 
80          oosource = r'svx        source\dialog\numpages.src      0       string  RID_SVXPAGE_NUM_OPTIONS STR_BULLET                      0       en-US   size *2 \\langle x \\rangle                             20050924 09:13:58' 
81          oofile = self.ooregen(oosource) 
82          assert r'size *2 \\langle x \\rangle' in oofile