コード例 #1
0
# Adds a field called field_len to objects in the_collection. It is based on the field called field
# It encodes the len of the string used

import sys
sys.path.append("../")
import base
base._init(37010, "")
from lmfdb.math_classes import ArtinRepresentation
the_collection = ArtinRepresentation.collection()
print "Got", the_collection

field = "Conductor"

from utils import len_val_fn

new_field = field + "_plus"


for x in the_collection.find():
    val = x[field]
    x[new_field] = len_val_fn(val)
    the_collection.save(x)
コード例 #2
0
from lmfdb.math_classes import ArtinRepresentation
from lmfdb.website import dbport

import base
base._init(dbport, "")

# x is raw
# a is of type ArtinRepresentation

# all the artin reps that come out of this are safe to appear on the website
# their L functions need to be fixed however

# if you want to do complex queries, and sort using pymongo's interface:
for x in ArtinRepresentation.collection().find():
    a = ArtinRepresentation(data=x)
    print a
    try:
        print a.Lfunction()
    except NotImplementedError or SyntaxError:
        print "Need CYC types and sign"

# if you want to list them all, using a wrapper to directly convert to ArtinRepresentation
for a in ArtinRepresentation.find():
    print a
    try:
        print a.Lfunction()
    except NotImplementedError or SyntaxError:
        print "Need CYC types"
# Adds a field called field_len to objects in the_collection. It is based on the field called field
# It encodes the len of the string used
# This is kind of a hack for mongodb, see lmfdb.utils.len_val_fn for explanation

import sys
LMFDB_FOLDER = "../../../"
sys.path.append(LMFDB_FOLDER)
import lmfdb.base as base
base._init(dbport, "")
from lmfdb.math_classes import ArtinRepresentation
the_collection = ArtinRepresentation.collection()
print "Got", the_collection

field = "Conductor"

from lmfdb.utils import len_val_fn

new_field = field + "_plus"

print "Updating"
for x in the_collection.find():
    val = x[field]
    x[new_field] = len_val_fn(val)
    the_collection.save(x)