def new_from_files(self, basepath, basename, repo, \
                    bohrs=False, \
                    software=_E_SW.ORCA, \
                    repo_clobber=False, **kwargs):
        """ Initialize with data from files.

        """

        # Imports
        import os
        from os import path as osp
        from ..xyz import OpanXYZ as OX
        from ..grad import OrcaEngrad as OE
        from ..hess import OrcaHess as OH
        from .repo import OpanAnharmRepo as OR
        from ..const import EnumDispDirection as E_DDir, EnumFileType as E_FT
        from ..const import EnumSoftware as E_SW
        from ..const import DEF
        from ..error import AnharmError as ANHErr

##        # Store working directory for restore?
##        prev_dir = os.getcwd()

        # Complain if anything is already bound
        if not self.w_xyz == None:
            raise ANHErr(ANHErr.STATUS,
                    "XYZ object is already bound",
                    "")
        ## end if
        if not self.w_grad == None:
            raise ANHErr(ANHErr.STATUS,
                    "GRAD object is already bound",
                    "")
        ## end if
        if not self.w_hess == None:
            raise ANHErr(ANHErr.STATUS,
                    "HESS object is already bound",
                    "")
        ## end if
        if not self.repo == None:
            raise ANHErr(ANHErr.STATUS,
                    "Repository object is already bound",
                    "")
        ## end if

        # RESUME: vpt2--factor for loading from different software pkgs

        # Load the three data files
        self.w_xyz = OX( osp.join(basepath, \
                basename + osp.extsep + xyz_ext) )
        self.w_grad = OE( osp.join(basepath, \
                basename + osp.extsep + engrad_ext), \
                0, E_DDir.NO_DISP, 0.0 )
        self.w_hess = OH( osp.join(basepath, \
                basename + osp.extsep + hess_ext), \
                0, E_DDir.NO_DISP, 0.0 )

        # Only accept new repos for now
        if not isinstance(repo, str):
            raise TypeError("Must create new repository when loading " +
                    "a new dataset.")
        ## end if

        # Repo is string, treat as filename and try to load
        # Check if it's a complete path
        # If it's a relative path, prepend the basepath
        if osp.split(repo[0]) > 0 and not osp.isabs(repo):
            repo = osp.join(basepath, repo)
        ## end if

        # Complain if it's a directory
        if osp.isdir(repo):
            raise IOError("Cannot bind repository -- specified " +
                    "location is a directory")
        ## end if

        # If file exists ...
        if osp.isfile(repo):
                # Depending on clobber, either delete existing or raise error
                if repo_clobber:
                    # Clobber old repo
                    os.remove(repo)
                else:
                    # Raise error
                    raise IOError("Target repository file exists and " +
                            "clobber is disabled.")
                ## end if
            ## end if

        # Should be good to create the repo
        self.repo = OR(repo)
def new_from_files ( self , basepath , basename , repo , bohrs = False , software = _E_SW . ORCA , repo_clobber = False , ** kwargs ) : import os from os import path as osp from . . xyz import OpanXYZ as OX from . . grad import OrcaEngrad as OE from . . hess import OrcaHess as OH from . repo import OpanAnharmRepo as OR from . . const import EnumDispDirection as E_DDir , EnumFileType as E_FT from . . const import EnumSoftware as E_SW from . . const import DEF from . . error import AnharmError as ANHErr if not self . w_xyz == None : raise ANHErr ( ANHErr . STATUS , "XYZ object is already bound" , "" ) if not self . w_grad == None : raise ANHErr ( ANHErr . STATUS , "GRAD object is already bound" , "" ) if not self . w_hess == None : raise ANHErr ( ANHErr . STATUS , "HESS object is already bound" , "" ) if not self . repo == None : raise ANHErr ( ANHErr . STATUS , "Repository object is already bound" , "" ) self . w_xyz = OX ( osp . join ( basepath , basename + osp . extsep + xyz_ext ) ) self . w_grad = OE ( osp . join ( basepath , basename + osp . extsep + engrad_ext ) , 0 , E_DDir . NO_DISP , 0.0 ) self . w_hess = OH ( osp . join ( basepath , basename + osp . extsep + hess_ext ) , 0 , E_DDir . NO_DISP , 0.0 ) if not isinstance ( repo , str ) : raise TypeError ( "Must create new repository when loading " + "a new dataset." ) if osp . split ( repo [ 0 ] ) > 0 and not osp . isabs ( repo ) : repo = osp . join ( basepath , repo ) if osp . isdir ( repo ) : raise IOError ( "Cannot bind repository -- specified " + "location is a directory" ) if osp . isfile ( repo ) : if repo_clobber : os . remove ( repo ) else : raise IOError ( "Target repository file exists and " + "clobber is disabled." ) self . repo = OR ( repo )
Initialize with data from files.