[svn] r4767 - trunk/tools/yam

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Mon Sep 25 15:02:31 CEST 2006


Author: dag
Date: 2006-09-25 15:02:31 +0200 (Mon, 25 Sep 2006)
New Revision: 4767

Modified:
   trunk/tools/yam/yam
Log:
More small improvements

Modified: trunk/tools/yam/yam
===================================================================
--- trunk/tools/yam/yam	2006-09-25 12:59:12 UTC (rev 4766)
+++ trunk/tools/yam/yam	2006-09-25 13:02:31 UTC (rev 4767)
@@ -552,11 +552,22 @@
 	def rpmlist(self):
 		"Capture a list of packages in the repository"
 		list = Set()
-		for root, dirs, files in os.walk(self.srcdir):
+
+		### os.walk() is a python 2.4 feature
+#		for root, dirs, files in os.walk(self.srcdir):
+#			for file in files:
+#				if os.path.exists(file) and file.endswith('.rpm'):
+#					size = os.stat(os.path.join(root, file)).st_size
+#					list.add( (file, size) )
+
+		### os.path.walk() goes back further
+		def addfile((list, ), path, files):
 			for file in files:
-				if os.path.exists(file) and file.endswith('.rpm'):
-					size = os.stat(os.path.join(root, file)).st_size
+				if os.path.exists(os.path.join(path, file)) and file.endswith('.rpm'):
+					size = os.stat(os.path.join(path, file)).st_size
 					list.add( (file, size) )
+
+		os.path.walk(self.srcdir, addfile, (list,))
 		list.sort()
 		return list
 
@@ -1467,20 +1478,19 @@
 				if new or removed:
 					msg = msg + '\n\n\tRepo: %s' % repo.name
 					info(2, '%s: Repository %s changed (new: %d, removed: %d)' % (dist.nick, repo.name, len(new), len(removed)))
-					info(4, '%s: New packages: %s' % (dist.nick, new))
-					info(4, '%s: Removed packages: %s' % (dist.nick, removed))
-					fd = open(cf.logfile, 'a')
+					fd = open(cf.logfile, 'a+')
 					date = time.strftime("%b %d %H:%M:%S", time.gmtime())
 
 					if new.list:
+						info(4, '%s: New packages: %s' % (dist.nick, new))
 						distnew += len(new)
 						for element in new.list:
 							fd.write('%s %s/%s Added %s (%d kiB)\n' % (date, dist.nick, repo.name, element[0], element[1]/1024))
 							msg = msg + '\n\t\t+ %s (%d kiB)' % (element[0], element[1]/1024)
 
 					if removed.list:
+						info(4, '%s: Removed packages: %s' % (dist.nick, removed))
 						distremoved += len(removed)
-						
 						for element in removed.list:
 							fd.write('%s %s/%s Removed %s (%d kiB)\n' % (date, dist.nick, repo.name, element[0], element[1]/1024))
 							msg = msg + '\n\t\t- %s (%d kiB)' % (element[0], element[1]/1024)



More information about the svn-commits mailing list