def get(scanner_class, properties): """ Returns an instance of previously registered scanner with the specified properties. """ scanner_name = str(scanner_class) if not registered(scanner_name): raise BaseException ("attempt to get unregisted scanner: %s" % scanner_name) relevant_properties = __scanners[scanner_name] r = property.select(relevant_properties, properties) scanner_id = scanner_name + '.' + '-'.join(r) if not __scanner_cache.has_key(scanner_name): __scanner_cache[scanner_name] = scanner_class(r) return __scanner_cache[scanner_name]
def get(scanner_class, properties): """ Returns an instance of previously registered scanner with the specified properties. """ assert issubclass(scanner_class, Scanner) assert is_iterable_typed(properties, basestring) scanner_name = str(scanner_class) if not registered(scanner_name): raise BaseException ("attempt to get unregistered scanner: %s" % scanner_name) relevant_properties = __scanners[scanner_name] r = property.select(relevant_properties, properties) scanner_id = scanner_name + '.' + '-'.join(r) if scanner_id not in __scanner_cache: __scanner_cache[scanner_id] = scanner_class(r) return __scanner_cache[scanner_id]
def __handle_flag_value(manager, value, properties): result = [] if get_grist(value): matches = property.select(value, properties) for p in matches: att = feature.attributes(get_grist(p)) ungristed = replace_grist(p, '') if 'dependency' in att: # the value of a dependency feature is a target # and must be actualized # FIXME: verify that 'find' actually works, ick! result.append(manager.targets().find(ungristed).actualize()) elif 'path' in att or 'free' in att: values = [] # Treat features with && in the value # specially -- each &&-separated element is considered # separate value. This is needed to handle searched # libraries, which must be in specific order. if not __re_two_ampersands.search(ungristed): values.append(ungristed) else: values.extend(value.split('&&')) result.extend(values) else: result.append(ungristed) else: result.append(value) return result
def __handle_flag_value (manager, value, properties): result = [] if get_grist (value): matches = property.select (value, properties) for p in matches: att = feature.attributes (get_grist (p)) ungristed = replace_grist (p, '') if 'dependency' in att: # the value of a dependency feature is a target # and must be actualized # FIXME: verify that 'find' actually works, ick! result.append (manager.targets ().find (ungristed).actualize ()) elif 'path' in att or 'free' in att: values = [] # Treat features with && in the value # specially -- each &&-separated element is considered # separate value. This is needed to handle searched # libraries, which must be in specific order. if not __re_two_ampersands.search (ungristed): values.append (ungristed) else: values.extend(value.split ('&&')) result.extend(values) else: result.append (ungristed) else: result.append (value) return result