Implemented creating of target files during creating symlinks
Change-Id: Ibeecbcf9210dcec219478dba3f5dadc901e4e99c
diff --git a/tempfiles.py b/tempfiles.py
index ac7dbca..c3ffb3d 100644
--- a/tempfiles.py
+++ b/tempfiles.py
@@ -41,6 +41,10 @@
self.logger.debug(msg)
return temp_dir
+ @property
+ def last_temp_dir(self):
+ return self._temp_dirs[-1]
+
def create_subdirs(self, subdirs, temp_dir):
if not os.path.isdir(temp_dir):
temp_dir = self.get_temp_dir()
@@ -66,3 +70,12 @@
self.logger.debug('Creates temporary symlink "{} -> {}"'
''.format(linkname, target))
return linkname
+
+ def get_file(self, content='', temp_dir=None):
+ if temp_dir is None:
+ temp_dir = self.get_temp_dir()
+ filename = tempfile.mktemp(dir=temp_dir)
+ with open(filename, 'w') as outfile:
+ outfile.write(content)
+ self.logger.debug('Creates temporary file "{}"'.format(filename))
+ return filename