Skip to content

Commit 7e7c605

Browse files
committed
misc padding and sync ninlib.pbix
1 parent 72200d9 commit 7e7c605

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

Template-Import-ninlib.pbix

1.7 KB
Binary file not shown.

Template-Import-ninlib.pq

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
let
77
// evaluates a .pq text file that's editable outside of power bi, without pasting updates. just refresh.
88
EvalQueryFunc = (filePath as text, optional options as nullable record) as any => [
9-
encoding = options[Encoding]? ?? TextEncoding.Utf8,
9+
encoding = options[Encoding]? ?? TextEncoding.Utf8,
1010
environment = options[Environment]? ?? #shared,
11-
bytes = File.Contents(filePath),
12-
lines = Text.FromBinary( bytes, encoding ),
13-
return = Expression.Evaluate( lines, environment )
11+
bytes = File.Contents(filePath),
12+
lines = Text.FromBinary( bytes, encoding ),
13+
return = Expression.Evaluate( lines, environment )
1414
][return]
1515
in
1616
EvalQueryFunc
@@ -21,11 +21,9 @@ in
2121

2222
// with extra
2323
let
24-
// AsWebRequest = Web.Contents( "https://github.com", [RelativePath = "/ninmonkey/Ninmonkey.PowerQueryLib/blob/318cea1e52b2d1ab456a004dca79d235dec3f82e/build/2024-04.ninlib.pq" ]),
25-
2624
/* this is the entry point */
27-
EvalQuery = (filePath as text, optional options as nullable record) as any => [
28-
encoding = options[Encoding]? ?? TextEncoding.Utf8,
25+
EvalQuery = ( filePath as text, optional options as nullable record ) as any => [
26+
encoding = options[Encoding]? ?? TextEncoding.Utf8,
2927
environment = options[Environment]? ?? #shared,
3028
bytes = File.Contents(filePath),
3129
lines = Text.FromBinary( bytes, encoding ),
@@ -94,18 +92,14 @@ in
9492

9593
// lib_meta
9694
let
97-
// summarize the module
9895
Source = lib,
99-
top_items = Table.Buffer(
100-
Table.FromValue( lib ), [ BufferMode = BufferMode.Delayed ] ),
101-
102-
// Custom1 = top_items,
96+
top_items = Table.Buffer( Table.FromValue( lib ) ),
97+
Custom1 = top_items,
10398
procRow = ( source as any) as nullable record => [
104-
target = Value.Metadata( Value.Type( source ) ),
99+
target = Value.Metadata( source ),
105100
hasKeys = Record.FieldCount( target ) > 0,
106101
ret = if hasKeys then source else null
107102
][target],
108-
// #"Added Custom" = Table.AddColumn(Custom1, "Custom", (row) => procRow(row), Record.Type )
109-
#"Added Custom" = Table.AddColumn(top_items, "Custom", (row) => procRow( row[Value] ), type any)
103+
#"Added Custom" = Table.AddColumn(Custom1, "Custom", (row) => procRow( row[Value] ), type record)
110104
in
111105
#"Added Custom"

source/prototype/Error.Summarize.pq

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
let
2-
fullPath = ..., // # try func to ensure naming
3-
bytes = File.Contents( fullPath ),
2+
fullPath = ..., // # try func to ensure naming
3+
bytes = File.Contents( fullPath ),
44
raw_text = Text.FromBinary( bytes, TextEncoding.Utf8 ),
5+
56
final_evaluation = try Expression.Evaluate( raw_text , #shared ),
6-
z = error
77

88
FormatError = (source as any) as any =>
99
error "NYI: refactor the formatting logic",
1010

11-
error_ast = final_evaluation[Error],
12-
error_json = Text.FromBinary( Json.FromValue( final_evaluation[Error] ), TextEncoding.Utf8 ),
11+
error_ast = final_evaluation[Error],
12+
error_json = Text.FromBinary( Json.FromValue( final_evaluation[Error] ), TextEncoding.Utf8 ),
1313
summary_message = Text.Replace( error_ast[Message], "] ", "]#(cr,lf)"),
1414

15+
1516
// converts strings "[171-18-171-28]" to structured location data
1617
error_location
1718
= let
1819
rawText = Text.AfterDelimiter( Text.BeforeDelimiter( error_ast[Message], "]"), "["),
19-
pairs = Text.Split( rawText, "-"),
20-
return = [
21-
StartLine = Number.From( Text.BeforeDelimiter( pairs{0}, "," )),
20+
pairs = Text.Split( rawText, "-"),
21+
return = [
22+
StartLine = Number.From( Text.BeforeDelimiter( pairs{0}, "," )),
2223
StartColumn = Number.From( Text.AfterDelimiter( pairs{0}, "," )),
23-
EndLine = Number.From( Text.BeforeDelimiter( pairs{1}, "," )),
24-
EndColumn = Number.From( Text.AfterDelimiter( pairs{1}, "," ))
24+
EndLine = Number.From( Text.BeforeDelimiter( pairs{1}, "," )),
25+
EndColumn = Number.From( Text.AfterDelimiter( pairs{1}, "," ))
2526
]
2627
in
2728
return,
@@ -56,4 +57,6 @@ let
5657
then table_listSourceFilesInDirectory
5758
else if not final_evaluation[HasError]
5859
then final_evaluation[Value]
59-
else formatted_errors
60+
else formatted_errors
61+
in
62+
return

0 commit comments

Comments
 (0)