def download_search(info, res): dltype = info['Submit'] delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'fields.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'fields.sage' if dltype == 'mathematica': com = '' com1 = '(*' com2 = '*)' delim = 'brace' filename = 'fields.ma' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'fields.m' s = com1 + "\n" s += com + ' Global number fields downloaded from the LMFDB downloaded %s\n'% mydate s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [polynomial, discriminant, t-number, class group]\n' s += com + ' Here the t-number is for the Galois group\n' s += com + ' If a class group was not computed, the entry is [-1]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'data := [' else: s += 'data = [' s += '\\\n' Qx = PolynomialRing(QQ,'x') str2pol = lambda s: Qx([QQ(str(c)) for c in s.split(',')]) for f in res: ## We should try to avoid using database specific information here ## Kept for now for speed # wnf = WebNumberField.from_data(f) # entry = ', '.join( # [str(wnf.poly()), str(wnf.disc()), str(wnf.galois_t()), str(wnf.class_group_invariants_raw())]) pol = str2pol(f['coeffs']) D = decodedisc(f['disc_abs_key'], f['disc_sign']) gal_t = f['galois']['t'] if 'class_group' in f: cl = string2list(f['class_group']) else: cl = [-1] entry = ', '.join([str(pol), str(D), str(gal_t), str(cl)]) s += '[' + entry + ']' + ',\\\n' s = s[:-3] if dltype == 'gp': s += '];\n' else: s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True)
def download_search(info, res): dltype = info.get('Submit') delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'fields.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'fields.sage' if dltype == 'mathematica': com = '' com1 = '(*' com2 = '*)' delim = 'brace' filename = 'fields.ma' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'fields.m' s = com1 + "\n" s += com + ' Global number fields downloaded from the LMFDB downloaded %s\n' % mydate s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [polynomial, discriminant, t-number, class group]\n' s += com + ' Here the t-number is for the Galois group\n' s += com + ' If a class group was not computed, the entry is [-1]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'data := [' else: s += 'data = [' s += '\\\n' Qx = PolynomialRing(QQ, 'x') str2pol = lambda s: Qx([QQ(str(c)) for c in s.split(',')]) for f in res: ## We should try to avoid using database specific information here ## Kept for now for speed # wnf = WebNumberField.from_data(f) # entry = ', '.join( # [str(wnf.poly()), str(wnf.disc()), str(wnf.galois_t()), str(wnf.class_group_invariants_raw())]) pol = str2pol(f['coeffs']) D = decodedisc(f['disc_abs_key'], f['disc_sign']) gal_t = f['galois']['t'] if 'class_group' in f: cl = string2list(f['class_group']) else: cl = [-1] entry = ', '.join([str(pol), str(D), str(gal_t), str(cl)]) s += '[' + entry + ']' + ',\\\n' s = s[:-3] if dltype == 'gp': s += '];\n' else: s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)