Exemplo n.º 1
0
    def get(cls, address):
        """Returns the specified module target if already parsed; otherwise, parses the buildfile in the
    context of its parent directory and returns the parsed target."""
        def lookup():
            return Target._targets_by_address[
                address] if address in Target._targets_by_address else None

        target = lookup()
        if target:
            return target
        else:
            ParseContext(address.buildfile).parse()
            return lookup()
Exemplo n.º 2
0
    def get_all_addresses(cls, buildfile):
        """Returns all of the target addresses in the specified buildfile if already parsed; otherwise,
    parses the buildfile to find all the addresses it contains and then returns them."""
        def lookup():
            if buildfile in Target._addresses_by_buildfile:
                return Target._addresses_by_buildfile[buildfile]
            else:
                return None

        addresses = lookup()
        if addresses:
            return addresses
        else:
            ParseContext(buildfile).parse()
            return lookup()
Exemplo n.º 3
0
 def locate(self):
   parse_context = ParseContext.locate()
   return Address(parse_context.buildfile, self.name, self.is_meta)
Exemplo n.º 4
0
  def _post_construct(self, func, *args, **kwargs):
    """Registers a command to invoke after this target's BUILD file is parsed."""

    ParseContext.locate().on_context_exit(func, *args, **kwargs)
Exemplo n.º 5
0
 def locate(self):
     parse_context = ParseContext.locate()
     return Address(parse_context.buildfile, self.name, self.is_meta)
Exemplo n.º 6
0
 def do_in_context(self, work):
     return ParseContext(self.address.buildfile).do_in_context(work)