# Path: postproclib/postproc.py
# class PostProc:
# 
#     def __str__(self):
#         string =  ('\nAvailable outputs in ' + self.resultsdir + ' include:\n\n')
#         string += ('\t{0:^24s}\t{1:>10s}\n'.format('field', 'records'))
#         #string += ('\t{0:^24s}\t{1:^10s}\n'.format('-'*24, '-'*10))
#         for key,field in sorted(self.plotlist.items()):
#             line = '\t{0:<24s}=\t{1:>10f},\n'.format(key, field.maxrec)
#             string += line
#         return string 
# 
# Path: postproclib/pplexceptions.py
# class NoResultsInDir(Exception):
#     pass


import os
from .cfdfields import *
from .postproc import PostProc
from .pplexceptions import NoResultsInDir 

class CFD_PostProc(PostProc):

    """ 
        Post processing class for CFD runs
    """

    def __init__(self,resultsdir,**kwargs):
        self.resultsdir = resultsdir
        self.plotlist = {} 

        # Check directory exists before instantiating object and check 
        # which files associated with plots are in directory
        if (not os.path.isdir(self.resultsdir)):
            print(("Directory " +  self.resultsdir + " not found"))
            raise IOError

        try:
            fobj = open(self.resultsdir + 'report','r') 
        except IOError:

# Path: postproclib/postproc.py
# class PostProc:
# 
#     def __str__(self):
#         string =  ('\nAvailable outputs in ' + self.resultsdir + ' include:\n\n')
#         string += ('\t{0:^24s}\t{1:>10s}\n'.format('field', 'records'))
#         #string += ('\t{0:^24s}\t{1:^10s}\n'.format('-'*24, '-'*10))
#         for key,field in sorted(self.plotlist.items()):
#             line = '\t{0:<24s}=\t{1:>10f},\n'.format(key, field.maxrec)
#             string += line
#         return string 
# 
# Path: postproclib/pplexceptions.py
# class NoResultsInDir(Exception):
#     pass


# Path: postproclib/cfdpostproc.py
import os
from .cfdfields import *
from .postproc import PostProc
from .pplexceptions import NoResultsInDir 


class CFD_PostProc(PostProc):

    """ 
        Post processing class for CFD runs
    """

    def __init__(self,resultsdir,**kwargs):
        self.resultsdir = resultsdir
        self.plotlist = {} 

        # Check directory exists before instantiating object and check 
        # which files associated with plots are in directory
        if (not os.path.isdir(self.resultsdir)):
            print(("Directory " +  self.resultsdir + " not found"))
            raise IOError

        try:
            fobj = open(self.resultsdir + 'report','r') 
        except IOError:

            raise NoResultsInDir