Better handing of python2 and SAX
svn: r120
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
%define ver      0.2.0
 | 
					%define ver      0.3.0
 | 
				
			||||||
%define rel      1
 | 
					%define rel      1
 | 
				
			||||||
%define prefix   /usr
 | 
					%define prefix   /usr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -13,8 +13,9 @@ BuildRoot: /var/tmp/%{name}-%{version}-root
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
URL: http://gramps.sourceforge.net
 | 
					URL: http://gramps.sourceforge.net
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Requires: python >= 1.5.2
 | 
					Requires: python = 1.5.2
 | 
				
			||||||
Requires: pygnome >= 1.0.53
 | 
					Requires: pygnome >= 1.0.53
 | 
				
			||||||
 | 
					Requires: pygnome-libglade
 | 
				
			||||||
Requires: PyXML
 | 
					Requires: PyXML
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%description
 | 
					%description
 | 
				
			||||||
@@ -53,6 +54,8 @@ rm -rf $RPM_BUILD_ROOT
 | 
				
			|||||||
%{prefix}/share/pixmaps/gramps.png
 | 
					%{prefix}/share/pixmaps/gramps.png
 | 
				
			||||||
# %{prefix}/share/gramps/*
 | 
					# %{prefix}/share/gramps/*
 | 
				
			||||||
