# Path: tensorboardX/record_writer.py
# class RecordWriter(object):
#     def __init__(self, path):
#         self._name_to_tf_name = {}
#         self._tf_names = set()
#         self.path = path
#         self._writer = None
#         self._writer = open_file(path)
# 
#     def write(self, data):
#         w = self._writer.write
#         header = struct.pack('Q', len(data))
#         w(header)
#         w(struct.pack('I', masked_crc32c(header)))
#         w(data)
#         w(struct.pack('I', masked_crc32c(data)))
# 
#     def flush(self):
#         self._writer.flush()
# 
#     def close(self):
#         self._writer.close()
# 
# def directory_check(path):
#     '''Initialize the directory for log files.'''
#     try:
#         prefix = path.split(':')[0]
#         factory = REGISTERED_FACTORIES[prefix]
#         return factory.directory_check(path)
#     except KeyError:
#         if not os.path.exists(path):
#             os.makedirs(path)


import os
import socket
import threading
import time
import multiprocessing
import six
from .proto import event_pb2
from .record_writer import RecordWriter, directory_check
        return_value = self.flush()
        with self._lock:
            self._py_recordio_writer.close()
        return return_value


class EventFileWriter(object):
    """Writes `Event` protocol buffers to an event file.

    The `EventFileWriter` class creates an event file in the specified directory,
    and asynchronously writes Event protocol buffers to the file. The Event file
    is encoded using the tfrecord format, which is similar to RecordIO.
    """

    def __init__(self, logdir, max_queue_size=10, flush_secs=120, filename_suffix=''):
        """Creates a `EventFileWriter` and an event file to write to.

        On construction the summary writer creates a new event file in `logdir`.
        This event file will contain `Event` protocol buffers, which are written to
        disk via the add_event method.
        The other arguments to the constructor control the asynchronous writes to
        the event file:

        Args:
          logdir: A string. Directory where event file will be written.
          max_queue_size: Integer. Size of the queue for pending events and summaries.
          flush_secs: Number. How often, in seconds, to flush the
            pending events and summaries to disk.
        """
        self._logdir = logdir

# Path: tensorboardX/record_writer.py
# class RecordWriter(object):
#     def __init__(self, path):
#         self._name_to_tf_name = {}
#         self._tf_names = set()
#         self.path = path
#         self._writer = None
#         self._writer = open_file(path)
# 
#     def write(self, data):
#         w = self._writer.write
#         header = struct.pack('Q', len(data))
#         w(header)
#         w(struct.pack('I', masked_crc32c(header)))
#         w(data)
#         w(struct.pack('I', masked_crc32c(data)))
# 
#     def flush(self):
#         self._writer.flush()
# 
#     def close(self):
#         self._writer.close()
# 
# def directory_check(path):
#     '''Initialize the directory for log files.'''
#     try:
#         prefix = path.split(':')[0]
#         factory = REGISTERED_FACTORIES[prefix]
#         return factory.directory_check(path)
#     except KeyError:
#         if not os.path.exists(path):
#             os.makedirs(path)


# Path: tensorboardX/event_file_writer.py
import os
import socket
import threading
import time
import multiprocessing
import six
from .proto import event_pb2
from .record_writer import RecordWriter, directory_check

        return_value = self.flush()
        with self._lock:
            self._py_recordio_writer.close()
        return return_value


class EventFileWriter(object):
    """Writes `Event` protocol buffers to an event file.

    The `EventFileWriter` class creates an event file in the specified directory,
    and asynchronously writes Event protocol buffers to the file. The Event file
    is encoded using the tfrecord format, which is similar to RecordIO.
    """

    def __init__(self, logdir, max_queue_size=10, flush_secs=120, filename_suffix=''):
        """Creates a `EventFileWriter` and an event file to write to.

        On construction the summary writer creates a new event file in `logdir`.
        This event file will contain `Event` protocol buffers, which are written to
        disk via the add_event method.
        The other arguments to the constructor control the asynchronous writes to
        the event file:

        Args:
          logdir: A string. Directory where event file will be written.
          max_queue_size: Integer. Size of the queue for pending events and summaries.
          flush_secs: Number. How often, in seconds, to flush the
            pending events and summaries to disk.
        """
        self._logdir = logdir

        directory_check(self._logdir)