示例#1
0
 def test_name_unique(self):
     u = self.get_user()
     n = "name_duplicate"
     r_1 = Reaction(name=n, user=u)
     r_1.save()
     r_2 = Reaction(name=n, user=u)
     self.assertRaises(Exception, r_2.save)
示例#2
0
def import_reactions(file_path=FILE_PATH, email=None):
    user = User.objects.get(email=email)
    with open(file_path, 'r') as fr:
        lines = r = fr.readlines()
        for line in lines:
            r_raw = line.replace('\n', '').split(SEPARATOR)
            r = Reaction(name=r_raw[0], user=user)
            r.save()
            r.load_smarts(r_raw[1])
            r.status_code = Reaction.status.ACTIVE
            r.save()
示例#3
0
def import_reactions(file_path=FILE_PATH, email="*****@*****.**"):
    user = User.objects.get(email=email)
    with open(file_path, "r") as fr:
        lines = r = fr.readlines()
        for line in lines:
            try:
                r_raw = line.replace("\n", "").split(SEPARATOR)
                r = Reaction(name=r_raw[0], user=user)
                r.save()
                r.load_smarts(r_raw[1])
                r.status_code = Reaction.status.ACTIVE
                r.save()
            except Exception as ex:
                print("error importing {}".format(r_raw[0]), ex)