1.1 --- a/micropython/common.py Sun Jun 26 17:01:29 2011 +0200
1.2 +++ b/micropython/common.py Sun Jun 26 23:54:37 2011 +0200
1.3 @@ -260,6 +260,30 @@
1.4
1.5 return hasattr(node, "unit") and node.unit.parent.has_key(node.unit.name)
1.6
1.7 +def get_object_types_for_usage(usage, objtable, name, unit_name):
1.8 +
1.9 + """
1.10 + Return for the given attribute 'usage', using the 'objtable', the object
1.11 + types which satisfy such usage, reporting any problems for the given 'name'
1.12 + and 'unit_name'.
1.13 + """
1.14 +
1.15 + all_objtypes = set()
1.16 +
1.17 + for attrnames in usage:
1.18 + objtypes = objtable.all_possible_objects_plus_status(attrnames)
1.19 + if not objtypes:
1.20 + print "Warning: usage in %r for %r finds no object supporting all attributes %r" % (
1.21 + unit_name, name, attrnames)
1.22 + objtypes = objtable.any_possible_objects_plus_status(attrnames)
1.23 + if not objtypes:
1.24 + print "Warning: usage in %r for %r finds no object supporting any attributes %r" % (
1.25 + unit_name, name, attrnames)
1.26 +
1.27 + all_objtypes.update(objtypes)
1.28 +
1.29 + return all_objtypes
1.30 +
1.31 # Errors.
1.32
1.33 class ProcessingError(Exception):