MCPcopy
hub / github.com/aws/aws-cli / append_file

Method append_file

awscli/testutils.py:646–659  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

isdirMethod · 0.45
makedirsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected