# Path: postproclib/pplexceptions.py
# class ScriptMissing(Exception):
#     pass


import os
from .pplexceptions import ScriptMissing
        os.chdir(self.savedPath )

class VmdReformat:

    def __init__(self, fdir, fname, scriptdir):

        self.fdir = fdir
        self.fname = fname
        self.scriptdir = scriptdir
        self.Reformatted = False

        headerfile = self.fdir + 'simulation_header'

        # Extract np from header
        fobj = open(headerfile,'r')
        self.np = 0
        while self.np==0:
            line = fobj.readline().split(';')
            if (line[1].strip() == 'globalnp'):
                self.np   = int(line[2].strip())

        self.domain = [0, 0, 0]
        for ixyz in range(3):
            while self.domain[ixyz]==0:
                line = fobj.readline().split(';')
                if (line[1].strip() == 'globaldomain(' + str(ixyz+1) + ')'):
                    self.domain[ixyz]   = float(line[2].strip())

        if not os.path.isfile(self.scriptdir + 'vmd_reformat.f90'):
            print('Error -- vmd_reformat.f90 is missing from ' +  self.scriptdir)

# Path: postproclib/pplexceptions.py
# class ScriptMissing(Exception):
#     pass


# Path: postproclib/vmd_reformat.py
import os
from .pplexceptions import ScriptMissing

        os.chdir(self.savedPath )

class VmdReformat:

    def __init__(self, fdir, fname, scriptdir):

        self.fdir = fdir
        self.fname = fname
        self.scriptdir = scriptdir
        self.Reformatted = False

        headerfile = self.fdir + 'simulation_header'

        # Extract np from header
        fobj = open(headerfile,'r')
        self.np = 0
        while self.np==0:
            line = fobj.readline().split(';')
            if (line[1].strip() == 'globalnp'):
                self.np   = int(line[2].strip())

        self.domain = [0, 0, 0]
        for ixyz in range(3):
            while self.domain[ixyz]==0:
                line = fobj.readline().split(';')
                if (line[1].strip() == 'globaldomain(' + str(ixyz+1) + ')'):
                    self.domain[ixyz]   = float(line[2].strip())

        if not os.path.isfile(self.scriptdir + 'vmd_reformat.f90'):
            print('Error -- vmd_reformat.f90 is missing from ' +  self.scriptdir)

            raise ScriptMissing