Skip to content
Permalink
Browse files
Move py_repr to erlfdb_util:repr
This is a useful function to have when using the FoundationDB binding
tester in comparison to the Python implementation.
  • Loading branch information
davisp committed Feb 22, 2019
1 parent c301d3c commit 709cb6f9c576ef9039c0e96e40421a1da7a1eb2d
Showing 2 changed files with 17 additions and 31 deletions.
@@ -15,7 +15,9 @@

-export([
get/2,
get/3
get/3,

repr/1
]).


@@ -29,3 +31,17 @@ get(List, Key, Default) ->
{Key, Value} -> Value;
_ -> Default
end.


repr(Bin) when is_binary(Bin) ->
[$'] ++ lists:map(fun(C) ->
case C of
9 -> "\\t";
10 -> "\\n";
13 -> "\\r";
39 -> "\\'";
92 -> "\\\\";
_ when C >= 32, C =< 126 -> C;
_ -> io_lib:format("\\x~2.16.0b", [C])
end
end, binary_to_list(Bin)) ++ [$'].
@@ -20,35 +20,6 @@
}).


py_repr(Bin) when is_binary(Bin) ->
[$'] ++ lists:map(fun(C) ->
case C of
%% 7 ->
%% "\\a";
%% 8 ->
%% "\\b";
9 ->
"\\t";
10 ->
"\\n";
%% 11 ->
%% "\\v";
%% 12 ->
%% "\\f";
13 ->
"\\r";
39 ->
"\\'";
92 ->
"\\\\";
_ when C >= 32, C =< 126 ->
C;
_ ->
io_lib:format("\\x~2.16.0b", [C])
end
end, binary_to_list(Bin)) ++ [$'].


stack_create() ->
Pid = spawn_link(fun() -> stack_loop([]) end),
spawn(fun() ->
@@ -702,7 +673,6 @@ main([Prefix, APIVsn]) ->
main([Prefix, APIVsn, ""]);

main([Prefix, APIVsn, ClusterFileStr]) ->
py_repr(<<"foo">>),
%% Prompt = io_lib:format("GDB Attach to: ~s~n", [os:getpid()]),
%% io:get_line(Prompt),
%% io:format("Running tests: ~s ~s ~s~n", [Prefix, APIVsn, ClusterFileStr]),

0 comments on commit 709cb6f

Please sign in to comment.