| 208 | keep = set() |
| 209 | |
| 210 | def queueForRemoval(tree): |
| 211 | global remove |
| 212 | if tree not in config.get("trees", {}): |
| 213 | return |
| 214 | mytree = trees[tree] |
| 215 | if options.verbose > 0: |
| 216 | print("* %s: %d items" % (tree, len(mytree["locs"]))) |
| 217 | # do varible substitution for this tree here |
| 218 | if isinstance(config["trees"][tree], basestring): |
| 219 | treeStr = config["trees"][tree] |
| 220 | if options.verbose > 5: |
| 221 | print(" Substituting $%s for tree %s" % (treeStr, tree)) |
| 222 | if treeStr not in config.get("variables", {}): |
| 223 | print(" ERROR: no variable: variables.%s for tree %s" % (treeStr, tree)) |
| 224 | sys.exit(1) |
| 225 | config["trees"][tree] = config["variables"][treeStr] |
| 226 | myconfig = config["trees"][tree] |
| 227 | if options.verbose > 4: |
| 228 | print(" Config: %s" % (myconfig)) |
| 229 | # Process this tree |
| 230 | if(len(myconfig)==0 or len(mytree["locs"])==0): |
| 231 | if(options.verbose>2): |
| 232 | print(" No processing for %s - skipping" % (tree)) |
| 233 | else: |
| 234 | only = None |
| 235 | if "only" in myconfig: |
| 236 | only = set(myconfig["only"]) |
| 237 | if (len(only)==0) and (mytree["treeprefix"] != ""): |
| 238 | thePool = "%spool.res" % (mytree["treeprefix"]) |
| 239 | if (thePool in itemset): |
| 240 | if(options.verbose>0): |
| 241 | print("Removing %s because tree %s is empty." % (thePool, tree)) |
| 242 | remove.add(thePool) |
| 243 | else: |
| 244 | print("tree %s - no ONLY") |
| 245 | for l in range(len(mytree["locs"])): |
| 246 | loc = mytree["locs"][l] |
| 247 | if (only is not None) and not loc in only: |
| 248 | # REMOVE loc |
| 249 | toRemove = "%s%s%s" % (mytree["treeprefix"], loc, mytree["extension"]) |
| 250 | if(options.verbose>6): |
| 251 | print("Queueing for removal: %s" % toRemove) |
| 252 | remove.add(toRemove) |
| 253 | |
| 254 | def addTreeByType(tree, mytree): |
| 255 | if(options.verbose>1): |