From 25028b6df27cbb754916aca7d824726aac66f298 Mon Sep 17 00:00:00 2001 From: phowell Date: Thu, 23 Mar 2023 11:48:10 -0700 Subject: [PATCH] recur_matcher didnt belong in depricated --- curric2022.py | 25 +++++++++++++++++++++++++ depricated.py | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/curric2022.py b/curric2022.py index 196f344..77f77f2 100644 --- a/curric2022.py +++ b/curric2022.py @@ -88,6 +88,31 @@ def clean(st): +def recur_matcher(item, depth=0): + indent = depth * " " + my_result_lines = [] + if type(item) == type({}): + if not match( item, + {'entityMetadata': {'entityTitle': _,'status': _, 'entityType':_, 'entityId':_ }}, + lambda title,status,typ,id: + my_result_lines.append("%s%s: %s (id %s) status: %s" % (indent, str(typ), str(title), str(id), str(status))) , + {'attributes': {'displayName': _}, 'lookUpDisplay': _, }, + lambda x,y: my_result_lines.append("%s%s: %s" % (indent, clean(str(x)), clean(str(y)))) , + {'attributes': {'displayName': _}, 'fieldValue': _, }, + lambda x,y: my_result_lines.append("%s%s: %s" % (indent, clean(str(x)), clean(str(y)))) , + {'sectionName': _}, + lambda x: my_result_lines.append("%sSection: %s" % (indent, str(x))) , + _, nothing + ): + for K,V in list(item.items()): + my_result_lines.extend(recur_matcher(V,depth+1)) + elif type(item) == type([]): + for V in item: + my_result_lines.extend(recur_matcher(V,depth+1)) + return my_result_lines + + + num_failed_course = 1 def single_course_parse(c): diff --git a/depricated.py b/depricated.py index 91a2a21..bdedc76 100644 --- a/depricated.py +++ b/depricated.py @@ -365,31 +365,6 @@ def sampleclass(): recur_look_for_leafs(theclass) print(leafcount) print(sorted(displaynames)) - - - -def recur_matcher(item, depth=0): - indent = depth * " " - my_result_lines = [] - if type(item) == type({}): - if not match( item, - {'entityMetadata': {'entityTitle': _,'status': _, 'entityType':_, 'entityId':_ }}, - lambda title,status,typ,id: - my_result_lines.append("%s%s: %s (id %s) status: %s" % (indent, str(typ), str(title), str(id), str(status))) , - {'attributes': {'displayName': _}, 'lookUpDisplay': _, }, - lambda x,y: my_result_lines.append("%s%s: %s" % (indent, clean(str(x)), clean(str(y)))) , - {'attributes': {'displayName': _}, 'fieldValue': _, }, - lambda x,y: my_result_lines.append("%s%s: %s" % (indent, clean(str(x)), clean(str(y)))) , - {'sectionName': _}, - lambda x: my_result_lines.append("%sSection: %s" % (indent, str(x))) , - _, nothing - ): - for K,V in list(item.items()): - my_result_lines.extend(recur_matcher(V,depth+1)) - elif type(item) == type([]): - for V in item: - my_result_lines.extend(recur_matcher(V,depth+1)) - return my_result_lines