# 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
            "Number of trr and tpr files not equal: "
            "{} != {}".format(len(trr_files), len(tpr_files))
        )
    out_files = list()

    for tpr_file, trr_file in zip(tpr_files, trr_files):
        out_file = trr_file.replace("trr", "gro")
        Trjconv(s=tpr_file, f=trr_file, o=out_file, dump=time, input="0")()
        out_files.append(out_file)
    return out_files


def get_n_solvent(folder, solvent="DCM"):
    """
    Find the number of solvent molecules of given type in topology file.

    Note, this function is being deprecated in favor of the more general
    :func:`get_solv_count_top`, which takes the strengths of this function
    while also allowing for specification of an exact top file.

    :param str folder: The folder in which to look for a file ending in '.top'.
    :param str solvent: Default: 'DCM'
    :return: The number of solvent molecules.
    :rtype: int
    """
    warnings.warn(
        "This function is deprecated. Please use " "get_solv_count_top",
        DeprecationWarning,
    )
    re_n_solv = re.compile(r"(?:^\s*{}\s+)(\d+)".format(solvent))

# 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

            "Number of trr and tpr files not equal: "
            "{} != {}".format(len(trr_files), len(tpr_files))
        )
    out_files = list()

    for tpr_file, trr_file in zip(tpr_files, trr_files):
        out_file = trr_file.replace("trr", "gro")
        Trjconv(s=tpr_file, f=trr_file, o=out_file, dump=time, input="0")()
        out_files.append(out_file)
    return out_files


def get_n_solvent(folder, solvent="DCM"):
    """
    Find the number of solvent molecules of given type in topology file.

    Note, this function is being deprecated in favor of the more general
    :func:`get_solv_count_top`, which takes the strengths of this function
    while also allowing for specification of an exact top file.

    :param str folder: The folder in which to look for a file ending in '.top'.
    :param str solvent: Default: 'DCM'
    :return: The number of solvent molecules.
    :rtype: int
    """
    warnings.warn(
        "This function is deprecated. Please use " "get_solv_count_top",
        DeprecationWarning,
    )
    re_n_solv = re.compile(r"(?:^\s*{}\s+)(\d+)".format(solvent))

    with cd(folder):