Exemple #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()
Exemple #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()
Exemple #3
0
 def locate(self):
   parse_context = ParseContext.locate()
   return Address(parse_context.buildfile, self.name, self.is_meta)
Exemple #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)
Exemple #5
0
 def locate(self):
     parse_context = ParseContext.locate()
     return Address(parse_context.buildfile, self.name, self.is_meta)
Exemple #6
0
 def do_in_context(self, work):
     return ParseContext(self.address.buildfile).do_in_context(work)