Commits

Shu Zong Chen  committed db062a2

masq now works across directories

  • Participants
  • Parent commits 4068b5e

Comments (0)

Files changed (1)

File masquerade/masq.py

 		data = Masquerade.read_from_source(self.source, self.fn)
 		masked = self.target.write(data)
 
-		tmp_dir, fn = self.mkfile(masked)
+		tmp_dir, tmp_fn = self.mkfile(masked)
 
 		while 1:
-			subprocess.call([self.editor, fn])
+			subprocess.call([self.editor, tmp_fn])
 
 			try:
-				unmasked = Masquerade.read_from_source(self.target, fn)
+				unmasked = Masquerade.read_from_source(self.target, tmp_fn)
 			except Exception as e:
 				print e
 				print e.message
 				raise e
 			break
 
-		self.rmfile(tmp_dir)
+		self.rmfile(tmp_dir, tmp_fn)
 
 	def get_formatter(self, format):
 		if format == 'sqlite':
 
 	def mkfile(self, data):
 		tmp_dir = tempfile.mkdtemp()
-		fn = os.path.join(tmp_dir, self.fn)
+		d, f = os.path.split(self.fn)
+		fn = os.path.join(tmp_dir, f)
 		with open(fn, 'w') as fh:
 			fh.write(data)
 		return tmp_dir, fn
 
-	def rmfile(self, dn):
-		os.unlink(os.path.join(dn, self.fn))
+	def rmfile(self, dn, fn):
+		os.unlink(fn)
 		os.rmdir(dn)
 
 	@staticmethod