@@ -77,55 +77,37 @@ def append_individual_image_meta(self, meta):
77
77
78
78
# Keys that are themselves Dnodes (subdirectories)
79
79
# neccessitate a new table
80
+ if isinstance (value , (dict , asdf .tags .core .ndarray .NDArrayType , QTable )):
81
+ continue
82
+
80
83
if isinstance (value , stnode .DNode ):
81
84
# Storage for keys and values
82
85
subtable_cols = []
83
86
subtable_vals = []
84
87
85
88
# Loop over items within the node
86
89
for subkey , subvalue in meta_dict [key ].items ():
87
- # Skip ndarrays
88
- if isinstance (subvalue , asdf .tags .core .ndarray .NDArrayType ):
89
- continue
90
- # Skip QTables
91
- if isinstance (subvalue , QTable ):
90
+ # Skip ndarrays and QTables
91
+ if isinstance (subvalue , (asdf .tags .core .ndarray .NDArrayType , QTable )):
92
92
continue
93
93
94
94
subtable_cols .append (subkey )
95
-
96
- if isinstance (subvalue , (list , dict )):
97
- subtable_vals .append ([str (subvalue )])
98
- else :
99
- subtable_vals .append ([subvalue ])
95
+ subtable_vals .append ([str (subvalue )] if isinstance (subvalue , (list , dict )) else [subvalue ])
100
96
101
97
# Skip this Table if it would be empty
102
- if len (subtable_vals ) == 0 :
103
- continue
104
-
105
- # Make new Keyword Table if needed
106
- if (key not in self .meta .individual_image_meta ) or (self .meta .individual_image_meta [key ].colnames == ["dummy" ]):
107
- self .meta .individual_image_meta [key ] = QTable (names = subtable_cols , data = subtable_vals )
108
- else :
109
- # Append to existing table
110
- self .meta .individual_image_meta [key ].add_row (subtable_vals )
111
- # Skip non-schema metas
112
- elif isinstance (value , dict ):
113
- continue
114
- # Skip ndarrays
115
- elif isinstance (value .strip (), asdf .tags .core .ndarray .NDArrayType ):
116
- continue
117
- # Skip QTables
118
- elif isinstance (value , QTable ):
119
- continue
98
+ if subtable_vals :
99
+ # Make new Keyword Table if needed
100
+ if (key not in self .meta .individual_image_meta ) or (
101
+ self .meta .individual_image_meta [key ].colnames == ["dummy" ]
102
+ ):
103
+ self .meta .individual_image_meta [key ] = QTable (names = subtable_cols , data = subtable_vals )
104
+ else :
105
+ # Append to existing table
106
+ self .meta .individual_image_meta [key ].add_row (subtable_vals )
120
107
else :
121
108
# Store Basic keyword
122
109
basic_cols .append (key )
123
-
124
- # Store value (lists converted to strings)
125
- if isinstance (value .strip (), list ):
126
- basic_vals .append ([str (value )])
127
- else :
128
- basic_vals .append ([value ])
110
+ basic_vals .append ([str (value )] if isinstance (value , list ) else [value ])
129
111
130
112
# Make Basic Table if needed
131
113
if self .meta .individual_image_meta .basic .colnames == ["dummy" ]:
0 commit comments