git » abk » commit 16befd1

Move all functions out of finfo.

author Alberto Bertogli
2005-05-01 14:49:46 UTC
committer Alberto Bertogli
2005-05-01 14:49:46 UTC
parent 227396156cf53b1cf269ca4e5da161ef7a02d8f8

Move all functions out of finfo.

abk +12 -17

diff --git a/abk b/abk
index 740a30e..27fdfb1 100644
--- a/abk
+++ b/abk
@@ -123,6 +123,9 @@ def finfo_copy_file_reg_gzip(finfo, dst):
 	sfile.close()
 	dfile.close()
 
+# the copy function is modified by configuration
+finfo_copy_file_reg = finfo_copy_file_reg_gzip
+
 
 def finfo_copy_file_link(finfo, dst):
 	"Copy a symbolic link."
@@ -152,7 +155,7 @@ def finfo_copy_file(finfo, dst):
 
 	# copy accordingly to the file type
 	if finfo.type == 'r':
-		finfo.copy_file_reg(dst)
+		finfo_copy_file_reg(finfo, dst)
 	elif finfo.type == 'l':
 		finfo_copy_file_link(finfo, dst)
 	elif finfo.type == 'b' or finfo.type == 'c':
@@ -201,6 +204,9 @@ def finfo_hash_file_none(finfo):
 	"Empty hash."
 	return '-'
 
+# the hash function is modified by configuration
+finfo_hash_file = finfo_hash_file_sha
+
 
 class file_info:
 	"Represents a file"
@@ -219,17 +225,6 @@ class file_info:
 		self.hash = None
 		self.stat = None
 
-	# to save memory, reference external functions
-	load = finfo_load
-	copy_file = finfo_copy_file
-
-	# the following functions are modified by configuration
-	# hashing function
-	hash_file = finfo_hash_file_sha
-
-	# copy function
-	copy_file_reg = finfo_copy_file_reg_gzip
-
 	def __repr__(self):
 		return "<%s: %s %d>" % (self.name, self.type, self.size)
 
@@ -274,7 +269,7 @@ class index_file:
 	def put_file(self, filename, fullpath):
 		"Incorporates a file into the index."
 		self.db[filename] = file_info(filename, fullpath)
-		self.db[filename].load()
+		finfo_load(self.db[filename])
 		if self.db[filename].type == 'u':
 			# ignore files of unknown types, like unix sockets
 			del(self.db[filename])
@@ -377,7 +372,7 @@ def make_sync(sources, srcidx_path, dst_path, dstidx_path):
 			dst = dst_path + '/' + f
 			printv('data\t', f, dst)
 			quiet_unlink(dst)
-			srcidx.db[f].copy_file(dst)
+			finfo_copy_file(srcidx.db[f], dst)
 			update_files.append((f, dst))
 		elif not finfo_cmp_mdata(srcidx.db[f], dstidx.db[f]):
 			# metadata changed
@@ -516,11 +511,11 @@ verbose = opts.verbose
 
 # configuration
 if opts.copy_mode == 'raw':
-	file_info.copy_file_reg = finfo_copy_file_reg_raw
+	file_info_copy_file_reg = finfo_copy_file_reg_raw
 elif opts.copy_mode == 'gzip':
-	file_info.copy_file_reg = finfo_copy_file_reg_gzip
+	file_info_copy_file_reg = finfo_copy_file_reg_gzip
 elif opts.copy_mode == 'bzip2':
-	file_info.copy_file_reg = finfo_copy_file_reg_bzip2
+	file_info_copy_file_reg = finfo_copy_file_reg_bzip2
 else:
 	parser.error("Invalid copy mode (%s)." % opts.copy_mode)