lmaurits / BEASTling

A linguistics-focussed command line tool for generating BEAST XML files.
BSD 2-Clause "Simplified" License
20 stars 6 forks source link

Refactored beastrun_tests and validate_ids #239

Closed xrotwang closed 5 years ago

xrotwang commented 5 years ago
xrotwang commented 5 years ago

Ah, yes, duplicating was more of an oversight. I'd now unify it, I guess, turning references into a Counter as well, and reducing the code to:

           for attr, collection in [('id', ids), ('idref', references)]:
               if attrib == attr:
                    if e in parent_map and parent_map[e].tag == 'plate':
                        # Quick and dirty plate handling.
                        # We only support plate matching in direct children of the plate.
                        var = parent_map[e].get('var')
                        for id_ in parent_map[e].get('range').split(','):
                            collection.update([value.replace('$({0})'.format(var), id_)])
                    else:
                        collection.update([value])