Skip to content

Commit

Permalink
Use ctx mgr in tar/tgz writer docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandler May committed Aug 15, 2017
1 parent 8fcedbf commit 73d2318
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions concrete/util/file_io.py
Expand Up @@ -514,9 +514,8 @@ class CommunicationWriter(object):
Sample usage::
writer = CommunicationWriter('foo.concrete')
writer.write(existing_comm_object)
writer.close()
with CommunicationWriter('foo.concrete') as writer:
writer.write(existing_comm_object)
"""

def __init__(self, filename=None, gzip=False):
Expand Down Expand Up @@ -568,15 +567,14 @@ def __exit__(self, type, value, traceback):


class CommunicationWriterTar(object):
"""Class for writing one or more Communications to a .TAR archive
"""Class for writing one or more Communications to a .tar archive
Sample usage::
writer = CommunicationWriterTar('multiple_comms.tar')
writer.write(comm_object_one, 'comm_one.concrete')
writer.write(comm_object_two, 'comm_two.concrete')
writer.write(comm_object_three, 'comm_three.concrete')
writer.close()
with CommunicationWriterTar('multiple_comms.tar') as writer:
writer.write(comm_object_one, 'comm_one.concrete')
writer.write(comm_object_two, 'comm_two.concrete')
writer.write(comm_object_three, 'comm_three.concrete')
"""

def __init__(self, tar_filename=None, gzip=False):
Expand All @@ -585,7 +583,7 @@ def __init__(self, tar_filename=None, gzip=False):
tar_filename (str): if specified, open file at this path
during construction (a file can alternatively be opened
after construction using the open method)
gzip (bool): Flag indicating if .TAR file should be
gzip (bool): Flag indicating if .tar file should be
compressed with gzip
"""
self.gzip = gzip
Expand Down Expand Up @@ -645,15 +643,15 @@ def __exit__(self, type, value, traceback):


class CommunicationWriterTGZ(CommunicationWriterTar):
"""Class for writing one or more Communications to a .TAR.GZ archive
"""Class for writing one or more Communications to a .tar.gz (.tgz)
archive
Sample usage::
writer = CommunicationWriterTGZ('multiple_comms.tgz')
writer.write(comm_object_one, 'comm_one.concrete')
writer.write(comm_object_two, 'comm_two.concrete')
writer.write(comm_object_three, 'comm_three.concrete')
writer.close()
with CommunicationWriterTGZ('multiple_comms.tar.gz') as writer:
writer.write(comm_object_one, 'comm_one.concrete')
writer.write(comm_object_two, 'comm_two.concrete')
writer.write(comm_object_three, 'comm_three.concrete')
"""

def __init__(self, tar_filename=None):
Expand Down

0 comments on commit 73d2318

Please sign in to comment.