From 587954cd7566b2fd729a1de4a2d17e91c4039557 Mon Sep 17 00:00:00 2001 From: Lyncoln Date: Mon, 12 Oct 2026 22:20:02 -0400 Subject: [PATCH] Working select filters with include and exclude logic --- .../__pycache__/operation.cpython-314.pyc | Bin 1018 -> 1243 bytes core/execution/operation/operation.py | 7 ++ .../runtimecontract.cpython-314.pyc | Bin 1065 -> 1122 bytes .../__pycache__/select.cpython-314.pyc | Bin 1497 -> 2896 bytes core/runtime/runtimecontract.py | 4 +- core/runtime/select.py | 89 +++++++++++++++++- .../__pycache__/getmessage.cpython-314.pyc | Bin 552 -> 746 bytes .../pullmessagelist.cpython-314.pyc | Bin 597 -> 629 bytes plugins/rmass/actions/getmessage.py | 55 ++++++----- plugins/rmass/actions/pullmessagelist.py | 28 +++++- .../pullmessagelist.cpython-314.pyc | Bin 368 -> 373 bytes plugins/rmass/operations/pullmessagelist.py | 2 +- tokens.json | 2 +- 13 files changed, 155 insertions(+), 32 deletions(-) diff --git a/core/execution/operation/__pycache__/operation.cpython-314.pyc b/core/execution/operation/__pycache__/operation.cpython-314.pyc index f08d160c804b3a24e8f812a6b1fb98fc16cb3076..b2d9526dd56bb37a1861bb06418fccf1ba89814a 100644 GIT binary patch delta 519 zcmeyxew&j|n~#@^0SG4Koz0rdGLi2GlN;k?4n|GJuE|D>f%VKFIS>eA31T#1g0R&g z6hn#;1A`1hxJdvTQ~-$zV$zX9aFN*p3~nL}3$YF>&a z`z@}N)U?dJOpy8_zR5gH3SumoC8@c$IEqq>3xH;%7PA92s3}agW(ww#05U-VT|8&< z3?|!HZlMWgGpw(3t6$<)zab%iUBTd@g24ufs|r@vC9E$<`4{rtp2_WRSG^!o?t~v4ZWgjKxI`$qx1#9D>(5BrbAD%#gUoq4ZIjL0Ia8%H(fM oJ7ho>u4E{Z1X4xfK;jmMO>TZlX-=wLk>cc2%o-dLjKW}90I0-mApigX delta 255 zcmcc3`HP)Tn~#@^0SJ~IJC)_eJdy7Q(*cIb9E_Tb?vsre0~y&TKVTHMH4S45-~_2c z1!1fvj1Uod25(OW22KV!hA?Jj22I9W9L3q01;r()1)8jr3z;NjIDqPIu_YE1q~@h) zvfbiJNlnYl%Ph&v&nx1YyoyPIpQ9+XxFA2TIJKA!s8nt81EyduQ6LNCxZ;G#w#>GQ zGU_YXF3VV4xm9lP8-8dkMQdLlCn#LkUL^i!y^I z>%C!9O4TbW%`3^wP1P#~YboLYT393wBvvvMNr2d5K;jmMO>TZlX-=wLkqnT_2*kz0 cK;i>4BO~K|hLEcaA$J*czObn<%7Qfk0FN**F#rGn delta 133 zcmaFFv66#Vn~#@^0SK&KoXOfhkynyYW1_kuPY{zhLkU|DvoeDw%ftkijayDJGO|pr zXR>4DoV<@Imr-o84)bP4_Q?;J)$NMJfZA6w6o~_=B2gf5i^C>2KczG$)vibi$YliL aVgVrWftit!@jgSyRfdo+94d^mU>yK$V;-OY diff --git a/core/runtime/__pycache__/select.cpython-314.pyc b/core/runtime/__pycache__/select.cpython-314.pyc index 8b3120b4b9f2f46de62eef0ba07d6194ccf8034f..988ac4df777f30bdf64b70cc76e11aa148511f51 100644 GIT binary patch literal 2896 zcmcJR&2Jh<6u@U;S->nc7%=|8ABk-Y7{_VtHck~+t=guoF{wqPB~t806t)hDfz`4k zcBDugaV`zY0Y|DDAF9e#70JgO+FK93R5BH7qgA9@N~B&%+&`di_QNbhD7kbbX5O3k z=FQH`dp|Mtmc0u>d;H+f8x3P=Rg<75V{SkcqaaCctEow z#87%I{;3~KD`w5kkaOzSjG)UTXO2uDWJSa1iaFjhi_bz_3X&3eBcIDkRGwXDlY(SQ z3v4DYnK(Y36@nJY!n1iUm(8;hl}HL{@HFQN0#^|7l3g=hOC^MaWK$w23W>u&uxyIm zkgSRY7UwPSZGOLh6gMe6b3K<~XHtn<>C_CL$t1FgHI|=A=6H67FJy%@7?q`GxJ}9S zO(DIW`bz#x-T`s&+45JRE20L4JVTXeIr`wsVzgmFJ?>(p?j5S!E#E!#hN|Asfj7Km zE0J|yQ1s30n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Rvbl&p77*)T zc_1Y>Uu&k;Je^Lj4(A*E(vwfIdFb*pNUMKjWe^nqBF4bV)uDZbMeGK**aG$o-0Bxt x)QbdxhWKeR6$t?8BH79O+)|3bKxF_0P%%G{_`nQ|n@>zajA~yrL>M)|>H#%`Pd@+v diff --git a/core/runtime/runtimecontract.py b/core/runtime/runtimecontract.py index 57e43e4..3958755 100644 --- a/core/runtime/runtimecontract.py +++ b/core/runtime/runtimecontract.py @@ -1,5 +1,5 @@ from core.runtime import buildSelect, buildSelect2, buildOutput, buildSave, buildLog - +from core.runtime.select import buildSelect3 #select_data = {} def buildRuntimeAttr(action, outputs, response): @@ -15,7 +15,7 @@ def buildRuntimeAttr(action, outputs, response): outputs = buildOutput(response, action, outputs)#, select_data) if hasattr(action, "select"): - select_data, action, outputs = buildSelect2(action, outputs) + select_data, action, outputs = buildSelect3(action, outputs) #print("AFTER buildOutput:", type(outputs)) #print("DEBUG buildSave") #print("outputs type:", type(outputs)) diff --git a/core/runtime/select.py b/core/runtime/select.py index 2f5e32d..10352bc 100644 --- a/core/runtime/select.py +++ b/core/runtime/select.py @@ -18,6 +18,7 @@ def buildSelect(response, action, outputs): return selection, action, outputs + def buildSelect2(action, outputs): #print(outputs) select_data = [] @@ -25,10 +26,29 @@ def buildSelect2(action, outputs): selectmethod = action.select["selectmethod"] targetkey = action.select["key"] targetvalue = action.select["value"] + + if isinstance(targetvalue, dict): + for resolvekey, resolveval in targetvalue.items(): + print(resolvekey) + print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + print (outputtarget) + targetvalue = outputtarget #for item in target: for item in target: #print (item) for key, value in item.items(): + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #outputtarget = targetvalue if selectmethod == "exclude": if targetkey == key and item[key] != targetvalue: select_data.append(item) @@ -37,9 +57,76 @@ def buildSelect2(action, outputs): if targetkey == key and item[key] == targetvalue: select_data.append(item) #print(item) - print(select_data) + outputs[action.select["source"]] = select_data + #print(outputs) return select_data, action, outputs #for item in outputs[output_name]: #for key, value in action.select.include.items(): #if key in item and item[key] == value: #select_data.append(item) + +def buildSelect3(action, outputs): + #print(outputs) + select_data = [] + target = outputs[action.select["source"]] + #selectmethod = action.select["selectmethod"] + includekey = action.select["include"]["key"] + includevalue = action.select["include"]["value"] + excludekey = action.select["exclude"]["key"] + excludevalue = action.select["exclude"]["value"] + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #targetvalue = outputtarget + #for item in target: + #include_match = True + #exclude_match = True + + for item in target: + include_match = True + exclude_match = True + + if includekey: + include_match = item[includekey] == includevalue + + if excludekey: + exclude_match = item[excludekey] != excludevalue + + if include_match and exclude_match: + select_data.append(item) + #print (item) + #for key, value in item.items(): + #if isinstance(targetvalue, dict): + #for resolvekey, resolveval in targetvalue.items(): + #print(resolvekey) + #print(resolveval) + #outputtarget = outputs[resolvekey] + #for thing in resolveval: + #outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]] + #print (outputtarget) + #outputtarget = targetvalue + #if selectmethod == "exclude": + #if item[excludekey] != excludevalue:# and item[includekey] == includevalue: + #if includekey == key and item[key] == includevalue: + #if item[excludekey] == excludevalue: + #continue + #select_data.append(item) + #if item[includekey] == includevalue: + #if includekey == key and item[key] == includevalue: + #continue + #select_data.append(item) + #if excludekey == key and item[key] != excludevalue: + #select_data.append(item) + #print(item) + #if selectmethod == "include": + #if excludekey == key and item[key] == excludevalue: + #select_data.append(item) + #print(item) + outputs[action.select["source"]] = select_data + print(select_data) + return select_data, action, outputs diff --git a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc index d06a256cea26c7f7c79a26bb61db2b5bd8f7326a..2f69930343f91d95afe08b8d6ea85d28bfe4898f 100644 GIT binary patch delta 389 zcmXw!O-sW-5Qca2xrrvN)z*)C5s_L1b14?@B6#q!f_M$dP^0~jY!bAm;3>zJ{sT|m z{3V{egcYP9UOWZ;18!-3VTNbk8HSl>2!rw92^l^60}O!XqDFJx+BpI!JC4&9LbR*gW_G(tdElmU4xz*blLdr_)24g zIP`#PksEd(;(8Alb34Gv0vOkWzSoU?;PNdzaD@T%xth4$7*4qk_wycM(Dxxc^Mj8k z88ywx9&Xi*5WF~KK>}PK#L-;=lkKl=0bXqPh#WfIedhdk~{CgQnobMZsL0 zxv9m)iRr1CDHH!#O7bM<=ar=v6(^Qt=I7nwfXWqXa!l@JG~r;+FD)r3Eh(OShtbzu z5@;$T5Eo|vi4V+-jEuJ#I3KW!G_X8i=Wk&7z`?*L)WG#Yi-C*3f$f7B1FPNx4uJ{U YlM|Rs_=P8UePCwdW@=(D5(nxA01px{xc~qF diff --git a/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/actions/__pycache__/pullmessagelist.cpython-314.pyc index 289ddf380ceb07075ba5bb8d4f21b77f78180743..2097e39ec9e9c7ff2722ab4e23df9714785872b0 100644 GIT binary patch delta 202 zcmcc0@|8thn~#@^0SIRHoz2Q&VPJR+;=lkWl<_%iqPnS=K0^?{K7&3}kU$V$kYEsh z9FVQgJTYy(Dtl&La!zSV>MiE%)XH0|Wr;bZskhiuDlfmLKOKa;qd90MzFN5%~n-Wwde9Yr@d_$LT`U}Y9y`@q4#$_Emw0Er1g#CW;5 Xm>SqVNP+cyU}oZGYGN;v0=f|Zu>>?L delta 188 zcmey$a+O70n~#@^0SKDjoyjt1W?*;>;=lk0l=0bXqPi(p5Py(BkYF5xKFh?S^;$f| zsX3|1CAq038Tl!<*i$Q#b4pWEZ!u@5R^DPO%_~YxOu5BcmY7qTI@yhJ5o7k`myBAT z4_Jh6a0pD$0}+}ZSeeDxJ}|R#Gc~Y(5MW^C?Z~*nA~eDC1`B70#SIqjj=&F`tXxbD TY*5J$%uL)&P3%QdKvw|(xfwLl diff --git a/plugins/rmass/actions/getmessage.py b/plugins/rmass/actions/getmessage.py index b13a967..a467e34 100644 --- a/plugins/rmass/actions/getmessage.py +++ b/plugins/rmass/actions/getmessage.py @@ -1,5 +1,7 @@ import os +#getoutputs = {"emails": [0, "id"]} + name = "Get message" kind = "action" @@ -8,29 +10,8 @@ kind = "action" showstatus = True -#skipstep = { -# "checkavailable": "validTo >= 3600" -#} - -#availabletime = int(os.environ.get("AVAILABLE_DURATION",3)) - -#duration = availabletime - 1 - -#keys = [ -# { -# "keytitle": "option", -# "keyvalue": 1, -# }, -# { -# "keytitle": "duration", -# "keyvalue": duration, -# }, -#] - method = "GET" -#messageid = 49971192 - #path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}" #path = [ # "https://rentmasseur.com/api/v1/mailbox/", @@ -40,7 +21,7 @@ method = "GET" path = [ "https://rentmasseur.com/api/v1/mailbox/", { - "output": "messageid", + "output": "emails", "keys": [0, "id"] } ] @@ -54,10 +35,36 @@ headers = { }, } -outputs = { - "conversation": "messages" +recursive = { + "source": "emails", + "target": "id" } + +outputs = { + "message": "messages" +} + +#select = { +# "source": "message", +# "selectmethod": "include", + #"key": "id", +# "key": "seen", + #"value": {"emails": [0, "id"]}, +# "value": "false", +#} + +select = { + "source": "message", + "include": { + "key": "seen", + "value": False, + }, + "exclude": { + "key": "senderId", + "value": 238302, + } +} #prints = { # "message": "messages" #} diff --git a/plugins/rmass/actions/pullmessagelist.py b/plugins/rmass/actions/pullmessagelist.py index ced788b..eb5a888 100644 --- a/plugins/rmass/actions/pullmessagelist.py +++ b/plugins/rmass/actions/pullmessagelist.py @@ -29,6 +29,16 @@ method = "GET" #path = "https://rentmasseur.com/api/v1/mailbox?page=1&folder=1&sort=1" path = "https://rentmasseur.com/api/v1/mailbox" + + +#path = [ +# "https://rentmasseur.com/api/v1/mailbox/", +# { +# "output": "emails", +# "keys": [0, "id"] +# } +#] + headers = { "Authorization": { "output": "access_token", @@ -36,11 +46,23 @@ headers = { }, } +#select = { +# "source": "emails", +# "selectmethod": "exclude", +# "key": "unread", +# "value": 0, +#} + select = { "source": "emails", - "selectmethod": "exclude", - "key": "unread", - "value": 0, + "include": { + "key": {}, + "value": {}, + }, + "exclude": { + "key": "unread", + "value": 0, + } } outputs = { diff --git a/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc b/plugins/rmass/operations/__pycache__/pullmessagelist.cpython-314.pyc index 83b224864706e8f1601d7bebe9909e004528704e..a6a5ccac831ee669b24a6363a149bb9d6490e371 100644 GIT binary patch delta 77 zcmeys^p#0nn~#@^0SFp7&t~;8GB7*_abSQM%J{4^QC*cKmRXN^qTg3W^~o-b3j8-% R_&%_+ax*ot7x4g<0RSoG4kZ8p delta 72 zcmey$^npoTn~#@^0SHoM&Sdp7GB7*_abSQ6%J{4`QC*cuk7;7SS4Ne|Zj1^%A6Qwr LnVQ&(cz`MZ-sB9( diff --git a/plugins/rmass/operations/pullmessagelist.py b/plugins/rmass/operations/pullmessagelist.py index 2b32993..c0a98e5 100644 --- a/plugins/rmass/operations/pullmessagelist.py +++ b/plugins/rmass/operations/pullmessagelist.py @@ -7,7 +7,7 @@ kind = "operation" actions = [ refresh_tokens, pullmessagelist, - #getmessage, + getmessage, #setavailable, ] diff --git a/tokens.json b/tokens.json index c6b3d6b..e4c8335 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE4MTU5NzksIm5iZiI6MTc5MTgxNTc5OSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90a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