# coding=utf-8
# Copyright 2016 Foursquare Labs Inc. All Rights Reserved.

from __future__ import (
  absolute_import,
  division,
  generators,
  nested_scopes,
  print_function,
  unicode_literals,
  with_statement,
)

from pants.task.task import Task
from pants.util.memo import memoized_property

from pants.contrib.buildgen.core.subsystems.buildgen_subsystem import BuildgenSubsystem


class BuildgenBase(Task):
  """"A base task that provides the buildgen subsystem to its implementers."""

  @classmethod
  def global_subsystems(cls):
    return super(BuildgenBase, cls).global_subsystems() + (BuildgenSubsystem.Factory,)

  @memoized_property
  def buildgen_subsystem(self):
    # TODO(pl): When pants is a proper library dep, remove this ignore.
    # pylint: disable=no-member
    return BuildgenSubsystem.Factory.global_instance().create()
