Build the getters support matrix.
428060
def build_getters_support_matrix(app):
    """"""
    status = subprocess.call("./test.sh", stdout=sys.stdout, stderr=sys.stderr)

    if status != 0:
        print("Something bad happened when processing the test reports.")
        sys.exit(-1)

    drivers = set()
    matrix = {
        m: defaultdict(dict)
        for m in dir(NetworkDriver)
        if not (m.startswith("_") or m in EXCLUDE_METHODS)
    }

    regex_name = re.compile(r"(?P<driver>\w+)\/.*::test_(?P<getter>\w+)")

    filename = "./support/tests/report.json"
    with open(filename, "r") as f:
        data = json.loads(f.read())
        for test in data["report"]["tests"]:
            match = regex_name.search(test["name"])
            if match:
                driver = match.group("driver")
                drivers.add(driver)
                method = match.group("getter")
            else:
                continue
            if method in EXCLUDE_IN_REPORT:
                continue
            result = test["outcome"]

            if method in METHOD_ALIASES.keys():
                method = METHOD_ALIASES[method]

            intermediate_result = matrix[method].get(driver, None)
            matrix[method][driver] = _merge_results(result, intermediate_result)

    sorted_methods = sorted(matrix.keys())
    drivers = sorted(drivers)
    env = Environment(loader=FileSystemLoader("."))
    template_file = env.get_template("matrix.j2")
    rendered_template = template_file.render(
        matrix=matrix, drivers=drivers, sorted_methods=sorted_methods
    )

    with open("support/matrix.rst", "w") as f:
        f.write(rendered_template)
199963
def generate_base(model, model_dict, config, manifest, source_config,
                  provider, adapter=None):
    """"""
    if provider is None:
        raise dbt.exceptions.InternalException(
            "Invalid provider given to context: {}".format(provider))

    target_name = config.target_name
    target = config.to_profile_info()
    del target['credentials']
    target.update(config.credentials.serialize(with_aliases=True))
    target['type'] = config.credentials.type
    target.pop('pass', None)
    target['name'] = target_name

    adapter = get_adapter(config)

    context = {'env': target}

    pre_hooks = None
    post_hooks = None

    db_wrapper = DatabaseWrapper(adapter)

    context = dbt.utils.merge(context, {
        "adapter": db_wrapper,
        "api": {
            "Relation": db_wrapper.Relation,
            "Column": adapter.Column,
        },
        "column": adapter.Column,
        "config": provider.Config(model_dict, source_config),
        "database": config.credentials.database,
        "env_var": env_var,
        "exceptions": dbt.exceptions.wrapped_exports(model),
        "execute": provider.execute,
        "flags": dbt.flags,
        # TODO: Do we have to leave this in?
        "graph": manifest.to_flat_graph(),
        "log": log,
        "model": model_dict,
        "modules": {
            "pytz": get_pytz_module_context(),
            "datetime": get_datetime_module_context(),
        },
        "post_hooks": post_hooks,
        "pre_hooks": pre_hooks,
        "ref": provider.ref(db_wrapper, model, config, manifest),
        "return": _return,
        "schema": config.credentials.schema,
        "sql": None,
        "sql_now": adapter.date_function(),
        "source": provider.source(db_wrapper, model, config, manifest),
        "fromjson": fromjson,
        "tojson": tojson,
        "target": target,
        "try_or_compiler_error": try_or_compiler_error(model)
    })

    return context
1235200
def build(self, **values: Any) -> str:
        """"""
        converted_values = {
            key: self._converters[key].to_url(value)
            for key, value in values.items()
            if key in self._converters
        }
        result = self._builder.format(**converted_values).split('|', 1)[1]
        query_string = urlencode(
            {
                key: value
                for key, value in values.items()
                if key not in self._converters and key not in self.defaults
            },
            doseq=True,
        )
        if query_string:
            result = "{}?{}".format(result, query_string)
        return result
271711
def as_models(self, klass):
        """"""
        try:
            return [klass(mod) for mod in self.tree.reply.data.results.array[0].item]
        except AttributeError:
            return []
79245
def _add_list_getter(self):
        
        prop_name = '%s_lst' % self._prop_name
        property_ = property(self._list_getter, None, None)
        setattr(self._element_cls, prop_name, property_)
628625
def _compute_sources_for_target(self, target):
    """"""
    def resolve_target_sources(target_sources):
      resolved_sources = []
      for tgt in target_sources:
        if tgt.has_sources():
          resolved_sources.extend(tgt.sources_relative_to_buildroot())
      return resolved_sources

    sources = [s for s in target.sources_relative_to_buildroot() if self._sources_predicate(s)]
    # TODO: Make this less hacky. Ideally target.java_sources will point to sources, not targets.
    if hasattr(target, 'java_sources') and target.java_sources:
      sources.extend(resolve_target_sources(target.java_sources))
    return sources
