|
@@ -53,27 +53,37 @@ class VectorXr(yaml.YAMLObject):
|
53
|
53
|
return "np.array(%r)" % (self.data)
|
54
|
54
|
|
55
|
55
|
from collections import OrderedDict
|
56
|
|
-def represent_ordereddict(dumper, data):
|
57
|
|
- value = []
|
58
|
|
- for item_key, item_value in data.items():
|
59
|
|
- node_key = dumper.represent_data(item_key)
|
60
|
|
- node_value = dumper.represent_data(item_value)
|
61
|
|
- value.append((node_key, node_value))
|
62
|
|
- return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
|
63
|
|
-yaml.add_representer(OrderedDict, represent_ordereddict)
|
|
56
|
+#def represent_ordereddict(dumper, data):
|
|
57
|
+# print("representing IN DA HOUSE!!!!!!!!!!!!!!!!!!!!!")
|
|
58
|
+# value = []
|
|
59
|
+# for item_key, item_value in data.items():
|
|
60
|
+# node_key = dumper.represent_data(item_key)
|
|
61
|
+# node_value = dumper.represent_data(item_value)
|
|
62
|
+# value.append((node_key, node_value))
|
|
63
|
+# return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
|
|
64
|
+#yaml.add_representer(OrderedDict, represent_ordereddict)
|
|
65
|
+
|
|
66
|
+def setup_yaml():
|
|
67
|
+ """ https://stackoverflow.com/a/8661021 """
|
|
68
|
+ represent_dict_order = lambda self, data: self.represent_mapping('tag:yaml.org,2002:map', data.items())
|
|
69
|
+ yaml.add_representer(OrderedDict, represent_dict_order)
|
|
70
|
+setup_yaml()
|
64
|
71
|
|
65
|
72
|
class AkvoYamlNode(yaml.YAMLObject):
|
66
|
73
|
yaml_tag = u'!AkvoData'
|
67
|
74
|
def __init__(self):
|
68
|
75
|
self.Akvo_VERSION = version
|
69
|
|
- self.Import = {}
|
|
76
|
+ self.Import = OrderedDict() # {}
|
70
|
77
|
self.Processing = OrderedDict()
|
71
|
|
- #self.ProcessingFlow = []
|
72
|
|
- #self.Data = {}
|
73
|
|
- # For going the other way, data import based on Yaml serialization,
|
|
78
|
+ #def __init__(self, node):
|
|
79
|
+ # self.Akvo_VERSION = node["version"]
|
|
80
|
+ # self.Import = OrderedDict( node["Import"] ) # {}
|
|
81
|
+ # self.Processing = OrderedDict( node["Processing"] )
|
74
|
82
|
def __repr__(self):
|
75
|
83
|
return "%s(name=%r, Akvo_VESION=%r, Import=%r, Processing=%r)" % (
|
76
|
|
- self.__class__.__name__, self.Akvo_VERSION, self.Import, OrderedDict(dict(self.Processing)) )
|
|
84
|
+ #self.__class__.__name__, self.Akvo_VERSION, self.Import, self.Processing )
|
|
85
|
+ self.__class__.__name__, self.Akvo_VERSION, self.Import, OrderedDict(self.Processing) )
|
|
86
|
+ #self.__class__.__name__, self.Akvo_VERSION, self.Import, OrderedDict(self.Processing))
|
77
|
87
|
|
78
|
88
|
try:
|
79
|
89
|
import thread
|
|
@@ -563,8 +573,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
563
|
573
|
# Window centres
|
564
|
574
|
|
565
|
575
|
with open(SaveStr, 'w') as outfile:
|
566
|
|
- for line in self.logText:
|
567
|
|
- outfile.write(line+"\n")
|
|
576
|
+ #for line in self.logText:
|
|
577
|
+ # outfile.write(line+"\n")
|
|
578
|
+ yaml.dump(self.YamlNode, outfile)
|
568
|
579
|
yaml.dump(INFO, outfile, default_flow_style=False)
|
569
|
580
|
|
570
|
581
|
def SavePreprocess(self):
|
|
@@ -604,8 +615,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
604
|
615
|
INFO["transFreq"] = self.RAWDataProc.transFreq
|
605
|
616
|
INFO["headerstr"] = str(self.headerstr)
|
606
|
617
|
INFO["log"] = yaml.dump( self.YamlNode ) #self.logText #MAK 20170127
|
607
|
|
-
|
608
|
|
- print ("YAML NODE", yaml.dump( self.YamlNode ) )
|
609
|
618
|
|
610
|
619
|
self.RAWDataProc.DATADICT["INFO"] = INFO
|
611
|
620
|
|
|
@@ -670,7 +679,15 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
670
|
679
|
#print ( self.RAWDataProc.DATADICT["INFO"]["log"] )
|
671
|
680
|
|
672
|
681
|
self.logText = self.RAWDataProc.DATADICT["INFO"]["log"] # YAML
|
673
|
|
- self.YamlNode = yaml.load( self.logText )
|
|
682
|
+
|
|
683
|
+ self.YamlNode = AkvoYamlNode( ) #self.logText )
|
|
684
|
+ self.YamlNode.Akvo_VERSION = (yaml.load( self.logText )).Akvo_VERSION
|
|
685
|
+ self.YamlNode.Import = OrderedDict((yaml.load( self.logText )).Import)
|
|
686
|
+ self.YamlNode.Processing = OrderedDict((yaml.load( self.logText )).Processing)
|
|
687
|
+ #self.YamlNode.Akvo_VERSION = 2 #yaml.load( self.logText )["Akvo_VERSION"] #, Loader=yaml.RoundTripLoader) # offending line!
|
|
688
|
+ #self.YamlNode = AkvoYamlNode( self.logText ) # offending line!
|
|
689
|
+ #print("import type", type( self.YamlNode.Processing ))
|
|
690
|
+ self.Log()
|
674
|
691
|
#self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
|
675
|
692
|
#except KeyError:
|
676
|
693
|
# pass
|
|
@@ -848,8 +865,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
848
|
865
|
#for line in nlogText:
|
849
|
866
|
# self.ui.logTextBrowser.append( line )
|
850
|
867
|
# self.logText.append( line )
|
851
|
|
-
|
852
|
|
- self.ui.logTextBrowser.clear()
|
|
868
|
+ self.ui.logTextBrowser.clear()
|
853
|
869
|
self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False) )
|
854
|
870
|
|
855
|
871
|
def disable(self):
|
|
@@ -954,7 +970,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
|
954
|
970
|
|
955
|
971
|
def calcQ(self):
|
956
|
972
|
if "Calc Q" not in self.YamlNode.Processing.keys():
|
|
973
|
+ print("In CalcQ", yaml.dump(self.YamlNode.Processing) )
|
957
|
974
|
self.YamlNode.Processing["Calc Q"] = True
|
|
975
|
+ print( yaml.dump(self.YamlNode.Processing) )
|
958
|
976
|
self.Log()
|
959
|
977
|
else:
|
960
|
978
|
err_msg = "Q values have already been calculated"
|