Append contents to a file ``filename`` should be a relative path, e.g. "foo/bar/baz.txt" It will be translated into a full path in a tmp dir. Returns the full path to the file.
(self, filename, contents, encoding=None)
| 644 | return filename |
| 645 | |
| 646 | def append_file(self, filename, contents, encoding=None): |
| 647 | """Append contents to a file |
| 648 | |
| 649 | ``filename`` should be a relative path, e.g. "foo/bar/baz.txt" |
| 650 | It will be translated into a full path in a tmp dir. |
| 651 | |
| 652 | Returns the full path to the file. |
| 653 | """ |
| 654 | full_path = os.path.join(self.rootdir, filename) |
| 655 | if not os.path.isdir(os.path.dirname(full_path)): |
| 656 | os.makedirs(os.path.dirname(full_path)) |
| 657 | with open(full_path, 'a', encoding=encoding) as f: |
| 658 | f.write(contents) |
| 659 | return full_path |
| 660 | |
| 661 | def full_path(self, filename): |
| 662 | """Translate relative path to full path in temp dir. |