Просмотр исходного кода

Factor out rename into a function

[SVN r37627]
Aleksey Gurtovoy 19 лет назад
Родитель
Сommit
1f3d4fb409

+ 5 - 5
tools/regression/xsl_reports/boost_wide_report.py

@@ -674,11 +674,11 @@ def fix_file_names( dir ):
         for file in files:
             if file.find( "%20" ) > -1:
                 new_name = file.replace( "%20", " " )
-                old_file_path = os.path.join( root, file )
-                new_file_path = os.path.join( root, new_name )
-                utils.log( 'Renaming %s to %s' % ( old_file_path, new_file_path ) )
-                os.unlink( new_file_path )
-                os.rename( old_file_path, new_file_path )
+                utils.rename(
+                      utils.log
+                    , os.path.join( root, file )
+                    , os.path.join( root, new_name )
+                    )
 
 
 def build_xsl_reports( 

+ 1 - 0
tools/regression/xsl_reports/utils/__init__.py

@@ -6,6 +6,7 @@ from checked_system import *
 from libxslt import *
 from log import *
 from makedirs import *
+from rename import *
 from tar import *
 from zip import *
 

+ 3 - 4
tools/regression/xsl_reports/utils/libxslt.py

@@ -6,6 +6,7 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 
 import utils.makedirs
+import utils.rename
 import os.path
 import os
 import sys
@@ -43,8 +44,6 @@ def libxslt( log, xml_file, xsl_file, output_file, parameters = None ):
 
     output_file = xslt_param( output_file, 0 )
     xlst_output_file = xslt_param( output_file )
-    if output_file != xlst_output_file:        
-        log( 'Renaming %s to %s' % ( xlst_output_file, output_file ) )
-        os.unlink( output_file )
-        os.rename( xlst_output_file, output_file )
+    if output_file != xlst_output_file:
+        utils.rename( log, xlst_output_file, output_file )
 

+ 17 - 0
tools/regression/xsl_reports/utils/rename.py

@@ -0,0 +1,17 @@
+
+# Copyright (c) MetaCommunications, Inc. 2003-2007
+#
+# Distributed under the Boost Software License, Version 1.0. 
+# (See accompanying file LICENSE_1_0.txt or copy at 
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os.path
+import os
+
+
+def rename( log, src, dst ):
+    log( 'Renaming %s to %s' % ( src, dst ) )
+    if os.path.exists( dst ):
+        os.unlink( dst )
+
+    os.rename( src, dst )

粤ICP备19079148号