From f4a446caa899724715ad4ca8b4532e7b4cdbb7b6 Mon Sep 17 00:00:00 2001 From: Romain Failliot Date: Mon, 22 Nov 2021 18:52:26 -0500 Subject: [PATCH] Fix some typos and convert windows-installer scripts to Python 3 The scripts are poorly converted as Windows is not really supoported anymore and would need some love from a contributor who actually uses Windows --- src/diffuse/main.py | 3 +-- windows-installer/build.py | 8 ++++---- windows-installer/setup.new.py | 14 +++++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/diffuse/main.py b/src/diffuse/main.py index 995e6df..b19f34b 100644 --- a/src/diffuse/main.py +++ b/src/diffuse/main.py @@ -534,8 +534,7 @@ class Diffuse(Gtk.Window): info.name, info.encoding, info.revision, info.label = name, encoding, None, label info.last_stat = info.stat = os.stat(name) self.setFileInfo(f, info) - # update the syntax highlighting incase we changed the file - # extension + # update the syntax highlighting in case we changed the file extension syntax = theResources.guessSyntaxForFile(name, ss) if syntax is not None: self.setSyntax(syntax) diff --git a/windows-installer/build.py b/windows-installer/build.py index 490c6e6..7a75155 100755 --- a/windows-installer/build.py +++ b/windows-installer/build.py @@ -46,7 +46,7 @@ def copyFile(src, dest, use_text_mode=False,enc=None): s = f.read() f.close() if enc is not None: - s = codecs.encode(unicode(s, 'utf_8'), enc) + s = codecs.encode(str(s, encoding='utf_8'), enc) f = open(dest, w) f.write(s) f.close() @@ -190,12 +190,12 @@ for lang in os.listdir(d): while True: i = s.find('&#', idx) if i < 0: - a.append(unicode(s[idx:], 'latin_1')) + a.append(str(s[idx:], encoding='latin_1')) break - a.append(unicode(s[idx:i], 'latin_1')) + a.append(str(s[idx:i], encoding='latin_1')) i += 2 j = s.find(';', i) - a.append(unichr(int(s[i:j]))) + a.append(chr(int(s[i:j]))) idx = j + 1 s = ''.join(a) s = codecs.encode(s, 'utf-8') diff --git a/windows-installer/setup.new.py b/windows-installer/setup.new.py index 2bb4c85..8750ef7 100644 --- a/windows-installer/setup.new.py +++ b/windows-installer/setup.new.py @@ -10,14 +10,14 @@ gnomeSiteDir = os.path.join(siteDir, "gnome") # This is the list of dll which are required by PyGI. # I get this list of DLL using http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx -# Procedure: +# Procedure: # 1) Run your from from your IDE # 2) Command for using listdlls.exe # c:/path/to/listdlls.exe python.exe > output.txt -# 3) This would return lists of all dll required by you program -# in my case most of dll file were located in c:\python27\Lib\site-packages\gnome +# 3) This would return lists of all dll required by you program +# in my case most of dll file were located in c:\python27\Lib\site-packages\gnome # (I am using PyGI (all in one) installer) -# 4) Below is the list of gnome dll I received from listdlls.exe result. +# 4) Below is the list of gnome dll I received from listdlls.exe result. # If you prefer you can import all dlls from c:\python27\Lib\site-packages\gnome folder #missingDll = glob.glob(gnomeSiteDir + "\\" + '*.dll') @@ -142,10 +142,10 @@ for dll in missingDll: includeFiles.append((os.path.join(gnomeSiteDir, dll), dll)) #includeFiles.append(dll) -# You can import all Gtk Runtime data from gtk folder +# You can import all Gtk Runtime data from gtk folder #gnomeLibs= ['etc','lib','share'] -# You can import only important Gtk Runtime data from gtk folder +# You can import only important Gtk Runtime data from gtk folder gnomeLibs = [ 'lib\\gdk-pixbuf-2.0', 'lib\\girepository-1.0', @@ -196,7 +196,7 @@ def copyFile(src, dest, use_text_mode=False,enc=None): s = f.read() f.close() if enc is not None: - s = codecs.encode(unicode(s, 'utf_8'), enc) + s = codecs.encode(str(s, encoding='utf_8'), enc) f = open(dest, w) f.write(s) f.close()