Use print() function in both Python 2 and Python 3
authorcclauss <cclauss@me.com>
Wed, 4 Mar 2020 23:08:24 +0000 (00:08 +0100)
committercclauss <cclauss@me.com>
Thu, 5 Mar 2020 10:35:30 +0000 (11:35 +0100)
Signed-off-by: cclauss <cclauss@me.com>
admin/linux/debian/scripts/git2changelog.py
admin/osx/macdeployqt.py
admin/win/nsi/l10n/bin/build_locale_nsi.py
shell_integration/nautilus/syncstate.py

index 3a1b44fb60a7d5657b07a2249b73c8e6b5f9425f..51c6afac0fa4d6e04c66bfcdf4e7f66f600e7858 100755 (executable)
@@ -1,5 +1,6 @@
 #!//usr/bin/env python2.7
 
+from __future__ import print_function
 import subprocess
 import re
 import sys
@@ -7,6 +8,11 @@ import datetime
 import os
 import ConfigParser
 
+try:
+    long
+except NameError:
+    long = int
+
 distribution="yakkety"
 
 versionTagRE = re.compile("^v([0-9]+((\.[0-9]+)+))(-(.+))?$")
@@ -123,12 +129,12 @@ def genChangeLogEntries(f, entries, distribution):
             version = upstreamVersion
         else:
             version = upstreamVersion + "~" + distribution + "1"
-        print >> f, "nextcloud-client (%s) %s; urgency=medium" % (version, distribution)
-        print >> f
-        print >> f, "  * " + subject
-        print >> f
-        print >> f, " -- %s <%s>  %s" % (name, email, date)
-        print >> f
+        print("nextcloud-client (%s) %s; urgency=medium" % (version, distribution), file=f)
+        print(file=f)
+        print("  * " + subject, file=f)
+        print(file=f)
+        print(" -- %s <%s>  %s" % (name, email, date), file=f)
+        print(file=f)
     return (latestBaseVersion, latestKind)
 
 if __name__ == "__main__":
@@ -141,4 +147,4 @@ if __name__ == "__main__":
 
     with open(sys.argv[1], "wt") as f:
         (baseVersion, kind) = genChangeLogEntries(f, entries, distribution)
-        print baseVersion, kind
+        print(baseVersion, kind)
index 2571b8eb9eef01652db76d7b4485fd437bbe9f6f..fbf4a1952ec44593eac974acff75e9f0e70ece9a 100755 (executable)
@@ -16,6 +16,7 @@
 #  You should have received a copy of the GNU General Public License
 #  along with ownCloud.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import os
 import re
 import subprocess
@@ -74,7 +75,7 @@ class CouldNotFindFrameworkError(Error):
   pass
 
 if len(sys.argv) < 3:
-  print 'Usage: %s <bundle.app> <path-to-qmake>' % sys.argv[0]
+  print('Usage: %s <bundle.app> <path-to-qmake>' % sys.argv[0])
   exit()
 
 def is_exe(fpath):
@@ -96,13 +97,13 @@ plugins_dir = os.path.join(bundle_dir, 'Contents', 'PlugIns')
 binaries = [i for i in glob(os.path.join(bundle_dir, 'Contents', 'MacOS', "*")) if is_exe(i)];
 
 qt_version = QueryQMake('QT_VERSION')
-print "Using Qt", qt_version
+print("Using Qt", qt_version)
 
 fixed_libraries = []
 fixed_frameworks = []
 
 def WriteQtConf():
-  print "Writing qt.conf..."
+  print("Writing qt.conf...")
   with open(os.path.join(resources_dir, 'qt.conf'), 'w') as f:
     f.write("[Paths]\nPlugins = PlugIns\n");
     f.close()
@@ -206,7 +207,7 @@ def FixLibrary(path):
     fixed_libraries.append(path)
   abs_path = FindLibrary(path)
   if abs_path == "":
-    print "Could not resolve %s, not fixing!" % path
+    print("Could not resolve %s, not fixing!" % path)
     return
   broken_libs = GetBrokenLibraries(abs_path)
   FixAllLibraries(broken_libs)
@@ -256,7 +257,7 @@ def CopyPlugin(path, subdir):
 
 def CopyFramework(source_dylib):
   parts = source_dylib.split(os.sep)
-  print "CopyFramework:", source_dylib
+  print("CopyFramework:", source_dylib)
   for i, part in enumerate(parts):
     matchObj = re.match(r'(\w+\.framework)', part)
     if matchObj:
@@ -354,9 +355,9 @@ else:
   commands.append(args)
 
 if len(sys.argv) <= 2:
-  print 'Will run %d commands:' % len(commands)
+  print('Will run %d commands:' % len(commands))
   for command in commands:
-    print ' '.join(command)
+    print(' '.join(command))
 
 for command in commands:
   p = subprocess.Popen(command)
index 977f62887c9908ed5e244f785076bf12a0d2f908..bf8eda7435e0d87c4e952d85374015156254c40c 100755 (executable)
@@ -9,6 +9,11 @@ import os
 import polib
 from optparse import OptionParser
 
+try:
+    unicode
+except NameError:
+    unicode = str
+
 parser = OptionParser()
 parser.add_option("-o", "--output", dest="output",
                   help="Directory for localized output", default="../Shared/installer/nightly_localized.nsi")
@@ -126,7 +131,7 @@ for root,dirs,files in os.walk(options.podir):
             if filename in localeToName:
                 language = localeToName[filename]
                 translationCache[language] = collections.OrderedDict()
-                
+
                 po = polib.pofile(os.path.join(root,file))
                 for entry in po.translated_entries():
                     # Loop through all our labels and add translation (each translation may have multiple labels)
@@ -165,14 +170,14 @@ for language,translations in translationCache.iteritems():
     for label,value in translations.iteritems():
         NSINewLines.append( tostr('StrCpy $%s "%s"\n' % (label,value)) )
         if language.upper() == options.lang.upper():
-           NSIDeclarations.append( tostr('Var %s\n' % label) )
+            NSIDeclarations.append( tostr('Var %s\n' % label) )
 
         count += 1
     NSIWorkingFile = open('%s/%s.nsh' % (options.output, language),"w")
     NSIWorkingFile.writelines(NSINewLines)
     NSIWorkingFile.close()
     print ( "%i translations merged for language '%s'"%(count,language) )
-    
+
 # Finally, let's write languages.nsh and declarations.nsh
 NSIWorkingFile = open('%s/languages.nsh' % options.output,"w")
 NSIWorkingFile.writelines(NSILanguages)
@@ -181,5 +186,5 @@ NSIWorkingFile.close()
 NSIWorkingFile = open('%s/declarations.nsh' % options.output,"w")
 NSIWorkingFile.writelines(NSIDeclarations)
 NSIWorkingFile.close()
-    
+
 print ( "NSI Localization Operation Complete" )
index 2d1494ca1dfd6a03d63b2cb9f019e0051fbb53a2..84a13161c3da4b3886c2b0dc65841a2b86a7450b 100644 (file)
@@ -296,6 +296,7 @@ class MenuExtension(GObject.GObject, Nautilus.MenuProvider):
         state = entry['state']
         state_ok = state.startswith('OK')
         state_sync = state.startswith('SYNC')
+        isDir = os.path.isdir(filename + os.sep)
         if state_ok:
             shareable = True
         elif state_sync and isDir: