View Ticket
Not logged in
Ticket UUID: 7ac304ac058264540383dbfea555368572f282f2
Title: IENG, ICOP, and ICMT are lost in translation
Status: Closed Type: Code_Defect
Severity: Minor Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2014-11-22 22:42:56
Version Found In: d0f178c2c0e9c7c7
User Comments:
anonymous added on 2014-11-19 15:32:13:
The IENG, ICOP, and ICMT chunks are not preserved in the translation to XML.

The following patch fixes this.  It also changes the handling of IPRD to work the same way as IENG, ICOP, and ICMT, since I don't think the original behaviour of inserting a default IPRD of SBAWE32 is desirable.

diff --git a/pysf.py b/pysf.py
index edce72e..8524740 100755
--- a/pysf.py
+++ b/pysf.py
@@ -827,7 +827,6 @@ def SfToXml(Src, Dst):
         u'ISNG': Def(Tree.CkIdStr('isng', None, -1), u'pysf song'),
         u'INAM': Def(Tree.CkIdStr('INAM', None, -1), u'pysf instruments'),
         u'ICRD': Def(Tree.CkIdStr('ICRD', None, -1), ustr(DateAsciiGet())),
-        u'IPRD': Def(Tree.CkIdStr('IPRD', None, -1), u'SBAWE32'),
         u'IFIL': {
             u'major': Major,
             u'minor': Minor
@@ -836,7 +835,12 @@ def SfToXml(Src, Dst):
             Tree.CkIdStr('ISFT', None, -1),
             u'pysf %d:pysf %d' % (PysfVersion, PysfVersion)
         )
-     }
+    }
+    for chunk in ('IENG', 'IPRD', 'ICOP', 'ICMT'):
+        val = Tree.CkIdStr(chunk, None, -1)
+        if val is not None:
+            Dict[unicode(chunk)] = val
+        
     OutHandle.write(DictToXmlStr({
         u'sf2': Dict
     }))
@@ -867,11 +871,11 @@ def SfInfo(Dict):
             'ICRD', SfStr(Def(Val(Dict, u'ICRD'), DateAsciiGet()))
         ]
     ]
-    Ieng = SfStr(Val(Dict, u'IENG'))
-    if Ieng != None:
-        List[1].append('IENG', Ieng)
+    for chunk in ('IENG', 'IPRD', 'ICOP', 'ICMT'):
+        val = SfStr(Val(Dict, unicode(chunk)))
+        if val is not None:
+            List[1].extend([chunk, val])
     map(List[1].append, [
-        'IPRD', SfStr(Def(Val(Dict, u'IPRD'), 'SBAWE32')),
         'ISFT', SfStr(Def(Val(Dict, u'ISFT'), 'SFEDT v1.28'))
     ])
     return List

bencollver added on 2014-11-22 22:42:56:
Thank you for the bug report and fix!  -Ben