Beispiel #1
0
    def testSaveEntry(self):
        """
        tests that save entry can run
        """
        from rmgpy.data.kinetics.common import saveEntry
        import os
        from rmgpy.data.base import Entry

        reactions = self.reactions

        fname = 'testfile.txt'
        fid = open('testfile.txt', 'w')

        wd = os.getcwd()
        wdir = wd + '/' + fname

        rxn = reactions[0]
        entry = Entry(index=1,
                      label=str(rxn),
                      item=rxn,
                      shortDesc='sdes',
                      longDesc='lsdes',
                      data='stuff',
                      rank=0)
        saveEntry(fid, entry)

        fid.close()

        os.remove(wdir)
Beispiel #2
0
    def saveTransitionStateGroups(self, path, entryName='entry'):
        """
        Save the current database to the file at location `path` on disk. The
        optional `entryName` parameter specifies the identifier used for each
        data entry.
        """
        entries = self.groups.getEntriesToSave()

        # Write the header
        f = codecs.open(path, 'w', 'utf-8')
        f.write('#!/usr/bin/env python\n')
        f.write('# encoding: utf-8\n\n')
        f.write('name = "{0}"\n'.format(self.groups.name))
        f.write('shortDesc = u"{0}"\n'.format(self.groups.shortDesc))
        f.write('longDesc = u"""\n')
        f.write(self.groups.longDesc)
        f.write('\n"""\n\n')

        # Save the entries
        for entry in entries:
            saveEntry(f, entry)

        # Write the tree
        if len(self.groups.top) > 0:
            f.write('tree(\n')
            f.write('"""\n')
            f.write(self.generateOldTree(self.groups.top, 1))
            f.write('"""\n')
            f.write(')\n\n')

        f.close()
 def testSaveEntry(self):
     """
     tests that save entry can run
     """
     reactions=self.reactions
     
     fname  = 'testfile.txt'
     fid = open('testfile.txt','w')
     
     wd = os.getcwd()
     wdir = wd+'/'+fname
     
     rxn = reactions[0]
     entry = Entry(index=1,label=str(rxn),item=rxn,shortDesc='sdes',longDesc='lsdes',data='stuff',rank=0)
     saveEntry(fid,entry)
     
     fid.close()
     
     os.remove(wdir)
Beispiel #4
0
 def saveEntry(self, f, entry):
     """
     Write the given `entry` in the database to the file object `f`.
     """
     return saveEntry(f, entry)