# Path: hurray/swmr/sync.py
# def reader(f):
#     """
#     Decorates methods reading a shared resource
#     """
# 
#     @wraps(f)
#     def func_wrapper(self, *args, **kwargs):
#         """
#         Wraps reading functions.
#         """
#         with handle_exit(append=True):
#             try:
#                 SWMR_SYNC.start_read(self.file)
#                 result = f(self, *args, **kwargs)  # critical section
#                 return result
#             finally:
#                 SWMR_SYNC.end_read(self.file)
# 
#     return func_wrapper
# 
# def writer(f):
#     """
#     Decorates methods writing to a shared resource
#     """
# 
#     @wraps(f)
#     def func_wrapper(self, *args, **kwargs):
#         """
#         Wraps writing functions.
#         """
#         with handle_exit(append=True):
#             try:
#                 SWMR_SYNC.start_write(self.file)
#                 return_val = f(self, *args, **kwargs)
#                 return return_val
#             finally:
#                 SWMR_SYNC.end_write(self.file)
# 
#     return func_wrapper
# 
# Path: hurray/server/log.py
# def _stderr_supports_color():
# def _unicode(value):
# def _safe_unicode(s):
#     def __init__(self, color=True, fmt=DEFAULT_FORMAT,
#                  datefmt=DEFAULT_DATE_FORMAT, colors=DEFAULT_COLORS):
#     def format(self, record):
# def enable_pretty_logging(options=None, logger=None):
# def define_logging_options(options=None):
# _TO_UNICODE_TYPES = (unicode_type, type(None))
#     DEFAULT_FORMAT = '%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]%(end_color)s %(message)s'
#     DEFAULT_DATE_FORMAT = '%y%m%d %H:%M:%S'
#     DEFAULT_COLORS = {
#         logging.DEBUG: 4,  # Blue
#         logging.INFO: 2,  # Green
#         logging.WARNING: 3,  # Yellow
#         logging.ERROR: 1,  # Red
#     }
# class LogFormatter(logging.Formatter):


import os
import h5py
from .sync import reader, writer
from hurray.server.log import app_log
        Wrapper around ``h5py.Group.require_group()``
        """
        with h5py.File(self.file, 'r+') as f:
            group = f[self.path]
            created_group = group.require_group(name)
            path = created_group.name

        return Group(self.file, path=path)

    @writer
    def create_dataset(self, **kwargs):
        """
        Wrapper around ``h5py.Group.create_dataset()``
        """
        overwrite = kwargs.get('overwrite', False)
        name = kwargs['name']
        # remove additional arguments because they are not supported by h5py
        try:
            del kwargs['overwrite']
        except Exception:
            pass
        with h5py.File(self.file, 'r+') as f:
            group = f[self.path]
            if overwrite and name in group:
                del group[name]
            dst = group.create_dataset(**kwargs)
            path = dst.name

        return Dataset(self.file, path=path)


# Path: hurray/swmr/sync.py
# def reader(f):
#     """
#     Decorates methods reading a shared resource
#     """
# 
#     @wraps(f)
#     def func_wrapper(self, *args, **kwargs):
#         """
#         Wraps reading functions.
#         """
#         with handle_exit(append=True):
#             try:
#                 SWMR_SYNC.start_read(self.file)
#                 result = f(self, *args, **kwargs)  # critical section
#                 return result
#             finally:
#                 SWMR_SYNC.end_read(self.file)
# 
#     return func_wrapper
# 
# def writer(f):
#     """
#     Decorates methods writing to a shared resource
#     """
# 
#     @wraps(f)
#     def func_wrapper(self, *args, **kwargs):
#         """
#         Wraps writing functions.
#         """
#         with handle_exit(append=True):
#             try:
#                 SWMR_SYNC.start_write(self.file)
#                 return_val = f(self, *args, **kwargs)
#                 return return_val
#             finally:
#                 SWMR_SYNC.end_write(self.file)
# 
#     return func_wrapper
# 
# Path: hurray/server/log.py
# def _stderr_supports_color():
# def _unicode(value):
# def _safe_unicode(s):
#     def __init__(self, color=True, fmt=DEFAULT_FORMAT,
#                  datefmt=DEFAULT_DATE_FORMAT, colors=DEFAULT_COLORS):
#     def format(self, record):
# def enable_pretty_logging(options=None, logger=None):
# def define_logging_options(options=None):
# _TO_UNICODE_TYPES = (unicode_type, type(None))
#     DEFAULT_FORMAT = '%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]%(end_color)s %(message)s'
#     DEFAULT_DATE_FORMAT = '%y%m%d %H:%M:%S'
#     DEFAULT_COLORS = {
#         logging.DEBUG: 4,  # Blue
#         logging.INFO: 2,  # Green
#         logging.WARNING: 3,  # Yellow
#         logging.ERROR: 1,  # Red
#     }
# class LogFormatter(logging.Formatter):


# Path: hurray/swmr/api.py
import os
import h5py
from .sync import reader, writer
from hurray.server.log import app_log

        Wrapper around ``h5py.Group.require_group()``
        """
        with h5py.File(self.file, 'r+') as f:
            group = f[self.path]
            created_group = group.require_group(name)
            path = created_group.name

        return Group(self.file, path=path)

    @writer
    def create_dataset(self, **kwargs):
        """
        Wrapper around ``h5py.Group.create_dataset()``
        """
        overwrite = kwargs.get('overwrite', False)
        name = kwargs['name']
        # remove additional arguments because they are not supported by h5py
        try:
            del kwargs['overwrite']
        except Exception:
            pass
        with h5py.File(self.file, 'r+') as f:
            group = f[self.path]
            if overwrite and name in group:
                del group[name]
            dst = group.create_dataset(**kwargs)
            path = dst.name

        return Dataset(self.file, path=path)


    @writer