Skip to content

Commit

Permalink
Merge pull request #3960 from datamel/remove-redundant-dump-item
Browse files Browse the repository at this point in the history
Remove redundant _dump_item method
  • Loading branch information
hjoliver authored Nov 29, 2020
2 parents 5298af7 + bd55488 commit 80bb050
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions cylc/flow/suite_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,28 +598,6 @@ def create_server_keys(keys, suite_srv_dir):
os.umask(old_umask)


def _dump_item(path, item, value):
"""Dump "value" to a file called "item" in the directory "path".
1. File permission should already be user-read-write-only on
creation by mkstemp.
2. The combination of os.fsync and os.rename should guarantee
that we don't end up with an incomplete file.
"""
os.makedirs(path, exist_ok=True)
from tempfile import NamedTemporaryFile
handle = NamedTemporaryFile(prefix=item, dir=path, delete=False)
try:
handle.write(value.encode())
except AttributeError:
handle.write(value)
os.fsync(handle.fileno())
handle.close()
fname = os.path.join(path, item)
os.rename(handle.name, fname)
LOG.debug('Generated %s', fname)


def get_suite_title(reg):
"""Return the the suite title without a full file parse
Expand Down

0 comments on commit 80bb050

Please sign in to comment.