[or-cvs] r20208: {translation} now with logging (translation/trunk/tools/gsoc09)

runa at seul.org runa at seul.org
Mon Aug 3 13:23:41 UTC 2009


Author: runa
Date: 2009-08-03 09:23:41 -0400 (Mon, 03 Aug 2009)
New Revision: 20208

Modified:
   translation/trunk/tools/gsoc09/wml2po.sh
Log:
now with logging

Modified: translation/trunk/tools/gsoc09/wml2po.sh
===================================================================
--- translation/trunk/tools/gsoc09/wml2po.sh	2009-08-03 11:40:06 UTC (rev 20207)
+++ translation/trunk/tools/gsoc09/wml2po.sh	2009-08-03 13:23:41 UTC (rev 20208)
@@ -34,6 +34,14 @@
 # category. For now, we only need the input tag.
 nodefault='<input>'
 
+# The script can write the name of unprocessed files to a log.
+# If you want to enable this option, set the logfile here.
+logfile=""
+
+# This is the temp logfile. Leave this line even if you don't want to
+# log. This will be deleted when the script is done.
+tmplog="tmp.log"
+
 ### end config ###
 
 # Create a lockfile to make sure that only one instance of the script
@@ -48,6 +56,12 @@
 
 trap "rm -f '$PWD/$LOCKFILE'" exit
 
+# If the logfile is set, write the date.
+if [ $logfile ]
+then
+	echo `date` > $logfile
+fi
+
 # cd to the right directory so we can commit the files later
 cd "$podir"
 
@@ -57,6 +71,9 @@
 
 # For every wml, update po
 for file in $wml ; do
+
+	# Create the temp log
+	touch $tmplog
 	
 	# Get the basename of the file we are dealing with
 	wmlfile=`basename $file`
@@ -122,6 +139,7 @@
 		# We need to rename the other file
 		for file in `find $popath -type f -name "*.$filename"` ; do
 			svn mv "$file" "$popath/$pofile"
+			echo "$popath/$pofile" > $tmplog
 		done
 	else
 		poexist=0
@@ -147,6 +165,7 @@
 			if [ $content = 0 ] 
 			then
 				rm -f "$popath/$pofile"
+				echo "$popath/$pofile" > $tmplog
 			else
 				# Set the right encoding and charset
 				sed -i '0,/ENCODING/ s/ENCODING/8bit/' "$popath/$pofile"
@@ -154,6 +173,7 @@
 
 				# And add it to the repository
 				svn add "$popath/$pofile"
+				echo "$popath/$pofile" > $tmplog
 			fi
 		fi
 	fi
@@ -180,6 +200,9 @@
 		if [ $before = $after ]
 		then
 			svn revert "$popath/$pofile"
+			echo "$popath/$pofile" > $tmplog
+		else
+			echo "$popath/$pofile" > $tmplog
 		fi
 	fi
 
@@ -192,7 +215,19 @@
 		# Update the file
 		po4a-updatepo -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
 	fi
+	
+	# Write to the logfile
+	if [ -e $logfile ]
+	then
+		if [ `cat $tmplog | grep "$popath/$pofile" | wc -l` -eq "0" ]
+		then
+			echo "could not process: " "$pofile" >> $logfile
+		fi
+	fi
 
+	# Delete the temp log
+	rm -f $tmplog
+			
 	# Commit the files
 	svn ci -m 'automatically generated and updated the po files'
 done



More information about the tor-commits mailing list