def __init__(self, **kwargs):
        """Initialize the build rule.

        Args:
          **kwargs: Assorted parameters; see subclass implementations for
                    details.
        """
        self.address = self.name = address.new(kwargs['name'])
        # TODO: eliminate use of .name
        self.subgraph = None
        self.params = {}
        log.debug('New target: %s', self.address)

        try:
            for param_name, param_type in self.required_params:
                self.params[param_name] = kwargs.pop(param_name)
                assert isinstance(self.params[param_name], param_type)
        except AssertionError as err:
            if isinstance(param_type, tuple) and len(param_type) > 1:
                msg = 'one of: %s' % ', '.join(param_type.__name__)
            else:
                msg = str(param_type.__name__)
            raise error.InvalidRule(
                'While loading %s: Invalid type for %s. '
                'Expected: %s. Actual: %s.' % (
                    self.address, param_name, msg,
                    repr(self.params[param_name])))
        except KeyError as err:
            log.error(err)
            raise error.InvalidRule(
                'While loading %s: Required parameter %s not given.' % repr(
                    self.address, param_name))

        for (param_name, param_type, param_default) in self.optional_params:
            if param_name not in kwargs:
                self.params[param_name] = param_default
            else:
                self.params[param_name] = kwargs.pop(param_name)
                if not isinstance(self.params[param_name], param_type):
                    msg = str(param_type.__name__)
                    if isinstance(param_type, tuple) and len(param_type) > 1:
                        msg = 'one of: %s' % ', '.join(param_type.__name__)
                    raise error.InvalidRule(
                        'While loading %s: Invalid type for %s. '
                        'Expected: %s. Actual: %s.' % (
                            self.address, param_name, msg,
                            repr(self.params[param_name])))

        if kwargs:  # There are leftover arguments.
            raise error.InvalidRule(
                '[%s]: Unknown argument(s): %s' % (
                    self.address, ', '.join(kwargs.keys())))

        if self.graphcontext is not None:
            self.graphcontext.add_node(self.address, target_obj=self)
            # TODO: process deps here?

        try:
            self.validate_args()
        except AssertionError as err:
            raise error.InvalidRule('Error in %s: %s' % (self.address, err))
def __init__ ( self , ** kwargs ) : self . address = self . name = address . new ( kwargs [ 'name' ] ) self . subgraph = None self . params = { } log . debug ( 'New target: %s' , self . address ) try : for param_name , param_type in self . required_params : self . params [ param_name ] = kwargs . pop ( param_name ) assert isinstance ( self . params [ param_name ] , param_type ) except AssertionError as err : if isinstance ( param_type , tuple ) and len ( param_type ) > 1 : msg = 'one of: %s' % ', ' . join ( param_type . __name__ ) else : msg = str ( param_type . __name__ ) raise error . InvalidRule ( 'While loading %s: Invalid type for %s. ' 'Expected: %s. Actual: %s.' % ( self . address , param_name , msg , repr ( self . params [ param_name ] ) ) ) except KeyError as err : log . error ( err ) raise error . InvalidRule ( 'While loading %s: Required parameter %s not given.' % repr ( self . address , param_name ) ) for ( param_name , param_type , param_default ) in self . optional_params : if param_name not in kwargs : self . params [ param_name ] = param_default else : self . params [ param_name ] = kwargs . pop ( param_name ) if not isinstance ( self . params [ param_name ] , param_type ) : msg = str ( param_type . __name__ ) if isinstance ( param_type , tuple ) and len ( param_type ) > 1 : msg = 'one of: %s' % ', ' . join ( param_type . __name__ ) raise error . InvalidRule ( 'While loading %s: Invalid type for %s. ' 'Expected: %s. Actual: %s.' % ( self . address , param_name , msg , repr ( self . params [ param_name ] ) ) ) if kwargs : raise error . InvalidRule ( '[%s]: Unknown argument(s): %s' % ( self . address , ', ' . join ( kwargs . keys ( ) ) ) ) if self . graphcontext is not None : self . graphcontext . add_node ( self . address , target_obj = self ) try : self . validate_args ( ) except AssertionError as err : raise error . InvalidRule ( 'Error in %s: %s' % ( self . address , err ) )
Initialize the build rule.

        Args:
          **kwargs: Assorted parameters; see subclass implementations for
                    details.