Skip to content

Commit

Permalink
Merge pull request #3 from Palani-SN/psn-max_cnf_parser
Browse files Browse the repository at this point in the history
Psn max cnf parser
  • Loading branch information
Palani-SN authored Jun 29, 2024
2 parents 7ebe37f + 8fcc348 commit 50e78fc
Show file tree
Hide file tree
Showing 109 changed files with 3,240 additions and 318 deletions.
6 changes: 6 additions & 0 deletions EXAMPLES/loosely_coupled/a/a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"subclasses": {
"aa": "loosely_coupled/a/aa/aa.json",
"ab": "loosely_coupled/a/ab/ab.json"
}
}
51 changes: 51 additions & 0 deletions EXAMPLES/loosely_coupled/a/a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from py4cli.maximal import cnf_parser

try:
from .aa.aa import AA
from .ab.ab import AB
except:
from aa.aa import AA
from ab.ab import AB

class A(cnf_parser):

# Path of files aa & ab to be passed in as arguments
def subclasses(self, aa:str, ab:str):
"""
a.yml:
subclasses:
aa: aa.yml
ab: ab.yml
a.json:
{
"subclasses": {
"aa": "aa.json",
"ab": "ab.json"
}
}
cmds:
1. python <__file__> a.yml
2. python <__file__> a.json
"""
results = {}
results["ret_aa"] = AA(aa).returned
results["ret_ab"] = AB(ab).returned
return results

if __name__ == '__main__':

import sys
import json

print(sys.argv)
obj = A()
print("")
if obj.returned:
out_dict = obj.returned.copy()
print(json.dumps(out_dict, indent=2, sort_keys=False), type(obj.returned))
else:
print(obj.returned, type(obj.returned))
4 changes: 4 additions & 0 deletions EXAMPLES/loosely_coupled/a/a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

subclasses:
aa: loosely_coupled/a/aa/aa.yml
ab: loosely_coupled/a/ab/ab.yml
24 changes: 24 additions & 0 deletions EXAMPLES/loosely_coupled/a/aa/aa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"sub_func": {
"aaa": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aab": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aac": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aad": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
}
}
}
66 changes: 66 additions & 0 deletions EXAMPLES/loosely_coupled/a/aa/aa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from py4cli.maximal import cnf_parser

class AA(cnf_parser):

# params aaa, aab, aac, aad to be passed in as arguments
def sub_func(self, aaa:dict, aab:dict, aac:dict, aad:dict):
"""
aa.yml:
sub_func:
aaa: { "k1": "v1", "k2": "v2", "k3": "v3" }
aab: { "k1": "v1", "k2": "v2", "k3": "v3" }
aac: { "k1": "v1", "k2": "v2", "k3": "v3" }
aad: { "k1": "v1", "k2": "v2", "k3": "v3" }
aa.json:
{
"subfunc": {
"aaa": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aab": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aac": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"aad": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
}
}
}
cmds:
1. python <__file__> aa.yml
2. python <__file__> aa.json
"""
results = {}
results["ret_aaa"] = aaa
results["ret_aab"] = aab
results["ret_aac"] = aac
results["ret_aad"] = aad
return results

if __name__ == '__main__':

import sys
import json

print(sys.argv)
obj = AA()
print("")
if obj.returned:
out_dict = obj.returned.copy()
print(json.dumps(out_dict, indent=2, sort_keys=False), type(obj.returned))
else:
print(obj.returned, type(obj.returned))
5 changes: 5 additions & 0 deletions EXAMPLES/loosely_coupled/a/aa/aa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sub_func:
aaa: { "k1": "v1", "k2": "v2", "k3": "v3" }
aab: { "k1": "v1", "k2": "v2", "k3": "v3" }
aac: { "k1": "v1", "k2": "v2", "k3": "v3" }
aad: { "k1": "v1", "k2": "v2", "k3": "v3" }
24 changes: 24 additions & 0 deletions EXAMPLES/loosely_coupled/a/ab/ab.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"sub_func": {
"aba": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abb": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abc": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abd": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
}
}
}
66 changes: 66 additions & 0 deletions EXAMPLES/loosely_coupled/a/ab/ab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from py4cli.maximal import cnf_parser

class AB(cnf_parser):

# params aba, abb, abc, abd to be passed in as arguments
def sub_func(self, aba:dict, abb:dict, abc:dict, abd:dict):
"""
ab.yml:
sub_func:
aba: { "k1": "v1", "k2": "v2", "k3": "v3" }
abb: { "k1": "v1", "k2": "v2", "k3": "v3" }
abc: { "k1": "v1", "k2": "v2", "k3": "v3" }
abd: { "k1": "v1", "k2": "v2", "k3": "v3" }
ab.json:
{
"subfunc": {
"aba": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abb": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abc": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"abd": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
}
}
}
cmds:
1. python <__file__> ab.yml
2. python <__file__> ab.json
"""
results = {}
results["ret_aba"] = aba
results["ret_abb"] = abb
results["ret_abc"] = abc
results["ret_abd"] = abd
return results

if __name__ == '__main__':

import sys
import json

print(sys.argv)
obj = AB()
print("")
if obj.returned:
out_dict = obj.returned.copy()
print(json.dumps(out_dict, indent=2, sort_keys=False), type(obj.returned))
else:
print(obj.returned, type(obj.returned))
5 changes: 5 additions & 0 deletions EXAMPLES/loosely_coupled/a/ab/ab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sub_func:
aba: {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
abb: {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
abc: {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
abd: {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
6 changes: 6 additions & 0 deletions EXAMPLES/loosely_coupled/b/b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"subclasses": {
"ba": "loosely_coupled/b/ba/ba.json",
"bb": "loosely_coupled/b/bb/bb.json"
}
}
51 changes: 51 additions & 0 deletions EXAMPLES/loosely_coupled/b/b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from py4cli.maximal import cnf_parser

try:
from .ba.ba import BA
from .bb.bb import BB
except:
from ba.ba import BA
from bb.bb import BB

class B(cnf_parser):

# Path of files ba & bb to be passed in as arguments
def subclasses(self, ba:str, bb:str):
"""
b.yml:
subclasses:
ba: ba.yml
bb: bb.yml
b.json:
{
"subclasses": {
"ba": "ba.json",
"bb": "bb.json"
}
}
cmds:
1. python <__file__> b.yml
2. python <__file__> b.json
"""
results = {}
results["ret_ba"] = BA(ba).returned
results["ret_bb"] = BB(bb).returned
return results

if __name__ == '__main__':

import sys
import json

print(sys.argv)
obj = B()
print("")
if obj.returned:
out_dict = obj.returned.copy()
print(json.dumps(out_dict, indent=2, sort_keys=False), type(obj.returned))
else:
print(obj.returned, type(obj.returned))
4 changes: 4 additions & 0 deletions EXAMPLES/loosely_coupled/b/b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

subclasses:
ba: loosely_coupled/b/ba/ba.yml
bb: loosely_coupled/b/bb/bb.yml
24 changes: 24 additions & 0 deletions EXAMPLES/loosely_coupled/b/ba/ba.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"sub_func": {
"baa": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"bab": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"bac": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
},
"bad": {
"k1": "v1",
"k2": "v2",
"k3": "v3"
}
}
}
Loading

0 comments on commit 50e78fc

Please sign in to comment.