<commit_before># Copyright Google Inc. All Rights Reserved.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.io/license
"""Implementation of the ng_module rule.
"""

load(":rules_typescript.bzl",
    "tsc_wrapped_tsconfig",
    "COMMON_ATTRIBUTES",
    "COMMON_OUTPUTS",
    "compile_ts",
    "DEPS_ASPECTS",
    "ts_providers_dict_to_struct",
)

def _basename_of(ctx, file):
  ext_len = len(".ts")
  if file.short_path.endswith(".ng.html"):
    ext_len = len(".ng.html")
  elif file.short_path.endswith(".html"):
    ext_len = len(".html")
  return file.short_path[len(ctx.label.package) + 1:-ext_len]

def _flat_module_out_file(ctx):
  """Provide a default for the flat_module_out_file attribute.

  We cannot use the default="" parameter of ctx.attr because the value is calculated
  from other attributes (name)

  Args:
    ctx: skylark rule execution context

  Returns:
    a basename used for the flat module out (no extension)
  """
  if hasattr(ctx.attr, "flat_module_out_file") and ctx.attr.flat_module_out_file:
    return ctx.attr.flat_module_out_file
  return "%s_public_index" % ctx.label.name

def _should_produce_flat_module_outs(ctx):
  """Should we produce flat module outputs.

  We only produce flat module outs when we expect the ng_module is meant to be published,
  based on the presence of the module_name attribute.

  Args:
    ctx: skylark rule execution context

  Returns:
    true iff we should run the bundle_index_host to produce flat module metadata and bundle index
  """
  return bool(ctx.attr.module_name)

# Calculate the expected output of the template compiler for every source in
# in the library. Most of these will be produced as empty files but it is
# unknown, without parsing, which will be empty.
def _expected_outs(ctx):
  devmode_js_files = []
  closure_js_files = []
  declaration_files = []
  summary_files = []
  metadata_files = []

  factory_basename_set = depset([_basename_of(ctx, src) for src in ctx.files.factories])<commit_msg>fix(bazel): don't try to do flatmoduleindex under Blaze (#23083)<commit_after># Copyright Google Inc. All Rights Reserved.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.io/license
"""Implementation of the ng_module rule.
"""

load(":rules_typescript.bzl",
    "tsc_wrapped_tsconfig",
    "COMMON_ATTRIBUTES",
    "COMMON_OUTPUTS",
    "compile_ts",
    "DEPS_ASPECTS",
    "ts_providers_dict_to_struct",
)

def _basename_of(ctx, file):
  ext_len = len(".ts")
  if file.short_path.endswith(".ng.html"):
    ext_len = len(".ng.html")
  elif file.short_path.endswith(".html"):
    ext_len = len(".html")
  return file.short_path[len(ctx.label.package) + 1:-ext_len]

def _flat_module_out_file(ctx):
  """Provide a default for the flat_module_out_file attribute.

  We cannot use the default="" parameter of ctx.attr because the value is calculated
  from other attributes (name)

  Args:
    ctx: skylark rule execution context

  Returns:
    a basename used for the flat module out (no extension)
  """
  if hasattr(ctx.attr, "flat_module_out_file") and ctx.attr.flat_module_out_file:
    return ctx.attr.flat_module_out_file
  return "%s_public_index" % ctx.label.name

def _should_produce_flat_module_outs(ctx):
  """Should we produce flat module outputs.

  We only produce flat module outs when we expect the ng_module is meant to be published,
  based on the presence of the module_name attribute.

  Args:
    ctx: skylark rule execution context

  Returns:
    true iff we should run the bundle_index_host to produce flat module metadata and bundle index
  """
  is_bazel = not hasattr(native, "genmpm")
  return is_bazel and ctx.attr.module_name

# Calculate the expected output of the template compiler for every source in
# in the library. Most of these will be produced as empty files but it is
# unknown, without parsing, which will be empty.
def _expected_outs(ctx):
  devmode_js_files = []
  closure_js_files = []
  declaration_files = []
  summary_files = []
  metadata_files = []

  factory_basename_set = depset([_basename_of(ctx, src) for src in ctx.files.factories])
{'fraction_non_alphanumeric': 0.09215825633736081, 'fraction_numerical': 0.001658374792703151, 'mean_word_length': 4.251243781094527, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '950289', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1324, 'n_words': 441}