Author: dsahlberg
Date: Wed May  1 09:03:30 2024
New Revision: 1917446

URL: http://svn.apache.org/viewvc?rev=1917446&view=rev
Log:
Make svn_apply_autoprops.py Python 3-compatible.

* contrib/client-side/svn_apply_autoprops.py:
  (get_autoprop_lines): Use raw strings for regexes, and `for line in
    fd` instead of `for line in fd.xreadlines()`.
  (filter_walk): Pass directory names separately.
  (main): Use `open()` instead of `file()`, and `os.walk()` instead of
    `os.path.walk()`.


Modified:
    subversion/trunk/contrib/client-side/svn_apply_autoprops.py

Modified: subversion/trunk/contrib/client-side/svn_apply_autoprops.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/contrib/client-side/svn_apply_autoprops.py?rev=1917446&r1=1917445&r2=1917446&view=diff
==============================================================================
--- subversion/trunk/contrib/client-side/svn_apply_autoprops.py (original)
+++ subversion/trunk/contrib/client-side/svn_apply_autoprops.py Wed May  1 
09:03:30 2024
@@ -68,10 +68,10 @@ def get_autoprop_lines(fd):
   lines = []
   reading_autoprops = 0
 
-  re_start_autoprops = re.compile('^\s*\[auto-props\]\s*')
-  re_end_autoprops = re.compile('^\s*\[\w+\]\s*')
+  re_start_autoprops = re.compile(r'^\s*\[auto-props\]\s*')
+  re_end_autoprops = re.compile(r'^\s*\[\w+\]\s*')
 
-  for line in fd.xreadlines():
+  for line in fd:
     if reading_autoprops:
       if re_end_autoprops.match(line):
         reading_autoprops = 0
@@ -124,13 +124,14 @@ def process_autoprop_lines(lines):
 
   return result
 
-def filter_walk(autoprop_lines, dirname, filenames):
+def filter_walk(autoprop_lines, dirname, dirnames, filenames):
   # Do not descend into a .svn directory.
   try:
-    filenames.remove(SVN_WC_ADM_DIR_NAME)
+    dirnames.remove(SVN_WC_ADM_DIR_NAME)
   except ValueError:
     pass
 
+  filenames += dirnames
   filenames.sort()
 
   # Find those filenames that match each fnmatch.
@@ -184,7 +185,7 @@ def main():
     return 1
 
   try:
-    fd = file(config_filename)
+    fd = open(config_filename)
   except IOError:
     print("Cannot open svn configuration file '%s' for reading: %s" \
           % (config_filename, sys.exc_value.strerror))
@@ -196,7 +197,8 @@ def main():
 
   autoprop_lines = process_autoprop_lines(autoprop_lines)
 
-  os.path.walk(wc_path, filter_walk, autoprop_lines)
+  for root, dirs, files in os.walk(wc_path):
+    filter_walk(autoprop_lines, root, dirs, files)
 
 if __name__ == '__main__':
   sys.exit(main())


Reply via email to