forked from ciaran-schembri/Shimura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddattribute.m
38 lines (32 loc) · 1.08 KB
/
addattribute.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
intrinsic ShimAddAttributes(filename::MonStgElt, attributes::SeqEnum) -> Any
{make a new file in ShimDB-v2 with the attributes of the form [<Shim, data>], with all being strings
Note that it will write from ShimDB to ShimDB-v2 so keep this in the right place}
file:=Sprintf("ShimDB-v1/%o",filename);
new_file:=Sprintf("ShimDB-v2/%o",filename);
r:=Open(file,"r");
while true do
line :=Gets(r);
if IsEof(line) then
break;
end if;
if "Shim" in line and "," notin line and "s`" notin line then
Write(new_file,Sprintf("%o,", line));
for i in [1..#attributes] do
attr:=attributes[i];
if i ne #attributes and #attributes gt 1 then
Write(new_file,Sprintf(" %o,",attr[1]));
else
Write(new_file,Sprintf(" %o",attr[1]));
end if;
end for;
elif line eq "return s;" then
for attr in attributes do
Write(new_file,Sprintf("s`%o := %o;\n",attr[1],attr[2]));
end for;
Write(new_file,line);
else
Write(new_file,line);
end if;
end while;
return "";
end intrinsic;