1
|
|
function printsequence(io::IO, source::Enumerable)
|
2
|
23
|
T = eltype(source)
|
3
|
20
|
rows = Base.IteratorSize(source) == Base.HasLength() ? length(source) : "?"
|
4
|
|
|
5
|
20
|
print(io, "$(rows)-element query result")
|
6
|
|
|
7
|
|
max_element_to_show = 10
|
8
|
|
|
9
|
|
i = 1
|
10
|
20
|
foo = iterate(source)
|
11
|
23
|
while foo!==nothing
|
12
|
|
v, s = foo
|
13
|
20
|
println(io)
|
14
|
23
|
if i==max_element_to_show+1
|
15
|
0
|
print(io, "... with ")
|
16
|
|
if Base.IteratorSize(source)!=Base.HasLength()
|
17
|
|
print(io, " more elements")
|
18
|
|
else
|
19
|
0
|
extra_rows = length(source) - max_element_to_show
|
20
|
0
|
print(io, "$extra_rows more $(extra_rows==1 ? "element" : "elements")")
|
21
|
|
end
|
22
|
0
|
break
|
23
|
|
else
|
24
|
20
|
print(io, " ")
|
25
|
20
|
show(IOContext(io, :compact => true), v)
|
26
|
|
end
|
27
|
20
|
i += 1
|
28
|
|
|
29
|
23
|
foo = iterate(source, s)
|
30
|
|
end
|
31
|
|
end
|
32
|
|
|
33
|
|
function Base.show(io::IO, source::Enumerable)
|
34
|
23
|
if eltype(source) <: NamedTuple
|
35
|
23
|
TableShowUtils.printtable(io, source, "query result")
|
36
|
|
else
|
37
|
23
|
printsequence(io, source)
|
38
|
|
end
|
39
|
|
end
|
40
|
|
|
41
|
|
function Base.show(io::IO, ::MIME"text/html", source::Enumerable)
|
42
|
23
|
if eltype(source) <: NamedTuple
|
43
|
23
|
TableShowUtils.printHTMLtable(io, source)
|
44
|
|
else
|
45
|
|
error("Cannot write this Enumerable as text/html.")
|
46
|
|
end
|
47
|
|
end
|
48
|
|
|
49
|
|
function Base.Multimedia.showable(::MIME"text/html", source::Enumerable)
|
50
|
0
|
return eltype(source) <: NamedTuple
|
51
|
|
end
|
52
|
|
|
53
|
|
function Base.show(io::IO, ::MIME"application/vnd.dataresource+json", source::Enumerable)
|
54
|
23
|
if eltype(source) <: NamedTuple
|
55
|
23
|
TableShowUtils.printdataresource(io, source)
|
56
|
|
else
|
57
|
|
error("Cannot write this Enumerable as 'application/vnd.dataresource+json'.")
|
58
|
|
end
|
59
|
|
end
|
60
|
|
|
61
|
|
function Base.Multimedia.showable(::MIME"application/vnd.dataresource+json", source::Enumerable)
|
62
|
0
|
return eltype(source) <: NamedTuple
|
63
|
|
end
|