Skip to content

Commit

Permalink
✨ prototype to support intermediate targets. step 1 for #335
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Oct 11, 2019
1 parent d7d66db commit 27e36bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion moban/core/mobanfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
extract_target,
extract_group_targets,
)
from .store import STORE

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -89,7 +90,8 @@ def handle_moban_file_v1(moban_file_configurations, command_line_options):

def handle_targets(merged_options, targets):
LOG.info("handling targets")
list_of_templating_parameters = parse_targets(merged_options, targets)
parse_targets(merged_options, targets)
list_of_templating_parameters = STORE.targets
jobs_for_each_engine = OrderedDict()

for target in list_of_templating_parameters:
Expand Down
11 changes: 11 additions & 0 deletions moban/core/mobanfile/store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Store:
def __init__(self):
self.targets = []
self.look_up_by_output = {}

def add(self, target):
self.targets.append(target)
self.look_up_by_output[target.output] = target


STORE = Store()
9 changes: 5 additions & 4 deletions moban/core/mobanfile/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from moban import core, constants, exceptions
from moban.externals import reporter
from moban.core.definitions import TemplateTarget
from moban.core.mobanfile.templates import handle_template
from .store import STORE
from .templates import handle_template

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -50,7 +51,7 @@ def parse_targets(options, targets):
for target in targets:
if constants.LABEL_OUTPUT in target:
for template_target in _handle_explicit_target(options, target):
yield template_target
STORE.add(template_target)
else:
for output, template_file in target.items():
if isinstance(template_file, str) is False:
Expand All @@ -60,12 +61,12 @@ def parse_targets(options, targets):
for template_target in _handle_group_target(
options, a_list_short_hand_targets, group_template_type
):
yield template_target
STORE.add(template_target)
else:
for template_target in _handle_implicit_target(
options, template_file, output
):
yield template_target
STORE.add(template_target)


def _handle_explicit_target(options, target):
Expand Down

0 comments on commit 27e36bd

Please sign in to comment.