diff --git a/nbs/00_core.ipynb b/nbs/00_core.ipynb index 024df05..1dba635 100644 --- a/nbs/00_core.ipynb +++ b/nbs/00_core.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 874, + "execution_count": 369, "metadata": {}, "outputs": [ { @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 875, + "execution_count": 370, "metadata": {}, "outputs": [], "source": [ @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 876, + "execution_count": 371, "metadata": {}, "outputs": [], "source": [ @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 877, + "execution_count": 372, "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 878, + "execution_count": 373, "metadata": {}, "outputs": [], "source": [ @@ -92,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 879, + "execution_count": 374, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 880, + "execution_count": 375, "metadata": {}, "outputs": [], "source": [ @@ -175,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 881, + "execution_count": 376, "metadata": {}, "outputs": [], "source": [ @@ -285,7 +285,7 @@ }, { "cell_type": "code", - "execution_count": 882, + "execution_count": 377, "metadata": {}, "outputs": [], "source": [ @@ -309,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 883, + "execution_count": 378, "metadata": {}, "outputs": [ { @@ -342,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 884, + "execution_count": 379, "metadata": {}, "outputs": [ { @@ -374,7 +374,7 @@ }, { "cell_type": "code", - "execution_count": 885, + "execution_count": 380, "metadata": {}, "outputs": [ { @@ -399,7 +399,7 @@ }, { "cell_type": "code", - "execution_count": 886, + "execution_count": 381, "metadata": {}, "outputs": [ { @@ -428,7 +428,7 @@ }, { "cell_type": "code", - "execution_count": 887, + "execution_count": 382, "metadata": {}, "outputs": [ { @@ -457,7 +457,7 @@ }, { "cell_type": "code", - "execution_count": 888, + "execution_count": 383, "metadata": {}, "outputs": [ { @@ -487,7 +487,7 @@ }, { "cell_type": "code", - "execution_count": 889, + "execution_count": 384, "metadata": {}, "outputs": [ { @@ -516,7 +516,7 @@ }, { "cell_type": "code", - "execution_count": 890, + "execution_count": 385, "metadata": {}, "outputs": [ { @@ -542,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 891, + "execution_count": 386, "metadata": {}, "outputs": [], "source": [ @@ -634,7 +634,7 @@ }, { "cell_type": "code", - "execution_count": 892, + "execution_count": 387, "metadata": {}, "outputs": [ { @@ -656,7 +656,7 @@ }, { "cell_type": "code", - "execution_count": 893, + "execution_count": 388, "metadata": {}, "outputs": [ { @@ -683,7 +683,7 @@ }, { "cell_type": "code", - "execution_count": 894, + "execution_count": 389, "metadata": {}, "outputs": [ { @@ -709,7 +709,7 @@ }, { "cell_type": "code", - "execution_count": 895, + "execution_count": 390, "metadata": {}, "outputs": [ { @@ -738,7 +738,7 @@ }, { "cell_type": "code", - "execution_count": 896, + "execution_count": 391, "metadata": {}, "outputs": [ { @@ -767,7 +767,7 @@ }, { "cell_type": "code", - "execution_count": 897, + "execution_count": 392, "metadata": {}, "outputs": [ { @@ -803,7 +803,7 @@ }, { "cell_type": "code", - "execution_count": 898, + "execution_count": 393, "metadata": {}, "outputs": [ { @@ -834,7 +834,7 @@ }, { "cell_type": "code", - "execution_count": 899, + "execution_count": 394, "metadata": {}, "outputs": [ { @@ -865,7 +865,7 @@ }, { "cell_type": "code", - "execution_count": 900, + "execution_count": 395, "metadata": {}, "outputs": [ { @@ -904,7 +904,7 @@ }, { "cell_type": "code", - "execution_count": 901, + "execution_count": 396, "metadata": {}, "outputs": [ { @@ -936,7 +936,7 @@ }, { "cell_type": "code", - "execution_count": 902, + "execution_count": 397, "metadata": {}, "outputs": [ { @@ -968,7 +968,7 @@ }, { "cell_type": "code", - "execution_count": 903, + "execution_count": 398, "metadata": {}, "outputs": [ { @@ -1007,7 +1007,7 @@ }, { "cell_type": "code", - "execution_count": 904, + "execution_count": 399, "metadata": {}, "outputs": [ { @@ -1048,7 +1048,7 @@ }, { "cell_type": "code", - "execution_count": 905, + "execution_count": 400, "metadata": {}, "outputs": [], "source": [ @@ -1074,7 +1074,7 @@ }, { "cell_type": "code", - "execution_count": 906, + "execution_count": 401, "metadata": {}, "outputs": [ { @@ -1115,7 +1115,7 @@ }, { "cell_type": "code", - "execution_count": 907, + "execution_count": 402, "metadata": {}, "outputs": [ { @@ -1156,7 +1156,7 @@ }, { "cell_type": "code", - "execution_count": 908, + "execution_count": 403, "metadata": {}, "outputs": [ { @@ -1197,7 +1197,7 @@ }, { "cell_type": "code", - "execution_count": 909, + "execution_count": 404, "metadata": {}, "outputs": [ { @@ -1245,7 +1245,7 @@ }, { "cell_type": "code", - "execution_count": 910, + "execution_count": 405, "metadata": {}, "outputs": [], "source": [ @@ -1264,7 +1264,7 @@ }, { "cell_type": "code", - "execution_count": 911, + "execution_count": 406, "metadata": {}, "outputs": [ { @@ -1322,7 +1322,7 @@ }, { "cell_type": "code", - "execution_count": 912, + "execution_count": 407, "metadata": {}, "outputs": [], "source": [ @@ -1366,7 +1366,7 @@ }, { "cell_type": "code", - "execution_count": 913, + "execution_count": 408, "metadata": {}, "outputs": [ { @@ -1394,7 +1394,7 @@ }, { "cell_type": "code", - "execution_count": 914, + "execution_count": 409, "metadata": {}, "outputs": [], "source": [ @@ -1430,7 +1430,7 @@ }, { "cell_type": "code", - "execution_count": 915, + "execution_count": 410, "metadata": {}, "outputs": [ { @@ -1450,7 +1450,7 @@ }, { "cell_type": "code", - "execution_count": 916, + "execution_count": 411, "metadata": {}, "outputs": [ { @@ -1470,7 +1470,7 @@ }, { "cell_type": "code", - "execution_count": 917, + "execution_count": 412, "metadata": {}, "outputs": [ { @@ -1492,7 +1492,7 @@ }, { "cell_type": "code", - "execution_count": 918, + "execution_count": 413, "metadata": {}, "outputs": [ { @@ -1521,7 +1521,7 @@ }, { "cell_type": "code", - "execution_count": 919, + "execution_count": 414, "metadata": {}, "outputs": [], "source": [ @@ -1569,27 +1569,27 @@ " ]\n", " )\n", "\n", - " # search for and/or within parentheses\n", - " # counter for parenthesis\n", - " k = 0\n", - " # counter for '\n", - " d = 0\n", - " # loop over string characters\n", - " and_or_position = []\n", - " for i, c in enumerate(s_code):\n", - " if c == \"(\" and d % 2 == 0: # The first (\n", - " k += 1\n", - " elif c == \")\" and k > 0 and d % 2 == 0:\n", - " k -= 1\n", - " elif s_code[i : i + 3] == \"AND\" and k > 0 and d % 2 == 0:\n", - " and_or_position.append(i)\n", - " elif s_code[i : i + 2] == \"OR\" and k > 0 and d % 2 == 0:\n", - " and_or_position.append(i)\n", - " elif c == \"'\":\n", - " d += 1\n", - " # remove linebreak starting from the end (index problem)\n", - " for i in and_or_position[::-1]:\n", - " s_code = s_code[: i - 5] + s_code[i - 1 :]\n", + " # # search for and/or within parentheses\n", + " # # counter for parenthesis\n", + " # k = 0\n", + " # # counter for '\n", + " # d = 0\n", + " # # loop over string characters\n", + " # and_or_position = []\n", + " # for i, c in enumerate(s_code):\n", + " # if c == \"(\" and d % 2 == 0: # The first (\n", + " # k += 1\n", + " # elif c == \")\" and k > 0 and d % 2 == 0:\n", + " # k -= 1\n", + " # elif s_code[i : i + 3] == \"AND\" and k > 0 and d % 2 == 0:\n", + " # and_or_position.append(i)\n", + " # elif s_code[i : i + 2] == \"OR\" and k > 0 and d % 2 == 0:\n", + " # and_or_position.append(i)\n", + " # elif c == \"'\":\n", + " # d += 1\n", + " # # remove linebreak starting from the end (index problem)\n", + " # for i in and_or_position[::-1]:\n", + " # s_code = s_code[: i - 5] + s_code[i - 1 :]\n", "\n", " s_code = indent_between_and_reset.sub(r\"\\1 \\2 \\3\", s_code)\n", " # s_code = \"\\n\".join([indent_between_and_indent.sub(r\"\\1 \\2\\n\" + \" \" * 12 + r\"\\3\", sp)\n", @@ -1609,7 +1609,7 @@ }, { "cell_type": "code", - "execution_count": 920, + "execution_count": 415, "metadata": {}, "outputs": [], "source": [ @@ -1717,7 +1717,7 @@ }, { "cell_type": "code", - "execution_count": 921, + "execution_count": 416, "metadata": {}, "outputs": [ { @@ -1736,7 +1736,7 @@ }, { "cell_type": "code", - "execution_count": 922, + "execution_count": 417, "metadata": {}, "outputs": [ { @@ -1762,7 +1762,7 @@ }, { "cell_type": "code", - "execution_count": 923, + "execution_count": 418, "metadata": {}, "outputs": [ { @@ -1786,7 +1786,7 @@ }, { "cell_type": "code", - "execution_count": 924, + "execution_count": 419, "metadata": {}, "outputs": [ { @@ -1814,7 +1814,7 @@ }, { "cell_type": "code", - "execution_count": 925, + "execution_count": 420, "metadata": {}, "outputs": [ { @@ -1838,7 +1838,7 @@ }, { "cell_type": "code", - "execution_count": 926, + "execution_count": 421, "metadata": {}, "outputs": [ { @@ -1869,7 +1869,7 @@ }, { "cell_type": "code", - "execution_count": 927, + "execution_count": 422, "metadata": {}, "outputs": [ { @@ -1902,7 +1902,7 @@ }, { "cell_type": "code", - "execution_count": 928, + "execution_count": 423, "metadata": {}, "outputs": [ { @@ -1919,7 +1919,7 @@ }, { "cell_type": "code", - "execution_count": 929, + "execution_count": 424, "metadata": {}, "outputs": [ { @@ -1948,7 +1948,7 @@ }, { "cell_type": "code", - "execution_count": 930, + "execution_count": 425, "metadata": {}, "outputs": [], "source": [ @@ -2033,7 +2033,7 @@ }, { "cell_type": "code", - "execution_count": 931, + "execution_count": 426, "metadata": {}, "outputs": [ { @@ -2066,7 +2066,7 @@ }, { "cell_type": "code", - "execution_count": 932, + "execution_count": 427, "metadata": {}, "outputs": [ { @@ -2092,7 +2092,7 @@ }, { "cell_type": "code", - "execution_count": 933, + "execution_count": 428, "metadata": {}, "outputs": [ { @@ -2123,7 +2123,7 @@ }, { "cell_type": "code", - "execution_count": 934, + "execution_count": 429, "metadata": {}, "outputs": [ { @@ -2141,7 +2141,7 @@ }, { "cell_type": "code", - "execution_count": 935, + "execution_count": 430, "metadata": {}, "outputs": [ { @@ -2171,7 +2171,7 @@ }, { "cell_type": "code", - "execution_count": 936, + "execution_count": 431, "metadata": {}, "outputs": [ { @@ -2202,7 +2202,7 @@ }, { "cell_type": "code", - "execution_count": 937, + "execution_count": 432, "metadata": {}, "outputs": [ { @@ -2239,7 +2239,7 @@ }, { "cell_type": "code", - "execution_count": 938, + "execution_count": 433, "metadata": {}, "outputs": [ { @@ -2260,7 +2260,7 @@ }, { "cell_type": "code", - "execution_count": 939, + "execution_count": 434, "metadata": {}, "outputs": [ { @@ -2288,7 +2288,7 @@ }, { "cell_type": "code", - "execution_count": 940, + "execution_count": 435, "metadata": {}, "outputs": [ { @@ -2324,7 +2324,7 @@ }, { "cell_type": "code", - "execution_count": 941, + "execution_count": 436, "metadata": {}, "outputs": [ { @@ -2372,7 +2372,7 @@ }, { "cell_type": "code", - "execution_count": 942, + "execution_count": 437, "metadata": {}, "outputs": [ { @@ -2420,7 +2420,7 @@ }, { "cell_type": "code", - "execution_count": 943, + "execution_count": 438, "metadata": {}, "outputs": [ { @@ -2464,7 +2464,7 @@ }, { "cell_type": "code", - "execution_count": 944, + "execution_count": 439, "metadata": {}, "outputs": [ { @@ -2501,7 +2501,7 @@ }, { "cell_type": "code", - "execution_count": 945, + "execution_count": 440, "metadata": {}, "outputs": [ { @@ -2510,22 +2510,22 @@ "\"select asdf,\\n case when asdf >= 1 \\n and asdf <= 10 \\n and substr(qwer, 1, 2) = 'abc' \\n and substr(qwer, 3, 2) = 'qwerty'\\n then 1\\n else 0\\n end as case_field,\\n asdf2\"" ] }, - "execution_count": 945, + "execution_count": 440, "metadata": {}, "output_type": "execute_result" } ], "source": [ - " format_select(\n", - " \"select asdf, case when asdf >= 1 and asdf <= 10 and\"\n", - " + \" substr(qwer, 1, 2) = 'abc' and substr(qwer, 3, 2) = 'qwerty'\"\n", - " + \" then 1 else 0 end as case_field, asdf2\"\n", - " )" + "format_select(\n", + " \"select asdf, case when asdf >= 1 and asdf <= 10 and\"\n", + " + \" substr(qwer, 1, 2) = 'abc' and substr(qwer, 3, 2) = 'qwerty'\"\n", + " + \" then 1 else 0 end as case_field, asdf2\"\n", + ")" ] }, { "cell_type": "code", - "execution_count": 946, + "execution_count": 441, "metadata": {}, "outputs": [ { @@ -2564,7 +2564,7 @@ }, { "cell_type": "code", - "execution_count": 947, + "execution_count": 442, "metadata": {}, "outputs": [ { @@ -2612,7 +2612,7 @@ }, { "cell_type": "code", - "execution_count": 948, + "execution_count": 443, "metadata": {}, "outputs": [ { @@ -2635,7 +2635,7 @@ }, { "cell_type": "code", - "execution_count": 949, + "execution_count": 444, "metadata": {}, "outputs": [ { @@ -2671,7 +2671,7 @@ }, { "cell_type": "code", - "execution_count": 950, + "execution_count": 445, "metadata": {}, "outputs": [ { @@ -2705,7 +2705,7 @@ }, { "cell_type": "code", - "execution_count": 951, + "execution_count": 446, "metadata": {}, "outputs": [ { @@ -2739,7 +2739,7 @@ }, { "cell_type": "code", - "execution_count": 952, + "execution_count": 447, "metadata": {}, "outputs": [ { @@ -2773,7 +2773,7 @@ }, { "cell_type": "code", - "execution_count": 953, + "execution_count": 448, "metadata": {}, "outputs": [ { @@ -2814,7 +2814,7 @@ }, { "cell_type": "code", - "execution_count": 954, + "execution_count": 449, "metadata": {}, "outputs": [ { @@ -2840,7 +2840,7 @@ }, { "cell_type": "code", - "execution_count": 955, + "execution_count": 450, "metadata": {}, "outputs": [ { @@ -2881,7 +2881,7 @@ }, { "cell_type": "code", - "execution_count": 956, + "execution_count": 451, "metadata": {}, "outputs": [ { @@ -2917,7 +2917,7 @@ }, { "cell_type": "code", - "execution_count": 957, + "execution_count": 452, "metadata": {}, "outputs": [ { @@ -2955,7 +2955,7 @@ }, { "cell_type": "code", - "execution_count": 958, + "execution_count": 453, "metadata": {}, "outputs": [ { @@ -2993,7 +2993,7 @@ }, { "cell_type": "code", - "execution_count": 959, + "execution_count": 454, "metadata": {}, "outputs": [ { @@ -3025,7 +3025,7 @@ }, { "cell_type": "code", - "execution_count": 960, + "execution_count": 455, "metadata": {}, "outputs": [ { @@ -3070,7 +3070,7 @@ }, { "cell_type": "code", - "execution_count": 961, + "execution_count": 456, "metadata": {}, "outputs": [ { @@ -3115,7 +3115,7 @@ }, { "cell_type": "code", - "execution_count": 962, + "execution_count": 457, "metadata": {}, "outputs": [ { @@ -3141,7 +3141,7 @@ }, { "cell_type": "code", - "execution_count": 963, + "execution_count": 458, "metadata": {}, "outputs": [ { @@ -3182,7 +3182,7 @@ }, { "cell_type": "code", - "execution_count": 964, + "execution_count": 459, "metadata": {}, "outputs": [ { @@ -3223,7 +3223,7 @@ }, { "cell_type": "code", - "execution_count": 965, + "execution_count": 460, "metadata": {}, "outputs": [], "source": [ @@ -3265,7 +3265,7 @@ }, { "cell_type": "code", - "execution_count": 966, + "execution_count": 461, "metadata": {}, "outputs": [ { @@ -3304,7 +3304,7 @@ }, { "cell_type": "code", - "execution_count": 967, + "execution_count": 462, "metadata": {}, "outputs": [], "source": [ @@ -3322,7 +3322,7 @@ }, { "cell_type": "code", - "execution_count": 968, + "execution_count": 463, "metadata": {}, "outputs": [ { @@ -3344,7 +3344,7 @@ }, { "cell_type": "code", - "execution_count": 969, + "execution_count": 464, "metadata": {}, "outputs": [ { @@ -3366,7 +3366,7 @@ }, { "cell_type": "code", - "execution_count": 970, + "execution_count": 465, "metadata": {}, "outputs": [ { @@ -3377,7 +3377,7 @@ " 'quote': False}]" ] }, - "execution_count": 970, + "execution_count": 465, "metadata": {}, "output_type": "execute_result" } @@ -3388,7 +3388,7 @@ }, { "cell_type": "code", - "execution_count": 971, + "execution_count": 466, "metadata": {}, "outputs": [], "source": [ @@ -3460,7 +3460,7 @@ }, { "cell_type": "code", - "execution_count": 972, + "execution_count": 467, "metadata": {}, "outputs": [ { @@ -3482,7 +3482,7 @@ }, { "cell_type": "code", - "execution_count": 973, + "execution_count": 468, "metadata": {}, "outputs": [ { @@ -3508,7 +3508,7 @@ }, { "cell_type": "code", - "execution_count": 974, + "execution_count": 469, "metadata": {}, "outputs": [ { @@ -3536,7 +3536,7 @@ }, { "cell_type": "code", - "execution_count": 975, + "execution_count": 470, "metadata": {}, "outputs": [ { @@ -3571,7 +3571,7 @@ }, { "cell_type": "code", - "execution_count": 976, + "execution_count": 471, "metadata": {}, "outputs": [ { @@ -3606,7 +3606,7 @@ }, { "cell_type": "code", - "execution_count": 977, + "execution_count": 472, "metadata": {}, "outputs": [], "source": [ @@ -3683,7 +3683,7 @@ }, { "cell_type": "code", - "execution_count": 978, + "execution_count": 473, "metadata": {}, "outputs": [ { @@ -3702,7 +3702,7 @@ }, { "cell_type": "code", - "execution_count": 979, + "execution_count": 474, "metadata": {}, "outputs": [], "source": [ @@ -3717,7 +3717,7 @@ }, { "cell_type": "code", - "execution_count": 980, + "execution_count": 475, "metadata": {}, "outputs": [ { @@ -3741,7 +3741,7 @@ }, { "cell_type": "code", - "execution_count": 981, + "execution_count": 476, "metadata": {}, "outputs": [ { @@ -3767,7 +3767,7 @@ }, { "cell_type": "code", - "execution_count": 982, + "execution_count": 477, "metadata": {}, "outputs": [ { @@ -3806,7 +3806,7 @@ }, { "cell_type": "code", - "execution_count": 983, + "execution_count": 478, "metadata": {}, "outputs": [], "source": [ @@ -3830,7 +3830,7 @@ }, { "cell_type": "code", - "execution_count": 984, + "execution_count": 479, "metadata": {}, "outputs": [ { @@ -3854,7 +3854,7 @@ }, { "cell_type": "code", - "execution_count": 985, + "execution_count": 480, "metadata": {}, "outputs": [ { @@ -3871,7 +3871,7 @@ }, { "cell_type": "code", - "execution_count": 986, + "execution_count": 481, "metadata": {}, "outputs": [ { @@ -3890,7 +3890,7 @@ }, { "cell_type": "code", - "execution_count": 987, + "execution_count": 482, "metadata": {}, "outputs": [ { @@ -3910,7 +3910,7 @@ }, { "cell_type": "code", - "execution_count": 988, + "execution_count": 483, "metadata": {}, "outputs": [ { @@ -3942,7 +3942,7 @@ }, { "cell_type": "code", - "execution_count": 989, + "execution_count": 484, "metadata": {}, "outputs": [], "source": [ @@ -3959,7 +3959,7 @@ }, { "cell_type": "code", - "execution_count": 990, + "execution_count": 485, "metadata": {}, "outputs": [ { @@ -3985,7 +3985,7 @@ }, { "cell_type": "code", - "execution_count": 991, + "execution_count": 486, "metadata": {}, "outputs": [], "source": [ @@ -4002,7 +4002,7 @@ }, { "cell_type": "code", - "execution_count": 992, + "execution_count": 487, "metadata": {}, "outputs": [ { @@ -4107,7 +4107,7 @@ }, { "cell_type": "code", - "execution_count": 993, + "execution_count": 488, "metadata": {}, "outputs": [], "source": [ @@ -4136,7 +4136,7 @@ }, { "cell_type": "code", - "execution_count": 994, + "execution_count": 489, "metadata": {}, "outputs": [], "source": [ @@ -4158,7 +4158,7 @@ }, { "cell_type": "code", - "execution_count": 995, + "execution_count": 490, "metadata": {}, "outputs": [ { @@ -4193,7 +4193,7 @@ }, { "cell_type": "code", - "execution_count": 996, + "execution_count": 491, "metadata": {}, "outputs": [ { @@ -4228,7 +4228,7 @@ }, { "cell_type": "code", - "execution_count": 997, + "execution_count": 492, "metadata": {}, "outputs": [ { @@ -4272,7 +4272,7 @@ }, { "cell_type": "code", - "execution_count": 998, + "execution_count": 493, "metadata": {}, "outputs": [], "source": [ @@ -4296,7 +4296,7 @@ }, { "cell_type": "code", - "execution_count": 999, + "execution_count": 494, "metadata": {}, "outputs": [ { @@ -4341,7 +4341,7 @@ }, { "cell_type": "code", - "execution_count": 1000, + "execution_count": 495, "metadata": {}, "outputs": [ { @@ -4393,7 +4393,7 @@ }, { "cell_type": "code", - "execution_count": 1001, + "execution_count": 496, "metadata": {}, "outputs": [], "source": [ @@ -4419,7 +4419,7 @@ }, { "cell_type": "code", - "execution_count": 1002, + "execution_count": 497, "metadata": {}, "outputs": [], "source": [ @@ -4453,7 +4453,7 @@ }, { "cell_type": "code", - "execution_count": 1003, + "execution_count": 498, "metadata": {}, "outputs": [], "source": [ @@ -4541,7 +4541,7 @@ }, { "cell_type": "code", - "execution_count": 1004, + "execution_count": 499, "metadata": {}, "outputs": [], "source": [ @@ -4628,7 +4628,7 @@ }, { "cell_type": "code", - "execution_count": 1005, + "execution_count": 500, "metadata": {}, "outputs": [ { @@ -4668,7 +4668,7 @@ }, { "cell_type": "code", - "execution_count": 1006, + "execution_count": 501, "metadata": {}, "outputs": [], "source": [ @@ -4691,7 +4691,7 @@ }, { "cell_type": "code", - "execution_count": 1007, + "execution_count": 502, "metadata": {}, "outputs": [], "source": [ @@ -4707,7 +4707,7 @@ }, { "cell_type": "code", - "execution_count": 1008, + "execution_count": 503, "metadata": {}, "outputs": [], "source": [ @@ -4736,7 +4736,7 @@ }, { "cell_type": "code", - "execution_count": 1009, + "execution_count": 504, "metadata": {}, "outputs": [ { @@ -4773,7 +4773,7 @@ }, { "cell_type": "code", - "execution_count": 1010, + "execution_count": 505, "metadata": {}, "outputs": [ { @@ -4863,7 +4863,7 @@ }, { "cell_type": "code", - "execution_count": 1011, + "execution_count": 506, "metadata": {}, "outputs": [ { @@ -4907,7 +4907,7 @@ }, { "cell_type": "code", - "execution_count": 1012, + "execution_count": 507, "metadata": {}, "outputs": [], "source": [ @@ -4927,7 +4927,7 @@ }, { "cell_type": "code", - "execution_count": 1013, + "execution_count": 508, "metadata": {}, "outputs": [], "source": [ @@ -4955,7 +4955,7 @@ }, { "cell_type": "code", - "execution_count": 1014, + "execution_count": 509, "metadata": {}, "outputs": [ { @@ -4989,7 +4989,7 @@ }, { "cell_type": "code", - "execution_count": 1015, + "execution_count": 510, "metadata": {}, "outputs": [ { @@ -5042,7 +5042,7 @@ }, { "cell_type": "code", - "execution_count": 1016, + "execution_count": 511, "metadata": {}, "outputs": [ { @@ -5089,7 +5089,7 @@ }, { "cell_type": "code", - "execution_count": 1017, + "execution_count": 512, "metadata": {}, "outputs": [ { @@ -5139,7 +5139,7 @@ }, { "cell_type": "code", - "execution_count": 1018, + "execution_count": 513, "metadata": {}, "outputs": [], "source": [ @@ -5180,7 +5180,7 @@ }, { "cell_type": "code", - "execution_count": 1019, + "execution_count": 514, "metadata": {}, "outputs": [], "source": [ @@ -5225,7 +5225,7 @@ }, { "cell_type": "code", - "execution_count": 1020, + "execution_count": 515, "metadata": {}, "outputs": [ { @@ -5278,7 +5278,7 @@ }, { "cell_type": "code", - "execution_count": 1021, + "execution_count": 516, "metadata": {}, "outputs": [ { diff --git a/ptypysql/core.py b/ptypysql/core.py index d70b8bd..fecfa85 100644 --- a/ptypysql/core.py +++ b/ptypysql/core.py @@ -346,27 +346,27 @@ def format_case_when(s, max_len=99): ] ) - # search for and/or within parentheses - # counter for parenthesis - k = 0 - # counter for ' - d = 0 - # loop over string characters - and_or_position = [] - for i, c in enumerate(s_code): - if c == "(" and d % 2 == 0: # The first ( - k += 1 - elif c == ")" and k > 0 and d % 2 == 0: - k -= 1 - elif s_code[i : i + 3] == "AND" and k > 0 and d % 2 == 0: - and_or_position.append(i) - elif s_code[i : i + 2] == "OR" and k > 0 and d % 2 == 0: - and_or_position.append(i) - elif c == "'": - d += 1 - # remove linebreak starting from the end (index problem) - for i in and_or_position[::-1]: - s_code = s_code[: i - 5] + s_code[i - 1 :] + # # search for and/or within parentheses + # # counter for parenthesis + # k = 0 + # # counter for ' + # d = 0 + # # loop over string characters + # and_or_position = [] + # for i, c in enumerate(s_code): + # if c == "(" and d % 2 == 0: # The first ( + # k += 1 + # elif c == ")" and k > 0 and d % 2 == 0: + # k -= 1 + # elif s_code[i : i + 3] == "AND" and k > 0 and d % 2 == 0: + # and_or_position.append(i) + # elif s_code[i : i + 2] == "OR" and k > 0 and d % 2 == 0: + # and_or_position.append(i) + # elif c == "'": + # d += 1 + # # remove linebreak starting from the end (index problem) + # for i in and_or_position[::-1]: + # s_code = s_code[: i - 5] + s_code[i - 1 :] s_code = indent_between_and_reset.sub(r"\1 \2 \3", s_code) # s_code = "\n".join([indent_between_and_indent.sub(r"\1 \2\n" + " " * 12 + r"\3", sp)