示例#1
0
文件: main.py 项目: kedlaya/lmfdb
def higher_genus_w_automorphisms_search(info, query):
    if info.get('signature'):
        #allow for ; in signature
        info['signature'] = info['signature'].replace(';',',')
        parse_bracketed_posints(info,query,'signature',split=False,name='Signature',keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(sort_sign(ast.literal_eval(query['signature']))).replace(' ','')
    parse_gap_id(info,query,'group',name='Group',qfield='group')
    parse_ints(info,query,'genus',name='Genus')
    parse_ints(info,query,'dim',name='Dimension of the family')
    if 'inc_hyper' in info:
        if info['inc_hyper'] == 'exclude':
            query['hyperelliptic'] = False
        elif info['inc_hyper'] == 'only':
            query['hyperelliptic'] = True
    if 'inc_cyc_trig' in info:
        if info['inc_cyc_trig'] == 'exclude':
            query['cyclic_trigonal'] = False
        elif info['inc_cyc_trig'] == 'only':
            query['cyclic_trigonal'] = True
    if 'inc_full' in info:
        if info['inc_full'] == 'exclude':
            query['full_auto'] = {'$exists': True}
        elif info['inc_full'] == 'only':
            query['full_auto'] = {'$exists': False}
    query['cc.1'] = 1
    if info.get('groupsize'):
        err, result = add_group_order_range(query, info['groupsize'])
        if err is not None:
            flash_error('Parse error on group order field. <font face="Courier New"><br />Given: ' + err + '<br />-------' + result + '</font>')

    info['group_display'] = sg_pretty
    info['sign_display'] = sign_display
示例#2
0
def higher_genus_w_automorphisms_search(info, query):
    if info.get('signature'):
        #allow for ; in signature
        info['signature'] = info['signature'].replace(';',',')
        parse_bracketed_posints(info,query,'signature',split=False,name='Signature',keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(sort_sign(ast.literal_eval(query['signature']))).replace(' ','')
    parse_gap_id(info,query,'group',name='Group',qfield='group')
    parse_ints(info,query,'genus',name='Genus')
    parse_ints(info,query,'dim',name='Dimension of the family')
    if 'inc_hyper' in info:
        if info['inc_hyper'] == 'exclude':
            query['hyperelliptic'] = False
        elif info['inc_hyper'] == 'only':
            query['hyperelliptic'] = True
    if 'inc_cyc_trig' in info:
        if info['inc_cyc_trig'] == 'exclude':
            query['cyclic_trigonal'] = False
        elif info['inc_cyc_trig'] == 'only':
            query['cyclic_trigonal'] = True
    if 'inc_full' in info:
        if info['inc_full'] == 'exclude':
            query['full_auto'] = {'$exists': True}
        elif info['inc_full'] == 'only':
            query['full_auto'] = {'$exists': False}
    query['cc.1'] = 1
    if info.get('groupsize'):
        err, result = add_group_order_range(query, info['groupsize'])
        if err is not None:
            flash_error('Parse error on group order field. <font face="Courier New"><br />Given: ' + err + '<br />-------' + result + '</font>')

    info['group_display'] = sg_pretty
    info['sign_display'] = sign_display
示例#3
0
文件: main.py 项目: lexmart/lmfdb
def higher_genus_w_automorphisms_search(**args):
    info = to_dict(args)
    bread = get_bread([("Search results", '')])
    C = base.getDBConnection()
    query = {}
    if 'jump_to' in info:
        labs = info['jump_to']
        if label_is_one_passport(labs):
            return render_passport({'passport_label': labs})
        elif label_is_one_family(labs):
            return render_family({'label': labs})
        else:
            flash_error(
                "The label %s is not a legitimate label for this data.", labs)
            return redirect(url_for(".index"))

    #allow for ; in signature
    if info.get('signature'):
        info['signature'] = info['signature'].replace(';', ',')

    try:
        parse_gap_id(info, query, 'group', 'Group')
        parse_ints(info, query, 'genus', name='Genus')
        parse_bracketed_posints(info,
                                query,
                                'signature',
                                split=False,
                                name='Signature',
                                keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(
                sort_sign(ast.literal_eval(query['signature']))).replace(
                    ' ', '')
        parse_ints(info, query, 'dim', name='Dimension of the family')
        if 'inc_hyper' in info:
            if info['inc_hyper'] == 'exclude':
                query['hyperelliptic'] = False
            elif info['inc_hyper'] == 'only':
                query['hyperelliptic'] = True
        if 'inc_cyc_trig' in info:
            if info['inc_cyc_trig'] == 'exclude':
                query['cyclic_trigonal'] = False
            elif info['inc_cyc_trig'] == 'only':
                query['cyclic_trigonal'] = True
        if 'inc_full' in info:
            if info['inc_full'] == 'exclude':
                query['full_auto'] = {'$exists': True}
            elif info['inc_full'] == 'only':
                query['full_auto'] = {'$exists': False}

        query['cc.1'] = 1

    except ValueError:
        return search_input_error(info, bread)
    count = parse_count(info)
    start = parse_start(info)

    if 'groupsize' in info and info['groupsize'] != '':
        err, result = add_group_order_range(query, info['groupsize'], C)
        if err != None:
            flash_error(
                'Parse error on group order field. <font face="Courier New"><br />Given: '
                + err + '<br />-------' + result + '</font>')
    """
    res = C.curve_automorphisms.passports.find(query).sort([(
         'genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0],pymongo.ASCENDING)])
    nres = res.count()
    res = res.skip(start).limit(count)

    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0


    L = [ ]
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])    
        L.append(field)

    code = ""
    download_code = 'download' in info
    first_download_entry = True
    for field in L:
        field['signature'] = ast.literal_eval(field['signature'])    
        if download_code:
            if first_download_entry:
                code += '\n'.join(hgcwa_code(label=field['passport_label'], download_type='magma').split('\n')[1:])
            else:
                code += hgcwa_code(label=field['passport_label'], download_type='magma').split('result_record:=[];')[1]
            first_download_entry = False

    
    

    if 'download' in info:
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response
    """

    res = C.curve_automorphisms.passports.find(query).sort([
        ('genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0], pymongo.ASCENDING)
    ])

    nres = res.count()
    res = res.skip(start).limit(count)

    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0

    L = []
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])
        L.append(field)

    if 'download_magma' in info:
        code = "// MAGMA CODE FOR SEACH RESULTS\n\n"
        first_download_entry = True
        for field in L:
            #print field
            if first_download_entry:
                code += ('\n'.join(
                    hgcwa_code(label=field['passport_label'],
                               download_type='magma').split('\n')[1:]
                )).replace(
                    ", and generate data which is the same for all entries",
                    "")
            else:
                code += hgcwa_code(
                    label=field['passport_label'],
                    download_type='magma').split('result_record:=[];')[1]
            first_download_entry = False
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response
    elif 'download_gap' in info:
        code = "# GAP CODE FOR SEARCH RESULTS\n\n"
        first_download_entry = True
        for field in L:
            print field['group']
            if first_download_entry:
                code += ('\n'.join(
                    hgcwa_code(label=field['passport_label'],
                               download_type='gap').split('\n')
                    [1:])).replace(
                        "# Generate data which is the same for all entries.\n",
                        "")
            else:
                code += hgcwa_code(
                    label=field['passport_label'],
                    download_type='gap').split('result_record:=[];')[1]
            first_download_entry = False
        response = make_response(code)
        response.headers['Content-type'] = 'text/plain'
        return response

    info['fields'] = L
    info['number'] = nres
    info['group_display'] = sg_pretty
    info['show_downloads'] = len(L) > 0

    info['sign_display'] = sign_display
    info['start'] = start
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (
                start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres

    return render_template(
        "hgcwa-search.html",
        info=info,
        title=
        "Families of Higher Genus Curves with Automorphisms Search Result",
        credit=credit,
        bread=bread)
示例#4
0
def higher_genus_w_automorphisms_search(**args):
    info = to_dict(args)
    bread = get_bread([("Search results", '')])
    C = base.getDBConnection()
    query = {}
    if 'jump_to' in info:
        labs = info['jump_to']
        if label_is_one_passport(labs):
            return render_passport({'passport_label': labs})
        elif label_is_one_family(labs):
            return render_family({'label': labs})
        else:
            flash_error(
                "The label %s is not a legitimate label for this data.", labs)
            return redirect(url_for(".index"))

    #allow for ; in signature
    if info.get('signature'):
        info['signature'] = info['signature'].replace(';', ',')

    try:
        parse_gap_id(info, query, 'group', 'Group')
        parse_ints(info, query, 'genus', name='Genus')
        parse_bracketed_posints(info,
                                query,
                                'signature',
                                split=False,
                                name='Signature',
                                keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(
                sort_sign(ast.literal_eval(query['signature']))).replace(
                    ' ', '')
        parse_ints(info, query, 'dim', name='Dimension of the family')
        if 'inc_hyper' in info:
            if info['inc_hyper'] == 'exclude':
                query['hyperelliptic'] = False
            elif info['inc_hyper'] == 'only':
                query['hyperelliptic'] = True
        if 'inc_cyc_trig' in info:
            if info['inc_cyc_trig'] == 'exclude':
                query['cyclic_trigonal'] = False
            elif info['inc_cyc_trig'] == 'only':
                query['cyclic_trigonal'] = True
        if 'inc_full' in info:
            if info['inc_full'] == 'exclude':
                query['full_auto'] = {'$exists': True}
            elif info['inc_full'] == 'only':
                query['full_auto'] = {'$exists': False}

        query['cc.1'] = 1

    except ValueError:
        return search_input_error(info, bread)
    count = parse_count(info)
    start = parse_start(info)

    res = C.curve_automorphisms.passports.find(query).sort([
        ('genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0], pymongo.ASCENDING)
    ])
    nres = res.count()
    res = res.skip(start).limit(count)

    if (start >= nres):
        start -= (1 + (start - nres) / count) * count
    if (start < 0):
        start = 0

    L = []
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])
        L.append(field)

    info['fields'] = L
    info['number'] = nres
    info['group_display'] = sg_pretty

    info['sign_display'] = sign_display
    info['start'] = start
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (
                start + 1, min(nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres

    return render_template(
        "hgcwa-search.html",
        info=info,
        title=
        "Families of Higher Genus Curves with Automorphisms Search Result",
        bread=bread)
示例#5
0
def higher_genus_w_automorphisms_search(**args):
    info = to_dict(args)
    bread = get_bread([("Search Results",'')])
    C = base.getDBConnection()
    query = {}
    if 'jump_to' in info:
        labs = info['jump_to']
        if label_is_one_passport(labs):
            return render_passport({'passport_label': labs})
        elif label_is_one_family(labs):
            return render_family({'label': labs})
        else:
            flash_error ("The label %s is not a legitimate label for this data.",labs)
            return redirect(url_for(".index"))

    #allow for ; in signature
    if info.get('signature'):
        info['signature'] = info['signature'].replace(';',',')

    try:
        parse_gap_id(info,query,'group','Group')
        parse_ints(info,query,'genus',name='Genus')
        parse_bracketed_posints(info,query,'signature',split=False,name='Signature',keepbrackets=True)
        if query.get('signature'):
            query['signature'] = info['signature'] = str(sort_sign(ast.literal_eval(query['signature']))).replace(' ','')
        parse_ints(info,query,'dim',name='Dimension of the family')
        if 'inc_hyper' in info:
            if info['inc_hyper'] == 'exclude':
                query['hyperelliptic'] = False
            elif info['inc_hyper'] == 'only':
                query['hyperelliptic'] = True
        if 'inc_cyc_trig' in info:
            if info['inc_cyc_trig'] == 'exclude':
                query['cyclic_trigonal'] = False
            elif info['inc_cyc_trig'] == 'only':
                query['cyclic_trigonal'] = True
        if 'inc_full' in info:
            if info['inc_full'] == 'exclude':
                query['full_auto'] = {'$exists': True}
            elif info['inc_full'] == 'only':
                query['full_auto'] = {'$exists': False}

        query['cc.1'] = 1

    except ValueError:
        return search_input_error(info, bread)
    count = parse_count(info)
    start = parse_start(info)

    if 'groupsize' in info and info['groupsize'] != '':
        err, result = add_group_order_range(query, info['groupsize'], C)
        if err != None:
            flash_error('Parse error on group order field. <font face="Courier New"><br />Given: ' + err + '<br />-------' + result + '</font>')
    res = C.curve_automorphisms.passports.find(query).sort([(
         'genus', pymongo.ASCENDING), ('dim', pymongo.ASCENDING),
        ('cc'[0],pymongo.ASCENDING)])

    nres = res.count()
    res = res.skip(start).limit(count)

    if(start >= nres):
        start -= (1 + (start - nres) / count) * count
    if(start < 0):
        start = 0

    L = [ ]
    for field in res:
        field['signature'] = ast.literal_eval(field['signature'])
        L.append(field)

    if 'download_magma' in info:
        return hgcwa_code_download_search(L,'magma')  #OR RES??????

    elif 'download_gap' in info:
        return hgcwa_code_download_search(L,'gap')  #OR L??????

    info['fields'] = L    
    info['number'] = nres
    info['group_display'] = sg_pretty
    info['show_downloads'] = len(L) > 0

    info['sign_display'] = sign_display
    info['start'] = start
    if nres == 1:
        info['report'] = 'unique match'
    else:
        if nres > count or start != 0:
            info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(
                               nres, start + count), nres)
        else:
            info['report'] = 'displaying all %s matches' % nres

    return render_template("hgcwa-search.html", info=info, title="Families of Higher Genus Curves with Automorphisms Search Result", credit=credit, bread=bread)