328180
def _build_dependent_model_list(self, obj_schema):
        '''
        
        '''
        dep_models_list = []

        if obj_schema:
            obj_schema['type'] = obj_schema.get('type', 'object')
        if obj_schema['type'] == 'array':
            dep_models_list.extend(self._build_dependent_model_list(obj_schema.get('items', {})))
        else:
            ref = obj_schema.get('$ref')
            if ref:
                ref_obj_model = ref.split("/")[-1]
                ref_obj_schema = self._models().get(ref_obj_model)
                dep_models_list.extend(self._build_dependent_model_list(ref_obj_schema))
                dep_models_list.extend([ref_obj_model])
            else:
                # need to walk each property object
                properties = obj_schema.get('properties')
                if properties:
                    for _, prop_obj_schema in six.iteritems(properties):
                        dep_models_list.extend(self._build_dependent_model_list(prop_obj_schema))
        return list(set(dep_models_list))
404270
def cast(keys, data):
        """"""
        matrix = Matrix()
        matrix.keys = keys
        matrix.data = data
        return matrix
1157480
def fetch_build_eggs(self, requires):
        """"""
        resolved_dists = pkg_resources.working_set.resolve(
            pkg_resources.parse_requirements(requires),
            installer=self.fetch_build_egg,
            replace_conflicting=True,
        )
        for dist in resolved_dists:
            pkg_resources.working_set.add(dist, replace=True)
        return resolved_dists
702852
def build_assets():
    """"""
    cwd = os.getcwd()
    try:
        from webassets.script import GenericArgparseImplementation
        from django_assets.env import get_env
        prog = "%s assets" % os.path.basename(sys.argv[0])
        impl = GenericArgparseImplementation(
            env=get_env(), log=LOGGER, no_global_options=True, prog=prog)
        impl.run_with_argv(["build"])
    except ImportError:
        pass
    os.chdir(cwd)
240090
def _build_inheritance_chain(cls, bases, *names, merge=False):
        """"""
        result = []
        for name in names:
            maps = []
            for base in bases:
                bmap = getattr(base, name, None)
                if bmap is not None:
                    assert isinstance(bmap, (dict, ChainMap))
                    if len(bmap):
                        if isinstance(bmap, ChainMap):
                            maps.extend(bmap.maps)
                        else:
                            maps.append(bmap)
            result.append(ChainMap({}, *maps))
        if merge:
            result = [dict(map) for map in result]
        if len(names) == 1:
            return result[0]
        return result
1341496
def _setup_gin():
  """"""
  # Imports for configurables
  # pylint: disable=g-import-not-at-top,unused-import,g-bad-import-order,reimported,unused-variable
  from tensor2tensor.trax import models as _trax_models
  from tensor2tensor.trax import optimizers as _trax_opt
  # pylint: disable=g-import-not-at-top,unused-import,g-bad-import-order,reimported,unused-variable

  configs = FLAGS.config or []
  # Override with --dataset and --model
  if FLAGS.dataset:
    configs.append("inputs.dataset_name='%s'" % FLAGS.dataset)
    if FLAGS.data_dir:
      configs.append("inputs.data_dir='%s'" % FLAGS.data_dir)
  if FLAGS.model:
    configs.append("train.model=@trax.models.%s" % FLAGS.model)
  gin.parse_config_files_and_bindings(FLAGS.config_file, configs)
107467
def to_api_repr(self):
        """"""

        source_refs = [
            {
                "projectId": table.project,
                "datasetId": table.dataset_id,
                "tableId": table.table_id,
            }
            for table in self.sources
        ]

        configuration = self._configuration.to_api_repr()
        _helpers._set_sub_prop(configuration, ["copy", "sourceTables"], source_refs)
        _helpers._set_sub_prop(
            configuration,
            ["copy", "destinationTable"],
            {
                "projectId": self.destination.project,
                "datasetId": self.destination.dataset_id,
                "tableId": self.destination.table_id,
            },
        )

        return {
            "jobReference": self._properties["jobReference"],
            "configuration": configuration,
        }
269558
def build(self, db=None, safe_mode=False, for_each_inst=None, extra=None):
        """"""
        result = copy(self.initial)
        result.update(self.static)
        if self.dynamic:
            result.update(self.build_dynamic(db, extra=extra, safe_mode=safe_mode))
        if self.for_each and for_each_inst:
            result.update(self.build_for_each(db, safe_mode=safe_mode, extra=extra))
        if isinstance(extra, dict):
            result.update(extra)
        return result
552365
def _build_brokers(self, brokers):
        """"""
        for broker_id, metadata in six.iteritems(brokers):
            self.brokers[broker_id] = self._create_broker(broker_id, metadata)
73271
def _roots_to_targets(self, build_graph, target_roots):
    """"""
    with self._run_tracker.new_workunit(name='parse', labels=[WorkUnitLabel.SETUP]):
      return [
        build_graph.get_target(address)
        for address
        in build_graph.inject_roots_closure(target_roots, self._fail_fast)
      ]
1080868
def _build_all_dependencies(self):
        '''
        
        '''
        ret = {}
        for model, schema in six.iteritems(self._models()):
            dep_list = self._build_dependent_model_list(schema)
            ret[model] = dep_list
        return ret