summaryrefslogtreecommitdiff
path: root/cad/src/dna/updater/fix_after_readmmp.py
blob: 5438efb4a7c03c753e9a87f3a4b7b86b9c723e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright 2008 Nanorex, Inc.  See LICENSE file for details. 
"""
fix_after_readmmp.py - helpers to fix dna-related structure after readmmp

@author: Bruce
@version: $Id$
@copyright: 2008 Nanorex, Inc.  See LICENSE file for details.
"""

from dna.updater.dna_updater_prefs import pref_fix_after_readmmp_before_updaters
from dna.updater.dna_updater_prefs import pref_fix_after_readmmp_after_updaters

def will_special_updates_after_readmmp_do_anything(assy):
    """
    Permit callers to optimize for the likely usual case
    of these debug_prefs both being off.
    """
    del assy
    if pref_fix_after_readmmp_before_updaters() or \
       pref_fix_after_readmmp_after_updaters():
        return True
    return False

def fix_after_readmmp_before_updaters(assy):
    if pref_fix_after_readmmp_before_updaters():
        ## print "\ndoing fix_after_readmmp_before_updaters"

        # note: this happens before updaters like dna updater and bond updater,
        # but not before update_parts has fixed the .part structure of assy.
        
        for part in assy.all_parts():
            part.enforce_permitted_members_in_groups( pre_updaters = True )
        pass
    return

def fix_after_readmmp_after_updaters(assy):
    if pref_fix_after_readmmp_after_updaters():
        ## print "\ndoing fix_after_readmmp_after_updaters"

        for part in assy.all_parts():
            part.enforce_permitted_members_in_groups( pre_updaters = False )
                # notice the different options than in before_updaters version
        pass
    return

# end