%{prefix}/share/locale/*/LC_MESSAGES/gramps.mo
 | 
					%{prefix}/share/locale/*/LC_MESSAGES/gramps.mo
 | 
				
			||||||
 | 
					%{prefix}/share/example/gedcom/*
 | 
				
			||||||
 | 
					%{prefix}/share/example/gramps/*
 | 
				
			||||||
%{prefix}/share/gramps/*.pyo
 | 
					%{prefix}/share/gramps/*.pyo
 | 
				
			||||||
%{prefix}/share/gramps/*.so
 | 
					%{prefix}/share/gramps/*.so
 | 
				
			||||||
%{prefix}/share/gramps/*.py
 | 
					%{prefix}/share/gramps/*.py
 | 
				
			||||||
@@ -62,5 +65,6 @@ rm -rf $RPM_BUILD_ROOT
 | 
				
			|||||||
%{prefix}/share/gramps/filters/*.py
 | 
					%{prefix}/share/gramps/filters/*.py
 | 
				
			||||||
%{prefix}/share/gramps/filters/*.pyo
 | 
					%{prefix}/share/gramps/filters/*.pyo
 | 
				
			||||||
%{prefix}/share/gramps/plugins/*.py
 | 
					%{prefix}/share/gramps/plugins/*.py
 | 
				
			||||||
 | 
					%{prefix}/share/gramps/plugins/*.glade
 | 
				
			||||||
%{prefix}/share/gramps/plugins/*.pyo
 | 
					%{prefix}/share/gramps/plugins/*.pyo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,7 @@ from Researcher import Researcher
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import string
 | 
					import string
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from xml.sax import handler
 | 
					from xml.sax import handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,11 +32,14 @@ from xml.sax import handler
 | 
				
			|||||||
# Try to abstract SAX1 from SAX2
 | 
					# Try to abstract SAX1 from SAX2
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
try:
 | 
					if sys.version[0] != '1':
 | 
				
			||||||
    import xml.sax.saxexts
 | 
					 | 
				
			||||||
    sax = 1
 | 
					 | 
				
			||||||
except:
 | 
					 | 
				
			||||||
    sax = 2
 | 
					    sax = 2
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        import xml.sax.saxexts
 | 
				
			||||||
 | 
					        sax = 1
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        sax = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from latin_utf8 import utf8_to_latin
 | 
					from latin_utf8 import utf8_to_latin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,7 @@ import gzip
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
from gnome.ui import *
 | 
					from gnome.ui import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import xml.sax
 | 
					import xml.sax
 | 
				
			||||||
import xml.sax.saxutils
 | 
					import xml.sax.saxutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,11 +39,15 @@ import xml.sax.saxutils
 | 
				
			|||||||
# Try to abstract SAX1 from SAX2
 | 
					# Try to abstract SAX1 from SAX2
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
try:
 | 
					
 | 
				
			||||||
    import xml.sax.saxexts
 | 
					if sys.version[0] != '1':
 | 
				
			||||||
    sax = 1
 | 
					 | 
				
			||||||
except:
 | 
					 | 
				
			||||||
    sax = 2
 | 
					    sax = 2
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        import xml.sax.saxexts
 | 
				
			||||||
 | 
					        sax = 1
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        sax = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import string
 | 
					import string
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import xml.sax
 | 
					import xml.sax
 | 
				
			||||||
import xml.sax.saxutils
 | 
					import xml.sax.saxutils
 | 
				
			||||||
import utils
 | 
					import utils
 | 
				
			||||||
@@ -29,12 +30,14 @@ import utils
 | 
				
			|||||||
# Try to abstract SAX1 from SAX2
 | 
					# Try to abstract SAX1 from SAX2
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#-------------------------------------------------------------------------
 | 
					#-------------------------------------------------------------------------
 | 
				
			||||||
try:
 | 
					if sys.version[0] != '1':
 | 
				
			||||||
    import xml.sax.saxexts
 | 
					 | 
				
			||||||
    sax = 1
 | 
					 | 
				
			||||||
except:
 | 
					 | 
				
			||||||
    sax = 2
 | 
					    sax = 2
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        import xml.sax.saxexts
 | 
				
			||||||
 | 
					        sax = 1
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        sax = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FONT_SANS_SERIF = 0
 | 
					FONT_SANS_SERIF = 0
 | 
				
			||||||
FONT_SERIF = 1
 | 
					FONT_SERIF = 1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,35 +18,44 @@
 | 
				
			|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
					# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cStringIO
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					if sys.version[0] != '1':
 | 
				
			||||||
    from xml.unicode.utf8_iso import code_to_utf8
 | 
					 | 
				
			||||||
    from xml.unicode.iso8859 import UTF8String
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def utf8_to_latin(s):
 | 
					 | 
				
			||||||
        y = UTF8String(s)
 | 
					 | 
				
			||||||
        return y.encode("iso-8859-1")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def latin_to_utf8(s):
 | 
					 | 
				
			||||||
        buff = cStringIO.StringIO()
 | 
					 | 
				
			||||||
        for c in s:
 | 
					 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                cv = code_to_utf8(1,c)
 | 
					 | 
				
			||||||
            except Exception,e:
 | 
					 | 
				
			||||||
                from traceback import print_exc
 | 
					 | 
				
			||||||
                print_exc()
 | 
					 | 
				
			||||||
                cv = ''
 | 
					 | 
				
			||||||
            buff.write(cv)
 | 
					 | 
				
			||||||
        ans = buff.getvalue()
 | 
					 | 
				
			||||||
        buff.close()
 | 
					 | 
				
			||||||
        return ans
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
except:
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    def utf8_to_latin(s):
 | 
					    def utf8_to_latin(s):
 | 
				
			||||||
        return s.encode('latin-1')
 | 
					        return s.encode('latin-1')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def latin_to_utf8(s):
 | 
					    def latin_to_utf8(s):
 | 
				
			||||||
        return s.encode('utf-8')
 | 
					        return s.encode('utf-8')
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        import cStringIO
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        from xml.unicode.utf8_iso import code_to_utf8
 | 
				
			||||||
 | 
					        from xml.unicode.iso8859 import UTF8String
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def utf8_to_latin(s):
 | 
				
			||||||
 | 
					            y = UTF8String(s)
 | 
				
			||||||
 | 
					            return y.encode("iso-8859-1")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def latin_to_utf8(s):
 | 
				
			||||||
 | 
					            buff = cStringIO.StringIO()
 | 
				
			||||||
 | 
					            for c in s:
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
 | 
					                    cv = code_to_utf8(1,c)
 | 
				
			||||||
 | 
					                except Exception,e:
 | 
				
			||||||
 | 
					                    from traceback import print_exc
 | 
				
			||||||
 | 
					                    print_exc()
 | 
				
			||||||
 | 
					                    cv = ''
 | 
				
			||||||
 | 
					                buff.write(cv)
 | 
				
			||||||
 | 
					            ans = buff.getvalue()
 | 
				
			||||||
 | 
					            buff.close()
 | 
				
			||||||
 | 
					            return ans
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    except:
 | 
				
			||||||
 | 
					        def utf8_to_latin(s):
 | 
				
			||||||
 | 
					            return s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def latin_to_utf8(s):
 | 
				
			||||||
 | 
					            return s
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user