# Path: paratemp/tools.py
# class _BlankStream(object):
#     """
#     A class for use when not actually wanting to write to a file.
#     """
# 
#     def write(self, string):
#         pass
# 
#     def fileno(self):
#         return 0  # Not sure if this works. Maybe None would be better
# 
#     def flush(self):
#         pass
# 
# Path: paratemp/exceptions.py
# class InputError(Exception):
#     """Exception raised for errors in the input.
# 
#     Attributes:
#         expr -- input expression in which the error occurred
#         msg  -- explanation of the error
#     """
# 
#     def __init__(self, expr, msg):
#         self.expr = expr
#         self.msg = msg
# 
#     def __str__(self):
#         output = 'Incorrect input "{}". {}'.format(self.expr, self.msg)
#         return repr(output)
# 
# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)
# 
# def copy_no_overwrite(src, dst, silent=False):
#     exists = False
#     if os.path.isdir(src):
#         raise OSError(errno.EISDIR, "Is a directory: {}".format(src))
#     elif os.path.isdir(dst):
#         if os.path.isfile(os.path.join(dst, os.path.basename(src))):
#             exists = True
#     elif os.path.isfile(dst):
#         exists = True
#     if exists:
#         if silent:
#             return dst
#         else:
#             raise OSError(errno.EEXIST, "File already exists", dst)
#     else:
#         return shutil.copy(src, dst)


import errno
import glob
import os
import pathlib
import py
import re
import subprocess
import warnings
from typing import Callable, Iterable, Match
from paratemp.tools import _BlankStream
from paratemp.exceptions import InputError
from paratemp.tools import cd, copy_no_overwrite
    from glob import glob
    from gromacs.tools import Trjconv
        for line in in_top:
            if line.strip().startswith(";"):
                pass
            elif not mol_section:
                if re.search(r"\[\s*molecules\s*\]", line, flags=re.IGNORECASE):
                    mol_section = True
            else:
                solv_match = re_n_solv.search(line)
                if solv_match:
                    return int(solv_match.group(1))
        # Not the right error, but fine for now
        raise RuntimeError(
            "Did not find a line with the solvent count in " "{}".format(n_top)
        )


def _get_n_top(n_top, folder):
    """
    Get path and name of topology file

    :param str n_top: None or path and file name of topology file.
    :param str folder: None or folder containing one topology file.
    :return: path to the topology file
    :rtype: str
    :raises ValueError: This is raised if more than one topology is found in
        the given folder.
    """
    if n_top is None:
        if folder is None:
            raise InputError("None", "Either folder or n_top must be " "specified")

# Path: paratemp/tools.py
# class _BlankStream(object):
#     """
#     A class for use when not actually wanting to write to a file.
#     """
# 
#     def write(self, string):
#         pass
# 
#     def fileno(self):
#         return 0  # Not sure if this works. Maybe None would be better
# 
#     def flush(self):
#         pass
# 
# Path: paratemp/exceptions.py
# class InputError(Exception):
#     """Exception raised for errors in the input.
# 
#     Attributes:
#         expr -- input expression in which the error occurred
#         msg  -- explanation of the error
#     """
# 
#     def __init__(self, expr, msg):
#         self.expr = expr
#         self.msg = msg
# 
#     def __str__(self):
#         output = 'Incorrect input "{}". {}'.format(self.expr, self.msg)
#         return repr(output)
# 
# Path: paratemp/tools.py
# @contextmanager
# def cd(new_dir):
#     prev_dir = os.getcwd()
#     os.chdir(os.path.expanduser(new_dir))
#     try:
#         yield
#     finally:
#         os.chdir(prev_dir)
# 
# def copy_no_overwrite(src, dst, silent=False):
#     exists = False
#     if os.path.isdir(src):
#         raise OSError(errno.EISDIR, "Is a directory: {}".format(src))
#     elif os.path.isdir(dst):
#         if os.path.isfile(os.path.join(dst, os.path.basename(src))):
#             exists = True
#     elif os.path.isfile(dst):
#         exists = True
#     if exists:
#         if silent:
#             return dst
#         else:
#             raise OSError(errno.EEXIST, "File already exists", dst)
#     else:
#         return shutil.copy(src, dst)


# Path: paratemp/sim_setup/sim_setup.py
import errno
import glob
import os
import pathlib
import py
import re
import subprocess
import warnings
from typing import Callable, Iterable, Match
from paratemp.tools import _BlankStream
from paratemp.exceptions import InputError
from paratemp.tools import cd, copy_no_overwrite
    from glob import glob
    from gromacs.tools import Trjconv

        for line in in_top:
            if line.strip().startswith(";"):
                pass
            elif not mol_section:
                if re.search(r"\[\s*molecules\s*\]", line, flags=re.IGNORECASE):
                    mol_section = True
            else:
                solv_match = re_n_solv.search(line)
                if solv_match:
                    return int(solv_match.group(1))
        # Not the right error, but fine for now
        raise RuntimeError(
            "Did not find a line with the solvent count in " "{}".format(n_top)
        )


def _get_n_top(n_top, folder):
    """
    Get path and name of topology file

    :param str n_top: None or path and file name of topology file.
    :param str folder: None or folder containing one topology file.
    :return: path to the topology file
    :rtype: str
    :raises ValueError: This is raised if more than one topology is found in
        the given folder.
    """
    if n_top is None:
        if folder is None:
            raise InputError("None", "Either folder or n_top must be " "specified")

        with cd(folder):