# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyGriddata/file_management.py
# def copy(src, dst):
#     """ 
#     If file !exists then copy src into dest
# 
#     :param string src: source file name
#     :param string dst: destination file name
# 
#     """
#     #if os.path.exists(dst+'/'+src) == False:
#     sh.copy(src, dst)
# 
# def mkdir(path):
#     """ 
#     If path !exists then :meth:`os.makedirs`
# 
#     :param string path: path of directory to create
# 
#     """
#     if not os.path.exists(path):
#         os.makedirs(path)


import glob, os, stat, subprocess, shutil 
import scipy.io as sio
import numpy as np
import polyadcirc.pyADCIRC.fort15_management as f15
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyADCIRC.plotADCIRC as plot
import polyadcirc.pyADCIRC.prep_management as prep
import polyadcirc.pyADCIRC.output as output
import polyadcirc.run_framework.domain as dom
from distutils.spawn import find_executable
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyGriddata.file_management import copy, mkdir
                        os.remove(os.path.join(my_PE_dir, l_input))
                    os.symlink(os.path.join(PE_dir, l_input),
                               os.path.join(my_PE_dir, l_input))
                # copy fort.13 into the PE* directories
                if os.path.exists(os.path.join(my_PE_dir, 'fort.13')):
                    os.remove(os.path.join(my_PE_dir, 'fort.13'))
                shutil.copy(os.path.join(PE_dir, 'fort.13'),
                            os.path.join(my_PE_dir, 'fort.13'))

    def remove_random_field_directories(self):
        """
        Remove directories for parallel funs of random fields

        """
        # Check to see if some of the directories already exist
        rf_dirs = glob.glob(os.path.join(self.save_dir, 'RF_directory_*'))
        # remove all rf_dirs
        for rf_dir in rf_dirs:
            shutil.rmtree(rf_dir)

    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into 
        
        :param string path: folder_name
        :param int num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)

# Path: polyadcirc/pyADCIRC/basic.py
# class pickleable(object):
#     """
#     Class that makes objects easily pickleable via a dict
#     """
#     def __init__(self):
#         super(pickleable, self).__init__()
# 
#     def __getstate__(self):
#         """
#         :rtype: dict
#         :returns: ``self.__dict__.copy()``
#         """
#         odict = self.__dict__.copy()
#         return odict
# 
#     def __setstate__(self, dict):
#         """
#         :param dict: dict to update
# 
#         ``self.__dict__.update(dict)``
#         """
#         self.__dict__.update(dict)
# 
# Path: polyadcirc/pyGriddata/file_management.py
# def copy(src, dst):
#     """ 
#     If file !exists then copy src into dest
# 
#     :param string src: source file name
#     :param string dst: destination file name
# 
#     """
#     #if os.path.exists(dst+'/'+src) == False:
#     sh.copy(src, dst)
# 
# def mkdir(path):
#     """ 
#     If path !exists then :meth:`os.makedirs`
# 
#     :param string path: path of directory to create
# 
#     """
#     if not os.path.exists(path):
#         os.makedirs(path)


# Path: polyadcirc/run_framework/random_manningsn.py
import glob, os, stat, subprocess, shutil 
import scipy.io as sio
import numpy as np
import polyadcirc.pyADCIRC.fort15_management as f15
import polyadcirc.pyGriddata.table_to_mesh_map as tmm
import polyadcirc.pyADCIRC.plotADCIRC as plot
import polyadcirc.pyADCIRC.prep_management as prep
import polyadcirc.pyADCIRC.output as output
import polyadcirc.run_framework.domain as dom
from distutils.spawn import find_executable
from polyadcirc.pyADCIRC.basic import pickleable
from polyadcirc.pyGriddata.file_management import copy, mkdir

                        os.remove(os.path.join(my_PE_dir, l_input))
                    os.symlink(os.path.join(PE_dir, l_input),
                               os.path.join(my_PE_dir, l_input))
                # copy fort.13 into the PE* directories
                if os.path.exists(os.path.join(my_PE_dir, 'fort.13')):
                    os.remove(os.path.join(my_PE_dir, 'fort.13'))
                shutil.copy(os.path.join(PE_dir, 'fort.13'),
                            os.path.join(my_PE_dir, 'fort.13'))

    def remove_random_field_directories(self):
        """
        Remove directories for parallel funs of random fields

        """
        # Check to see if some of the directories already exist
        rf_dirs = glob.glob(os.path.join(self.save_dir, 'RF_directory_*'))
        # remove all rf_dirs
        for rf_dir in rf_dirs:
            shutil.rmtree(rf_dir)

    def setup_rfdir(self, path, num_procs):
        """
        Creates the directory path and copies required files from
        ``self.base_dir`` into 
        
        :param string path: folder_name
        :param int num_procs: number of processors per :program:`ADCIRC` run

        """
        mkdir(path)

        copy(os.path.join(self.save_dir, 'fort.13'), path)