Search is not available for this dataset
identifier
stringlengths 1
155
| parameters
stringlengths 2
6.09k
| docstring
stringlengths 11
63.4k
| docstring_summary
stringlengths 0
63.4k
| function
stringlengths 29
99.8k
| function_tokens
sequence | start_point
sequence | end_point
sequence | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
LegacyDatasource.add_batch_kwargs_generator | (self, name, class_name, **kwargs) | Add a BatchKwargGenerator to the datasource.
Args:
name (str): the name of the new BatchKwargGenerator to add
class_name: class of the BatchKwargGenerator to add
kwargs: additional keyword arguments will be passed directly to the new BatchKwargGenerator's constructor
Returns:
BatchKwargGenerator (BatchKwargGenerator)
| Add a BatchKwargGenerator to the datasource. | def add_batch_kwargs_generator(self, name, class_name, **kwargs):
"""Add a BatchKwargGenerator to the datasource.
Args:
name (str): the name of the new BatchKwargGenerator to add
class_name: class of the BatchKwargGenerator to add
kwargs: additional keyword arguments will be passed directly to the new BatchKwargGenerator's constructor
Returns:
BatchKwargGenerator (BatchKwargGenerator)
"""
kwargs["class_name"] = class_name
generator = self._build_batch_kwargs_generator(**kwargs)
if "batch_kwargs_generators" not in self._datasource_config:
self._datasource_config["batch_kwargs_generators"] = dict()
self._datasource_config["batch_kwargs_generators"][name] = kwargs
return generator | [
"def",
"add_batch_kwargs_generator",
"(",
"self",
",",
"name",
",",
"class_name",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"class_name\"",
"]",
"=",
"class_name",
"generator",
"=",
"self",
".",
"_build_batch_kwargs_generator",
"(",
"*",
"*",
"kwargs",
")",
"if",
"\"batch_kwargs_generators\"",
"not",
"in",
"self",
".",
"_datasource_config",
":",
"self",
".",
"_datasource_config",
"[",
"\"batch_kwargs_generators\"",
"]",
"=",
"dict",
"(",
")",
"self",
".",
"_datasource_config",
"[",
"\"batch_kwargs_generators\"",
"]",
"[",
"name",
"]",
"=",
"kwargs",
"return",
"generator"
] | [
221,
4
] | [
238,
24
] | python | en | ['en', 'ny', 'en'] | True |
LegacyDatasource._build_batch_kwargs_generator | (self, **kwargs) | Build a BatchKwargGenerator using the provided configuration and return the newly-built generator. | Build a BatchKwargGenerator using the provided configuration and return the newly-built generator. | def _build_batch_kwargs_generator(self, **kwargs):
"""Build a BatchKwargGenerator using the provided configuration and return the newly-built generator."""
generator = instantiate_class_from_config(
config=kwargs,
runtime_environment={"datasource": self},
config_defaults={
"module_name": "great_expectations.datasource.batch_kwargs_generator"
},
)
if not generator:
raise ClassInstantiationError(
module_name="great_expectations.datasource.batch_kwargs_generator",
package_name=None,
class_name=kwargs["class_name"],
)
return generator | [
"def",
"_build_batch_kwargs_generator",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"generator",
"=",
"instantiate_class_from_config",
"(",
"config",
"=",
"kwargs",
",",
"runtime_environment",
"=",
"{",
"\"datasource\"",
":",
"self",
"}",
",",
"config_defaults",
"=",
"{",
"\"module_name\"",
":",
"\"great_expectations.datasource.batch_kwargs_generator\"",
"}",
",",
")",
"if",
"not",
"generator",
":",
"raise",
"ClassInstantiationError",
"(",
"module_name",
"=",
"\"great_expectations.datasource.batch_kwargs_generator\"",
",",
"package_name",
"=",
"None",
",",
"class_name",
"=",
"kwargs",
"[",
"\"class_name\"",
"]",
",",
")",
"return",
"generator"
] | [
240,
4
] | [
256,
24
] | python | en | ['en', 'en', 'en'] | True |
LegacyDatasource.get_batch_kwargs_generator | (self, name) | Get the (named) BatchKwargGenerator from a datasource)
Args:
name (str): name of BatchKwargGenerator (default value is 'default')
Returns:
BatchKwargGenerator (BatchKwargGenerator)
| Get the (named) BatchKwargGenerator from a datasource) | def get_batch_kwargs_generator(self, name):
"""Get the (named) BatchKwargGenerator from a datasource)
Args:
name (str): name of BatchKwargGenerator (default value is 'default')
Returns:
BatchKwargGenerator (BatchKwargGenerator)
"""
if name in self._batch_kwargs_generators:
return self._batch_kwargs_generators[name]
elif (
"batch_kwargs_generators" in self._datasource_config
and name in self._datasource_config["batch_kwargs_generators"]
):
generator_config = copy.deepcopy(
self._datasource_config["batch_kwargs_generators"][name]
)
else:
raise ValueError(
"Unable to load batch kwargs generator %s -- no configuration found or invalid configuration."
% name
)
generator = self._build_batch_kwargs_generator(**generator_config)
self._batch_kwargs_generators[name] = generator
return generator | [
"def",
"get_batch_kwargs_generator",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_batch_kwargs_generators",
":",
"return",
"self",
".",
"_batch_kwargs_generators",
"[",
"name",
"]",
"elif",
"(",
"\"batch_kwargs_generators\"",
"in",
"self",
".",
"_datasource_config",
"and",
"name",
"in",
"self",
".",
"_datasource_config",
"[",
"\"batch_kwargs_generators\"",
"]",
")",
":",
"generator_config",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_datasource_config",
"[",
"\"batch_kwargs_generators\"",
"]",
"[",
"name",
"]",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Unable to load batch kwargs generator %s -- no configuration found or invalid configuration.\"",
"%",
"name",
")",
"generator",
"=",
"self",
".",
"_build_batch_kwargs_generator",
"(",
"*",
"*",
"generator_config",
")",
"self",
".",
"_batch_kwargs_generators",
"[",
"name",
"]",
"=",
"generator",
"return",
"generator"
] | [
258,
4
] | [
283,
24
] | python | en | ['en', 'en', 'en'] | True |
LegacyDatasource.list_batch_kwargs_generators | (self) | List currently-configured BatchKwargGenerator for this datasource.
Returns:
List(dict): each dictionary includes "name" and "type" keys
| List currently-configured BatchKwargGenerator for this datasource. | def list_batch_kwargs_generators(self):
"""List currently-configured BatchKwargGenerator for this datasource.
Returns:
List(dict): each dictionary includes "name" and "type" keys
"""
generators = []
if "batch_kwargs_generators" in self._datasource_config:
for key, value in self._datasource_config[
"batch_kwargs_generators"
].items():
generators.append({"name": key, "class_name": value["class_name"]})
return generators | [
"def",
"list_batch_kwargs_generators",
"(",
"self",
")",
":",
"generators",
"=",
"[",
"]",
"if",
"\"batch_kwargs_generators\"",
"in",
"self",
".",
"_datasource_config",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"_datasource_config",
"[",
"\"batch_kwargs_generators\"",
"]",
".",
"items",
"(",
")",
":",
"generators",
".",
"append",
"(",
"{",
"\"name\"",
":",
"key",
",",
"\"class_name\"",
":",
"value",
"[",
"\"class_name\"",
"]",
"}",
")",
"return",
"generators"
] | [
285,
4
] | [
299,
25
] | python | en | ['en', 'en', 'en'] | True |
LegacyDatasource.process_batch_parameters | (self, limit=None, dataset_options=None) | Use datasource-specific configuration to translate any batch parameters into batch kwargs at the datasource
level.
Args:
limit (int): a parameter all datasources must accept to allow limiting a batch to a smaller number of rows.
dataset_options (dict): a set of kwargs that will be passed to the constructor of a dataset built using
these batch_kwargs
Returns:
batch_kwargs: Result will include both parameters passed via argument and configured parameters.
| Use datasource-specific configuration to translate any batch parameters into batch kwargs at the datasource
level. | def process_batch_parameters(self, limit=None, dataset_options=None):
"""Use datasource-specific configuration to translate any batch parameters into batch kwargs at the datasource
level.
Args:
limit (int): a parameter all datasources must accept to allow limiting a batch to a smaller number of rows.
dataset_options (dict): a set of kwargs that will be passed to the constructor of a dataset built using
these batch_kwargs
Returns:
batch_kwargs: Result will include both parameters passed via argument and configured parameters.
"""
batch_kwargs = self._datasource_config.get("batch_kwargs", {})
if limit is not None:
batch_kwargs["limit"] = limit
if dataset_options is not None:
# Then update with any locally-specified reader options
if not batch_kwargs.get("dataset_options"):
batch_kwargs["dataset_options"] = dict()
batch_kwargs["dataset_options"].update(dataset_options)
return batch_kwargs | [
"def",
"process_batch_parameters",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"dataset_options",
"=",
"None",
")",
":",
"batch_kwargs",
"=",
"self",
".",
"_datasource_config",
".",
"get",
"(",
"\"batch_kwargs\"",
",",
"{",
"}",
")",
"if",
"limit",
"is",
"not",
"None",
":",
"batch_kwargs",
"[",
"\"limit\"",
"]",
"=",
"limit",
"if",
"dataset_options",
"is",
"not",
"None",
":",
"# Then update with any locally-specified reader options",
"if",
"not",
"batch_kwargs",
".",
"get",
"(",
"\"dataset_options\"",
")",
":",
"batch_kwargs",
"[",
"\"dataset_options\"",
"]",
"=",
"dict",
"(",
")",
"batch_kwargs",
"[",
"\"dataset_options\"",
"]",
".",
"update",
"(",
"dataset_options",
")",
"return",
"batch_kwargs"
] | [
302,
4
] | [
325,
27
] | python | en | ['en', 'en', 'sw'] | True |
LegacyDatasource.get_batch | (self, batch_kwargs, batch_parameters=None) | Get a batch of data from the datasource.
Args:
batch_kwargs: the BatchKwargs to use to construct the batch
batch_parameters: optional parameters to store as the reference description of the batch. They should
reflect parameters that would provide the passed BatchKwargs.
Returns:
Batch
| Get a batch of data from the datasource. | def get_batch(self, batch_kwargs, batch_parameters=None):
"""Get a batch of data from the datasource.
Args:
batch_kwargs: the BatchKwargs to use to construct the batch
batch_parameters: optional parameters to store as the reference description of the batch. They should
reflect parameters that would provide the passed BatchKwargs.
Returns:
Batch
"""
raise NotImplementedError | [
"def",
"get_batch",
"(",
"self",
",",
"batch_kwargs",
",",
"batch_parameters",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | [
328,
4
] | [
341,
33
] | python | en | ['en', 'en', 'en'] | True |
LegacyDatasource.get_available_data_asset_names | (self, batch_kwargs_generator_names=None) |
Returns a dictionary of data_asset_names that the specified batch kwarg
generator can provide. Note that some batch kwargs generators may not be
capable of describing specific named data assets, and some (such as
filesystem glob batch kwargs generators) require the user to configure
data asset names.
Args:
batch_kwargs_generator_names: the BatchKwargGenerator for which to get available data asset names.
Returns:
dictionary consisting of sets of generator assets available for the specified generators:
::
{
generator_name: {
names: [ (data_asset_1, data_asset_1_type), (data_asset_2, data_asset_2_type) ... ]
}
...
}
|
Returns a dictionary of data_asset_names that the specified batch kwarg
generator can provide. Note that some batch kwargs generators may not be
capable of describing specific named data assets, and some (such as
filesystem glob batch kwargs generators) require the user to configure
data asset names. | def get_available_data_asset_names(self, batch_kwargs_generator_names=None):
"""
Returns a dictionary of data_asset_names that the specified batch kwarg
generator can provide. Note that some batch kwargs generators may not be
capable of describing specific named data assets, and some (such as
filesystem glob batch kwargs generators) require the user to configure
data asset names.
Args:
batch_kwargs_generator_names: the BatchKwargGenerator for which to get available data asset names.
Returns:
dictionary consisting of sets of generator assets available for the specified generators:
::
{
generator_name: {
names: [ (data_asset_1, data_asset_1_type), (data_asset_2, data_asset_2_type) ... ]
}
...
}
"""
available_data_asset_names = {}
if batch_kwargs_generator_names is None:
batch_kwargs_generator_names = [
generator["name"] for generator in self.list_batch_kwargs_generators()
]
elif isinstance(batch_kwargs_generator_names, str):
batch_kwargs_generator_names = [batch_kwargs_generator_names]
for generator_name in batch_kwargs_generator_names:
generator = self.get_batch_kwargs_generator(generator_name)
available_data_asset_names[
generator_name
] = generator.get_available_data_asset_names()
return available_data_asset_names | [
"def",
"get_available_data_asset_names",
"(",
"self",
",",
"batch_kwargs_generator_names",
"=",
"None",
")",
":",
"available_data_asset_names",
"=",
"{",
"}",
"if",
"batch_kwargs_generator_names",
"is",
"None",
":",
"batch_kwargs_generator_names",
"=",
"[",
"generator",
"[",
"\"name\"",
"]",
"for",
"generator",
"in",
"self",
".",
"list_batch_kwargs_generators",
"(",
")",
"]",
"elif",
"isinstance",
"(",
"batch_kwargs_generator_names",
",",
"str",
")",
":",
"batch_kwargs_generator_names",
"=",
"[",
"batch_kwargs_generator_names",
"]",
"for",
"generator_name",
"in",
"batch_kwargs_generator_names",
":",
"generator",
"=",
"self",
".",
"get_batch_kwargs_generator",
"(",
"generator_name",
")",
"available_data_asset_names",
"[",
"generator_name",
"]",
"=",
"generator",
".",
"get_available_data_asset_names",
"(",
")",
"return",
"available_data_asset_names"
] | [
343,
4
] | [
379,
41
] | python | en | ['en', 'error', 'th'] | False |
run_migrations_offline | () | Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
| Run migrations in 'offline' mode. | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations() | [
"def",
"run_migrations_offline",
"(",
")",
":",
"url",
"=",
"config",
".",
"get_main_option",
"(",
"\"sqlalchemy.url\"",
")",
"context",
".",
"configure",
"(",
"url",
"=",
"url",
",",
"target_metadata",
"=",
"target_metadata",
",",
"literal_binds",
"=",
"True",
")",
"with",
"context",
".",
"begin_transaction",
"(",
")",
":",
"context",
".",
"run_migrations",
"(",
")"
] | [
34,
0
] | [
52,
32
] | python | en | ['en', 'nl', 'en'] | True |
run_migrations_online | () | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
| Run migrations in 'online' mode. | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
connectable = current_app.extensions['migrate'].db.get_engine()
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
)
with context.begin_transaction():
context.run_migrations() | [
"def",
"run_migrations_online",
"(",
")",
":",
"# this callback is used to prevent an auto-migration from being generated",
"# when there are no changes to the schema",
"# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html",
"def",
"process_revision_directives",
"(",
"context",
",",
"revision",
",",
"directives",
")",
":",
"if",
"getattr",
"(",
"config",
".",
"cmd_opts",
",",
"'autogenerate'",
",",
"False",
")",
":",
"script",
"=",
"directives",
"[",
"0",
"]",
"if",
"script",
".",
"upgrade_ops",
".",
"is_empty",
"(",
")",
":",
"directives",
"[",
":",
"]",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"'No changes in schema detected.'",
")",
"connectable",
"=",
"current_app",
".",
"extensions",
"[",
"'migrate'",
"]",
".",
"db",
".",
"get_engine",
"(",
")",
"with",
"connectable",
".",
"connect",
"(",
")",
"as",
"connection",
":",
"context",
".",
"configure",
"(",
"connection",
"=",
"connection",
",",
"target_metadata",
"=",
"target_metadata",
",",
"process_revision_directives",
"=",
"process_revision_directives",
",",
"*",
"*",
"current_app",
".",
"extensions",
"[",
"'migrate'",
"]",
".",
"configure_args",
")",
"with",
"context",
".",
"begin_transaction",
"(",
")",
":",
"context",
".",
"run_migrations",
"(",
")"
] | [
55,
0
] | [
84,
36
] | python | en | ['en', 'nl', 'it'] | False |
version | () |
Show Ambassador's version
|
Show Ambassador's version
| def version():
"""
Show Ambassador's version
"""
print("Ambassador %s" % __version__)
scout = Scout()
print("Ambassador Scout version %s" % scout.version)
print("Ambassador Scout semver %s" % scout.get_semver(scout.version))
result = scout.report(action="version", mode="cli")
show_notices(result, printer=stdout_printer) | [
"def",
"version",
"(",
")",
":",
"print",
"(",
"\"Ambassador %s\"",
"%",
"__version__",
")",
"scout",
"=",
"Scout",
"(",
")",
"print",
"(",
"\"Ambassador Scout version %s\"",
"%",
"scout",
".",
"version",
")",
"print",
"(",
"\"Ambassador Scout semver %s\"",
"%",
"scout",
".",
"get_semver",
"(",
"scout",
".",
"version",
")",
")",
"result",
"=",
"scout",
".",
"report",
"(",
"action",
"=",
"\"version\"",
",",
"mode",
"=",
"\"cli\"",
")",
"show_notices",
"(",
"result",
",",
"printer",
"=",
"stdout_printer",
")"
] | [
85,
0
] | [
98,
48
] | python | en | ['en', 'error', 'th'] | False |
showid | () |
Show Ambassador's installation ID
|
Show Ambassador's installation ID
| def showid():
"""
Show Ambassador's installation ID
"""
scout = Scout()
print("Ambassador Scout installation ID %s" % scout.install_id)
result= scout.report(action="showid", mode="cli")
show_notices(result, printer=stdout_printer) | [
"def",
"showid",
"(",
")",
":",
"scout",
"=",
"Scout",
"(",
")",
"print",
"(",
"\"Ambassador Scout installation ID %s\"",
"%",
"scout",
".",
"install_id",
")",
"result",
"=",
"scout",
".",
"report",
"(",
"action",
"=",
"\"showid\"",
",",
"mode",
"=",
"\"cli\"",
")",
"show_notices",
"(",
"result",
",",
"printer",
"=",
"stdout_printer",
")"
] | [
101,
0
] | [
111,
48
] | python | en | ['en', 'error', 'th'] | False |
dump | (config_dir_path: Parameter.REQUIRED, *,
secret_dir_path=None, watt=False, debug=False, debug_scout=False, k8s=False, recurse=False,
stats=False, nopretty=False, everything=False, aconf=False, ir=False, v2=False, v3=False, diag=False,
features=False, profile=False) |
Dump various forms of an Ambassador configuration for debugging
Use --aconf, --ir, and --envoy to control what gets dumped. If none are requested, the IR
will be dumped.
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
:param secret_dir_path: Directory into which to save secrets
:param watt: If set, input must be a WATT snapshot
:param debug: If set, generate debugging output
:param debug_scout: If set, generate debugging output
:param k8s: If set, assume configuration files are annotated K8s manifests
:param recurse: If set, recurse into directories below config_dir_path
:param stats: If set, dump statistics to stderr
:param nopretty: If set, do not pretty print the dumped JSON
:param aconf: If set, dump the Ambassador config
:param ir: If set, dump the IR
:param v2: If set, dump the Envoy V2 config
:param v3: If set, dump the Envoy V3 config
:param diag: If set, dump the Diagnostics overview
:param everything: If set, dump everything
:param features: If set, dump the feature set
:param profile: If set, profile with the cProfile module
|
Dump various forms of an Ambassador configuration for debugging | def dump(config_dir_path: Parameter.REQUIRED, *,
secret_dir_path=None, watt=False, debug=False, debug_scout=False, k8s=False, recurse=False,
stats=False, nopretty=False, everything=False, aconf=False, ir=False, v2=False, v3=False, diag=False,
features=False, profile=False):
"""
Dump various forms of an Ambassador configuration for debugging
Use --aconf, --ir, and --envoy to control what gets dumped. If none are requested, the IR
will be dumped.
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
:param secret_dir_path: Directory into which to save secrets
:param watt: If set, input must be a WATT snapshot
:param debug: If set, generate debugging output
:param debug_scout: If set, generate debugging output
:param k8s: If set, assume configuration files are annotated K8s manifests
:param recurse: If set, recurse into directories below config_dir_path
:param stats: If set, dump statistics to stderr
:param nopretty: If set, do not pretty print the dumped JSON
:param aconf: If set, dump the Ambassador config
:param ir: If set, dump the IR
:param v2: If set, dump the Envoy V2 config
:param v3: If set, dump the Envoy V3 config
:param diag: If set, dump the Diagnostics overview
:param everything: If set, dump everything
:param features: If set, dump the feature set
:param profile: If set, profile with the cProfile module
"""
if not secret_dir_path:
secret_dir_path = "/tmp/cli-secrets"
if not os.path.isdir(secret_dir_path):
secret_dir_path = os.path.dirname(secret_dir_path)
if debug:
logger.setLevel(logging.DEBUG)
if debug_scout:
logging.getLogger('ambassador.scout').setLevel(logging.DEBUG)
if everything:
aconf = True
ir = True
v2 = True
v3 = True
diag = True
features = True
elif not (aconf or ir or v2 or v3 or diag or features):
aconf = True
ir = True
v2 = True
v3 = False
diag = False
features = False
dump_aconf = aconf
dump_ir = ir
dump_v2 = v2
dump_v3 = v3
dump_diag = diag
dump_features = features
od = {}
diagconfig: Optional[EnvoyConfig] = None
_profile: Optional[cProfile.Profile] = None
_rc = 0
if profile:
_profile = cProfile.Profile()
_profile.enable()
try:
total_timer = Timer("total")
total_timer.start()
fetch_timer = Timer("fetch resources")
with fetch_timer:
aconf = Config()
fetcher = ResourceFetcher(logger, aconf)
if watt:
fetcher.parse_watt(open(config_dir_path, "r").read())
else:
fetcher.load_from_filesystem(config_dir_path, k8s=k8s, recurse=True)
load_timer = Timer("load fetched resources")
with load_timer:
aconf.load_all(fetcher.sorted())
# aconf.post_error("Error from string, boo yah")
# aconf.post_error(RichStatus.fromError("Error from RichStatus"))
irgen_timer = Timer("ir generation")
with irgen_timer:
secret_handler = NullSecretHandler(logger, config_dir_path, secret_dir_path, "0")
ir = IR(aconf, file_checker=file_checker, secret_handler=secret_handler)
aconf_timer = Timer("aconf")
with aconf_timer:
if dump_aconf:
od['aconf'] = aconf.as_dict()
ir_timer = Timer("ir")
with ir_timer:
if dump_ir:
od['ir'] = ir.as_dict()
v2_timer = Timer("v2")
with v2_timer:
if dump_v2:
v2config = V2Config(ir)
diagconfig = v2config
od['v2'] = v2config.as_dict()
v3_timer = Timer("v3")
with v3_timer:
if dump_v3:
v3config = V3Config(ir)
diagconfig = v3config
od['v3'] = v3config.as_dict()
diag_timer = Timer("diag")
with diag_timer:
if dump_diag:
if not diagconfig:
diagconfig = V2Config(ir)
diagconfigv3 = V3Config(ir)
econf = typecast(EnvoyConfig, diagconfig)
econfv3 = typecast(EnvoyConfig, diagconfigv3)
diag = Diagnostics(ir, econf)
diagv3 = Diagnostics(ir, econfv3)
od['diag'] = diag.as_dict()
od['elements'] = econf.elements
od['diagv3'] = diagv3.as_dict()
od['elementsv3'] = econfv3.elements
features_timer = Timer("features")
with features_timer:
if dump_features:
od['features'] = ir.features()
# scout = Scout()
# scout_args = {}
#
# if ir and not os.environ.get("AMBASSADOR_DISABLE_FEATURES", None):
# scout_args["features"] = ir.features()
#
# result = scout.report(action="dump", mode="cli", **scout_args)
# show_notices(result)
dump_timer = Timer("dump JSON")
with dump_timer:
js = dump_json(od, pretty=not nopretty)
jslen = len(js)
write_timer = Timer("write JSON")
with write_timer:
sys.stdout.write(js)
sys.stdout.write("\n")
total_timer.stop()
route_count = 0
vhost_count = 0
filter_chain_count = 0
filter_count = 0
apiversion = 'v2' if v2 else 'v3'
if apiversion in od:
for listener in od[apiversion]['static_resources']['listeners']:
for fc in listener['filter_chains']:
filter_chain_count += 1
for f in fc['filters']:
filter_count += 1
for vh in f['typed_config']['route_config']['virtual_hosts']:
vhost_count += 1
route_count += len(vh['routes'])
if stats:
sys.stderr.write("STATS:\n")
sys.stderr.write(" config bytes: %d\n" % jslen)
sys.stderr.write(" vhosts: %d\n" % vhost_count)
sys.stderr.write(" filter chains: %d\n" % filter_chain_count)
sys.stderr.write(" filters: %d\n" % filter_count)
sys.stderr.write(" routes: %d\n" % route_count)
sys.stderr.write(" routes/vhosts: %.3f\n" % float(float(route_count)/float(vhost_count)))
sys.stderr.write("TIMERS:\n")
sys.stderr.write(" fetch resources: %.3fs\n" % fetch_timer.average)
sys.stderr.write(" load resources: %.3fs\n" % load_timer.average)
sys.stderr.write(" ir generation: %.3fs\n" % irgen_timer.average)
sys.stderr.write(" aconf: %.3fs\n" % aconf_timer.average)
sys.stderr.write(" envoy v2: %.3fs\n" % v2_timer.average)
sys.stderr.write(" diag: %.3fs\n" % diag_timer.average)
sys.stderr.write(" features: %.3fs\n" % features_timer.average)
sys.stderr.write(" dump json: %.3fs\n" % dump_timer.average)
sys.stderr.write(" write json: %.3fs\n" % write_timer.average)
sys.stderr.write(" ----------------------\n")
sys.stderr.write(" total: %.3fs\n" % total_timer.average)
except Exception as e:
handle_exception("EXCEPTION from dump", e,
config_dir_path=config_dir_path)
_rc = 1
if _profile:
_profile.disable()
_profile.dump_stats("ambassador.profile")
sys.exit(_rc) | [
"def",
"dump",
"(",
"config_dir_path",
":",
"Parameter",
".",
"REQUIRED",
",",
"*",
",",
"secret_dir_path",
"=",
"None",
",",
"watt",
"=",
"False",
",",
"debug",
"=",
"False",
",",
"debug_scout",
"=",
"False",
",",
"k8s",
"=",
"False",
",",
"recurse",
"=",
"False",
",",
"stats",
"=",
"False",
",",
"nopretty",
"=",
"False",
",",
"everything",
"=",
"False",
",",
"aconf",
"=",
"False",
",",
"ir",
"=",
"False",
",",
"v2",
"=",
"False",
",",
"v3",
"=",
"False",
",",
"diag",
"=",
"False",
",",
"features",
"=",
"False",
",",
"profile",
"=",
"False",
")",
":",
"if",
"not",
"secret_dir_path",
":",
"secret_dir_path",
"=",
"\"/tmp/cli-secrets\"",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"secret_dir_path",
")",
":",
"secret_dir_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"secret_dir_path",
")",
"if",
"debug",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"if",
"debug_scout",
":",
"logging",
".",
"getLogger",
"(",
"'ambassador.scout'",
")",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"if",
"everything",
":",
"aconf",
"=",
"True",
"ir",
"=",
"True",
"v2",
"=",
"True",
"v3",
"=",
"True",
"diag",
"=",
"True",
"features",
"=",
"True",
"elif",
"not",
"(",
"aconf",
"or",
"ir",
"or",
"v2",
"or",
"v3",
"or",
"diag",
"or",
"features",
")",
":",
"aconf",
"=",
"True",
"ir",
"=",
"True",
"v2",
"=",
"True",
"v3",
"=",
"False",
"diag",
"=",
"False",
"features",
"=",
"False",
"dump_aconf",
"=",
"aconf",
"dump_ir",
"=",
"ir",
"dump_v2",
"=",
"v2",
"dump_v3",
"=",
"v3",
"dump_diag",
"=",
"diag",
"dump_features",
"=",
"features",
"od",
"=",
"{",
"}",
"diagconfig",
":",
"Optional",
"[",
"EnvoyConfig",
"]",
"=",
"None",
"_profile",
":",
"Optional",
"[",
"cProfile",
".",
"Profile",
"]",
"=",
"None",
"_rc",
"=",
"0",
"if",
"profile",
":",
"_profile",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"_profile",
".",
"enable",
"(",
")",
"try",
":",
"total_timer",
"=",
"Timer",
"(",
"\"total\"",
")",
"total_timer",
".",
"start",
"(",
")",
"fetch_timer",
"=",
"Timer",
"(",
"\"fetch resources\"",
")",
"with",
"fetch_timer",
":",
"aconf",
"=",
"Config",
"(",
")",
"fetcher",
"=",
"ResourceFetcher",
"(",
"logger",
",",
"aconf",
")",
"if",
"watt",
":",
"fetcher",
".",
"parse_watt",
"(",
"open",
"(",
"config_dir_path",
",",
"\"r\"",
")",
".",
"read",
"(",
")",
")",
"else",
":",
"fetcher",
".",
"load_from_filesystem",
"(",
"config_dir_path",
",",
"k8s",
"=",
"k8s",
",",
"recurse",
"=",
"True",
")",
"load_timer",
"=",
"Timer",
"(",
"\"load fetched resources\"",
")",
"with",
"load_timer",
":",
"aconf",
".",
"load_all",
"(",
"fetcher",
".",
"sorted",
"(",
")",
")",
"# aconf.post_error(\"Error from string, boo yah\")",
"# aconf.post_error(RichStatus.fromError(\"Error from RichStatus\"))",
"irgen_timer",
"=",
"Timer",
"(",
"\"ir generation\"",
")",
"with",
"irgen_timer",
":",
"secret_handler",
"=",
"NullSecretHandler",
"(",
"logger",
",",
"config_dir_path",
",",
"secret_dir_path",
",",
"\"0\"",
")",
"ir",
"=",
"IR",
"(",
"aconf",
",",
"file_checker",
"=",
"file_checker",
",",
"secret_handler",
"=",
"secret_handler",
")",
"aconf_timer",
"=",
"Timer",
"(",
"\"aconf\"",
")",
"with",
"aconf_timer",
":",
"if",
"dump_aconf",
":",
"od",
"[",
"'aconf'",
"]",
"=",
"aconf",
".",
"as_dict",
"(",
")",
"ir_timer",
"=",
"Timer",
"(",
"\"ir\"",
")",
"with",
"ir_timer",
":",
"if",
"dump_ir",
":",
"od",
"[",
"'ir'",
"]",
"=",
"ir",
".",
"as_dict",
"(",
")",
"v2_timer",
"=",
"Timer",
"(",
"\"v2\"",
")",
"with",
"v2_timer",
":",
"if",
"dump_v2",
":",
"v2config",
"=",
"V2Config",
"(",
"ir",
")",
"diagconfig",
"=",
"v2config",
"od",
"[",
"'v2'",
"]",
"=",
"v2config",
".",
"as_dict",
"(",
")",
"v3_timer",
"=",
"Timer",
"(",
"\"v3\"",
")",
"with",
"v3_timer",
":",
"if",
"dump_v3",
":",
"v3config",
"=",
"V3Config",
"(",
"ir",
")",
"diagconfig",
"=",
"v3config",
"od",
"[",
"'v3'",
"]",
"=",
"v3config",
".",
"as_dict",
"(",
")",
"diag_timer",
"=",
"Timer",
"(",
"\"diag\"",
")",
"with",
"diag_timer",
":",
"if",
"dump_diag",
":",
"if",
"not",
"diagconfig",
":",
"diagconfig",
"=",
"V2Config",
"(",
"ir",
")",
"diagconfigv3",
"=",
"V3Config",
"(",
"ir",
")",
"econf",
"=",
"typecast",
"(",
"EnvoyConfig",
",",
"diagconfig",
")",
"econfv3",
"=",
"typecast",
"(",
"EnvoyConfig",
",",
"diagconfigv3",
")",
"diag",
"=",
"Diagnostics",
"(",
"ir",
",",
"econf",
")",
"diagv3",
"=",
"Diagnostics",
"(",
"ir",
",",
"econfv3",
")",
"od",
"[",
"'diag'",
"]",
"=",
"diag",
".",
"as_dict",
"(",
")",
"od",
"[",
"'elements'",
"]",
"=",
"econf",
".",
"elements",
"od",
"[",
"'diagv3'",
"]",
"=",
"diagv3",
".",
"as_dict",
"(",
")",
"od",
"[",
"'elementsv3'",
"]",
"=",
"econfv3",
".",
"elements",
"features_timer",
"=",
"Timer",
"(",
"\"features\"",
")",
"with",
"features_timer",
":",
"if",
"dump_features",
":",
"od",
"[",
"'features'",
"]",
"=",
"ir",
".",
"features",
"(",
")",
"# scout = Scout()",
"# scout_args = {}",
"#",
"# if ir and not os.environ.get(\"AMBASSADOR_DISABLE_FEATURES\", None):",
"# scout_args[\"features\"] = ir.features()",
"#",
"# result = scout.report(action=\"dump\", mode=\"cli\", **scout_args)",
"# show_notices(result)",
"dump_timer",
"=",
"Timer",
"(",
"\"dump JSON\"",
")",
"with",
"dump_timer",
":",
"js",
"=",
"dump_json",
"(",
"od",
",",
"pretty",
"=",
"not",
"nopretty",
")",
"jslen",
"=",
"len",
"(",
"js",
")",
"write_timer",
"=",
"Timer",
"(",
"\"write JSON\"",
")",
"with",
"write_timer",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"js",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\n\"",
")",
"total_timer",
".",
"stop",
"(",
")",
"route_count",
"=",
"0",
"vhost_count",
"=",
"0",
"filter_chain_count",
"=",
"0",
"filter_count",
"=",
"0",
"apiversion",
"=",
"'v2'",
"if",
"v2",
"else",
"'v3'",
"if",
"apiversion",
"in",
"od",
":",
"for",
"listener",
"in",
"od",
"[",
"apiversion",
"]",
"[",
"'static_resources'",
"]",
"[",
"'listeners'",
"]",
":",
"for",
"fc",
"in",
"listener",
"[",
"'filter_chains'",
"]",
":",
"filter_chain_count",
"+=",
"1",
"for",
"f",
"in",
"fc",
"[",
"'filters'",
"]",
":",
"filter_count",
"+=",
"1",
"for",
"vh",
"in",
"f",
"[",
"'typed_config'",
"]",
"[",
"'route_config'",
"]",
"[",
"'virtual_hosts'",
"]",
":",
"vhost_count",
"+=",
"1",
"route_count",
"+=",
"len",
"(",
"vh",
"[",
"'routes'",
"]",
")",
"if",
"stats",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"STATS:\\n\"",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" config bytes: %d\\n\"",
"%",
"jslen",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" vhosts: %d\\n\"",
"%",
"vhost_count",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" filter chains: %d\\n\"",
"%",
"filter_chain_count",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" filters: %d\\n\"",
"%",
"filter_count",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" routes: %d\\n\"",
"%",
"route_count",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" routes/vhosts: %.3f\\n\"",
"%",
"float",
"(",
"float",
"(",
"route_count",
")",
"/",
"float",
"(",
"vhost_count",
")",
")",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"TIMERS:\\n\"",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" fetch resources: %.3fs\\n\"",
"%",
"fetch_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" load resources: %.3fs\\n\"",
"%",
"load_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" ir generation: %.3fs\\n\"",
"%",
"irgen_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" aconf: %.3fs\\n\"",
"%",
"aconf_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" envoy v2: %.3fs\\n\"",
"%",
"v2_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" diag: %.3fs\\n\"",
"%",
"diag_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" features: %.3fs\\n\"",
"%",
"features_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" dump json: %.3fs\\n\"",
"%",
"dump_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" write json: %.3fs\\n\"",
"%",
"write_timer",
".",
"average",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" ----------------------\\n\"",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\" total: %.3fs\\n\"",
"%",
"total_timer",
".",
"average",
")",
"except",
"Exception",
"as",
"e",
":",
"handle_exception",
"(",
"\"EXCEPTION from dump\"",
",",
"e",
",",
"config_dir_path",
"=",
"config_dir_path",
")",
"_rc",
"=",
"1",
"if",
"_profile",
":",
"_profile",
".",
"disable",
"(",
")",
"_profile",
".",
"dump_stats",
"(",
"\"ambassador.profile\"",
")",
"sys",
".",
"exit",
"(",
"_rc",
")"
] | [
143,
0
] | [
352,
17
] | python | en | ['en', 'error', 'th'] | False |
validate | (config_dir_path: Parameter.REQUIRED, **kwargs) |
Validate an Ambassador configuration. This is an extension of "config" that
redirects output to devnull and always exits on error.
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
|
Validate an Ambassador configuration. This is an extension of "config" that
redirects output to devnull and always exits on error. | def validate(config_dir_path: Parameter.REQUIRED, **kwargs):
"""
Validate an Ambassador configuration. This is an extension of "config" that
redirects output to devnull and always exits on error.
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
"""
config(config_dir_path, os.devnull, exit_on_error=True, **kwargs) | [
"def",
"validate",
"(",
"config_dir_path",
":",
"Parameter",
".",
"REQUIRED",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"(",
"config_dir_path",
",",
"os",
".",
"devnull",
",",
"exit_on_error",
"=",
"True",
",",
"*",
"*",
"kwargs",
")"
] | [
355,
0
] | [
362,
69
] | python | en | ['en', 'error', 'th'] | False |
config | (config_dir_path: Parameter.REQUIRED, output_json_path: Parameter.REQUIRED, *,
debug=False, debug_scout=False, check=False, k8s=False, ir=None, aconf=None,
exit_on_error=False) |
Generate an Envoy configuration
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
:param output_json_path: Path to output envoy.json
:param debug: If set, generate debugging output
:param debug_scout: If set, generate debugging output when talking to Scout
:param check: If set, generate configuration only if it doesn't already exist
:param k8s: If set, assume configuration files are annotated K8s manifests
:param exit_on_error: If set, will exit with status 1 on any configuration error
:param ir: Pathname to which to dump the IR (not dumped if not present)
:param aconf: Pathname to which to dump the aconf (not dumped if not present)
|
Generate an Envoy configuration | def config(config_dir_path: Parameter.REQUIRED, output_json_path: Parameter.REQUIRED, *,
debug=False, debug_scout=False, check=False, k8s=False, ir=None, aconf=None,
exit_on_error=False):
"""
Generate an Envoy configuration
:param config_dir_path: Configuration directory to scan for Ambassador YAML files
:param output_json_path: Path to output envoy.json
:param debug: If set, generate debugging output
:param debug_scout: If set, generate debugging output when talking to Scout
:param check: If set, generate configuration only if it doesn't already exist
:param k8s: If set, assume configuration files are annotated K8s manifests
:param exit_on_error: If set, will exit with status 1 on any configuration error
:param ir: Pathname to which to dump the IR (not dumped if not present)
:param aconf: Pathname to which to dump the aconf (not dumped if not present)
"""
if debug:
logger.setLevel(logging.DEBUG)
if debug_scout:
logging.getLogger('ambassador.scout').setLevel(logging.DEBUG)
try:
logger.debug("CHECK MODE %s" % check)
logger.debug("CONFIG DIR %s" % config_dir_path)
logger.debug("OUTPUT PATH %s" % output_json_path)
dump_aconf: Optional[str] = aconf
dump_ir: Optional[str] = ir
# Bypass the existence check...
output_exists = False
if check:
# ...oh no wait, they explicitly asked for the existence check!
# Assume that the file exists (ie, we'll do nothing) unless we
# determine otherwise.
output_exists = True
try:
parse_json(open(output_json_path, "r").read())
except FileNotFoundError:
logger.debug("output file does not exist")
output_exists = False
except OSError:
logger.warning("output file is not sane?")
output_exists = False
except json.decoder.JSONDecodeError:
logger.warning("output file is not valid JSON")
output_exists = False
logger.info("Output file %s" % ("exists" if output_exists else "does not exist"))
rc = RichStatus.fromError("impossible error")
if not output_exists:
# Either we didn't need to check, or the check didn't turn up
# a valid config. Regenerate.
logger.info("Generating new Envoy configuration...")
aconf = Config()
fetcher = ResourceFetcher(logger, aconf)
fetcher.load_from_filesystem(config_dir_path, k8s=k8s)
aconf.load_all(fetcher.sorted())
if dump_aconf:
with open(dump_aconf, "w") as output:
output.write(aconf.as_json())
output.write("\n")
# If exit_on_error is set, log _errors and exit with status 1
if exit_on_error and aconf.errors:
raise Exception("errors in: {0}".format(', '.join(aconf.errors.keys())))
secret_handler = NullSecretHandler(logger, config_dir_path, config_dir_path, "0")
ir = IR(aconf, file_checker=file_checker, secret_handler=secret_handler)
if dump_ir:
with open(dump_ir, "w") as output:
output.write(ir.as_json())
output.write("\n")
# clize considers kwargs with False for default value as flags,
# resulting in the logic below.
# https://clize.readthedocs.io/en/stable/basics.html#accepting-flags
logger.info("Writing envoy V2 configuration")
v2config = V2Config(ir)
rc = RichStatus.OK(msg="huh_v2")
if rc:
with open(output_json_path, "w") as output:
output.write(v2config.as_json())
output.write("\n")
else:
logger.error("Could not generate new Envoy configuration: %s" % rc.error)
scout = Scout()
result = scout.report(action="config", mode="cli")
show_notices(result)
except Exception as e:
handle_exception("EXCEPTION from config", e,
config_dir_path=config_dir_path, output_json_path=output_json_path)
# This is fatal.
sys.exit(1) | [
"def",
"config",
"(",
"config_dir_path",
":",
"Parameter",
".",
"REQUIRED",
",",
"output_json_path",
":",
"Parameter",
".",
"REQUIRED",
",",
"*",
",",
"debug",
"=",
"False",
",",
"debug_scout",
"=",
"False",
",",
"check",
"=",
"False",
",",
"k8s",
"=",
"False",
",",
"ir",
"=",
"None",
",",
"aconf",
"=",
"None",
",",
"exit_on_error",
"=",
"False",
")",
":",
"if",
"debug",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"if",
"debug_scout",
":",
"logging",
".",
"getLogger",
"(",
"'ambassador.scout'",
")",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"try",
":",
"logger",
".",
"debug",
"(",
"\"CHECK MODE %s\"",
"%",
"check",
")",
"logger",
".",
"debug",
"(",
"\"CONFIG DIR %s\"",
"%",
"config_dir_path",
")",
"logger",
".",
"debug",
"(",
"\"OUTPUT PATH %s\"",
"%",
"output_json_path",
")",
"dump_aconf",
":",
"Optional",
"[",
"str",
"]",
"=",
"aconf",
"dump_ir",
":",
"Optional",
"[",
"str",
"]",
"=",
"ir",
"# Bypass the existence check...",
"output_exists",
"=",
"False",
"if",
"check",
":",
"# ...oh no wait, they explicitly asked for the existence check!",
"# Assume that the file exists (ie, we'll do nothing) unless we",
"# determine otherwise.",
"output_exists",
"=",
"True",
"try",
":",
"parse_json",
"(",
"open",
"(",
"output_json_path",
",",
"\"r\"",
")",
".",
"read",
"(",
")",
")",
"except",
"FileNotFoundError",
":",
"logger",
".",
"debug",
"(",
"\"output file does not exist\"",
")",
"output_exists",
"=",
"False",
"except",
"OSError",
":",
"logger",
".",
"warning",
"(",
"\"output file is not sane?\"",
")",
"output_exists",
"=",
"False",
"except",
"json",
".",
"decoder",
".",
"JSONDecodeError",
":",
"logger",
".",
"warning",
"(",
"\"output file is not valid JSON\"",
")",
"output_exists",
"=",
"False",
"logger",
".",
"info",
"(",
"\"Output file %s\"",
"%",
"(",
"\"exists\"",
"if",
"output_exists",
"else",
"\"does not exist\"",
")",
")",
"rc",
"=",
"RichStatus",
".",
"fromError",
"(",
"\"impossible error\"",
")",
"if",
"not",
"output_exists",
":",
"# Either we didn't need to check, or the check didn't turn up",
"# a valid config. Regenerate.",
"logger",
".",
"info",
"(",
"\"Generating new Envoy configuration...\"",
")",
"aconf",
"=",
"Config",
"(",
")",
"fetcher",
"=",
"ResourceFetcher",
"(",
"logger",
",",
"aconf",
")",
"fetcher",
".",
"load_from_filesystem",
"(",
"config_dir_path",
",",
"k8s",
"=",
"k8s",
")",
"aconf",
".",
"load_all",
"(",
"fetcher",
".",
"sorted",
"(",
")",
")",
"if",
"dump_aconf",
":",
"with",
"open",
"(",
"dump_aconf",
",",
"\"w\"",
")",
"as",
"output",
":",
"output",
".",
"write",
"(",
"aconf",
".",
"as_json",
"(",
")",
")",
"output",
".",
"write",
"(",
"\"\\n\"",
")",
"# If exit_on_error is set, log _errors and exit with status 1",
"if",
"exit_on_error",
"and",
"aconf",
".",
"errors",
":",
"raise",
"Exception",
"(",
"\"errors in: {0}\"",
".",
"format",
"(",
"', '",
".",
"join",
"(",
"aconf",
".",
"errors",
".",
"keys",
"(",
")",
")",
")",
")",
"secret_handler",
"=",
"NullSecretHandler",
"(",
"logger",
",",
"config_dir_path",
",",
"config_dir_path",
",",
"\"0\"",
")",
"ir",
"=",
"IR",
"(",
"aconf",
",",
"file_checker",
"=",
"file_checker",
",",
"secret_handler",
"=",
"secret_handler",
")",
"if",
"dump_ir",
":",
"with",
"open",
"(",
"dump_ir",
",",
"\"w\"",
")",
"as",
"output",
":",
"output",
".",
"write",
"(",
"ir",
".",
"as_json",
"(",
")",
")",
"output",
".",
"write",
"(",
"\"\\n\"",
")",
"# clize considers kwargs with False for default value as flags,",
"# resulting in the logic below.",
"# https://clize.readthedocs.io/en/stable/basics.html#accepting-flags",
"logger",
".",
"info",
"(",
"\"Writing envoy V2 configuration\"",
")",
"v2config",
"=",
"V2Config",
"(",
"ir",
")",
"rc",
"=",
"RichStatus",
".",
"OK",
"(",
"msg",
"=",
"\"huh_v2\"",
")",
"if",
"rc",
":",
"with",
"open",
"(",
"output_json_path",
",",
"\"w\"",
")",
"as",
"output",
":",
"output",
".",
"write",
"(",
"v2config",
".",
"as_json",
"(",
")",
")",
"output",
".",
"write",
"(",
"\"\\n\"",
")",
"else",
":",
"logger",
".",
"error",
"(",
"\"Could not generate new Envoy configuration: %s\"",
"%",
"rc",
".",
"error",
")",
"scout",
"=",
"Scout",
"(",
")",
"result",
"=",
"scout",
".",
"report",
"(",
"action",
"=",
"\"config\"",
",",
"mode",
"=",
"\"cli\"",
")",
"show_notices",
"(",
"result",
")",
"except",
"Exception",
"as",
"e",
":",
"handle_exception",
"(",
"\"EXCEPTION from config\"",
",",
"e",
",",
"config_dir_path",
"=",
"config_dir_path",
",",
"output_json_path",
"=",
"output_json_path",
")",
"# This is fatal.",
"sys",
".",
"exit",
"(",
"1",
")"
] | [
365,
0
] | [
472,
19
] | python | en | ['en', 'error', 'th'] | False |
ExpectationSuite.isEquivalentTo | (self, other) |
ExpectationSuite equivalence relies only on expectations and evaluation parameters. It does not include:
- data_asset_name
- expectation_suite_name
- meta
- data_asset_type
|
ExpectationSuite equivalence relies only on expectations and evaluation parameters. It does not include:
- data_asset_name
- expectation_suite_name
- meta
- data_asset_type
| def isEquivalentTo(self, other):
"""
ExpectationSuite equivalence relies only on expectations and evaluation parameters. It does not include:
- data_asset_name
- expectation_suite_name
- meta
- data_asset_type
"""
if not isinstance(other, self.__class__):
if isinstance(other, dict):
try:
other = expectationSuiteSchema.load(other)
except ValidationError:
logger.debug(
"Unable to evaluate equivalence of ExpectationConfiguration object with dict because "
"dict other could not be instantiated as an ExpectationConfiguration"
)
return NotImplemented
else:
# Delegate comparison to the other instance
return NotImplemented
return len(self.expectations) == len(other.expectations) and all(
[
mine.isEquivalentTo(theirs)
for (mine, theirs) in zip(self.expectations, other.expectations)
]
) | [
"def",
"isEquivalentTo",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"dict",
")",
":",
"try",
":",
"other",
"=",
"expectationSuiteSchema",
".",
"load",
"(",
"other",
")",
"except",
"ValidationError",
":",
"logger",
".",
"debug",
"(",
"\"Unable to evaluate equivalence of ExpectationConfiguration object with dict because \"",
"\"dict other could not be instantiated as an ExpectationConfiguration\"",
")",
"return",
"NotImplemented",
"else",
":",
"# Delegate comparison to the other instance",
"return",
"NotImplemented",
"return",
"len",
"(",
"self",
".",
"expectations",
")",
"==",
"len",
"(",
"other",
".",
"expectations",
")",
"and",
"all",
"(",
"[",
"mine",
".",
"isEquivalentTo",
"(",
"theirs",
")",
"for",
"(",
"mine",
",",
"theirs",
")",
"in",
"zip",
"(",
"self",
".",
"expectations",
",",
"other",
".",
"expectations",
")",
"]",
")"
] | [
120,
4
] | [
147,
9
] | python | en | ['en', 'error', 'th'] | False |
ExpectationSuite.__eq__ | (self, other) | ExpectationSuite equality ignores instance identity, relying only on properties. | ExpectationSuite equality ignores instance identity, relying only on properties. | def __eq__(self, other):
"""ExpectationSuite equality ignores instance identity, relying only on properties."""
if not isinstance(other, self.__class__):
# Delegate comparison to the other instance's __eq__.
return NotImplemented
return all(
(
self.expectation_suite_name == other.expectation_suite_name,
self.expectations == other.expectations,
self.evaluation_parameters == other.evaluation_parameters,
self.data_asset_type == other.data_asset_type,
self.meta == other.meta,
)
) | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"# Delegate comparison to the other instance's __eq__.",
"return",
"NotImplemented",
"return",
"all",
"(",
"(",
"self",
".",
"expectation_suite_name",
"==",
"other",
".",
"expectation_suite_name",
",",
"self",
".",
"expectations",
"==",
"other",
".",
"expectations",
",",
"self",
".",
"evaluation_parameters",
"==",
"other",
".",
"evaluation_parameters",
",",
"self",
".",
"data_asset_type",
"==",
"other",
".",
"data_asset_type",
",",
"self",
".",
"meta",
"==",
"other",
".",
"meta",
",",
")",
")"
] | [
149,
4
] | [
162,
9
] | python | en | ['en', 'en', 'en'] | True |
ExpectationSuite.get_table_expectations | (self) | Return a list of table expectations. | Return a list of table expectations. | def get_table_expectations(self):
"""Return a list of table expectations."""
return [
e
for e in self.expectations
if e.expectation_type.startswith("expect_table_")
] | [
"def",
"get_table_expectations",
"(",
"self",
")",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"expectations",
"if",
"e",
".",
"expectation_type",
".",
"startswith",
"(",
"\"expect_table_\"",
")",
"]"
] | [
221,
4
] | [
227,
9
] | python | en | ['en', 'en', 'en'] | True |
ExpectationSuite.get_column_expectations | (self) | Return a list of column map expectations. | Return a list of column map expectations. | def get_column_expectations(self):
"""Return a list of column map expectations."""
return [e for e in self.expectations if "column" in e.kwargs] | [
"def",
"get_column_expectations",
"(",
"self",
")",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"expectations",
"if",
"\"column\"",
"in",
"e",
".",
"kwargs",
"]"
] | [
229,
4
] | [
231,
69
] | python | en | ['en', 'en', 'en'] | True |
ExpectationSuite.append_expectation | (self, expectation_config) | Appends an expectation.
Args:
expectation_config (ExpectationConfiguration): \
The expectation to be added to the list.
Notes:
May want to add type-checking in the future.
| Appends an expectation. | def append_expectation(self, expectation_config):
"""Appends an expectation.
Args:
expectation_config (ExpectationConfiguration): \
The expectation to be added to the list.
Notes:
May want to add type-checking in the future.
"""
self.expectations.append(expectation_config) | [
"def",
"append_expectation",
"(",
"self",
",",
"expectation_config",
")",
":",
"self",
".",
"expectations",
".",
"append",
"(",
"expectation_config",
")"
] | [
249,
4
] | [
259,
52
] | python | en | ['en', 'en', 'en'] | True |
ExpectationSuite.remove_expectation | (
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
remove_multiple_matches: bool = False,
) |
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against for
for the removal of expectations.
match_type: This determines what kwargs to use when matching. Options are 'domain' to match based
on the data evaluated by that expectation, 'success' to match based on all configuration parameters
that influence whether an expectation succeeds based on a given batch of data, and 'runtime' to match
based on all configuration parameters
remove_multiple_matches: If True, will remove multiple matching expectations. If False, will raise a ValueError.
Returns: The list of deleted ExpectationConfigurations
Raises:
No match
More than 1 match, if remove_multiple_matches = False
| def remove_expectation(
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
remove_multiple_matches: bool = False,
) -> List[ExpectationConfiguration]:
"""
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against for
for the removal of expectations.
match_type: This determines what kwargs to use when matching. Options are 'domain' to match based
on the data evaluated by that expectation, 'success' to match based on all configuration parameters
that influence whether an expectation succeeds based on a given batch of data, and 'runtime' to match
based on all configuration parameters
remove_multiple_matches: If True, will remove multiple matching expectations. If False, will raise a ValueError.
Returns: The list of deleted ExpectationConfigurations
Raises:
No match
More than 1 match, if remove_multiple_matches = False
"""
found_expectation_indexes = self.find_expectation_indexes(
expectation_configuration, match_type
)
if len(found_expectation_indexes) < 1:
raise ValueError("No matching expectation was found.")
elif len(found_expectation_indexes) > 1:
if remove_multiple_matches:
removed_expectations = []
for index in sorted(found_expectation_indexes, reverse=True):
removed_expectations.append(self.expectations.pop(index))
return removed_expectations
else:
raise ValueError(
"More than one matching expectation was found. Specify more precise matching criteria,"
"or set remove_multiple_matches=True"
)
else:
return [self.expectations.pop(found_expectation_indexes[0])] | [
"def",
"remove_expectation",
"(",
"self",
",",
"expectation_configuration",
":",
"ExpectationConfiguration",
",",
"match_type",
":",
"str",
"=",
"\"domain\"",
",",
"remove_multiple_matches",
":",
"bool",
"=",
"False",
",",
")",
"->",
"List",
"[",
"ExpectationConfiguration",
"]",
":",
"found_expectation_indexes",
"=",
"self",
".",
"find_expectation_indexes",
"(",
"expectation_configuration",
",",
"match_type",
")",
"if",
"len",
"(",
"found_expectation_indexes",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"No matching expectation was found.\"",
")",
"elif",
"len",
"(",
"found_expectation_indexes",
")",
">",
"1",
":",
"if",
"remove_multiple_matches",
":",
"removed_expectations",
"=",
"[",
"]",
"for",
"index",
"in",
"sorted",
"(",
"found_expectation_indexes",
",",
"reverse",
"=",
"True",
")",
":",
"removed_expectations",
".",
"append",
"(",
"self",
".",
"expectations",
".",
"pop",
"(",
"index",
")",
")",
"return",
"removed_expectations",
"else",
":",
"raise",
"ValueError",
"(",
"\"More than one matching expectation was found. Specify more precise matching criteria,\"",
"\"or set remove_multiple_matches=True\"",
")",
"else",
":",
"return",
"[",
"self",
".",
"expectations",
".",
"pop",
"(",
"found_expectation_indexes",
"[",
"0",
"]",
")",
"]"
] | [
261,
4
] | [
302,
72
] | python | en | ['en', 'error', 'th'] | False |
|
ExpectationSuite.find_expectation_indexes | (
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
) |
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against to
find the index of any matching Expectation Configurations on the suite.
match_type: This determines what kwargs to use when matching. Options are 'domain' to match based
on the data evaluated by that expectation, 'success' to match based on all configuration parameters
that influence whether an expectation succeeds based on a given batch of data, and 'runtime' to match
based on all configuration parameters
Returns: A list of indexes of matching ExpectationConfiguration
Raises:
InvalidExpectationConfigurationError
| def find_expectation_indexes(
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
) -> List[int]:
"""
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against to
find the index of any matching Expectation Configurations on the suite.
match_type: This determines what kwargs to use when matching. Options are 'domain' to match based
on the data evaluated by that expectation, 'success' to match based on all configuration parameters
that influence whether an expectation succeeds based on a given batch of data, and 'runtime' to match
based on all configuration parameters
Returns: A list of indexes of matching ExpectationConfiguration
Raises:
InvalidExpectationConfigurationError
"""
if not isinstance(expectation_configuration, ExpectationConfiguration):
raise InvalidExpectationConfigurationError(
"Ensure that expectation configuration is valid."
)
match_indexes = []
for idx, expectation in enumerate(self.expectations):
if expectation.isEquivalentTo(expectation_configuration, match_type):
match_indexes.append(idx)
return match_indexes | [
"def",
"find_expectation_indexes",
"(",
"self",
",",
"expectation_configuration",
":",
"ExpectationConfiguration",
",",
"match_type",
":",
"str",
"=",
"\"domain\"",
",",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"not",
"isinstance",
"(",
"expectation_configuration",
",",
"ExpectationConfiguration",
")",
":",
"raise",
"InvalidExpectationConfigurationError",
"(",
"\"Ensure that expectation configuration is valid.\"",
")",
"match_indexes",
"=",
"[",
"]",
"for",
"idx",
",",
"expectation",
"in",
"enumerate",
"(",
"self",
".",
"expectations",
")",
":",
"if",
"expectation",
".",
"isEquivalentTo",
"(",
"expectation_configuration",
",",
"match_type",
")",
":",
"match_indexes",
".",
"append",
"(",
"idx",
")",
"return",
"match_indexes"
] | [
322,
4
] | [
352,
28
] | python | en | ['en', 'error', 'th'] | False |
|
ExpectationSuite.patch_expectation | (
self,
expectation_configuration: ExpectationConfiguration,
op: str,
path: str,
value: Any,
match_type: str,
) |
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against to
find the expectation to patch.
op: A jsonpatch operation (one of 'add','update', or 'remove') (see http://jsonpatch.com/)
path: A jsonpatch path for the patch operation (see http://jsonpatch.com/)
value: The value to patch (see http://jsonpatch.com/)
match_type: The match type to use for find_expectation_index()
Returns: The patched ExpectationConfiguration
Raises:
No match
More than 1 match
| def patch_expectation(
self,
expectation_configuration: ExpectationConfiguration,
op: str,
path: str,
value: Any,
match_type: str,
) -> ExpectationConfiguration:
"""
Args:
expectation_configuration: A potentially incomplete (partial) Expectation Configuration to match against to
find the expectation to patch.
op: A jsonpatch operation (one of 'add','update', or 'remove') (see http://jsonpatch.com/)
path: A jsonpatch path for the patch operation (see http://jsonpatch.com/)
value: The value to patch (see http://jsonpatch.com/)
match_type: The match type to use for find_expectation_index()
Returns: The patched ExpectationConfiguration
Raises:
No match
More than 1 match
"""
found_expectation_indexes = self.find_expectation_indexes(
expectation_configuration, match_type
)
if len(found_expectation_indexes) < 1:
raise ValueError("No matching expectation was found.")
elif len(found_expectation_indexes) > 1:
raise ValueError(
"More than one matching expectation was found. Please be more specific with your search "
"criteria"
)
self.expectations[found_expectation_indexes[0]].patch(op, path, value)
return self.expectations[found_expectation_indexes[0]] | [
"def",
"patch_expectation",
"(",
"self",
",",
"expectation_configuration",
":",
"ExpectationConfiguration",
",",
"op",
":",
"str",
",",
"path",
":",
"str",
",",
"value",
":",
"Any",
",",
"match_type",
":",
"str",
",",
")",
"->",
"ExpectationConfiguration",
":",
"found_expectation_indexes",
"=",
"self",
".",
"find_expectation_indexes",
"(",
"expectation_configuration",
",",
"match_type",
")",
"if",
"len",
"(",
"found_expectation_indexes",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"No matching expectation was found.\"",
")",
"elif",
"len",
"(",
"found_expectation_indexes",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"More than one matching expectation was found. Please be more specific with your search \"",
"\"criteria\"",
")",
"self",
".",
"expectations",
"[",
"found_expectation_indexes",
"[",
"0",
"]",
"]",
".",
"patch",
"(",
"op",
",",
"path",
",",
"value",
")",
"return",
"self",
".",
"expectations",
"[",
"found_expectation_indexes",
"[",
"0",
"]",
"]"
] | [
371,
4
] | [
409,
62
] | python | en | ['en', 'error', 'th'] | False |
|
ExpectationSuite.add_expectation | (
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
overwrite_existing: bool = True,
) |
Args:
expectation_configuration: The ExpectationConfiguration to add or update
match_type: The criteria used to determine whether the Suite already has an ExpectationConfiguration
and so whether we should add or replace.
overwrite_existing: If the expectation already exists, this will overwrite if True and raise an error if
False.
Returns:
The ExpectationConfiguration to add or replace.
Raises:
More than one match
One match if overwrite_existing = False
| def add_expectation(
self,
expectation_configuration: ExpectationConfiguration,
match_type: str = "domain",
overwrite_existing: bool = True,
) -> ExpectationConfiguration:
"""
Args:
expectation_configuration: The ExpectationConfiguration to add or update
match_type: The criteria used to determine whether the Suite already has an ExpectationConfiguration
and so whether we should add or replace.
overwrite_existing: If the expectation already exists, this will overwrite if True and raise an error if
False.
Returns:
The ExpectationConfiguration to add or replace.
Raises:
More than one match
One match if overwrite_existing = False
"""
found_expectation_indexes = self.find_expectation_indexes(
expectation_configuration, match_type
)
if len(found_expectation_indexes) > 1:
raise ValueError(
"More than one matching expectation was found. Please be more specific with your search "
"criteria"
)
elif len(found_expectation_indexes) == 1:
# Currently, we completely replace the expectation_configuration, but we could potentially use patch_expectation
# to update instead. We need to consider how to handle meta in that situation.
# patch_expectation = jsonpatch.make_patch(self.expectations[found_expectation_index] \
# .kwargs, expectation_configuration.kwargs)
# patch_expectation.apply(self.expectations[found_expectation_index].kwargs, in_place=True)
if overwrite_existing:
self.expectations[
found_expectation_indexes[0]
] = expectation_configuration
else:
raise DataContextError(
"A matching ExpectationConfiguration already exists. If you would like to overwrite this "
"ExpectationConfiguration, set overwrite_existing=True"
)
else:
self.append_expectation(expectation_configuration)
return expectation_configuration | [
"def",
"add_expectation",
"(",
"self",
",",
"expectation_configuration",
":",
"ExpectationConfiguration",
",",
"match_type",
":",
"str",
"=",
"\"domain\"",
",",
"overwrite_existing",
":",
"bool",
"=",
"True",
",",
")",
"->",
"ExpectationConfiguration",
":",
"found_expectation_indexes",
"=",
"self",
".",
"find_expectation_indexes",
"(",
"expectation_configuration",
",",
"match_type",
")",
"if",
"len",
"(",
"found_expectation_indexes",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"More than one matching expectation was found. Please be more specific with your search \"",
"\"criteria\"",
")",
"elif",
"len",
"(",
"found_expectation_indexes",
")",
"==",
"1",
":",
"# Currently, we completely replace the expectation_configuration, but we could potentially use patch_expectation",
"# to update instead. We need to consider how to handle meta in that situation.",
"# patch_expectation = jsonpatch.make_patch(self.expectations[found_expectation_index] \\",
"# .kwargs, expectation_configuration.kwargs)",
"# patch_expectation.apply(self.expectations[found_expectation_index].kwargs, in_place=True)",
"if",
"overwrite_existing",
":",
"self",
".",
"expectations",
"[",
"found_expectation_indexes",
"[",
"0",
"]",
"]",
"=",
"expectation_configuration",
"else",
":",
"raise",
"DataContextError",
"(",
"\"A matching ExpectationConfiguration already exists. If you would like to overwrite this \"",
"\"ExpectationConfiguration, set overwrite_existing=True\"",
")",
"else",
":",
"self",
".",
"append_expectation",
"(",
"expectation_configuration",
")",
"return",
"expectation_configuration"
] | [
411,
4
] | [
458,
40
] | python | en | ['en', 'error', 'th'] | False |
|
XcodeArchsVariableMapping | (archs, archs_including_64_bit=None) | Constructs a dictionary with expansion for $(ARCHS_STANDARD) variable,
and optionally for $(ARCHS_STANDARD_INCLUDING_64_BIT). | Constructs a dictionary with expansion for $(ARCHS_STANDARD) variable,
and optionally for $(ARCHS_STANDARD_INCLUDING_64_BIT). | def XcodeArchsVariableMapping(archs, archs_including_64_bit=None):
"""Constructs a dictionary with expansion for $(ARCHS_STANDARD) variable,
and optionally for $(ARCHS_STANDARD_INCLUDING_64_BIT)."""
mapping = {'$(ARCHS_STANDARD)': archs}
if archs_including_64_bit:
mapping['$(ARCHS_STANDARD_INCLUDING_64_BIT)'] = archs_including_64_bit
return mapping | [
"def",
"XcodeArchsVariableMapping",
"(",
"archs",
",",
"archs_including_64_bit",
"=",
"None",
")",
":",
"mapping",
"=",
"{",
"'$(ARCHS_STANDARD)'",
":",
"archs",
"}",
"if",
"archs_including_64_bit",
":",
"mapping",
"[",
"'$(ARCHS_STANDARD_INCLUDING_64_BIT)'",
"]",
"=",
"archs_including_64_bit",
"return",
"mapping"
] | [
30,
0
] | [
36,
16
] | python | en | ['en', 'en', 'en'] | True |
GetXcodeArchsDefault | () | Returns the |XcodeArchsDefault| object to use to expand ARCHS for the
installed version of Xcode. The default values used by Xcode for ARCHS
and the expansion of the variables depends on the version of Xcode used.
For all version anterior to Xcode 5.0 or posterior to Xcode 5.1 included
uses $(ARCHS_STANDARD) if ARCHS is unset, while Xcode 5.0 to 5.0.2 uses
$(ARCHS_STANDARD_INCLUDING_64_BIT). This variable was added to Xcode 5.0
and deprecated with Xcode 5.1.
For "macosx" SDKROOT, all version starting with Xcode 5.0 includes 64-bit
architecture as part of $(ARCHS_STANDARD) and default to only building it.
For "iphoneos" and "iphonesimulator" SDKROOT, 64-bit architectures are part
of $(ARCHS_STANDARD_INCLUDING_64_BIT) from Xcode 5.0. From Xcode 5.1, they
are also part of $(ARCHS_STANDARD).
All thoses rules are coded in the construction of the |XcodeArchsDefault|
object to use depending on the version of Xcode detected. The object is
for performance reason. | Returns the |XcodeArchsDefault| object to use to expand ARCHS for the
installed version of Xcode. The default values used by Xcode for ARCHS
and the expansion of the variables depends on the version of Xcode used. | def GetXcodeArchsDefault():
"""Returns the |XcodeArchsDefault| object to use to expand ARCHS for the
installed version of Xcode. The default values used by Xcode for ARCHS
and the expansion of the variables depends on the version of Xcode used.
For all version anterior to Xcode 5.0 or posterior to Xcode 5.1 included
uses $(ARCHS_STANDARD) if ARCHS is unset, while Xcode 5.0 to 5.0.2 uses
$(ARCHS_STANDARD_INCLUDING_64_BIT). This variable was added to Xcode 5.0
and deprecated with Xcode 5.1.
For "macosx" SDKROOT, all version starting with Xcode 5.0 includes 64-bit
architecture as part of $(ARCHS_STANDARD) and default to only building it.
For "iphoneos" and "iphonesimulator" SDKROOT, 64-bit architectures are part
of $(ARCHS_STANDARD_INCLUDING_64_BIT) from Xcode 5.0. From Xcode 5.1, they
are also part of $(ARCHS_STANDARD).
All thoses rules are coded in the construction of the |XcodeArchsDefault|
object to use depending on the version of Xcode detected. The object is
for performance reason."""
global XCODE_ARCHS_DEFAULT_CACHE
if XCODE_ARCHS_DEFAULT_CACHE:
return XCODE_ARCHS_DEFAULT_CACHE
xcode_version, _ = XcodeVersion()
if xcode_version < '0500':
XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
'$(ARCHS_STANDARD)',
XcodeArchsVariableMapping(['i386']),
XcodeArchsVariableMapping(['i386']),
XcodeArchsVariableMapping(['armv7']))
elif xcode_version < '0510':
XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
'$(ARCHS_STANDARD_INCLUDING_64_BIT)',
XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
XcodeArchsVariableMapping(['i386'], ['i386', 'x86_64']),
XcodeArchsVariableMapping(
['armv7', 'armv7s'],
['armv7', 'armv7s', 'arm64']))
else:
XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
'$(ARCHS_STANDARD)',
XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
XcodeArchsVariableMapping(['i386', 'x86_64'], ['i386', 'x86_64']),
XcodeArchsVariableMapping(
['armv7', 'armv7s', 'arm64'],
['armv7', 'armv7s', 'arm64']))
return XCODE_ARCHS_DEFAULT_CACHE | [
"def",
"GetXcodeArchsDefault",
"(",
")",
":",
"global",
"XCODE_ARCHS_DEFAULT_CACHE",
"if",
"XCODE_ARCHS_DEFAULT_CACHE",
":",
"return",
"XCODE_ARCHS_DEFAULT_CACHE",
"xcode_version",
",",
"_",
"=",
"XcodeVersion",
"(",
")",
"if",
"xcode_version",
"<",
"'0500'",
":",
"XCODE_ARCHS_DEFAULT_CACHE",
"=",
"XcodeArchsDefault",
"(",
"'$(ARCHS_STANDARD)'",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'i386'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'i386'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'armv7'",
"]",
")",
")",
"elif",
"xcode_version",
"<",
"'0510'",
":",
"XCODE_ARCHS_DEFAULT_CACHE",
"=",
"XcodeArchsDefault",
"(",
"'$(ARCHS_STANDARD_INCLUDING_64_BIT)'",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'x86_64'",
"]",
",",
"[",
"'x86_64'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'i386'",
"]",
",",
"[",
"'i386'",
",",
"'x86_64'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'armv7'",
",",
"'armv7s'",
"]",
",",
"[",
"'armv7'",
",",
"'armv7s'",
",",
"'arm64'",
"]",
")",
")",
"else",
":",
"XCODE_ARCHS_DEFAULT_CACHE",
"=",
"XcodeArchsDefault",
"(",
"'$(ARCHS_STANDARD)'",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'x86_64'",
"]",
",",
"[",
"'x86_64'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'i386'",
",",
"'x86_64'",
"]",
",",
"[",
"'i386'",
",",
"'x86_64'",
"]",
")",
",",
"XcodeArchsVariableMapping",
"(",
"[",
"'armv7'",
",",
"'armv7s'",
",",
"'arm64'",
"]",
",",
"[",
"'armv7'",
",",
"'armv7s'",
",",
"'arm64'",
"]",
")",
")",
"return",
"XCODE_ARCHS_DEFAULT_CACHE"
] | [
94,
0
] | [
140,
34
] | python | en | ['en', 'en', 'en'] | True |
XcodeVersion | () | Returns a tuple of version and build version of installed Xcode. | Returns a tuple of version and build version of installed Xcode. | def XcodeVersion():
"""Returns a tuple of version and build version of installed Xcode."""
# `xcodebuild -version` output looks like
# Xcode 4.6.3
# Build version 4H1503
# or like
# Xcode 3.2.6
# Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0
# BuildVersion: 10M2518
# Convert that to '0463', '4H1503'.
global XCODE_VERSION_CACHE
if XCODE_VERSION_CACHE:
return XCODE_VERSION_CACHE
try:
version_list = GetStdoutQuiet(['xcodebuild', '-version']).splitlines()
# In some circumstances xcodebuild exits 0 but doesn't return
# the right results; for example, a user on 10.7 or 10.8 with
# a bogus path set via xcode-select
# In that case this may be a CLT-only install so fall back to
# checking that version.
if len(version_list) < 2:
raise GypError("xcodebuild returned unexpected results")
except:
version = CLTVersion()
if version:
version = re.match(r'(\d+\.\d+\.?\d*)', version).groups()[0]
else:
raise GypError("No Xcode or CLT version detected!")
# The CLT has no build information, so we return an empty string.
version_list = [version, '']
version = version_list[0]
build = version_list[-1]
# Be careful to convert "4.2" to "0420":
version = version.split()[-1].replace('.', '')
version = (version + '0' * (3 - len(version))).zfill(4)
if build:
build = build.split()[-1]
XCODE_VERSION_CACHE = (version, build)
return XCODE_VERSION_CACHE | [
"def",
"XcodeVersion",
"(",
")",
":",
"# `xcodebuild -version` output looks like",
"# Xcode 4.6.3",
"# Build version 4H1503",
"# or like",
"# Xcode 3.2.6",
"# Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0",
"# BuildVersion: 10M2518",
"# Convert that to '0463', '4H1503'.",
"global",
"XCODE_VERSION_CACHE",
"if",
"XCODE_VERSION_CACHE",
":",
"return",
"XCODE_VERSION_CACHE",
"try",
":",
"version_list",
"=",
"GetStdoutQuiet",
"(",
"[",
"'xcodebuild'",
",",
"'-version'",
"]",
")",
".",
"splitlines",
"(",
")",
"# In some circumstances xcodebuild exits 0 but doesn't return",
"# the right results; for example, a user on 10.7 or 10.8 with",
"# a bogus path set via xcode-select",
"# In that case this may be a CLT-only install so fall back to",
"# checking that version.",
"if",
"len",
"(",
"version_list",
")",
"<",
"2",
":",
"raise",
"GypError",
"(",
"\"xcodebuild returned unexpected results\"",
")",
"except",
":",
"version",
"=",
"CLTVersion",
"(",
")",
"if",
"version",
":",
"version",
"=",
"re",
".",
"match",
"(",
"r'(\\d+\\.\\d+\\.?\\d*)'",
",",
"version",
")",
".",
"groups",
"(",
")",
"[",
"0",
"]",
"else",
":",
"raise",
"GypError",
"(",
"\"No Xcode or CLT version detected!\"",
")",
"# The CLT has no build information, so we return an empty string.",
"version_list",
"=",
"[",
"version",
",",
"''",
"]",
"version",
"=",
"version_list",
"[",
"0",
"]",
"build",
"=",
"version_list",
"[",
"-",
"1",
"]",
"# Be careful to convert \"4.2\" to \"0420\":",
"version",
"=",
"version",
".",
"split",
"(",
")",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
"version",
"=",
"(",
"version",
"+",
"'0'",
"*",
"(",
"3",
"-",
"len",
"(",
"version",
")",
")",
")",
".",
"zfill",
"(",
"4",
")",
"if",
"build",
":",
"build",
"=",
"build",
".",
"split",
"(",
")",
"[",
"-",
"1",
"]",
"XCODE_VERSION_CACHE",
"=",
"(",
"version",
",",
"build",
")",
"return",
"XCODE_VERSION_CACHE"
] | [
1252,
0
] | [
1290,
28
] | python | en | ['en', 'en', 'en'] | True |
CLTVersion | () | Returns the version of command-line tools from pkgutil. | Returns the version of command-line tools from pkgutil. | def CLTVersion():
"""Returns the version of command-line tools from pkgutil."""
# pkgutil output looks like
# package-id: com.apple.pkg.CLTools_Executables
# version: 5.0.1.0.1.1382131676
# volume: /
# location: /
# install-time: 1382544035
# groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group
STANDALONE_PKG_ID = "com.apple.pkg.DeveloperToolsCLILeo"
FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI"
MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables"
regex = re.compile('version: (?P<version>.+)')
for key in [MAVERICKS_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID]:
try:
output = GetStdout(['/usr/sbin/pkgutil', '--pkg-info', key])
return re.search(regex, output).groupdict()['version']
except:
continue | [
"def",
"CLTVersion",
"(",
")",
":",
"# pkgutil output looks like",
"# package-id: com.apple.pkg.CLTools_Executables",
"# version: 5.0.1.0.1.1382131676",
"# volume: /",
"# location: /",
"# install-time: 1382544035",
"# groups: com.apple.FindSystemFiles.pkg-group com.apple.DevToolsBoth.pkg-group com.apple.DevToolsNonRelocatableShared.pkg-group",
"STANDALONE_PKG_ID",
"=",
"\"com.apple.pkg.DeveloperToolsCLILeo\"",
"FROM_XCODE_PKG_ID",
"=",
"\"com.apple.pkg.DeveloperToolsCLI\"",
"MAVERICKS_PKG_ID",
"=",
"\"com.apple.pkg.CLTools_Executables\"",
"regex",
"=",
"re",
".",
"compile",
"(",
"'version: (?P<version>.+)'",
")",
"for",
"key",
"in",
"[",
"MAVERICKS_PKG_ID",
",",
"STANDALONE_PKG_ID",
",",
"FROM_XCODE_PKG_ID",
"]",
":",
"try",
":",
"output",
"=",
"GetStdout",
"(",
"[",
"'/usr/sbin/pkgutil'",
",",
"'--pkg-info'",
",",
"key",
"]",
")",
"return",
"re",
".",
"search",
"(",
"regex",
",",
"output",
")",
".",
"groupdict",
"(",
")",
"[",
"'version'",
"]",
"except",
":",
"continue"
] | [
1294,
0
] | [
1313,
14
] | python | en | ['en', 'en', 'en'] | True |
GetStdoutQuiet | (cmdlist) | Returns the content of standard output returned by invoking |cmdlist|.
Ignores the stderr.
Raises |GypError| if the command return with a non-zero return code. | Returns the content of standard output returned by invoking |cmdlist|.
Ignores the stderr.
Raises |GypError| if the command return with a non-zero return code. | def GetStdoutQuiet(cmdlist):
"""Returns the content of standard output returned by invoking |cmdlist|.
Ignores the stderr.
Raises |GypError| if the command return with a non-zero return code."""
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = job.communicate()[0]
if job.returncode != 0:
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
return out.rstrip('\n') | [
"def",
"GetStdoutQuiet",
"(",
"cmdlist",
")",
":",
"job",
"=",
"subprocess",
".",
"Popen",
"(",
"cmdlist",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
"=",
"job",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
"if",
"job",
".",
"returncode",
"!=",
"0",
":",
"raise",
"GypError",
"(",
"'Error %d running %s'",
"%",
"(",
"job",
".",
"returncode",
",",
"cmdlist",
"[",
"0",
"]",
")",
")",
"return",
"out",
".",
"rstrip",
"(",
"'\\n'",
")"
] | [
1316,
0
] | [
1324,
25
] | python | en | ['en', 'en', 'en'] | True |
GetStdout | (cmdlist) | Returns the content of standard output returned by invoking |cmdlist|.
Raises |GypError| if the command return with a non-zero return code. | Returns the content of standard output returned by invoking |cmdlist|.
Raises |GypError| if the command return with a non-zero return code. | def GetStdout(cmdlist):
"""Returns the content of standard output returned by invoking |cmdlist|.
Raises |GypError| if the command return with a non-zero return code."""
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
out = job.communicate()[0]
if job.returncode != 0:
sys.stderr.write(out + '\n')
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
return out.rstrip('\n') | [
"def",
"GetStdout",
"(",
"cmdlist",
")",
":",
"job",
"=",
"subprocess",
".",
"Popen",
"(",
"cmdlist",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
"=",
"job",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
"if",
"job",
".",
"returncode",
"!=",
"0",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"out",
"+",
"'\\n'",
")",
"raise",
"GypError",
"(",
"'Error %d running %s'",
"%",
"(",
"job",
".",
"returncode",
",",
"cmdlist",
"[",
"0",
"]",
")",
")",
"return",
"out",
".",
"rstrip",
"(",
"'\\n'",
")"
] | [
1327,
0
] | [
1335,
25
] | python | en | ['en', 'en', 'en'] | True |
MergeGlobalXcodeSettingsToSpec | (global_dict, spec) | Merges the global xcode_settings dictionary into each configuration of the
target represented by spec. For keys that are both in the global and the local
xcode_settings dict, the local key gets precendence.
| Merges the global xcode_settings dictionary into each configuration of the
target represented by spec. For keys that are both in the global and the local
xcode_settings dict, the local key gets precendence.
| def MergeGlobalXcodeSettingsToSpec(global_dict, spec):
"""Merges the global xcode_settings dictionary into each configuration of the
target represented by spec. For keys that are both in the global and the local
xcode_settings dict, the local key gets precendence.
"""
# The xcode generator special-cases global xcode_settings and does something
# that amounts to merging in the global xcode_settings into each local
# xcode_settings dict.
global_xcode_settings = global_dict.get('xcode_settings', {})
for config in spec['configurations'].values():
if 'xcode_settings' in config:
new_settings = global_xcode_settings.copy()
new_settings.update(config['xcode_settings'])
config['xcode_settings'] = new_settings | [
"def",
"MergeGlobalXcodeSettingsToSpec",
"(",
"global_dict",
",",
"spec",
")",
":",
"# The xcode generator special-cases global xcode_settings and does something",
"# that amounts to merging in the global xcode_settings into each local",
"# xcode_settings dict.",
"global_xcode_settings",
"=",
"global_dict",
".",
"get",
"(",
"'xcode_settings'",
",",
"{",
"}",
")",
"for",
"config",
"in",
"spec",
"[",
"'configurations'",
"]",
".",
"values",
"(",
")",
":",
"if",
"'xcode_settings'",
"in",
"config",
":",
"new_settings",
"=",
"global_xcode_settings",
".",
"copy",
"(",
")",
"new_settings",
".",
"update",
"(",
"config",
"[",
"'xcode_settings'",
"]",
")",
"config",
"[",
"'xcode_settings'",
"]",
"=",
"new_settings"
] | [
1338,
0
] | [
1351,
45
] | python | en | ['en', 'en', 'en'] | True |
IsMacBundle | (flavor, spec) | Returns if |spec| should be treated as a bundle.
Bundles are directories with a certain subdirectory structure, instead of
just a single file. Bundle rules do not produce a binary but also package
resources into that directory. | Returns if |spec| should be treated as a bundle. | def IsMacBundle(flavor, spec):
"""Returns if |spec| should be treated as a bundle.
Bundles are directories with a certain subdirectory structure, instead of
just a single file. Bundle rules do not produce a binary but also package
resources into that directory."""
is_mac_bundle = (int(spec.get('mac_bundle', 0)) != 0 and flavor == 'mac')
if is_mac_bundle:
assert spec['type'] != 'none', (
'mac_bundle targets cannot have type none (target "%s")' %
spec['target_name'])
return is_mac_bundle | [
"def",
"IsMacBundle",
"(",
"flavor",
",",
"spec",
")",
":",
"is_mac_bundle",
"=",
"(",
"int",
"(",
"spec",
".",
"get",
"(",
"'mac_bundle'",
",",
"0",
")",
")",
"!=",
"0",
"and",
"flavor",
"==",
"'mac'",
")",
"if",
"is_mac_bundle",
":",
"assert",
"spec",
"[",
"'type'",
"]",
"!=",
"'none'",
",",
"(",
"'mac_bundle targets cannot have type none (target \"%s\")'",
"%",
"spec",
"[",
"'target_name'",
"]",
")",
"return",
"is_mac_bundle"
] | [
1354,
0
] | [
1365,
22
] | python | en | ['en', 'en', 'en'] | True |
GetMacBundleResources | (product_dir, xcode_settings, resources) | Yields (output, resource) pairs for every resource in |resources|.
Only call this for mac bundle targets.
Args:
product_dir: Path to the directory containing the output bundle,
relative to the build directory.
xcode_settings: The XcodeSettings of the current target.
resources: A list of bundle resources, relative to the build directory.
| Yields (output, resource) pairs for every resource in |resources|.
Only call this for mac bundle targets. | def GetMacBundleResources(product_dir, xcode_settings, resources):
"""Yields (output, resource) pairs for every resource in |resources|.
Only call this for mac bundle targets.
Args:
product_dir: Path to the directory containing the output bundle,
relative to the build directory.
xcode_settings: The XcodeSettings of the current target.
resources: A list of bundle resources, relative to the build directory.
"""
dest = os.path.join(product_dir,
xcode_settings.GetBundleResourceFolder())
for res in resources:
output = dest
# The make generator doesn't support it, so forbid it everywhere
# to keep the generators more interchangable.
assert ' ' not in res, (
"Spaces in resource filenames not supported (%s)" % res)
# Split into (path,file).
res_parts = os.path.split(res)
# Now split the path into (prefix,maybe.lproj).
lproj_parts = os.path.split(res_parts[0])
# If the resource lives in a .lproj bundle, add that to the destination.
if lproj_parts[1].endswith('.lproj'):
output = os.path.join(output, lproj_parts[1])
output = os.path.join(output, res_parts[1])
# Compiled XIB files are referred to by .nib.
if output.endswith('.xib'):
output = os.path.splitext(output)[0] + '.nib'
# Compiled storyboard files are referred to by .storyboardc.
if output.endswith('.storyboard'):
output = os.path.splitext(output)[0] + '.storyboardc'
yield output, res | [
"def",
"GetMacBundleResources",
"(",
"product_dir",
",",
"xcode_settings",
",",
"resources",
")",
":",
"dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"product_dir",
",",
"xcode_settings",
".",
"GetBundleResourceFolder",
"(",
")",
")",
"for",
"res",
"in",
"resources",
":",
"output",
"=",
"dest",
"# The make generator doesn't support it, so forbid it everywhere",
"# to keep the generators more interchangable.",
"assert",
"' '",
"not",
"in",
"res",
",",
"(",
"\"Spaces in resource filenames not supported (%s)\"",
"%",
"res",
")",
"# Split into (path,file).",
"res_parts",
"=",
"os",
".",
"path",
".",
"split",
"(",
"res",
")",
"# Now split the path into (prefix,maybe.lproj).",
"lproj_parts",
"=",
"os",
".",
"path",
".",
"split",
"(",
"res_parts",
"[",
"0",
"]",
")",
"# If the resource lives in a .lproj bundle, add that to the destination.",
"if",
"lproj_parts",
"[",
"1",
"]",
".",
"endswith",
"(",
"'.lproj'",
")",
":",
"output",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output",
",",
"lproj_parts",
"[",
"1",
"]",
")",
"output",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output",
",",
"res_parts",
"[",
"1",
"]",
")",
"# Compiled XIB files are referred to by .nib.",
"if",
"output",
".",
"endswith",
"(",
"'.xib'",
")",
":",
"output",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"output",
")",
"[",
"0",
"]",
"+",
"'.nib'",
"# Compiled storyboard files are referred to by .storyboardc.",
"if",
"output",
".",
"endswith",
"(",
"'.storyboard'",
")",
":",
"output",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"output",
")",
"[",
"0",
"]",
"+",
"'.storyboardc'",
"yield",
"output",
",",
"res"
] | [
1368,
0
] | [
1405,
21
] | python | en | ['en', 'en', 'en'] | True |
GetMacInfoPlist | (product_dir, xcode_settings, gyp_path_to_build_path) | Returns (info_plist, dest_plist, defines, extra_env), where:
* |info_plist| is the source plist path, relative to the
build directory,
* |dest_plist| is the destination plist path, relative to the
build directory,
* |defines| is a list of preprocessor defines (empty if the plist
shouldn't be preprocessed,
* |extra_env| is a dict of env variables that should be exported when
invoking |mac_tool copy-info-plist|.
Only call this for mac bundle targets.
Args:
product_dir: Path to the directory containing the output bundle,
relative to the build directory.
xcode_settings: The XcodeSettings of the current target.
gyp_to_build_path: A function that converts paths relative to the
current gyp file to paths relative to the build direcotry.
| Returns (info_plist, dest_plist, defines, extra_env), where:
* |info_plist| is the source plist path, relative to the
build directory,
* |dest_plist| is the destination plist path, relative to the
build directory,
* |defines| is a list of preprocessor defines (empty if the plist
shouldn't be preprocessed,
* |extra_env| is a dict of env variables that should be exported when
invoking |mac_tool copy-info-plist|. | def GetMacInfoPlist(product_dir, xcode_settings, gyp_path_to_build_path):
"""Returns (info_plist, dest_plist, defines, extra_env), where:
* |info_plist| is the source plist path, relative to the
build directory,
* |dest_plist| is the destination plist path, relative to the
build directory,
* |defines| is a list of preprocessor defines (empty if the plist
shouldn't be preprocessed,
* |extra_env| is a dict of env variables that should be exported when
invoking |mac_tool copy-info-plist|.
Only call this for mac bundle targets.
Args:
product_dir: Path to the directory containing the output bundle,
relative to the build directory.
xcode_settings: The XcodeSettings of the current target.
gyp_to_build_path: A function that converts paths relative to the
current gyp file to paths relative to the build direcotry.
"""
info_plist = xcode_settings.GetPerTargetSetting('INFOPLIST_FILE')
if not info_plist:
return None, None, [], {}
# The make generator doesn't support it, so forbid it everywhere
# to keep the generators more interchangable.
assert ' ' not in info_plist, (
"Spaces in Info.plist filenames not supported (%s)" % info_plist)
info_plist = gyp_path_to_build_path(info_plist)
# If explicitly set to preprocess the plist, invoke the C preprocessor and
# specify any defines as -D flags.
if xcode_settings.GetPerTargetSetting(
'INFOPLIST_PREPROCESS', default='NO') == 'YES':
# Create an intermediate file based on the path.
defines = shlex.split(xcode_settings.GetPerTargetSetting(
'INFOPLIST_PREPROCESSOR_DEFINITIONS', default=''))
else:
defines = []
dest_plist = os.path.join(product_dir, xcode_settings.GetBundlePlistPath())
extra_env = xcode_settings.GetPerTargetSettings()
return info_plist, dest_plist, defines, extra_env | [
"def",
"GetMacInfoPlist",
"(",
"product_dir",
",",
"xcode_settings",
",",
"gyp_path_to_build_path",
")",
":",
"info_plist",
"=",
"xcode_settings",
".",
"GetPerTargetSetting",
"(",
"'INFOPLIST_FILE'",
")",
"if",
"not",
"info_plist",
":",
"return",
"None",
",",
"None",
",",
"[",
"]",
",",
"{",
"}",
"# The make generator doesn't support it, so forbid it everywhere",
"# to keep the generators more interchangable.",
"assert",
"' '",
"not",
"in",
"info_plist",
",",
"(",
"\"Spaces in Info.plist filenames not supported (%s)\"",
"%",
"info_plist",
")",
"info_plist",
"=",
"gyp_path_to_build_path",
"(",
"info_plist",
")",
"# If explicitly set to preprocess the plist, invoke the C preprocessor and",
"# specify any defines as -D flags.",
"if",
"xcode_settings",
".",
"GetPerTargetSetting",
"(",
"'INFOPLIST_PREPROCESS'",
",",
"default",
"=",
"'NO'",
")",
"==",
"'YES'",
":",
"# Create an intermediate file based on the path.",
"defines",
"=",
"shlex",
".",
"split",
"(",
"xcode_settings",
".",
"GetPerTargetSetting",
"(",
"'INFOPLIST_PREPROCESSOR_DEFINITIONS'",
",",
"default",
"=",
"''",
")",
")",
"else",
":",
"defines",
"=",
"[",
"]",
"dest_plist",
"=",
"os",
".",
"path",
".",
"join",
"(",
"product_dir",
",",
"xcode_settings",
".",
"GetBundlePlistPath",
"(",
")",
")",
"extra_env",
"=",
"xcode_settings",
".",
"GetPerTargetSettings",
"(",
")",
"return",
"info_plist",
",",
"dest_plist",
",",
"defines",
",",
"extra_env"
] | [
1408,
0
] | [
1452,
51
] | python | en | ['en', 'fr', 'en'] | True |
_GetXcodeEnv | (xcode_settings, built_products_dir, srcroot, configuration,
additional_settings=None) | Return the environment variables that Xcode would set. See
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153
for a full list.
Args:
xcode_settings: An XcodeSettings object. If this is None, this function
returns an empty dict.
built_products_dir: Absolute path to the built products dir.
srcroot: Absolute path to the source root.
configuration: The build configuration name.
additional_settings: An optional dict with more values to add to the
result.
| Return the environment variables that Xcode would set. See
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153
for a full list. | def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration,
additional_settings=None):
"""Return the environment variables that Xcode would set. See
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153
for a full list.
Args:
xcode_settings: An XcodeSettings object. If this is None, this function
returns an empty dict.
built_products_dir: Absolute path to the built products dir.
srcroot: Absolute path to the source root.
configuration: The build configuration name.
additional_settings: An optional dict with more values to add to the
result.
"""
if not xcode_settings: return {}
# This function is considered a friend of XcodeSettings, so let it reach into
# its implementation details.
spec = xcode_settings.spec
# These are filled in on a as-needed basis.
env = {
'BUILT_FRAMEWORKS_DIR' : built_products_dir,
'BUILT_PRODUCTS_DIR' : built_products_dir,
'CONFIGURATION' : configuration,
'PRODUCT_NAME' : xcode_settings.GetProductName(),
# See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME
'SRCROOT' : srcroot,
'SOURCE_ROOT': '${SRCROOT}',
# This is not true for static libraries, but currently the env is only
# written for bundles:
'TARGET_BUILD_DIR' : built_products_dir,
'TEMP_DIR' : '${TMPDIR}',
}
if xcode_settings.GetPerConfigSetting('SDKROOT', configuration):
env['SDKROOT'] = xcode_settings._SdkPath(configuration)
else:
env['SDKROOT'] = ''
if spec['type'] in (
'executable', 'static_library', 'shared_library', 'loadable_module'):
env['EXECUTABLE_NAME'] = xcode_settings.GetExecutableName()
env['EXECUTABLE_PATH'] = xcode_settings.GetExecutablePath()
env['FULL_PRODUCT_NAME'] = xcode_settings.GetFullProductName()
mach_o_type = xcode_settings.GetMachOType()
if mach_o_type:
env['MACH_O_TYPE'] = mach_o_type
env['PRODUCT_TYPE'] = xcode_settings.GetProductType()
if xcode_settings._IsBundle():
env['CONTENTS_FOLDER_PATH'] = \
xcode_settings.GetBundleContentsFolderPath()
env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \
xcode_settings.GetBundleResourceFolder()
env['INFOPLIST_PATH'] = xcode_settings.GetBundlePlistPath()
env['WRAPPER_NAME'] = xcode_settings.GetWrapperName()
install_name = xcode_settings.GetInstallName()
if install_name:
env['LD_DYLIB_INSTALL_NAME'] = install_name
install_name_base = xcode_settings.GetInstallNameBase()
if install_name_base:
env['DYLIB_INSTALL_NAME_BASE'] = install_name_base
if XcodeVersion() >= '0500' and not env.get('SDKROOT'):
sdk_root = xcode_settings._SdkRoot(configuration)
if not sdk_root:
sdk_root = xcode_settings._XcodeSdkPath('')
if sdk_root is None:
sdk_root = ''
env['SDKROOT'] = sdk_root
if not additional_settings:
additional_settings = {}
else:
# Flatten lists to strings.
for k in additional_settings:
if not isinstance(additional_settings[k], str):
additional_settings[k] = ' '.join(additional_settings[k])
additional_settings.update(env)
for k in additional_settings:
additional_settings[k] = _NormalizeEnvVarReferences(additional_settings[k])
return additional_settings | [
"def",
"_GetXcodeEnv",
"(",
"xcode_settings",
",",
"built_products_dir",
",",
"srcroot",
",",
"configuration",
",",
"additional_settings",
"=",
"None",
")",
":",
"if",
"not",
"xcode_settings",
":",
"return",
"{",
"}",
"# This function is considered a friend of XcodeSettings, so let it reach into",
"# its implementation details.",
"spec",
"=",
"xcode_settings",
".",
"spec",
"# These are filled in on a as-needed basis.",
"env",
"=",
"{",
"'BUILT_FRAMEWORKS_DIR'",
":",
"built_products_dir",
",",
"'BUILT_PRODUCTS_DIR'",
":",
"built_products_dir",
",",
"'CONFIGURATION'",
":",
"configuration",
",",
"'PRODUCT_NAME'",
":",
"xcode_settings",
".",
"GetProductName",
"(",
")",
",",
"# See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\\ Product\\ Types.xcspec for FULL_PRODUCT_NAME",
"'SRCROOT'",
":",
"srcroot",
",",
"'SOURCE_ROOT'",
":",
"'${SRCROOT}'",
",",
"# This is not true for static libraries, but currently the env is only",
"# written for bundles:",
"'TARGET_BUILD_DIR'",
":",
"built_products_dir",
",",
"'TEMP_DIR'",
":",
"'${TMPDIR}'",
",",
"}",
"if",
"xcode_settings",
".",
"GetPerConfigSetting",
"(",
"'SDKROOT'",
",",
"configuration",
")",
":",
"env",
"[",
"'SDKROOT'",
"]",
"=",
"xcode_settings",
".",
"_SdkPath",
"(",
"configuration",
")",
"else",
":",
"env",
"[",
"'SDKROOT'",
"]",
"=",
"''",
"if",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'executable'",
",",
"'static_library'",
",",
"'shared_library'",
",",
"'loadable_module'",
")",
":",
"env",
"[",
"'EXECUTABLE_NAME'",
"]",
"=",
"xcode_settings",
".",
"GetExecutableName",
"(",
")",
"env",
"[",
"'EXECUTABLE_PATH'",
"]",
"=",
"xcode_settings",
".",
"GetExecutablePath",
"(",
")",
"env",
"[",
"'FULL_PRODUCT_NAME'",
"]",
"=",
"xcode_settings",
".",
"GetFullProductName",
"(",
")",
"mach_o_type",
"=",
"xcode_settings",
".",
"GetMachOType",
"(",
")",
"if",
"mach_o_type",
":",
"env",
"[",
"'MACH_O_TYPE'",
"]",
"=",
"mach_o_type",
"env",
"[",
"'PRODUCT_TYPE'",
"]",
"=",
"xcode_settings",
".",
"GetProductType",
"(",
")",
"if",
"xcode_settings",
".",
"_IsBundle",
"(",
")",
":",
"env",
"[",
"'CONTENTS_FOLDER_PATH'",
"]",
"=",
"xcode_settings",
".",
"GetBundleContentsFolderPath",
"(",
")",
"env",
"[",
"'UNLOCALIZED_RESOURCES_FOLDER_PATH'",
"]",
"=",
"xcode_settings",
".",
"GetBundleResourceFolder",
"(",
")",
"env",
"[",
"'INFOPLIST_PATH'",
"]",
"=",
"xcode_settings",
".",
"GetBundlePlistPath",
"(",
")",
"env",
"[",
"'WRAPPER_NAME'",
"]",
"=",
"xcode_settings",
".",
"GetWrapperName",
"(",
")",
"install_name",
"=",
"xcode_settings",
".",
"GetInstallName",
"(",
")",
"if",
"install_name",
":",
"env",
"[",
"'LD_DYLIB_INSTALL_NAME'",
"]",
"=",
"install_name",
"install_name_base",
"=",
"xcode_settings",
".",
"GetInstallNameBase",
"(",
")",
"if",
"install_name_base",
":",
"env",
"[",
"'DYLIB_INSTALL_NAME_BASE'",
"]",
"=",
"install_name_base",
"if",
"XcodeVersion",
"(",
")",
">=",
"'0500'",
"and",
"not",
"env",
".",
"get",
"(",
"'SDKROOT'",
")",
":",
"sdk_root",
"=",
"xcode_settings",
".",
"_SdkRoot",
"(",
"configuration",
")",
"if",
"not",
"sdk_root",
":",
"sdk_root",
"=",
"xcode_settings",
".",
"_XcodeSdkPath",
"(",
"''",
")",
"if",
"sdk_root",
"is",
"None",
":",
"sdk_root",
"=",
"''",
"env",
"[",
"'SDKROOT'",
"]",
"=",
"sdk_root",
"if",
"not",
"additional_settings",
":",
"additional_settings",
"=",
"{",
"}",
"else",
":",
"# Flatten lists to strings.",
"for",
"k",
"in",
"additional_settings",
":",
"if",
"not",
"isinstance",
"(",
"additional_settings",
"[",
"k",
"]",
",",
"str",
")",
":",
"additional_settings",
"[",
"k",
"]",
"=",
"' '",
".",
"join",
"(",
"additional_settings",
"[",
"k",
"]",
")",
"additional_settings",
".",
"update",
"(",
"env",
")",
"for",
"k",
"in",
"additional_settings",
":",
"additional_settings",
"[",
"k",
"]",
"=",
"_NormalizeEnvVarReferences",
"(",
"additional_settings",
"[",
"k",
"]",
")",
"return",
"additional_settings"
] | [
1455,
0
] | [
1538,
28
] | python | en | ['en', 'en', 'en'] | True |
_NormalizeEnvVarReferences | (str) | Takes a string containing variable references in the form ${FOO}, $(FOO),
or $FOO, and returns a string with all variable references in the form ${FOO}.
| Takes a string containing variable references in the form ${FOO}, $(FOO),
or $FOO, and returns a string with all variable references in the form ${FOO}.
| def _NormalizeEnvVarReferences(str):
"""Takes a string containing variable references in the form ${FOO}, $(FOO),
or $FOO, and returns a string with all variable references in the form ${FOO}.
"""
# $FOO -> ${FOO}
str = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'${\1}', str)
# $(FOO) -> ${FOO}
matches = re.findall(r'(\$\(([a-zA-Z0-9\-_]+)\))', str)
for match in matches:
to_replace, variable = match
assert '$(' not in match, '$($(FOO)) variables not supported: ' + match
str = str.replace(to_replace, '${' + variable + '}')
return str | [
"def",
"_NormalizeEnvVarReferences",
"(",
"str",
")",
":",
"# $FOO -> ${FOO}",
"str",
"=",
"re",
".",
"sub",
"(",
"r'\\$([a-zA-Z_][a-zA-Z0-9_]*)'",
",",
"r'${\\1}'",
",",
"str",
")",
"# $(FOO) -> ${FOO}",
"matches",
"=",
"re",
".",
"findall",
"(",
"r'(\\$\\(([a-zA-Z0-9\\-_]+)\\))'",
",",
"str",
")",
"for",
"match",
"in",
"matches",
":",
"to_replace",
",",
"variable",
"=",
"match",
"assert",
"'$('",
"not",
"in",
"match",
",",
"'$($(FOO)) variables not supported: '",
"+",
"match",
"str",
"=",
"str",
".",
"replace",
"(",
"to_replace",
",",
"'${'",
"+",
"variable",
"+",
"'}'",
")",
"return",
"str"
] | [
1541,
0
] | [
1555,
12
] | python | en | ['en', 'en', 'en'] | True |
ExpandEnvVars | (string, expansions) | Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
expansions list. If the variable expands to something that references
another variable, this variable is expanded as well if it's in env --
until no variables present in env are left. | Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
expansions list. If the variable expands to something that references
another variable, this variable is expanded as well if it's in env --
until no variables present in env are left. | def ExpandEnvVars(string, expansions):
"""Expands ${VARIABLES}, $(VARIABLES), and $VARIABLES in string per the
expansions list. If the variable expands to something that references
another variable, this variable is expanded as well if it's in env --
until no variables present in env are left."""
for k, v in reversed(expansions):
string = string.replace('${' + k + '}', v)
string = string.replace('$(' + k + ')', v)
string = string.replace('$' + k, v)
return string | [
"def",
"ExpandEnvVars",
"(",
"string",
",",
"expansions",
")",
":",
"for",
"k",
",",
"v",
"in",
"reversed",
"(",
"expansions",
")",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"'${'",
"+",
"k",
"+",
"'}'",
",",
"v",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"'$('",
"+",
"k",
"+",
"')'",
",",
"v",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"'$'",
"+",
"k",
",",
"v",
")",
"return",
"string"
] | [
1558,
0
] | [
1567,
15
] | python | en | ['en', 'en', 'en'] | True |
_TopologicallySortedEnvVarKeys | (env) | Takes a dict |env| whose values are strings that can refer to other keys,
for example env['foo'] = '$(bar) and $(baz)'. Returns a list L of all keys of
env such that key2 is after key1 in L if env[key2] refers to env[key1].
Throws an Exception in case of dependency cycles.
| Takes a dict |env| whose values are strings that can refer to other keys,
for example env['foo'] = '$(bar) and $(baz)'. Returns a list L of all keys of
env such that key2 is after key1 in L if env[key2] refers to env[key1]. | def _TopologicallySortedEnvVarKeys(env):
"""Takes a dict |env| whose values are strings that can refer to other keys,
for example env['foo'] = '$(bar) and $(baz)'. Returns a list L of all keys of
env such that key2 is after key1 in L if env[key2] refers to env[key1].
Throws an Exception in case of dependency cycles.
"""
# Since environment variables can refer to other variables, the evaluation
# order is important. Below is the logic to compute the dependency graph
# and sort it.
regex = re.compile(r'\$\{([a-zA-Z0-9\-_]+)\}')
def GetEdges(node):
# Use a definition of edges such that user_of_variable -> used_varible.
# This happens to be easier in this case, since a variable's
# definition contains all variables it references in a single string.
# We can then reverse the result of the topological sort at the end.
# Since: reverse(topsort(DAG)) = topsort(reverse_edges(DAG))
matches = set([v for v in regex.findall(env[node]) if v in env])
for dependee in matches:
assert '${' not in dependee, 'Nested variables not supported: ' + dependee
return matches
try:
# Topologically sort, and then reverse, because we used an edge definition
# that's inverted from the expected result of this function (see comment
# above).
order = gyp.common.TopologicallySorted(env.keys(), GetEdges)
order.reverse()
return order
except gyp.common.CycleError, e:
raise GypError(
'Xcode environment variables are cyclically dependent: ' + str(e.nodes)) | [
"def",
"_TopologicallySortedEnvVarKeys",
"(",
"env",
")",
":",
"# Since environment variables can refer to other variables, the evaluation",
"# order is important. Below is the logic to compute the dependency graph",
"# and sort it.",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'\\$\\{([a-zA-Z0-9\\-_]+)\\}'",
")",
"def",
"GetEdges",
"(",
"node",
")",
":",
"# Use a definition of edges such that user_of_variable -> used_varible.",
"# This happens to be easier in this case, since a variable's",
"# definition contains all variables it references in a single string.",
"# We can then reverse the result of the topological sort at the end.",
"# Since: reverse(topsort(DAG)) = topsort(reverse_edges(DAG))",
"matches",
"=",
"set",
"(",
"[",
"v",
"for",
"v",
"in",
"regex",
".",
"findall",
"(",
"env",
"[",
"node",
"]",
")",
"if",
"v",
"in",
"env",
"]",
")",
"for",
"dependee",
"in",
"matches",
":",
"assert",
"'${'",
"not",
"in",
"dependee",
",",
"'Nested variables not supported: '",
"+",
"dependee",
"return",
"matches",
"try",
":",
"# Topologically sort, and then reverse, because we used an edge definition",
"# that's inverted from the expected result of this function (see comment",
"# above).",
"order",
"=",
"gyp",
".",
"common",
".",
"TopologicallySorted",
"(",
"env",
".",
"keys",
"(",
")",
",",
"GetEdges",
")",
"order",
".",
"reverse",
"(",
")",
"return",
"order",
"except",
"gyp",
".",
"common",
".",
"CycleError",
",",
"e",
":",
"raise",
"GypError",
"(",
"'Xcode environment variables are cyclically dependent: '",
"+",
"str",
"(",
"e",
".",
"nodes",
")",
")"
] | [
1570,
0
] | [
1601,
80
] | python | en | ['en', 'en', 'en'] | True |
GetSpecPostbuildCommands | (spec, quiet=False) | Returns the list of postbuilds explicitly defined on |spec|, in a form
executable by a shell. | Returns the list of postbuilds explicitly defined on |spec|, in a form
executable by a shell. | def GetSpecPostbuildCommands(spec, quiet=False):
"""Returns the list of postbuilds explicitly defined on |spec|, in a form
executable by a shell."""
postbuilds = []
for postbuild in spec.get('postbuilds', []):
if not quiet:
postbuilds.append('echo POSTBUILD\\(%s\\) %s' % (
spec['target_name'], postbuild['postbuild_name']))
postbuilds.append(gyp.common.EncodePOSIXShellList(postbuild['action']))
return postbuilds | [
"def",
"GetSpecPostbuildCommands",
"(",
"spec",
",",
"quiet",
"=",
"False",
")",
":",
"postbuilds",
"=",
"[",
"]",
"for",
"postbuild",
"in",
"spec",
".",
"get",
"(",
"'postbuilds'",
",",
"[",
"]",
")",
":",
"if",
"not",
"quiet",
":",
"postbuilds",
".",
"append",
"(",
"'echo POSTBUILD\\\\(%s\\\\) %s'",
"%",
"(",
"spec",
"[",
"'target_name'",
"]",
",",
"postbuild",
"[",
"'postbuild_name'",
"]",
")",
")",
"postbuilds",
".",
"append",
"(",
"gyp",
".",
"common",
".",
"EncodePOSIXShellList",
"(",
"postbuild",
"[",
"'action'",
"]",
")",
")",
"return",
"postbuilds"
] | [
1611,
0
] | [
1620,
19
] | python | en | ['en', 'en', 'en'] | True |
_HasIOSTarget | (targets) | Returns true if any target contains the iOS specific key
IPHONEOS_DEPLOYMENT_TARGET. | Returns true if any target contains the iOS specific key
IPHONEOS_DEPLOYMENT_TARGET. | def _HasIOSTarget(targets):
"""Returns true if any target contains the iOS specific key
IPHONEOS_DEPLOYMENT_TARGET."""
for target_dict in targets.values():
for config in target_dict['configurations'].values():
if config.get('xcode_settings', {}).get('IPHONEOS_DEPLOYMENT_TARGET'):
return True
return False | [
"def",
"_HasIOSTarget",
"(",
"targets",
")",
":",
"for",
"target_dict",
"in",
"targets",
".",
"values",
"(",
")",
":",
"for",
"config",
"in",
"target_dict",
"[",
"'configurations'",
"]",
".",
"values",
"(",
")",
":",
"if",
"config",
".",
"get",
"(",
"'xcode_settings'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'IPHONEOS_DEPLOYMENT_TARGET'",
")",
":",
"return",
"True",
"return",
"False"
] | [
1623,
0
] | [
1630,
14
] | python | en | ['en', 'en', 'en'] | True |
_AddIOSDeviceConfigurations | (targets) | Clone all targets and append -iphoneos to the name. Configure these targets
to build for iOS devices and use correct architectures for those builds. | Clone all targets and append -iphoneos to the name. Configure these targets
to build for iOS devices and use correct architectures for those builds. | def _AddIOSDeviceConfigurations(targets):
"""Clone all targets and append -iphoneos to the name. Configure these targets
to build for iOS devices and use correct architectures for those builds."""
for target_dict in targets.itervalues():
toolset = target_dict['toolset']
configs = target_dict['configurations']
for config_name, config_dict in dict(configs).iteritems():
iphoneos_config_dict = copy.deepcopy(config_dict)
configs[config_name + '-iphoneos'] = iphoneos_config_dict
configs[config_name + '-iphonesimulator'] = config_dict
if toolset == 'target':
iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos'
return targets | [
"def",
"_AddIOSDeviceConfigurations",
"(",
"targets",
")",
":",
"for",
"target_dict",
"in",
"targets",
".",
"itervalues",
"(",
")",
":",
"toolset",
"=",
"target_dict",
"[",
"'toolset'",
"]",
"configs",
"=",
"target_dict",
"[",
"'configurations'",
"]",
"for",
"config_name",
",",
"config_dict",
"in",
"dict",
"(",
"configs",
")",
".",
"iteritems",
"(",
")",
":",
"iphoneos_config_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"config_dict",
")",
"configs",
"[",
"config_name",
"+",
"'-iphoneos'",
"]",
"=",
"iphoneos_config_dict",
"configs",
"[",
"config_name",
"+",
"'-iphonesimulator'",
"]",
"=",
"config_dict",
"if",
"toolset",
"==",
"'target'",
":",
"iphoneos_config_dict",
"[",
"'xcode_settings'",
"]",
"[",
"'SDKROOT'",
"]",
"=",
"'iphoneos'",
"return",
"targets"
] | [
1633,
0
] | [
1645,
16
] | python | en | ['en', 'en', 'en'] | True |
CloneConfigurationForDeviceAndEmulator | (target_dicts) | If |target_dicts| contains any iOS targets, automatically create -iphoneos
targets for iOS device builds. | If |target_dicts| contains any iOS targets, automatically create -iphoneos
targets for iOS device builds. | def CloneConfigurationForDeviceAndEmulator(target_dicts):
"""If |target_dicts| contains any iOS targets, automatically create -iphoneos
targets for iOS device builds."""
if _HasIOSTarget(target_dicts):
return _AddIOSDeviceConfigurations(target_dicts)
return target_dicts | [
"def",
"CloneConfigurationForDeviceAndEmulator",
"(",
"target_dicts",
")",
":",
"if",
"_HasIOSTarget",
"(",
"target_dicts",
")",
":",
"return",
"_AddIOSDeviceConfigurations",
"(",
"target_dicts",
")",
"return",
"target_dicts"
] | [
1647,
0
] | [
1652,
21
] | python | en | ['en', 'en', 'en'] | True |
XcodeArchsDefault._VariableMapping | (self, sdkroot) | Returns the dictionary of variable mapping depending on the SDKROOT. | Returns the dictionary of variable mapping depending on the SDKROOT. | def _VariableMapping(self, sdkroot):
"""Returns the dictionary of variable mapping depending on the SDKROOT."""
sdkroot = sdkroot.lower()
if 'iphoneos' in sdkroot:
return self._archs['ios']
elif 'iphonesimulator' in sdkroot:
return self._archs['iossim']
else:
return self._archs['mac'] | [
"def",
"_VariableMapping",
"(",
"self",
",",
"sdkroot",
")",
":",
"sdkroot",
"=",
"sdkroot",
".",
"lower",
"(",
")",
"if",
"'iphoneos'",
"in",
"sdkroot",
":",
"return",
"self",
".",
"_archs",
"[",
"'ios'",
"]",
"elif",
"'iphonesimulator'",
"in",
"sdkroot",
":",
"return",
"self",
".",
"_archs",
"[",
"'iossim'",
"]",
"else",
":",
"return",
"self",
".",
"_archs",
"[",
"'mac'",
"]"
] | [
52,
2
] | [
60,
31
] | python | en | ['en', 'en', 'en'] | True |
XcodeArchsDefault._ExpandArchs | (self, archs, sdkroot) | Expands variables references in ARCHS, and remove duplicates. | Expands variables references in ARCHS, and remove duplicates. | def _ExpandArchs(self, archs, sdkroot):
"""Expands variables references in ARCHS, and remove duplicates."""
variable_mapping = self._VariableMapping(sdkroot)
expanded_archs = []
for arch in archs:
if self.variable_pattern.match(arch):
variable = arch
try:
variable_expansion = variable_mapping[variable]
for arch in variable_expansion:
if arch not in expanded_archs:
expanded_archs.append(arch)
except KeyError as e:
print 'Warning: Ignoring unsupported variable "%s".' % variable
elif arch not in expanded_archs:
expanded_archs.append(arch)
return expanded_archs | [
"def",
"_ExpandArchs",
"(",
"self",
",",
"archs",
",",
"sdkroot",
")",
":",
"variable_mapping",
"=",
"self",
".",
"_VariableMapping",
"(",
"sdkroot",
")",
"expanded_archs",
"=",
"[",
"]",
"for",
"arch",
"in",
"archs",
":",
"if",
"self",
".",
"variable_pattern",
".",
"match",
"(",
"arch",
")",
":",
"variable",
"=",
"arch",
"try",
":",
"variable_expansion",
"=",
"variable_mapping",
"[",
"variable",
"]",
"for",
"arch",
"in",
"variable_expansion",
":",
"if",
"arch",
"not",
"in",
"expanded_archs",
":",
"expanded_archs",
".",
"append",
"(",
"arch",
")",
"except",
"KeyError",
"as",
"e",
":",
"print",
"'Warning: Ignoring unsupported variable \"%s\".'",
"%",
"variable",
"elif",
"arch",
"not",
"in",
"expanded_archs",
":",
"expanded_archs",
".",
"append",
"(",
"arch",
")",
"return",
"expanded_archs"
] | [
62,
2
] | [
78,
25
] | python | en | ['en', 'en', 'en'] | True |
XcodeArchsDefault.ActiveArchs | (self, archs, valid_archs, sdkroot) | Expands variables references in ARCHS, and filter by VALID_ARCHS if it
is defined (if not set, Xcode accept any value in ARCHS, otherwise, only
values present in VALID_ARCHS are kept). | Expands variables references in ARCHS, and filter by VALID_ARCHS if it
is defined (if not set, Xcode accept any value in ARCHS, otherwise, only
values present in VALID_ARCHS are kept). | def ActiveArchs(self, archs, valid_archs, sdkroot):
"""Expands variables references in ARCHS, and filter by VALID_ARCHS if it
is defined (if not set, Xcode accept any value in ARCHS, otherwise, only
values present in VALID_ARCHS are kept)."""
expanded_archs = self._ExpandArchs(archs or self._default, sdkroot or '')
if valid_archs:
filtered_archs = []
for arch in expanded_archs:
if arch in valid_archs:
filtered_archs.append(arch)
expanded_archs = filtered_archs
return expanded_archs | [
"def",
"ActiveArchs",
"(",
"self",
",",
"archs",
",",
"valid_archs",
",",
"sdkroot",
")",
":",
"expanded_archs",
"=",
"self",
".",
"_ExpandArchs",
"(",
"archs",
"or",
"self",
".",
"_default",
",",
"sdkroot",
"or",
"''",
")",
"if",
"valid_archs",
":",
"filtered_archs",
"=",
"[",
"]",
"for",
"arch",
"in",
"expanded_archs",
":",
"if",
"arch",
"in",
"valid_archs",
":",
"filtered_archs",
".",
"append",
"(",
"arch",
")",
"expanded_archs",
"=",
"filtered_archs",
"return",
"expanded_archs"
] | [
80,
2
] | [
91,
25
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._ConvertConditionalKeys | (self, configname) | Converts or warns on conditional keys. Xcode supports conditional keys,
such as CODE_SIGN_IDENTITY[sdk=iphoneos*]. This is a partial implementation
with some keys converted while the rest force a warning. | Converts or warns on conditional keys. Xcode supports conditional keys,
such as CODE_SIGN_IDENTITY[sdk=iphoneos*]. This is a partial implementation
with some keys converted while the rest force a warning. | def _ConvertConditionalKeys(self, configname):
"""Converts or warns on conditional keys. Xcode supports conditional keys,
such as CODE_SIGN_IDENTITY[sdk=iphoneos*]. This is a partial implementation
with some keys converted while the rest force a warning."""
settings = self.xcode_settings[configname]
conditional_keys = [key for key in settings if key.endswith(']')]
for key in conditional_keys:
# If you need more, speak up at http://crbug.com/122592
if key.endswith("[sdk=iphoneos*]"):
if configname.endswith("iphoneos"):
new_key = key.split("[")[0]
settings[new_key] = settings[key]
else:
print 'Warning: Conditional keys not implemented, ignoring:', \
' '.join(conditional_keys)
del settings[key] | [
"def",
"_ConvertConditionalKeys",
"(",
"self",
",",
"configname",
")",
":",
"settings",
"=",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
"conditional_keys",
"=",
"[",
"key",
"for",
"key",
"in",
"settings",
"if",
"key",
".",
"endswith",
"(",
"']'",
")",
"]",
"for",
"key",
"in",
"conditional_keys",
":",
"# If you need more, speak up at http://crbug.com/122592",
"if",
"key",
".",
"endswith",
"(",
"\"[sdk=iphoneos*]\"",
")",
":",
"if",
"configname",
".",
"endswith",
"(",
"\"iphoneos\"",
")",
":",
"new_key",
"=",
"key",
".",
"split",
"(",
"\"[\"",
")",
"[",
"0",
"]",
"settings",
"[",
"new_key",
"]",
"=",
"settings",
"[",
"key",
"]",
"else",
":",
"print",
"'Warning: Conditional keys not implemented, ignoring:'",
",",
"' '",
".",
"join",
"(",
"conditional_keys",
")",
"del",
"settings",
"[",
"key",
"]"
] | [
183,
2
] | [
198,
23
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetFrameworkVersion | (self) | Returns the framework version of the current target. Only valid for
bundles. | Returns the framework version of the current target. Only valid for
bundles. | def GetFrameworkVersion(self):
"""Returns the framework version of the current target. Only valid for
bundles."""
assert self._IsBundle()
return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A') | [
"def",
"GetFrameworkVersion",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"return",
"self",
".",
"GetPerTargetSetting",
"(",
"'FRAMEWORK_VERSION'",
",",
"default",
"=",
"'A'",
")"
] | [
238,
2
] | [
242,
69
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetWrapperExtension | (self) | Returns the bundle extension (.app, .framework, .plugin, etc). Only
valid for bundles. | Returns the bundle extension (.app, .framework, .plugin, etc). Only
valid for bundles. | def GetWrapperExtension(self):
"""Returns the bundle extension (.app, .framework, .plugin, etc). Only
valid for bundles."""
assert self._IsBundle()
if self.spec['type'] in ('loadable_module', 'shared_library'):
default_wrapper_extension = {
'loadable_module': 'bundle',
'shared_library': 'framework',
}[self.spec['type']]
wrapper_extension = self.GetPerTargetSetting(
'WRAPPER_EXTENSION', default=default_wrapper_extension)
return '.' + self.spec.get('product_extension', wrapper_extension)
elif self.spec['type'] == 'executable':
if self._IsIosAppExtension() or self._IsIosWatchKitExtension():
return '.' + self.spec.get('product_extension', 'appex')
else:
return '.' + self.spec.get('product_extension', 'app')
else:
assert False, "Don't know extension for '%s', target '%s'" % (
self.spec['type'], self.spec['target_name']) | [
"def",
"GetWrapperExtension",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'loadable_module'",
",",
"'shared_library'",
")",
":",
"default_wrapper_extension",
"=",
"{",
"'loadable_module'",
":",
"'bundle'",
",",
"'shared_library'",
":",
"'framework'",
",",
"}",
"[",
"self",
".",
"spec",
"[",
"'type'",
"]",
"]",
"wrapper_extension",
"=",
"self",
".",
"GetPerTargetSetting",
"(",
"'WRAPPER_EXTENSION'",
",",
"default",
"=",
"default_wrapper_extension",
")",
"return",
"'.'",
"+",
"self",
".",
"spec",
".",
"get",
"(",
"'product_extension'",
",",
"wrapper_extension",
")",
"elif",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'executable'",
":",
"if",
"self",
".",
"_IsIosAppExtension",
"(",
")",
"or",
"self",
".",
"_IsIosWatchKitExtension",
"(",
")",
":",
"return",
"'.'",
"+",
"self",
".",
"spec",
".",
"get",
"(",
"'product_extension'",
",",
"'appex'",
")",
"else",
":",
"return",
"'.'",
"+",
"self",
".",
"spec",
".",
"get",
"(",
"'product_extension'",
",",
"'app'",
")",
"else",
":",
"assert",
"False",
",",
"\"Don't know extension for '%s', target '%s'\"",
"%",
"(",
"self",
".",
"spec",
"[",
"'type'",
"]",
",",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")"
] | [
244,
2
] | [
263,
54
] | python | en | ['en', 'da', 'en'] | True |
XcodeSettings.GetProductName | (self) | Returns PRODUCT_NAME. | Returns PRODUCT_NAME. | def GetProductName(self):
"""Returns PRODUCT_NAME."""
return self.spec.get('product_name', self.spec['target_name']) | [
"def",
"GetProductName",
"(",
"self",
")",
":",
"return",
"self",
".",
"spec",
".",
"get",
"(",
"'product_name'",
",",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")"
] | [
265,
2
] | [
267,
66
] | python | en | ['en', 'en', 'en'] | False |
XcodeSettings.GetFullProductName | (self) | Returns FULL_PRODUCT_NAME. | Returns FULL_PRODUCT_NAME. | def GetFullProductName(self):
"""Returns FULL_PRODUCT_NAME."""
if self._IsBundle():
return self.GetWrapperName()
else:
return self._GetStandaloneBinaryPath() | [
"def",
"GetFullProductName",
"(",
"self",
")",
":",
"if",
"self",
".",
"_IsBundle",
"(",
")",
":",
"return",
"self",
".",
"GetWrapperName",
"(",
")",
"else",
":",
"return",
"self",
".",
"_GetStandaloneBinaryPath",
"(",
")"
] | [
269,
2
] | [
274,
44
] | python | en | ['en', 'no', 'en'] | False |
XcodeSettings.GetWrapperName | (self) | Returns the directory name of the bundle represented by this target.
Only valid for bundles. | Returns the directory name of the bundle represented by this target.
Only valid for bundles. | def GetWrapperName(self):
"""Returns the directory name of the bundle represented by this target.
Only valid for bundles."""
assert self._IsBundle()
return self.GetProductName() + self.GetWrapperExtension() | [
"def",
"GetWrapperName",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"return",
"self",
".",
"GetProductName",
"(",
")",
"+",
"self",
".",
"GetWrapperExtension",
"(",
")"
] | [
276,
2
] | [
280,
61
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetBundleContentsFolderPath | (self) | Returns the qualified path to the bundle's contents folder. E.g.
Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles. | Returns the qualified path to the bundle's contents folder. E.g.
Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles. | def GetBundleContentsFolderPath(self):
"""Returns the qualified path to the bundle's contents folder. E.g.
Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles."""
if self.isIOS:
return self.GetWrapperName()
assert self._IsBundle()
if self.spec['type'] == 'shared_library':
return os.path.join(
self.GetWrapperName(), 'Versions', self.GetFrameworkVersion())
else:
# loadable_modules have a 'Contents' folder like executables.
return os.path.join(self.GetWrapperName(), 'Contents') | [
"def",
"GetBundleContentsFolderPath",
"(",
"self",
")",
":",
"if",
"self",
".",
"isIOS",
":",
"return",
"self",
".",
"GetWrapperName",
"(",
")",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'shared_library'",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetWrapperName",
"(",
")",
",",
"'Versions'",
",",
"self",
".",
"GetFrameworkVersion",
"(",
")",
")",
"else",
":",
"# loadable_modules have a 'Contents' folder like executables.",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetWrapperName",
"(",
")",
",",
"'Contents'",
")"
] | [
282,
2
] | [
293,
60
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetBundleResourceFolder | (self) | Returns the qualified path to the bundle's resource folder. E.g.
Chromium.app/Contents/Resources. Only valid for bundles. | Returns the qualified path to the bundle's resource folder. E.g.
Chromium.app/Contents/Resources. Only valid for bundles. | def GetBundleResourceFolder(self):
"""Returns the qualified path to the bundle's resource folder. E.g.
Chromium.app/Contents/Resources. Only valid for bundles."""
assert self._IsBundle()
if self.isIOS:
return self.GetBundleContentsFolderPath()
return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') | [
"def",
"GetBundleResourceFolder",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"if",
"self",
".",
"isIOS",
":",
"return",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
",",
"'Resources'",
")"
] | [
295,
2
] | [
301,
72
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetBundlePlistPath | (self) | Returns the qualified path to the bundle's plist file. E.g.
Chromium.app/Contents/Info.plist. Only valid for bundles. | Returns the qualified path to the bundle's plist file. E.g.
Chromium.app/Contents/Info.plist. Only valid for bundles. | def GetBundlePlistPath(self):
"""Returns the qualified path to the bundle's plist file. E.g.
Chromium.app/Contents/Info.plist. Only valid for bundles."""
assert self._IsBundle()
if self.spec['type'] in ('executable', 'loadable_module'):
return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist')
else:
return os.path.join(self.GetBundleContentsFolderPath(),
'Resources', 'Info.plist') | [
"def",
"GetBundlePlistPath",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'executable'",
",",
"'loadable_module'",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
",",
"'Info.plist'",
")",
"else",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
",",
"'Resources'",
",",
"'Info.plist'",
")"
] | [
303,
2
] | [
311,
52
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetProductType | (self) | Returns the PRODUCT_TYPE of this target. | Returns the PRODUCT_TYPE of this target. | def GetProductType(self):
"""Returns the PRODUCT_TYPE of this target."""
if self._IsIosAppExtension():
assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle '
'(target %s)' % self.spec['target_name'])
return 'com.apple.product-type.app-extension'
if self._IsIosWatchKitExtension():
assert self._IsBundle(), ('ios_watchkit_extension flag requires '
'mac_bundle (target %s)' % self.spec['target_name'])
return 'com.apple.product-type.watchkit-extension'
if self._IsIosWatchApp():
assert self._IsBundle(), ('ios_watch_app flag requires mac_bundle '
'(target %s)' % self.spec['target_name'])
return 'com.apple.product-type.application.watchapp'
if self._IsBundle():
return {
'executable': 'com.apple.product-type.application',
'loadable_module': 'com.apple.product-type.bundle',
'shared_library': 'com.apple.product-type.framework',
}[self.spec['type']]
else:
return {
'executable': 'com.apple.product-type.tool',
'loadable_module': 'com.apple.product-type.library.dynamic',
'shared_library': 'com.apple.product-type.library.dynamic',
'static_library': 'com.apple.product-type.library.static',
}[self.spec['type']] | [
"def",
"GetProductType",
"(",
"self",
")",
":",
"if",
"self",
".",
"_IsIosAppExtension",
"(",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
",",
"(",
"'ios_app_extension flag requires mac_bundle '",
"'(target %s)'",
"%",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"return",
"'com.apple.product-type.app-extension'",
"if",
"self",
".",
"_IsIosWatchKitExtension",
"(",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
",",
"(",
"'ios_watchkit_extension flag requires '",
"'mac_bundle (target %s)'",
"%",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"return",
"'com.apple.product-type.watchkit-extension'",
"if",
"self",
".",
"_IsIosWatchApp",
"(",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
",",
"(",
"'ios_watch_app flag requires mac_bundle '",
"'(target %s)'",
"%",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"return",
"'com.apple.product-type.application.watchapp'",
"if",
"self",
".",
"_IsBundle",
"(",
")",
":",
"return",
"{",
"'executable'",
":",
"'com.apple.product-type.application'",
",",
"'loadable_module'",
":",
"'com.apple.product-type.bundle'",
",",
"'shared_library'",
":",
"'com.apple.product-type.framework'",
",",
"}",
"[",
"self",
".",
"spec",
"[",
"'type'",
"]",
"]",
"else",
":",
"return",
"{",
"'executable'",
":",
"'com.apple.product-type.tool'",
",",
"'loadable_module'",
":",
"'com.apple.product-type.library.dynamic'",
",",
"'shared_library'",
":",
"'com.apple.product-type.library.dynamic'",
",",
"'static_library'",
":",
"'com.apple.product-type.library.static'",
",",
"}",
"[",
"self",
".",
"spec",
"[",
"'type'",
"]",
"]"
] | [
313,
2
] | [
339,
26
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetMachOType | (self) | Returns the MACH_O_TYPE of this target. | Returns the MACH_O_TYPE of this target. | def GetMachOType(self):
"""Returns the MACH_O_TYPE of this target."""
# Weird, but matches Xcode.
if not self._IsBundle() and self.spec['type'] == 'executable':
return ''
return {
'executable': 'mh_execute',
'static_library': 'staticlib',
'shared_library': 'mh_dylib',
'loadable_module': 'mh_bundle',
}[self.spec['type']] | [
"def",
"GetMachOType",
"(",
"self",
")",
":",
"# Weird, but matches Xcode.",
"if",
"not",
"self",
".",
"_IsBundle",
"(",
")",
"and",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'executable'",
":",
"return",
"''",
"return",
"{",
"'executable'",
":",
"'mh_execute'",
",",
"'static_library'",
":",
"'staticlib'",
",",
"'shared_library'",
":",
"'mh_dylib'",
",",
"'loadable_module'",
":",
"'mh_bundle'",
",",
"}",
"[",
"self",
".",
"spec",
"[",
"'type'",
"]",
"]"
] | [
341,
2
] | [
351,
24
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetBundleBinaryPath | (self) | Returns the name of the bundle binary of by this target.
E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles. | Returns the name of the bundle binary of by this target.
E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles. | def _GetBundleBinaryPath(self):
"""Returns the name of the bundle binary of by this target.
E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles."""
assert self._IsBundle()
if self.spec['type'] in ('shared_library') or self.isIOS:
path = self.GetBundleContentsFolderPath()
elif self.spec['type'] in ('executable', 'loadable_module'):
path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS')
return os.path.join(path, self.GetExecutableName()) | [
"def",
"_GetBundleBinaryPath",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_IsBundle",
"(",
")",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'shared_library'",
")",
"or",
"self",
".",
"isIOS",
":",
"path",
"=",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
"elif",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'executable'",
",",
"'loadable_module'",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"GetBundleContentsFolderPath",
"(",
")",
",",
"'MacOS'",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"self",
".",
"GetExecutableName",
"(",
")",
")"
] | [
353,
2
] | [
361,
55
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetStandaloneBinaryPath | (self) | Returns the name of the non-bundle binary represented by this target.
E.g. hello_world. Only valid for non-bundles. | Returns the name of the non-bundle binary represented by this target.
E.g. hello_world. Only valid for non-bundles. | def _GetStandaloneBinaryPath(self):
"""Returns the name of the non-bundle binary represented by this target.
E.g. hello_world. Only valid for non-bundles."""
assert not self._IsBundle()
assert self.spec['type'] in (
'executable', 'shared_library', 'static_library', 'loadable_module'), (
'Unexpected type %s' % self.spec['type'])
target = self.spec['target_name']
if self.spec['type'] == 'static_library':
if target[:3] == 'lib':
target = target[3:]
elif self.spec['type'] in ('loadable_module', 'shared_library'):
if target[:3] == 'lib':
target = target[3:]
target_prefix = self._GetStandaloneExecutablePrefix()
target = self.spec.get('product_name', target)
target_ext = self._GetStandaloneExecutableSuffix()
return target_prefix + target + target_ext | [
"def",
"_GetStandaloneBinaryPath",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"_IsBundle",
"(",
")",
"assert",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'executable'",
",",
"'shared_library'",
",",
"'static_library'",
",",
"'loadable_module'",
")",
",",
"(",
"'Unexpected type %s'",
"%",
"self",
".",
"spec",
"[",
"'type'",
"]",
")",
"target",
"=",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'static_library'",
":",
"if",
"target",
"[",
":",
"3",
"]",
"==",
"'lib'",
":",
"target",
"=",
"target",
"[",
"3",
":",
"]",
"elif",
"self",
".",
"spec",
"[",
"'type'",
"]",
"in",
"(",
"'loadable_module'",
",",
"'shared_library'",
")",
":",
"if",
"target",
"[",
":",
"3",
"]",
"==",
"'lib'",
":",
"target",
"=",
"target",
"[",
"3",
":",
"]",
"target_prefix",
"=",
"self",
".",
"_GetStandaloneExecutablePrefix",
"(",
")",
"target",
"=",
"self",
".",
"spec",
".",
"get",
"(",
"'product_name'",
",",
"target",
")",
"target_ext",
"=",
"self",
".",
"_GetStandaloneExecutableSuffix",
"(",
")",
"return",
"target_prefix",
"+",
"target",
"+",
"target_ext"
] | [
383,
2
] | [
401,
46
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetExecutableName | (self) | Returns the executable name of the bundle represented by this target.
E.g. Chromium. | Returns the executable name of the bundle represented by this target.
E.g. Chromium. | def GetExecutableName(self):
"""Returns the executable name of the bundle represented by this target.
E.g. Chromium."""
if self._IsBundle():
return self.spec.get('product_name', self.spec['target_name'])
else:
return self._GetStandaloneBinaryPath() | [
"def",
"GetExecutableName",
"(",
"self",
")",
":",
"if",
"self",
".",
"_IsBundle",
"(",
")",
":",
"return",
"self",
".",
"spec",
".",
"get",
"(",
"'product_name'",
",",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"else",
":",
"return",
"self",
".",
"_GetStandaloneBinaryPath",
"(",
")"
] | [
403,
2
] | [
409,
44
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetExecutablePath | (self) | Returns the directory name of the bundle represented by this target. E.g.
Chromium.app/Contents/MacOS/Chromium. | Returns the directory name of the bundle represented by this target. E.g.
Chromium.app/Contents/MacOS/Chromium. | def GetExecutablePath(self):
"""Returns the directory name of the bundle represented by this target. E.g.
Chromium.app/Contents/MacOS/Chromium."""
if self._IsBundle():
return self._GetBundleBinaryPath()
else:
return self._GetStandaloneBinaryPath() | [
"def",
"GetExecutablePath",
"(",
"self",
")",
":",
"if",
"self",
".",
"_IsBundle",
"(",
")",
":",
"return",
"self",
".",
"_GetBundleBinaryPath",
"(",
")",
"else",
":",
"return",
"self",
".",
"_GetStandaloneBinaryPath",
"(",
")"
] | [
411,
2
] | [
417,
44
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetActiveArchs | (self, configname) | Returns the architectures this target should be built for. | Returns the architectures this target should be built for. | def GetActiveArchs(self, configname):
"""Returns the architectures this target should be built for."""
config_settings = self.xcode_settings[configname]
xcode_archs_default = GetXcodeArchsDefault()
return xcode_archs_default.ActiveArchs(
config_settings.get('ARCHS'),
config_settings.get('VALID_ARCHS'),
config_settings.get('SDKROOT')) | [
"def",
"GetActiveArchs",
"(",
"self",
",",
"configname",
")",
":",
"config_settings",
"=",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
"xcode_archs_default",
"=",
"GetXcodeArchsDefault",
"(",
")",
"return",
"xcode_archs_default",
".",
"ActiveArchs",
"(",
"config_settings",
".",
"get",
"(",
"'ARCHS'",
")",
",",
"config_settings",
".",
"get",
"(",
"'VALID_ARCHS'",
")",
",",
"config_settings",
".",
"get",
"(",
"'SDKROOT'",
")",
")"
] | [
419,
2
] | [
426,
39
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetCflags | (self, configname, arch=None) | Returns flags that need to be added to .c, .cc, .m, and .mm
compilations. | Returns flags that need to be added to .c, .cc, .m, and .mm
compilations. | def GetCflags(self, configname, arch=None):
"""Returns flags that need to be added to .c, .cc, .m, and .mm
compilations."""
# This functions (and the similar ones below) do not offer complete
# emulation of all xcode_settings keys. They're implemented on demand.
self.configname = configname
cflags = []
sdk_root = self._SdkPath()
if 'SDKROOT' in self._Settings() and sdk_root:
cflags.append('-isysroot %s' % sdk_root)
if self._Test('CLANG_WARN_CONSTANT_CONVERSION', 'YES', default='NO'):
cflags.append('-Wconstant-conversion')
if self._Test('GCC_CHAR_IS_UNSIGNED_CHAR', 'YES', default='NO'):
cflags.append('-funsigned-char')
if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'):
cflags.append('-fasm-blocks')
if 'GCC_DYNAMIC_NO_PIC' in self._Settings():
if self._Settings()['GCC_DYNAMIC_NO_PIC'] == 'YES':
cflags.append('-mdynamic-no-pic')
else:
pass
# TODO: In this case, it depends on the target. xcode passes
# mdynamic-no-pic by default for executable and possibly static lib
# according to mento
if self._Test('GCC_ENABLE_PASCAL_STRINGS', 'YES', default='YES'):
cflags.append('-mpascal-strings')
self._Appendf(cflags, 'GCC_OPTIMIZATION_LEVEL', '-O%s', default='s')
if self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES'):
dbg_format = self._Settings().get('DEBUG_INFORMATION_FORMAT', 'dwarf')
if dbg_format == 'dwarf':
cflags.append('-gdwarf-2')
elif dbg_format == 'stabs':
raise NotImplementedError('stabs debug format is not supported yet.')
elif dbg_format == 'dwarf-with-dsym':
cflags.append('-gdwarf-2')
else:
raise NotImplementedError('Unknown debug format %s' % dbg_format)
if self._Settings().get('GCC_STRICT_ALIASING') == 'YES':
cflags.append('-fstrict-aliasing')
elif self._Settings().get('GCC_STRICT_ALIASING') == 'NO':
cflags.append('-fno-strict-aliasing')
if self._Test('GCC_SYMBOLS_PRIVATE_EXTERN', 'YES', default='NO'):
cflags.append('-fvisibility=hidden')
if self._Test('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES', default='NO'):
cflags.append('-Werror')
if self._Test('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES', default='NO'):
cflags.append('-Wnewline-eof')
# In Xcode, this is only activated when GCC_COMPILER_VERSION is clang or
# llvm-gcc. It also requires a fairly recent libtool, and
# if the system clang isn't used, DYLD_LIBRARY_PATH needs to contain the
# path to the libLTO.dylib that matches the used clang.
if self._Test('LLVM_LTO', 'YES', default='NO'):
cflags.append('-flto')
self._AppendPlatformVersionMinFlags(cflags)
# TODO:
if self._Test('COPY_PHASE_STRIP', 'YES', default='NO'):
self._WarnUnimplemented('COPY_PHASE_STRIP')
self._WarnUnimplemented('GCC_DEBUGGING_SYMBOLS')
self._WarnUnimplemented('GCC_ENABLE_OBJC_EXCEPTIONS')
# TODO: This is exported correctly, but assigning to it is not supported.
self._WarnUnimplemented('MACH_O_TYPE')
self._WarnUnimplemented('PRODUCT_TYPE')
if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented('ARCHS')
archs = ['i386']
cflags.append('-arch ' + archs[0])
if archs[0] in ('i386', 'x86_64'):
if self._Test('GCC_ENABLE_SSE3_EXTENSIONS', 'YES', default='NO'):
cflags.append('-msse3')
if self._Test('GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS', 'YES',
default='NO'):
cflags.append('-mssse3') # Note 3rd 's'.
if self._Test('GCC_ENABLE_SSE41_EXTENSIONS', 'YES', default='NO'):
cflags.append('-msse4.1')
if self._Test('GCC_ENABLE_SSE42_EXTENSIONS', 'YES', default='NO'):
cflags.append('-msse4.2')
cflags += self._Settings().get('WARNING_CFLAGS', [])
if self._IsXCTest():
platform_root = self._XcodePlatformPath(configname)
if platform_root:
cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')
if sdk_root:
framework_root = sdk_root
else:
framework_root = ''
config = self.spec['configurations'][self.configname]
framework_dirs = config.get('mac_framework_dirs', [])
for directory in framework_dirs:
cflags.append('-F' + directory.replace('$(SDKROOT)', framework_root))
self.configname = None
return cflags | [
"def",
"GetCflags",
"(",
"self",
",",
"configname",
",",
"arch",
"=",
"None",
")",
":",
"# This functions (and the similar ones below) do not offer complete",
"# emulation of all xcode_settings keys. They're implemented on demand.",
"self",
".",
"configname",
"=",
"configname",
"cflags",
"=",
"[",
"]",
"sdk_root",
"=",
"self",
".",
"_SdkPath",
"(",
")",
"if",
"'SDKROOT'",
"in",
"self",
".",
"_Settings",
"(",
")",
"and",
"sdk_root",
":",
"cflags",
".",
"append",
"(",
"'-isysroot %s'",
"%",
"sdk_root",
")",
"if",
"self",
".",
"_Test",
"(",
"'CLANG_WARN_CONSTANT_CONVERSION'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-Wconstant-conversion'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_CHAR_IS_UNSIGNED_CHAR'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-funsigned-char'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_CW_ASM_SYNTAX'",
",",
"'YES'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags",
".",
"append",
"(",
"'-fasm-blocks'",
")",
"if",
"'GCC_DYNAMIC_NO_PIC'",
"in",
"self",
".",
"_Settings",
"(",
")",
":",
"if",
"self",
".",
"_Settings",
"(",
")",
"[",
"'GCC_DYNAMIC_NO_PIC'",
"]",
"==",
"'YES'",
":",
"cflags",
".",
"append",
"(",
"'-mdynamic-no-pic'",
")",
"else",
":",
"pass",
"# TODO: In this case, it depends on the target. xcode passes",
"# mdynamic-no-pic by default for executable and possibly static lib",
"# according to mento",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_PASCAL_STRINGS'",
",",
"'YES'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags",
".",
"append",
"(",
"'-mpascal-strings'",
")",
"self",
".",
"_Appendf",
"(",
"cflags",
",",
"'GCC_OPTIMIZATION_LEVEL'",
",",
"'-O%s'",
",",
"default",
"=",
"'s'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_GENERATE_DEBUGGING_SYMBOLS'",
",",
"'YES'",
",",
"default",
"=",
"'YES'",
")",
":",
"dbg_format",
"=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'DEBUG_INFORMATION_FORMAT'",
",",
"'dwarf'",
")",
"if",
"dbg_format",
"==",
"'dwarf'",
":",
"cflags",
".",
"append",
"(",
"'-gdwarf-2'",
")",
"elif",
"dbg_format",
"==",
"'stabs'",
":",
"raise",
"NotImplementedError",
"(",
"'stabs debug format is not supported yet.'",
")",
"elif",
"dbg_format",
"==",
"'dwarf-with-dsym'",
":",
"cflags",
".",
"append",
"(",
"'-gdwarf-2'",
")",
"else",
":",
"raise",
"NotImplementedError",
"(",
"'Unknown debug format %s'",
"%",
"dbg_format",
")",
"if",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'GCC_STRICT_ALIASING'",
")",
"==",
"'YES'",
":",
"cflags",
".",
"append",
"(",
"'-fstrict-aliasing'",
")",
"elif",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'GCC_STRICT_ALIASING'",
")",
"==",
"'NO'",
":",
"cflags",
".",
"append",
"(",
"'-fno-strict-aliasing'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_SYMBOLS_PRIVATE_EXTERN'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-fvisibility=hidden'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_TREAT_WARNINGS_AS_ERRORS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-Werror'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_WARN_ABOUT_MISSING_NEWLINE'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-Wnewline-eof'",
")",
"# In Xcode, this is only activated when GCC_COMPILER_VERSION is clang or",
"# llvm-gcc. It also requires a fairly recent libtool, and",
"# if the system clang isn't used, DYLD_LIBRARY_PATH needs to contain the",
"# path to the libLTO.dylib that matches the used clang.",
"if",
"self",
".",
"_Test",
"(",
"'LLVM_LTO'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-flto'",
")",
"self",
".",
"_AppendPlatformVersionMinFlags",
"(",
"cflags",
")",
"# TODO:",
"if",
"self",
".",
"_Test",
"(",
"'COPY_PHASE_STRIP'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"self",
".",
"_WarnUnimplemented",
"(",
"'COPY_PHASE_STRIP'",
")",
"self",
".",
"_WarnUnimplemented",
"(",
"'GCC_DEBUGGING_SYMBOLS'",
")",
"self",
".",
"_WarnUnimplemented",
"(",
"'GCC_ENABLE_OBJC_EXCEPTIONS'",
")",
"# TODO: This is exported correctly, but assigning to it is not supported.",
"self",
".",
"_WarnUnimplemented",
"(",
"'MACH_O_TYPE'",
")",
"self",
".",
"_WarnUnimplemented",
"(",
"'PRODUCT_TYPE'",
")",
"if",
"arch",
"is",
"not",
"None",
":",
"archs",
"=",
"[",
"arch",
"]",
"else",
":",
"assert",
"self",
".",
"configname",
"archs",
"=",
"self",
".",
"GetActiveArchs",
"(",
"self",
".",
"configname",
")",
"if",
"len",
"(",
"archs",
")",
"!=",
"1",
":",
"# TODO: Supporting fat binaries will be annoying.",
"self",
".",
"_WarnUnimplemented",
"(",
"'ARCHS'",
")",
"archs",
"=",
"[",
"'i386'",
"]",
"cflags",
".",
"append",
"(",
"'-arch '",
"+",
"archs",
"[",
"0",
"]",
")",
"if",
"archs",
"[",
"0",
"]",
"in",
"(",
"'i386'",
",",
"'x86_64'",
")",
":",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_SSE3_EXTENSIONS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-msse3'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-mssse3'",
")",
"# Note 3rd 's'.",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_SSE41_EXTENSIONS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-msse4.1'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_SSE42_EXTENSIONS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags",
".",
"append",
"(",
"'-msse4.2'",
")",
"cflags",
"+=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'WARNING_CFLAGS'",
",",
"[",
"]",
")",
"if",
"self",
".",
"_IsXCTest",
"(",
")",
":",
"platform_root",
"=",
"self",
".",
"_XcodePlatformPath",
"(",
"configname",
")",
"if",
"platform_root",
":",
"cflags",
".",
"append",
"(",
"'-F'",
"+",
"platform_root",
"+",
"'/Developer/Library/Frameworks/'",
")",
"if",
"sdk_root",
":",
"framework_root",
"=",
"sdk_root",
"else",
":",
"framework_root",
"=",
"''",
"config",
"=",
"self",
".",
"spec",
"[",
"'configurations'",
"]",
"[",
"self",
".",
"configname",
"]",
"framework_dirs",
"=",
"config",
".",
"get",
"(",
"'mac_framework_dirs'",
",",
"[",
"]",
")",
"for",
"directory",
"in",
"framework_dirs",
":",
"cflags",
".",
"append",
"(",
"'-F'",
"+",
"directory",
".",
"replace",
"(",
"'$(SDKROOT)'",
",",
"framework_root",
")",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"cflags"
] | [
469,
2
] | [
588,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetCflagsC | (self, configname) | Returns flags that need to be added to .c, and .m compilations. | Returns flags that need to be added to .c, and .m compilations. | def GetCflagsC(self, configname):
"""Returns flags that need to be added to .c, and .m compilations."""
self.configname = configname
cflags_c = []
if self._Settings().get('GCC_C_LANGUAGE_STANDARD', '') == 'ansi':
cflags_c.append('-ansi')
else:
self._Appendf(cflags_c, 'GCC_C_LANGUAGE_STANDARD', '-std=%s')
cflags_c += self._Settings().get('OTHER_CFLAGS', [])
self.configname = None
return cflags_c | [
"def",
"GetCflagsC",
"(",
"self",
",",
"configname",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"cflags_c",
"=",
"[",
"]",
"if",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'GCC_C_LANGUAGE_STANDARD'",
",",
"''",
")",
"==",
"'ansi'",
":",
"cflags_c",
".",
"append",
"(",
"'-ansi'",
")",
"else",
":",
"self",
".",
"_Appendf",
"(",
"cflags_c",
",",
"'GCC_C_LANGUAGE_STANDARD'",
",",
"'-std=%s'",
")",
"cflags_c",
"+=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'OTHER_CFLAGS'",
",",
"[",
"]",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"cflags_c"
] | [
590,
2
] | [
600,
19
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetCflagsCC | (self, configname) | Returns flags that need to be added to .cc, and .mm compilations. | Returns flags that need to be added to .cc, and .mm compilations. | def GetCflagsCC(self, configname):
"""Returns flags that need to be added to .cc, and .mm compilations."""
self.configname = configname
cflags_cc = []
clang_cxx_language_standard = self._Settings().get(
'CLANG_CXX_LANGUAGE_STANDARD')
# Note: Don't make c++0x to c++11 so that c++0x can be used with older
# clangs that don't understand c++11 yet (like Xcode 4.2's).
if clang_cxx_language_standard:
cflags_cc.append('-std=%s' % clang_cxx_language_standard)
self._Appendf(cflags_cc, 'CLANG_CXX_LIBRARY', '-stdlib=%s')
if self._Test('GCC_ENABLE_CPP_RTTI', 'NO', default='YES'):
cflags_cc.append('-fno-rtti')
if self._Test('GCC_ENABLE_CPP_EXCEPTIONS', 'NO', default='YES'):
cflags_cc.append('-fno-exceptions')
if self._Test('GCC_INLINES_ARE_PRIVATE_EXTERN', 'YES', default='NO'):
cflags_cc.append('-fvisibility-inlines-hidden')
if self._Test('GCC_THREADSAFE_STATICS', 'NO', default='YES'):
cflags_cc.append('-fno-threadsafe-statics')
# Note: This flag is a no-op for clang, it only has an effect for gcc.
if self._Test('GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO', 'NO', default='YES'):
cflags_cc.append('-Wno-invalid-offsetof')
other_ccflags = []
for flag in self._Settings().get('OTHER_CPLUSPLUSFLAGS', ['$(inherited)']):
# TODO: More general variable expansion. Missing in many other places too.
if flag in ('$inherited', '$(inherited)', '${inherited}'):
flag = '$OTHER_CFLAGS'
if flag in ('$OTHER_CFLAGS', '$(OTHER_CFLAGS)', '${OTHER_CFLAGS}'):
other_ccflags += self._Settings().get('OTHER_CFLAGS', [])
else:
other_ccflags.append(flag)
cflags_cc += other_ccflags
self.configname = None
return cflags_cc | [
"def",
"GetCflagsCC",
"(",
"self",
",",
"configname",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"cflags_cc",
"=",
"[",
"]",
"clang_cxx_language_standard",
"=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'CLANG_CXX_LANGUAGE_STANDARD'",
")",
"# Note: Don't make c++0x to c++11 so that c++0x can be used with older",
"# clangs that don't understand c++11 yet (like Xcode 4.2's).",
"if",
"clang_cxx_language_standard",
":",
"cflags_cc",
".",
"append",
"(",
"'-std=%s'",
"%",
"clang_cxx_language_standard",
")",
"self",
".",
"_Appendf",
"(",
"cflags_cc",
",",
"'CLANG_CXX_LIBRARY'",
",",
"'-stdlib=%s'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_CPP_RTTI'",
",",
"'NO'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags_cc",
".",
"append",
"(",
"'-fno-rtti'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_ENABLE_CPP_EXCEPTIONS'",
",",
"'NO'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags_cc",
".",
"append",
"(",
"'-fno-exceptions'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_INLINES_ARE_PRIVATE_EXTERN'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags_cc",
".",
"append",
"(",
"'-fvisibility-inlines-hidden'",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_THREADSAFE_STATICS'",
",",
"'NO'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags_cc",
".",
"append",
"(",
"'-fno-threadsafe-statics'",
")",
"# Note: This flag is a no-op for clang, it only has an effect for gcc.",
"if",
"self",
".",
"_Test",
"(",
"'GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO'",
",",
"'NO'",
",",
"default",
"=",
"'YES'",
")",
":",
"cflags_cc",
".",
"append",
"(",
"'-Wno-invalid-offsetof'",
")",
"other_ccflags",
"=",
"[",
"]",
"for",
"flag",
"in",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'OTHER_CPLUSPLUSFLAGS'",
",",
"[",
"'$(inherited)'",
"]",
")",
":",
"# TODO: More general variable expansion. Missing in many other places too.",
"if",
"flag",
"in",
"(",
"'$inherited'",
",",
"'$(inherited)'",
",",
"'${inherited}'",
")",
":",
"flag",
"=",
"'$OTHER_CFLAGS'",
"if",
"flag",
"in",
"(",
"'$OTHER_CFLAGS'",
",",
"'$(OTHER_CFLAGS)'",
",",
"'${OTHER_CFLAGS}'",
")",
":",
"other_ccflags",
"+=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'OTHER_CFLAGS'",
",",
"[",
"]",
")",
"else",
":",
"other_ccflags",
".",
"append",
"(",
"flag",
")",
"cflags_cc",
"+=",
"other_ccflags",
"self",
".",
"configname",
"=",
"None",
"return",
"cflags_cc"
] | [
602,
2
] | [
641,
20
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetCflagsObjC | (self, configname) | Returns flags that need to be added to .m compilations. | Returns flags that need to be added to .m compilations. | def GetCflagsObjC(self, configname):
"""Returns flags that need to be added to .m compilations."""
self.configname = configname
cflags_objc = []
self._AddObjectiveCGarbageCollectionFlags(cflags_objc)
self._AddObjectiveCARCFlags(cflags_objc)
self._AddObjectiveCMissingPropertySynthesisFlags(cflags_objc)
self.configname = None
return cflags_objc | [
"def",
"GetCflagsObjC",
"(",
"self",
",",
"configname",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"cflags_objc",
"=",
"[",
"]",
"self",
".",
"_AddObjectiveCGarbageCollectionFlags",
"(",
"cflags_objc",
")",
"self",
".",
"_AddObjectiveCARCFlags",
"(",
"cflags_objc",
")",
"self",
".",
"_AddObjectiveCMissingPropertySynthesisFlags",
"(",
"cflags_objc",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"cflags_objc"
] | [
659,
2
] | [
667,
22
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetCflagsObjCC | (self, configname) | Returns flags that need to be added to .mm compilations. | Returns flags that need to be added to .mm compilations. | def GetCflagsObjCC(self, configname):
"""Returns flags that need to be added to .mm compilations."""
self.configname = configname
cflags_objcc = []
self._AddObjectiveCGarbageCollectionFlags(cflags_objcc)
self._AddObjectiveCARCFlags(cflags_objcc)
self._AddObjectiveCMissingPropertySynthesisFlags(cflags_objcc)
if self._Test('GCC_OBJC_CALL_CXX_CDTORS', 'YES', default='NO'):
cflags_objcc.append('-fobjc-call-cxx-cdtors')
self.configname = None
return cflags_objcc | [
"def",
"GetCflagsObjCC",
"(",
"self",
",",
"configname",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"cflags_objcc",
"=",
"[",
"]",
"self",
".",
"_AddObjectiveCGarbageCollectionFlags",
"(",
"cflags_objcc",
")",
"self",
".",
"_AddObjectiveCARCFlags",
"(",
"cflags_objcc",
")",
"self",
".",
"_AddObjectiveCMissingPropertySynthesisFlags",
"(",
"cflags_objcc",
")",
"if",
"self",
".",
"_Test",
"(",
"'GCC_OBJC_CALL_CXX_CDTORS'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"cflags_objcc",
".",
"append",
"(",
"'-fobjc-call-cxx-cdtors'",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"cflags_objcc"
] | [
669,
2
] | [
679,
23
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetInstallNameBase | (self) | Return DYLIB_INSTALL_NAME_BASE for this target. | Return DYLIB_INSTALL_NAME_BASE for this target. | def GetInstallNameBase(self):
"""Return DYLIB_INSTALL_NAME_BASE for this target."""
# Xcode sets this for shared_libraries, and for nonbundled loadable_modules.
if (self.spec['type'] != 'shared_library' and
(self.spec['type'] != 'loadable_module' or self._IsBundle())):
return None
install_base = self.GetPerTargetSetting(
'DYLIB_INSTALL_NAME_BASE',
default='/Library/Frameworks' if self._IsBundle() else '/usr/local/lib')
return install_base | [
"def",
"GetInstallNameBase",
"(",
"self",
")",
":",
"# Xcode sets this for shared_libraries, and for nonbundled loadable_modules.",
"if",
"(",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'shared_library'",
"and",
"(",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'loadable_module'",
"or",
"self",
".",
"_IsBundle",
"(",
")",
")",
")",
":",
"return",
"None",
"install_base",
"=",
"self",
".",
"GetPerTargetSetting",
"(",
"'DYLIB_INSTALL_NAME_BASE'",
",",
"default",
"=",
"'/Library/Frameworks'",
"if",
"self",
".",
"_IsBundle",
"(",
")",
"else",
"'/usr/local/lib'",
")",
"return",
"install_base"
] | [
681,
2
] | [
690,
23
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._StandardizePath | (self, path) | Do :standardizepath processing for path. | Do :standardizepath processing for path. | def _StandardizePath(self, path):
"""Do :standardizepath processing for path."""
# I'm not quite sure what :standardizepath does. Just call normpath(),
# but don't let @executable_path/../foo collapse to foo.
if '/' in path:
prefix, rest = '', path
if path.startswith('@'):
prefix, rest = path.split('/', 1)
rest = os.path.normpath(rest) # :standardizepath
path = os.path.join(prefix, rest)
return path | [
"def",
"_StandardizePath",
"(",
"self",
",",
"path",
")",
":",
"# I'm not quite sure what :standardizepath does. Just call normpath(),",
"# but don't let @executable_path/../foo collapse to foo.",
"if",
"'/'",
"in",
"path",
":",
"prefix",
",",
"rest",
"=",
"''",
",",
"path",
"if",
"path",
".",
"startswith",
"(",
"'@'",
")",
":",
"prefix",
",",
"rest",
"=",
"path",
".",
"split",
"(",
"'/'",
",",
"1",
")",
"rest",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"rest",
")",
"# :standardizepath",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"prefix",
",",
"rest",
")",
"return",
"path"
] | [
692,
2
] | [
702,
15
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetInstallName | (self) | Return LD_DYLIB_INSTALL_NAME for this target. | Return LD_DYLIB_INSTALL_NAME for this target. | def GetInstallName(self):
"""Return LD_DYLIB_INSTALL_NAME for this target."""
# Xcode sets this for shared_libraries, and for nonbundled loadable_modules.
if (self.spec['type'] != 'shared_library' and
(self.spec['type'] != 'loadable_module' or self._IsBundle())):
return None
default_install_name = \
'$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)'
install_name = self.GetPerTargetSetting(
'LD_DYLIB_INSTALL_NAME', default=default_install_name)
# Hardcode support for the variables used in chromium for now, to
# unblock people using the make build.
if '$' in install_name:
assert install_name in ('$(DYLIB_INSTALL_NAME_BASE:standardizepath)/'
'$(WRAPPER_NAME)/$(PRODUCT_NAME)', default_install_name), (
'Variables in LD_DYLIB_INSTALL_NAME are not generally supported '
'yet in target \'%s\' (got \'%s\')' %
(self.spec['target_name'], install_name))
install_name = install_name.replace(
'$(DYLIB_INSTALL_NAME_BASE:standardizepath)',
self._StandardizePath(self.GetInstallNameBase()))
if self._IsBundle():
# These are only valid for bundles, hence the |if|.
install_name = install_name.replace(
'$(WRAPPER_NAME)', self.GetWrapperName())
install_name = install_name.replace(
'$(PRODUCT_NAME)', self.GetProductName())
else:
assert '$(WRAPPER_NAME)' not in install_name
assert '$(PRODUCT_NAME)' not in install_name
install_name = install_name.replace(
'$(EXECUTABLE_PATH)', self.GetExecutablePath())
return install_name | [
"def",
"GetInstallName",
"(",
"self",
")",
":",
"# Xcode sets this for shared_libraries, and for nonbundled loadable_modules.",
"if",
"(",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'shared_library'",
"and",
"(",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'loadable_module'",
"or",
"self",
".",
"_IsBundle",
"(",
")",
")",
")",
":",
"return",
"None",
"default_install_name",
"=",
"'$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)'",
"install_name",
"=",
"self",
".",
"GetPerTargetSetting",
"(",
"'LD_DYLIB_INSTALL_NAME'",
",",
"default",
"=",
"default_install_name",
")",
"# Hardcode support for the variables used in chromium for now, to",
"# unblock people using the make build.",
"if",
"'$'",
"in",
"install_name",
":",
"assert",
"install_name",
"in",
"(",
"'$(DYLIB_INSTALL_NAME_BASE:standardizepath)/'",
"'$(WRAPPER_NAME)/$(PRODUCT_NAME)'",
",",
"default_install_name",
")",
",",
"(",
"'Variables in LD_DYLIB_INSTALL_NAME are not generally supported '",
"'yet in target \\'%s\\' (got \\'%s\\')'",
"%",
"(",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
",",
"install_name",
")",
")",
"install_name",
"=",
"install_name",
".",
"replace",
"(",
"'$(DYLIB_INSTALL_NAME_BASE:standardizepath)'",
",",
"self",
".",
"_StandardizePath",
"(",
"self",
".",
"GetInstallNameBase",
"(",
")",
")",
")",
"if",
"self",
".",
"_IsBundle",
"(",
")",
":",
"# These are only valid for bundles, hence the |if|.",
"install_name",
"=",
"install_name",
".",
"replace",
"(",
"'$(WRAPPER_NAME)'",
",",
"self",
".",
"GetWrapperName",
"(",
")",
")",
"install_name",
"=",
"install_name",
".",
"replace",
"(",
"'$(PRODUCT_NAME)'",
",",
"self",
".",
"GetProductName",
"(",
")",
")",
"else",
":",
"assert",
"'$(WRAPPER_NAME)'",
"not",
"in",
"install_name",
"assert",
"'$(PRODUCT_NAME)'",
"not",
"in",
"install_name",
"install_name",
"=",
"install_name",
".",
"replace",
"(",
"'$(EXECUTABLE_PATH)'",
",",
"self",
".",
"GetExecutablePath",
"(",
")",
")",
"return",
"install_name"
] | [
704,
2
] | [
740,
23
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._MapLinkerFlagFilename | (self, ldflag, gyp_to_build_path) | Checks if ldflag contains a filename and if so remaps it from
gyp-directory-relative to build-directory-relative. | Checks if ldflag contains a filename and if so remaps it from
gyp-directory-relative to build-directory-relative. | def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path):
"""Checks if ldflag contains a filename and if so remaps it from
gyp-directory-relative to build-directory-relative."""
# This list is expanded on demand.
# They get matched as:
# -exported_symbols_list file
# -Wl,exported_symbols_list file
# -Wl,exported_symbols_list,file
LINKER_FILE = r'(\S+)'
WORD = r'\S+'
linker_flags = [
['-exported_symbols_list', LINKER_FILE], # Needed for NaCl.
['-unexported_symbols_list', LINKER_FILE],
['-reexported_symbols_list', LINKER_FILE],
['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting.
]
for flag_pattern in linker_flags:
regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern))
m = regex.match(ldflag)
if m:
ldflag = ldflag[:m.start(1)] + gyp_to_build_path(m.group(1)) + \
ldflag[m.end(1):]
# Required for ffmpeg (no idea why they don't use LIBRARY_SEARCH_PATHS,
# TODO(thakis): Update ffmpeg.gyp):
if ldflag.startswith('-L'):
ldflag = '-L' + gyp_to_build_path(ldflag[len('-L'):])
return ldflag | [
"def",
"_MapLinkerFlagFilename",
"(",
"self",
",",
"ldflag",
",",
"gyp_to_build_path",
")",
":",
"# This list is expanded on demand.",
"# They get matched as:",
"# -exported_symbols_list file",
"# -Wl,exported_symbols_list file",
"# -Wl,exported_symbols_list,file",
"LINKER_FILE",
"=",
"r'(\\S+)'",
"WORD",
"=",
"r'\\S+'",
"linker_flags",
"=",
"[",
"[",
"'-exported_symbols_list'",
",",
"LINKER_FILE",
"]",
",",
"# Needed for NaCl.",
"[",
"'-unexported_symbols_list'",
",",
"LINKER_FILE",
"]",
",",
"[",
"'-reexported_symbols_list'",
",",
"LINKER_FILE",
"]",
",",
"[",
"'-sectcreate'",
",",
"WORD",
",",
"WORD",
",",
"LINKER_FILE",
"]",
",",
"# Needed for remoting.",
"]",
"for",
"flag_pattern",
"in",
"linker_flags",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"'(?:-Wl,)?'",
"+",
"'[ ,]'",
".",
"join",
"(",
"flag_pattern",
")",
")",
"m",
"=",
"regex",
".",
"match",
"(",
"ldflag",
")",
"if",
"m",
":",
"ldflag",
"=",
"ldflag",
"[",
":",
"m",
".",
"start",
"(",
"1",
")",
"]",
"+",
"gyp_to_build_path",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"+",
"ldflag",
"[",
"m",
".",
"end",
"(",
"1",
")",
":",
"]",
"# Required for ffmpeg (no idea why they don't use LIBRARY_SEARCH_PATHS,",
"# TODO(thakis): Update ffmpeg.gyp):",
"if",
"ldflag",
".",
"startswith",
"(",
"'-L'",
")",
":",
"ldflag",
"=",
"'-L'",
"+",
"gyp_to_build_path",
"(",
"ldflag",
"[",
"len",
"(",
"'-L'",
")",
":",
"]",
")",
"return",
"ldflag"
] | [
742,
2
] | [
768,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetLdflags | (self, configname, product_dir, gyp_to_build_path, arch=None) | Returns flags that need to be passed to the linker.
Args:
configname: The name of the configuration to get ld flags for.
product_dir: The directory where products such static and dynamic
libraries are placed. This is added to the library search path.
gyp_to_build_path: A function that converts paths relative to the
current gyp file to paths relative to the build direcotry.
| Returns flags that need to be passed to the linker. | def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
"""Returns flags that need to be passed to the linker.
Args:
configname: The name of the configuration to get ld flags for.
product_dir: The directory where products such static and dynamic
libraries are placed. This is added to the library search path.
gyp_to_build_path: A function that converts paths relative to the
current gyp file to paths relative to the build direcotry.
"""
self.configname = configname
ldflags = []
# The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS
# can contain entries that depend on this. Explicitly absolutify these.
for ldflag in self._Settings().get('OTHER_LDFLAGS', []):
ldflags.append(self._MapLinkerFlagFilename(ldflag, gyp_to_build_path))
if self._Test('DEAD_CODE_STRIPPING', 'YES', default='NO'):
ldflags.append('-Wl,-dead_strip')
if self._Test('PREBINDING', 'YES', default='NO'):
ldflags.append('-Wl,-prebind')
self._Appendf(
ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s')
self._Appendf(
ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s')
self._AppendPlatformVersionMinFlags(ldflags)
if 'SDKROOT' in self._Settings() and self._SdkPath():
ldflags.append('-isysroot ' + self._SdkPath())
for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []):
ldflags.append('-L' + gyp_to_build_path(library_path))
if 'ORDER_FILE' in self._Settings():
ldflags.append('-Wl,-order_file ' +
'-Wl,' + gyp_to_build_path(
self._Settings()['ORDER_FILE']))
if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented('ARCHS')
archs = ['i386']
ldflags.append('-arch ' + archs[0])
# Xcode adds the product directory by default.
ldflags.append('-L' + product_dir)
install_name = self.GetInstallName()
if install_name and self.spec['type'] != 'loadable_module':
ldflags.append('-install_name ' + install_name.replace(' ', r'\ '))
for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
ldflags.append('-Wl,-rpath,' + rpath)
sdk_root = self._SdkPath()
if not sdk_root:
sdk_root = ''
config = self.spec['configurations'][self.configname]
framework_dirs = config.get('mac_framework_dirs', [])
for directory in framework_dirs:
ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
if self._IsXCTest():
platform_root = self._XcodePlatformPath(configname)
if platform_root:
cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')
is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
if sdk_root and is_extension:
# Adds the link flags for extensions. These flags are common for all
# extensions and provide loader and main function.
# These flags reflect the compilation options used by xcode to compile
# extensions.
ldflags.append('-lpkstart')
if XcodeVersion() < '0900':
ldflags.append(sdk_root +
'/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit')
ldflags.append('-fapplication-extension')
ldflags.append('-Xlinker -rpath '
'-Xlinker @executable_path/../../Frameworks')
self._Appendf(ldflags, 'CLANG_CXX_LIBRARY', '-stdlib=%s')
self.configname = None
return ldflags | [
"def",
"GetLdflags",
"(",
"self",
",",
"configname",
",",
"product_dir",
",",
"gyp_to_build_path",
",",
"arch",
"=",
"None",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"ldflags",
"=",
"[",
"]",
"# The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS",
"# can contain entries that depend on this. Explicitly absolutify these.",
"for",
"ldflag",
"in",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'OTHER_LDFLAGS'",
",",
"[",
"]",
")",
":",
"ldflags",
".",
"append",
"(",
"self",
".",
"_MapLinkerFlagFilename",
"(",
"ldflag",
",",
"gyp_to_build_path",
")",
")",
"if",
"self",
".",
"_Test",
"(",
"'DEAD_CODE_STRIPPING'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"ldflags",
".",
"append",
"(",
"'-Wl,-dead_strip'",
")",
"if",
"self",
".",
"_Test",
"(",
"'PREBINDING'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
":",
"ldflags",
".",
"append",
"(",
"'-Wl,-prebind'",
")",
"self",
".",
"_Appendf",
"(",
"ldflags",
",",
"'DYLIB_COMPATIBILITY_VERSION'",
",",
"'-compatibility_version %s'",
")",
"self",
".",
"_Appendf",
"(",
"ldflags",
",",
"'DYLIB_CURRENT_VERSION'",
",",
"'-current_version %s'",
")",
"self",
".",
"_AppendPlatformVersionMinFlags",
"(",
"ldflags",
")",
"if",
"'SDKROOT'",
"in",
"self",
".",
"_Settings",
"(",
")",
"and",
"self",
".",
"_SdkPath",
"(",
")",
":",
"ldflags",
".",
"append",
"(",
"'-isysroot '",
"+",
"self",
".",
"_SdkPath",
"(",
")",
")",
"for",
"library_path",
"in",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'LIBRARY_SEARCH_PATHS'",
",",
"[",
"]",
")",
":",
"ldflags",
".",
"append",
"(",
"'-L'",
"+",
"gyp_to_build_path",
"(",
"library_path",
")",
")",
"if",
"'ORDER_FILE'",
"in",
"self",
".",
"_Settings",
"(",
")",
":",
"ldflags",
".",
"append",
"(",
"'-Wl,-order_file '",
"+",
"'-Wl,'",
"+",
"gyp_to_build_path",
"(",
"self",
".",
"_Settings",
"(",
")",
"[",
"'ORDER_FILE'",
"]",
")",
")",
"if",
"arch",
"is",
"not",
"None",
":",
"archs",
"=",
"[",
"arch",
"]",
"else",
":",
"assert",
"self",
".",
"configname",
"archs",
"=",
"self",
".",
"GetActiveArchs",
"(",
"self",
".",
"configname",
")",
"if",
"len",
"(",
"archs",
")",
"!=",
"1",
":",
"# TODO: Supporting fat binaries will be annoying.",
"self",
".",
"_WarnUnimplemented",
"(",
"'ARCHS'",
")",
"archs",
"=",
"[",
"'i386'",
"]",
"ldflags",
".",
"append",
"(",
"'-arch '",
"+",
"archs",
"[",
"0",
"]",
")",
"# Xcode adds the product directory by default.",
"ldflags",
".",
"append",
"(",
"'-L'",
"+",
"product_dir",
")",
"install_name",
"=",
"self",
".",
"GetInstallName",
"(",
")",
"if",
"install_name",
"and",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'loadable_module'",
":",
"ldflags",
".",
"append",
"(",
"'-install_name '",
"+",
"install_name",
".",
"replace",
"(",
"' '",
",",
"r'\\ '",
")",
")",
"for",
"rpath",
"in",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'LD_RUNPATH_SEARCH_PATHS'",
",",
"[",
"]",
")",
":",
"ldflags",
".",
"append",
"(",
"'-Wl,-rpath,'",
"+",
"rpath",
")",
"sdk_root",
"=",
"self",
".",
"_SdkPath",
"(",
")",
"if",
"not",
"sdk_root",
":",
"sdk_root",
"=",
"''",
"config",
"=",
"self",
".",
"spec",
"[",
"'configurations'",
"]",
"[",
"self",
".",
"configname",
"]",
"framework_dirs",
"=",
"config",
".",
"get",
"(",
"'mac_framework_dirs'",
",",
"[",
"]",
")",
"for",
"directory",
"in",
"framework_dirs",
":",
"ldflags",
".",
"append",
"(",
"'-F'",
"+",
"directory",
".",
"replace",
"(",
"'$(SDKROOT)'",
",",
"sdk_root",
")",
")",
"if",
"self",
".",
"_IsXCTest",
"(",
")",
":",
"platform_root",
"=",
"self",
".",
"_XcodePlatformPath",
"(",
"configname",
")",
"if",
"platform_root",
":",
"cflags",
".",
"append",
"(",
"'-F'",
"+",
"platform_root",
"+",
"'/Developer/Library/Frameworks/'",
")",
"is_extension",
"=",
"self",
".",
"_IsIosAppExtension",
"(",
")",
"or",
"self",
".",
"_IsIosWatchKitExtension",
"(",
")",
"if",
"sdk_root",
"and",
"is_extension",
":",
"# Adds the link flags for extensions. These flags are common for all",
"# extensions and provide loader and main function.",
"# These flags reflect the compilation options used by xcode to compile",
"# extensions.",
"ldflags",
".",
"append",
"(",
"'-lpkstart'",
")",
"if",
"XcodeVersion",
"(",
")",
"<",
"'0900'",
":",
"ldflags",
".",
"append",
"(",
"sdk_root",
"+",
"'/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit'",
")",
"ldflags",
".",
"append",
"(",
"'-fapplication-extension'",
")",
"ldflags",
".",
"append",
"(",
"'-Xlinker -rpath '",
"'-Xlinker @executable_path/../../Frameworks'",
")",
"self",
".",
"_Appendf",
"(",
"ldflags",
",",
"'CLANG_CXX_LIBRARY'",
",",
"'-stdlib=%s'",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"ldflags"
] | [
770,
2
] | [
863,
18
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetLibtoolflags | (self, configname) | Returns flags that need to be passed to the static linker.
Args:
configname: The name of the configuration to get ld flags for.
| Returns flags that need to be passed to the static linker. | def GetLibtoolflags(self, configname):
"""Returns flags that need to be passed to the static linker.
Args:
configname: The name of the configuration to get ld flags for.
"""
self.configname = configname
libtoolflags = []
for libtoolflag in self._Settings().get('OTHER_LDFLAGS', []):
libtoolflags.append(libtoolflag)
# TODO(thakis): ARCHS?
self.configname = None
return libtoolflags | [
"def",
"GetLibtoolflags",
"(",
"self",
",",
"configname",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"libtoolflags",
"=",
"[",
"]",
"for",
"libtoolflag",
"in",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'OTHER_LDFLAGS'",
",",
"[",
"]",
")",
":",
"libtoolflags",
".",
"append",
"(",
"libtoolflag",
")",
"# TODO(thakis): ARCHS?",
"self",
".",
"configname",
"=",
"None",
"return",
"libtoolflags"
] | [
865,
2
] | [
879,
23
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetPerTargetSettings | (self) | Gets a list of all the per-target settings. This will only fetch keys
whose values are the same across all configurations. | Gets a list of all the per-target settings. This will only fetch keys
whose values are the same across all configurations. | def GetPerTargetSettings(self):
"""Gets a list of all the per-target settings. This will only fetch keys
whose values are the same across all configurations."""
first_pass = True
result = {}
for configname in sorted(self.xcode_settings.keys()):
if first_pass:
result = dict(self.xcode_settings[configname])
first_pass = False
else:
for key, value in self.xcode_settings[configname].iteritems():
if key not in result:
continue
elif result[key] != value:
del result[key]
return result | [
"def",
"GetPerTargetSettings",
"(",
"self",
")",
":",
"first_pass",
"=",
"True",
"result",
"=",
"{",
"}",
"for",
"configname",
"in",
"sorted",
"(",
"self",
".",
"xcode_settings",
".",
"keys",
"(",
")",
")",
":",
"if",
"first_pass",
":",
"result",
"=",
"dict",
"(",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
")",
"first_pass",
"=",
"False",
"else",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
".",
"iteritems",
"(",
")",
":",
"if",
"key",
"not",
"in",
"result",
":",
"continue",
"elif",
"result",
"[",
"key",
"]",
"!=",
"value",
":",
"del",
"result",
"[",
"key",
"]",
"return",
"result"
] | [
881,
2
] | [
896,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.GetPerTargetSetting | (self, setting, default=None) | Tries to get xcode_settings.setting from spec. Assumes that the setting
has the same value in all configurations and throws otherwise. | Tries to get xcode_settings.setting from spec. Assumes that the setting
has the same value in all configurations and throws otherwise. | def GetPerTargetSetting(self, setting, default=None):
"""Tries to get xcode_settings.setting from spec. Assumes that the setting
has the same value in all configurations and throws otherwise."""
is_first_pass = True
result = None
for configname in sorted(self.xcode_settings.keys()):
if is_first_pass:
result = self.xcode_settings[configname].get(setting, None)
is_first_pass = False
else:
assert result == self.xcode_settings[configname].get(setting, None), (
"Expected per-target setting for '%s', got per-config setting "
"(target %s)" % (setting, self.spec['target_name']))
if result is None:
return default
return result | [
"def",
"GetPerTargetSetting",
"(",
"self",
",",
"setting",
",",
"default",
"=",
"None",
")",
":",
"is_first_pass",
"=",
"True",
"result",
"=",
"None",
"for",
"configname",
"in",
"sorted",
"(",
"self",
".",
"xcode_settings",
".",
"keys",
"(",
")",
")",
":",
"if",
"is_first_pass",
":",
"result",
"=",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
".",
"get",
"(",
"setting",
",",
"None",
")",
"is_first_pass",
"=",
"False",
"else",
":",
"assert",
"result",
"==",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
".",
"get",
"(",
"setting",
",",
"None",
")",
",",
"(",
"\"Expected per-target setting for '%s', got per-config setting \"",
"\"(target %s)\"",
"%",
"(",
"setting",
",",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
")",
"if",
"result",
"is",
"None",
":",
"return",
"default",
"return",
"result"
] | [
904,
2
] | [
919,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetStripPostbuilds | (self, configname, output_binary, quiet) | Returns a list of shell commands that contain the shell commands
neccessary to strip this target's binary. These should be run as postbuilds
before the actual postbuilds run. | Returns a list of shell commands that contain the shell commands
neccessary to strip this target's binary. These should be run as postbuilds
before the actual postbuilds run. | def _GetStripPostbuilds(self, configname, output_binary, quiet):
"""Returns a list of shell commands that contain the shell commands
neccessary to strip this target's binary. These should be run as postbuilds
before the actual postbuilds run."""
self.configname = configname
result = []
if (self._Test('DEPLOYMENT_POSTPROCESSING', 'YES', default='NO') and
self._Test('STRIP_INSTALLED_PRODUCT', 'YES', default='NO')):
default_strip_style = 'debugging'
if self.spec['type'] == 'loadable_module' and self._IsBundle():
default_strip_style = 'non-global'
elif self.spec['type'] == 'executable':
default_strip_style = 'all'
strip_style = self._Settings().get('STRIP_STYLE', default_strip_style)
strip_flags = {
'all': '',
'non-global': '-x',
'debugging': '-S',
}[strip_style]
explicit_strip_flags = self._Settings().get('STRIPFLAGS', '')
if explicit_strip_flags:
strip_flags += ' ' + _NormalizeEnvVarReferences(explicit_strip_flags)
if not quiet:
result.append('echo STRIP\\(%s\\)' % self.spec['target_name'])
result.append('strip %s %s' % (strip_flags, output_binary))
self.configname = None
return result | [
"def",
"_GetStripPostbuilds",
"(",
"self",
",",
"configname",
",",
"output_binary",
",",
"quiet",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"result",
"=",
"[",
"]",
"if",
"(",
"self",
".",
"_Test",
"(",
"'DEPLOYMENT_POSTPROCESSING'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
"and",
"self",
".",
"_Test",
"(",
"'STRIP_INSTALLED_PRODUCT'",
",",
"'YES'",
",",
"default",
"=",
"'NO'",
")",
")",
":",
"default_strip_style",
"=",
"'debugging'",
"if",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'loadable_module'",
"and",
"self",
".",
"_IsBundle",
"(",
")",
":",
"default_strip_style",
"=",
"'non-global'",
"elif",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'executable'",
":",
"default_strip_style",
"=",
"'all'",
"strip_style",
"=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'STRIP_STYLE'",
",",
"default_strip_style",
")",
"strip_flags",
"=",
"{",
"'all'",
":",
"''",
",",
"'non-global'",
":",
"'-x'",
",",
"'debugging'",
":",
"'-S'",
",",
"}",
"[",
"strip_style",
"]",
"explicit_strip_flags",
"=",
"self",
".",
"_Settings",
"(",
")",
".",
"get",
"(",
"'STRIPFLAGS'",
",",
"''",
")",
"if",
"explicit_strip_flags",
":",
"strip_flags",
"+=",
"' '",
"+",
"_NormalizeEnvVarReferences",
"(",
"explicit_strip_flags",
")",
"if",
"not",
"quiet",
":",
"result",
".",
"append",
"(",
"'echo STRIP\\\\(%s\\\\)'",
"%",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"result",
".",
"append",
"(",
"'strip %s %s'",
"%",
"(",
"strip_flags",
",",
"output_binary",
")",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"result"
] | [
921,
2
] | [
953,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetDebugInfoPostbuilds | (self, configname, output, output_binary, quiet) | Returns a list of shell commands that contain the shell commands
neccessary to massage this target's debug information. These should be run
as postbuilds before the actual postbuilds run. | Returns a list of shell commands that contain the shell commands
neccessary to massage this target's debug information. These should be run
as postbuilds before the actual postbuilds run. | def _GetDebugInfoPostbuilds(self, configname, output, output_binary, quiet):
"""Returns a list of shell commands that contain the shell commands
neccessary to massage this target's debug information. These should be run
as postbuilds before the actual postbuilds run."""
self.configname = configname
# For static libraries, no dSYMs are created.
result = []
if (self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES') and
self._Test(
'DEBUG_INFORMATION_FORMAT', 'dwarf-with-dsym', default='dwarf') and
self.spec['type'] != 'static_library'):
if not quiet:
result.append('echo DSYMUTIL\\(%s\\)' % self.spec['target_name'])
result.append('dsymutil %s -o %s' % (output_binary, output + '.dSYM'))
self.configname = None
return result | [
"def",
"_GetDebugInfoPostbuilds",
"(",
"self",
",",
"configname",
",",
"output",
",",
"output_binary",
",",
"quiet",
")",
":",
"self",
".",
"configname",
"=",
"configname",
"# For static libraries, no dSYMs are created.",
"result",
"=",
"[",
"]",
"if",
"(",
"self",
".",
"_Test",
"(",
"'GCC_GENERATE_DEBUGGING_SYMBOLS'",
",",
"'YES'",
",",
"default",
"=",
"'YES'",
")",
"and",
"self",
".",
"_Test",
"(",
"'DEBUG_INFORMATION_FORMAT'",
",",
"'dwarf-with-dsym'",
",",
"default",
"=",
"'dwarf'",
")",
"and",
"self",
".",
"spec",
"[",
"'type'",
"]",
"!=",
"'static_library'",
")",
":",
"if",
"not",
"quiet",
":",
"result",
".",
"append",
"(",
"'echo DSYMUTIL\\\\(%s\\\\)'",
"%",
"self",
".",
"spec",
"[",
"'target_name'",
"]",
")",
"result",
".",
"append",
"(",
"'dsymutil %s -o %s'",
"%",
"(",
"output_binary",
",",
"output",
"+",
"'.dSYM'",
")",
")",
"self",
".",
"configname",
"=",
"None",
"return",
"result"
] | [
955,
2
] | [
972,
17
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetTargetPostbuilds | (self, configname, output, output_binary,
quiet=False) | Returns a list of shell commands that contain the shell commands
to run as postbuilds for this target, before the actual postbuilds. | Returns a list of shell commands that contain the shell commands
to run as postbuilds for this target, before the actual postbuilds. | def _GetTargetPostbuilds(self, configname, output, output_binary,
quiet=False):
"""Returns a list of shell commands that contain the shell commands
to run as postbuilds for this target, before the actual postbuilds."""
# dSYMs need to build before stripping happens.
return (
self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) +
self._GetStripPostbuilds(configname, output_binary, quiet)) | [
"def",
"_GetTargetPostbuilds",
"(",
"self",
",",
"configname",
",",
"output",
",",
"output_binary",
",",
"quiet",
"=",
"False",
")",
":",
"# dSYMs need to build before stripping happens.",
"return",
"(",
"self",
".",
"_GetDebugInfoPostbuilds",
"(",
"configname",
",",
"output",
",",
"output_binary",
",",
"quiet",
")",
"+",
"self",
".",
"_GetStripPostbuilds",
"(",
"configname",
",",
"output_binary",
",",
"quiet",
")",
")"
] | [
974,
2
] | [
981,
67
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._GetIOSPostbuilds | (self, configname, output_binary) | Return a shell command to codesign the iOS output binary so it can
be deployed to a device. This should be run as the very last step of the
build. | Return a shell command to codesign the iOS output binary so it can
be deployed to a device. This should be run as the very last step of the
build. | def _GetIOSPostbuilds(self, configname, output_binary):
"""Return a shell command to codesign the iOS output binary so it can
be deployed to a device. This should be run as the very last step of the
build."""
if not (self.isIOS and self.spec['type'] == 'executable'):
return []
settings = self.xcode_settings[configname]
key = self._GetIOSCodeSignIdentityKey(settings)
if not key:
return []
# Warn for any unimplemented signing xcode keys.
unimpl = ['OTHER_CODE_SIGN_FLAGS']
unimpl = set(unimpl) & set(self.xcode_settings[configname].keys())
if unimpl:
print 'Warning: Some codesign keys not implemented, ignoring: %s' % (
', '.join(sorted(unimpl)))
return ['%s code-sign-bundle "%s" "%s" "%s" "%s"' % (
os.path.join('${TARGET_BUILD_DIR}', 'gyp-mac-tool'), key,
settings.get('CODE_SIGN_RESOURCE_RULES_PATH', ''),
settings.get('CODE_SIGN_ENTITLEMENTS', ''),
settings.get('PROVISIONING_PROFILE', ''))
] | [
"def",
"_GetIOSPostbuilds",
"(",
"self",
",",
"configname",
",",
"output_binary",
")",
":",
"if",
"not",
"(",
"self",
".",
"isIOS",
"and",
"self",
".",
"spec",
"[",
"'type'",
"]",
"==",
"'executable'",
")",
":",
"return",
"[",
"]",
"settings",
"=",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
"key",
"=",
"self",
".",
"_GetIOSCodeSignIdentityKey",
"(",
"settings",
")",
"if",
"not",
"key",
":",
"return",
"[",
"]",
"# Warn for any unimplemented signing xcode keys.",
"unimpl",
"=",
"[",
"'OTHER_CODE_SIGN_FLAGS'",
"]",
"unimpl",
"=",
"set",
"(",
"unimpl",
")",
"&",
"set",
"(",
"self",
".",
"xcode_settings",
"[",
"configname",
"]",
".",
"keys",
"(",
")",
")",
"if",
"unimpl",
":",
"print",
"'Warning: Some codesign keys not implemented, ignoring: %s'",
"%",
"(",
"', '",
".",
"join",
"(",
"sorted",
"(",
"unimpl",
")",
")",
")",
"return",
"[",
"'%s code-sign-bundle \"%s\" \"%s\" \"%s\" \"%s\"'",
"%",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'${TARGET_BUILD_DIR}'",
",",
"'gyp-mac-tool'",
")",
",",
"key",
",",
"settings",
".",
"get",
"(",
"'CODE_SIGN_RESOURCE_RULES_PATH'",
",",
"''",
")",
",",
"settings",
".",
"get",
"(",
"'CODE_SIGN_ENTITLEMENTS'",
",",
"''",
")",
",",
"settings",
".",
"get",
"(",
"'PROVISIONING_PROFILE'",
",",
"''",
")",
")",
"]"
] | [
983,
2
] | [
1007,
5
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.AddImplicitPostbuilds | (self, configname, output, output_binary,
postbuilds=[], quiet=False) | Returns a list of shell commands that should run before and after
|postbuilds|. | Returns a list of shell commands that should run before and after
|postbuilds|. | def AddImplicitPostbuilds(self, configname, output, output_binary,
postbuilds=[], quiet=False):
"""Returns a list of shell commands that should run before and after
|postbuilds|."""
assert output_binary is not None
pre = self._GetTargetPostbuilds(configname, output, output_binary, quiet)
post = self._GetIOSPostbuilds(configname, output_binary)
return pre + postbuilds + post | [
"def",
"AddImplicitPostbuilds",
"(",
"self",
",",
"configname",
",",
"output",
",",
"output_binary",
",",
"postbuilds",
"=",
"[",
"]",
",",
"quiet",
"=",
"False",
")",
":",
"assert",
"output_binary",
"is",
"not",
"None",
"pre",
"=",
"self",
".",
"_GetTargetPostbuilds",
"(",
"configname",
",",
"output",
",",
"output_binary",
",",
"quiet",
")",
"post",
"=",
"self",
".",
"_GetIOSPostbuilds",
"(",
"configname",
",",
"output_binary",
")",
"return",
"pre",
"+",
"postbuilds",
"+",
"post"
] | [
1025,
2
] | [
1032,
34
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings.AdjustLibraries | (self, libraries, config_name=None) | Transforms entries like 'Cocoa.framework' in libraries into entries like
'-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc.
| Transforms entries like 'Cocoa.framework' in libraries into entries like
'-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc.
| def AdjustLibraries(self, libraries, config_name=None):
"""Transforms entries like 'Cocoa.framework' in libraries into entries like
'-framework Cocoa', 'libcrypto.dylib' into '-lcrypto', etc.
"""
libraries = [self._AdjustLibrary(library, config_name)
for library in libraries]
return libraries | [
"def",
"AdjustLibraries",
"(",
"self",
",",
"libraries",
",",
"config_name",
"=",
"None",
")",
":",
"libraries",
"=",
"[",
"self",
".",
"_AdjustLibrary",
"(",
"library",
",",
"config_name",
")",
"for",
"library",
"in",
"libraries",
"]",
"return",
"libraries"
] | [
1065,
2
] | [
1071,
20
] | python | en | ['es', 'en', 'en'] | True |
XcodeSettings.GetExtraPlistItems | (self, configname=None) | Returns a dictionary with extra items to insert into Info.plist. | Returns a dictionary with extra items to insert into Info.plist. | def GetExtraPlistItems(self, configname=None):
"""Returns a dictionary with extra items to insert into Info.plist."""
if configname not in XcodeSettings._plist_cache:
cache = {}
cache['BuildMachineOSBuild'] = self._BuildMachineOSBuild()
xcode, xcode_build = XcodeVersion()
cache['DTXcode'] = xcode
cache['DTXcodeBuild'] = xcode_build
sdk_root = self._SdkRoot(configname)
if not sdk_root:
sdk_root = self._DefaultSdkRoot()
cache['DTSDKName'] = sdk_root
if xcode >= '0430':
cache['DTSDKBuild'] = self._GetSdkVersionInfoItem(
sdk_root, 'ProductBuildVersion')
else:
cache['DTSDKBuild'] = cache['BuildMachineOSBuild']
if self.isIOS:
cache['DTPlatformName'] = cache['DTSDKName']
if configname.endswith("iphoneos"):
cache['DTPlatformVersion'] = self._GetSdkVersionInfoItem(
sdk_root, 'ProductVersion')
cache['CFBundleSupportedPlatforms'] = ['iPhoneOS']
else:
cache['CFBundleSupportedPlatforms'] = ['iPhoneSimulator']
XcodeSettings._plist_cache[configname] = cache
# Include extra plist items that are per-target, not per global
# XcodeSettings.
items = dict(XcodeSettings._plist_cache[configname])
if self.isIOS:
items['UIDeviceFamily'] = self._XcodeIOSDeviceFamily(configname)
return items | [
"def",
"GetExtraPlistItems",
"(",
"self",
",",
"configname",
"=",
"None",
")",
":",
"if",
"configname",
"not",
"in",
"XcodeSettings",
".",
"_plist_cache",
":",
"cache",
"=",
"{",
"}",
"cache",
"[",
"'BuildMachineOSBuild'",
"]",
"=",
"self",
".",
"_BuildMachineOSBuild",
"(",
")",
"xcode",
",",
"xcode_build",
"=",
"XcodeVersion",
"(",
")",
"cache",
"[",
"'DTXcode'",
"]",
"=",
"xcode",
"cache",
"[",
"'DTXcodeBuild'",
"]",
"=",
"xcode_build",
"sdk_root",
"=",
"self",
".",
"_SdkRoot",
"(",
"configname",
")",
"if",
"not",
"sdk_root",
":",
"sdk_root",
"=",
"self",
".",
"_DefaultSdkRoot",
"(",
")",
"cache",
"[",
"'DTSDKName'",
"]",
"=",
"sdk_root",
"if",
"xcode",
">=",
"'0430'",
":",
"cache",
"[",
"'DTSDKBuild'",
"]",
"=",
"self",
".",
"_GetSdkVersionInfoItem",
"(",
"sdk_root",
",",
"'ProductBuildVersion'",
")",
"else",
":",
"cache",
"[",
"'DTSDKBuild'",
"]",
"=",
"cache",
"[",
"'BuildMachineOSBuild'",
"]",
"if",
"self",
".",
"isIOS",
":",
"cache",
"[",
"'DTPlatformName'",
"]",
"=",
"cache",
"[",
"'DTSDKName'",
"]",
"if",
"configname",
".",
"endswith",
"(",
"\"iphoneos\"",
")",
":",
"cache",
"[",
"'DTPlatformVersion'",
"]",
"=",
"self",
".",
"_GetSdkVersionInfoItem",
"(",
"sdk_root",
",",
"'ProductVersion'",
")",
"cache",
"[",
"'CFBundleSupportedPlatforms'",
"]",
"=",
"[",
"'iPhoneOS'",
"]",
"else",
":",
"cache",
"[",
"'CFBundleSupportedPlatforms'",
"]",
"=",
"[",
"'iPhoneSimulator'",
"]",
"XcodeSettings",
".",
"_plist_cache",
"[",
"configname",
"]",
"=",
"cache",
"# Include extra plist items that are per-target, not per global",
"# XcodeSettings.",
"items",
"=",
"dict",
"(",
"XcodeSettings",
".",
"_plist_cache",
"[",
"configname",
"]",
")",
"if",
"self",
".",
"isIOS",
":",
"items",
"[",
"'UIDeviceFamily'",
"]",
"=",
"self",
".",
"_XcodeIOSDeviceFamily",
"(",
"configname",
")",
"return",
"items"
] | [
1080,
2
] | [
1115,
16
] | python | en | ['en', 'en', 'en'] | True |
XcodeSettings._DefaultSdkRoot | (self) | Returns the default SDKROOT to use.
Prior to version 5.0.0, if SDKROOT was not explicitly set in the Xcode
project, then the environment variable was empty. Starting with this
version, Xcode uses the name of the newest SDK installed.
| Returns the default SDKROOT to use. | def _DefaultSdkRoot(self):
"""Returns the default SDKROOT to use.
Prior to version 5.0.0, if SDKROOT was not explicitly set in the Xcode
project, then the environment variable was empty. Starting with this
version, Xcode uses the name of the newest SDK installed.
"""
xcode_version, xcode_build = XcodeVersion()
if xcode_version < '0500':
return ''
default_sdk_path = self._XcodeSdkPath('')
default_sdk_root = XcodeSettings._sdk_root_cache.get(default_sdk_path)
if default_sdk_root:
return default_sdk_root
try:
all_sdks = GetStdout(['xcodebuild', '-showsdks'])
except:
# If xcodebuild fails, there will be no valid SDKs
return ''
for line in all_sdks.splitlines():
items = line.split()
if len(items) >= 3 and items[-2] == '-sdk':
sdk_root = items[-1]
sdk_path = self._XcodeSdkPath(sdk_root)
if sdk_path == default_sdk_path:
return sdk_root
return '' | [
"def",
"_DefaultSdkRoot",
"(",
"self",
")",
":",
"xcode_version",
",",
"xcode_build",
"=",
"XcodeVersion",
"(",
")",
"if",
"xcode_version",
"<",
"'0500'",
":",
"return",
"''",
"default_sdk_path",
"=",
"self",
".",
"_XcodeSdkPath",
"(",
"''",
")",
"default_sdk_root",
"=",
"XcodeSettings",
".",
"_sdk_root_cache",
".",
"get",
"(",
"default_sdk_path",
")",
"if",
"default_sdk_root",
":",
"return",
"default_sdk_root",
"try",
":",
"all_sdks",
"=",
"GetStdout",
"(",
"[",
"'xcodebuild'",
",",
"'-showsdks'",
"]",
")",
"except",
":",
"# If xcodebuild fails, there will be no valid SDKs",
"return",
"''",
"for",
"line",
"in",
"all_sdks",
".",
"splitlines",
"(",
")",
":",
"items",
"=",
"line",
".",
"split",
"(",
")",
"if",
"len",
"(",
"items",
")",
">=",
"3",
"and",
"items",
"[",
"-",
"2",
"]",
"==",
"'-sdk'",
":",
"sdk_root",
"=",
"items",
"[",
"-",
"1",
"]",
"sdk_path",
"=",
"self",
".",
"_XcodeSdkPath",
"(",
"sdk_root",
")",
"if",
"sdk_path",
"==",
"default_sdk_path",
":",
"return",
"sdk_root",
"return",
"''"
] | [
1117,
2
] | [
1143,
13
] | python | en | ['en', 'en', 'en'] | True |
MacPrefixHeader.__init__ | (self, xcode_settings,
gyp_path_to_build_path, gyp_path_to_build_output) | If xcode_settings is None, all methods on this class are no-ops.
Args:
gyp_path_to_build_path: A function that takes a gyp-relative path,
and returns a path relative to the build directory.
gyp_path_to_build_output: A function that takes a gyp-relative path and
a language code ('c', 'cc', 'm', or 'mm'), and that returns a path
to where the output of precompiling that path for that language
should be placed (without the trailing '.gch').
| If xcode_settings is None, all methods on this class are no-ops. | def __init__(self, xcode_settings,
gyp_path_to_build_path, gyp_path_to_build_output):
"""If xcode_settings is None, all methods on this class are no-ops.
Args:
gyp_path_to_build_path: A function that takes a gyp-relative path,
and returns a path relative to the build directory.
gyp_path_to_build_output: A function that takes a gyp-relative path and
a language code ('c', 'cc', 'm', or 'mm'), and that returns a path
to where the output of precompiling that path for that language
should be placed (without the trailing '.gch').
"""
# This doesn't support per-configuration prefix headers. Good enough
# for now.
self.header = None
self.compile_headers = False
if xcode_settings:
self.header = xcode_settings.GetPerTargetSetting('GCC_PREFIX_HEADER')
self.compile_headers = xcode_settings.GetPerTargetSetting(
'GCC_PRECOMPILE_PREFIX_HEADER', default='NO') != 'NO'
self.compiled_headers = {}
if self.header:
if self.compile_headers:
for lang in ['c', 'cc', 'm', 'mm']:
self.compiled_headers[lang] = gyp_path_to_build_output(
self.header, lang)
self.header = gyp_path_to_build_path(self.header) | [
"def",
"__init__",
"(",
"self",
",",
"xcode_settings",
",",
"gyp_path_to_build_path",
",",
"gyp_path_to_build_output",
")",
":",
"# This doesn't support per-configuration prefix headers. Good enough",
"# for now.",
"self",
".",
"header",
"=",
"None",
"self",
".",
"compile_headers",
"=",
"False",
"if",
"xcode_settings",
":",
"self",
".",
"header",
"=",
"xcode_settings",
".",
"GetPerTargetSetting",
"(",
"'GCC_PREFIX_HEADER'",
")",
"self",
".",
"compile_headers",
"=",
"xcode_settings",
".",
"GetPerTargetSetting",
"(",
"'GCC_PRECOMPILE_PREFIX_HEADER'",
",",
"default",
"=",
"'NO'",
")",
"!=",
"'NO'",
"self",
".",
"compiled_headers",
"=",
"{",
"}",
"if",
"self",
".",
"header",
":",
"if",
"self",
".",
"compile_headers",
":",
"for",
"lang",
"in",
"[",
"'c'",
",",
"'cc'",
",",
"'m'",
",",
"'mm'",
"]",
":",
"self",
".",
"compiled_headers",
"[",
"lang",
"]",
"=",
"gyp_path_to_build_output",
"(",
"self",
".",
"header",
",",
"lang",
")",
"self",
".",
"header",
"=",
"gyp_path_to_build_path",
"(",
"self",
".",
"header",
")"
] | [
1168,
2
] | [
1194,
55
] | python | en | ['en', 'en', 'en'] | True |
MacPrefixHeader.GetInclude | (self, lang, arch=None) | Gets the cflags to include the prefix header for language |lang|. | Gets the cflags to include the prefix header for language |lang|. | def GetInclude(self, lang, arch=None):
"""Gets the cflags to include the prefix header for language |lang|."""
if self.compile_headers and lang in self.compiled_headers:
return '-include %s' % self._CompiledHeader(lang, arch)
elif self.header:
return '-include %s' % self.header
else:
return '' | [
"def",
"GetInclude",
"(",
"self",
",",
"lang",
",",
"arch",
"=",
"None",
")",
":",
"if",
"self",
".",
"compile_headers",
"and",
"lang",
"in",
"self",
".",
"compiled_headers",
":",
"return",
"'-include %s'",
"%",
"self",
".",
"_CompiledHeader",
"(",
"lang",
",",
"arch",
")",
"elif",
"self",
".",
"header",
":",
"return",
"'-include %s'",
"%",
"self",
".",
"header",
"else",
":",
"return",
"''"
] | [
1203,
2
] | [
1210,
15
] | python | en | ['en', 'en', 'en'] | True |
MacPrefixHeader._Gch | (self, lang, arch) | Returns the actual file name of the prefix header for language |lang|. | Returns the actual file name of the prefix header for language |lang|. | def _Gch(self, lang, arch):
"""Returns the actual file name of the prefix header for language |lang|."""
assert self.compile_headers
return self._CompiledHeader(lang, arch) + '.gch' | [
"def",
"_Gch",
"(",
"self",
",",
"lang",
",",
"arch",
")",
":",
"assert",
"self",
".",
"compile_headers",
"return",
"self",
".",
"_CompiledHeader",
"(",
"lang",
",",
"arch",
")",
"+",
"'.gch'"
] | [
1212,
2
] | [
1215,
52
] | python | en | ['en', 'en', 'en'] | True |
MacPrefixHeader.GetObjDependencies | (self, sources, objs, arch=None) | Given a list of source files and the corresponding object files, returns
a list of (source, object, gch) tuples, where |gch| is the build-directory
relative path to the gch file each object file depends on. |compilable[i]|
has to be the source file belonging to |objs[i]|. | Given a list of source files and the corresponding object files, returns
a list of (source, object, gch) tuples, where |gch| is the build-directory
relative path to the gch file each object file depends on. |compilable[i]|
has to be the source file belonging to |objs[i]|. | def GetObjDependencies(self, sources, objs, arch=None):
"""Given a list of source files and the corresponding object files, returns
a list of (source, object, gch) tuples, where |gch| is the build-directory
relative path to the gch file each object file depends on. |compilable[i]|
has to be the source file belonging to |objs[i]|."""
if not self.header or not self.compile_headers:
return []
result = []
for source, obj in zip(sources, objs):
ext = os.path.splitext(source)[1]
lang = {
'.c': 'c',
'.cpp': 'cc', '.cc': 'cc', '.cxx': 'cc',
'.m': 'm',
'.mm': 'mm',
}.get(ext, None)
if lang:
result.append((source, obj, self._Gch(lang, arch)))
return result | [
"def",
"GetObjDependencies",
"(",
"self",
",",
"sources",
",",
"objs",
",",
"arch",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"header",
"or",
"not",
"self",
".",
"compile_headers",
":",
"return",
"[",
"]",
"result",
"=",
"[",
"]",
"for",
"source",
",",
"obj",
"in",
"zip",
"(",
"sources",
",",
"objs",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"source",
")",
"[",
"1",
"]",
"lang",
"=",
"{",
"'.c'",
":",
"'c'",
",",
"'.cpp'",
":",
"'cc'",
",",
"'.cc'",
":",
"'cc'",
",",
"'.cxx'",
":",
"'cc'",
",",
"'.m'",
":",
"'m'",
",",
"'.mm'",
":",
"'mm'",
",",
"}",
".",
"get",
"(",
"ext",
",",
"None",
")",
"if",
"lang",
":",
"result",
".",
"append",
"(",
"(",
"source",
",",
"obj",
",",
"self",
".",
"_Gch",
"(",
"lang",
",",
"arch",
")",
")",
")",
"return",
"result"
] | [
1217,
2
] | [
1236,
17
] | python | en | ['en', 'en', 'en'] | True |
MacPrefixHeader.GetPchBuildCommands | (self, arch=None) | Returns [(path_to_gch, language_flag, language, header)].
|path_to_gch| and |header| are relative to the build directory.
| Returns [(path_to_gch, language_flag, language, header)].
|path_to_gch| and |header| are relative to the build directory.
| def GetPchBuildCommands(self, arch=None):
"""Returns [(path_to_gch, language_flag, language, header)].
|path_to_gch| and |header| are relative to the build directory.
"""
if not self.header or not self.compile_headers:
return []
return [
(self._Gch('c', arch), '-x c-header', 'c', self.header),
(self._Gch('cc', arch), '-x c++-header', 'cc', self.header),
(self._Gch('m', arch), '-x objective-c-header', 'm', self.header),
(self._Gch('mm', arch), '-x objective-c++-header', 'mm', self.header),
] | [
"def",
"GetPchBuildCommands",
"(",
"self",
",",
"arch",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"header",
"or",
"not",
"self",
".",
"compile_headers",
":",
"return",
"[",
"]",
"return",
"[",
"(",
"self",
".",
"_Gch",
"(",
"'c'",
",",
"arch",
")",
",",
"'-x c-header'",
",",
"'c'",
",",
"self",
".",
"header",
")",
",",
"(",
"self",
".",
"_Gch",
"(",
"'cc'",
",",
"arch",
")",
",",
"'-x c++-header'",
",",
"'cc'",
",",
"self",
".",
"header",
")",
",",
"(",
"self",
".",
"_Gch",
"(",
"'m'",
",",
"arch",
")",
",",
"'-x objective-c-header'",
",",
"'m'",
",",
"self",
".",
"header",
")",
",",
"(",
"self",
".",
"_Gch",
"(",
"'mm'",
",",
"arch",
")",
",",
"'-x objective-c++-header'",
",",
"'mm'",
",",
"self",
".",
"header",
")",
",",
"]"
] | [
1238,
2
] | [
1249,
5
] | python | en | ['en', 'jv', 'en'] | True |
OrionDBExplorer.__init__ | (self, user, database='orion', mongodb_config=None) | Initiaize this OrionDBExplorer.
Args:
user (str):
Unique identifier of the user that creates this OrionExporer
instance. This username or user ID will be used to populate
the ``created_by`` field of all the objects created in the
database during this session.
database (str):
Name of the MongoDB database to use. Defaults to ``orion``.
mongodb_config (dict or str):
A dict or a path to JSON file with additional arguments can be
passed to provide connection details different than the defaults
for the MongoDB Database:
* ``host``: Hostname or IP address of the MongoDB Instance.
* ``port``: Port to which MongoDB is listening.
* ``username``: username to authenticate with.
* ``password``: password to authenticate with.
* ``authentication_source``: database to authenticate against.
| Initiaize this OrionDBExplorer. | def __init__(self, user, database='orion', mongodb_config=None):
"""Initiaize this OrionDBExplorer.
Args:
user (str):
Unique identifier of the user that creates this OrionExporer
instance. This username or user ID will be used to populate
the ``created_by`` field of all the objects created in the
database during this session.
database (str):
Name of the MongoDB database to use. Defaults to ``orion``.
mongodb_config (dict or str):
A dict or a path to JSON file with additional arguments can be
passed to provide connection details different than the defaults
for the MongoDB Database:
* ``host``: Hostname or IP address of the MongoDB Instance.
* ``port``: Port to which MongoDB is listening.
* ``username``: username to authenticate with.
* ``password``: password to authenticate with.
* ``authentication_source``: database to authenticate against.
"""
if mongodb_config is None:
mongodb_config = dict()
elif isinstance(mongodb_config, str):
with open(mongodb_config) as config_file:
mongodb_config = json.load(config_file)
elif isinstance(mongodb_config, dict):
mongodb_config = mongodb_config.copy()
self.user = user
self.database = mongodb_config.pop('database', database)
self._db = connect(database, **mongodb_config)
self._fs = GridFS(Database(self._db, self.database)) | [
"def",
"__init__",
"(",
"self",
",",
"user",
",",
"database",
"=",
"'orion'",
",",
"mongodb_config",
"=",
"None",
")",
":",
"if",
"mongodb_config",
"is",
"None",
":",
"mongodb_config",
"=",
"dict",
"(",
")",
"elif",
"isinstance",
"(",
"mongodb_config",
",",
"str",
")",
":",
"with",
"open",
"(",
"mongodb_config",
")",
"as",
"config_file",
":",
"mongodb_config",
"=",
"json",
".",
"load",
"(",
"config_file",
")",
"elif",
"isinstance",
"(",
"mongodb_config",
",",
"dict",
")",
":",
"mongodb_config",
"=",
"mongodb_config",
".",
"copy",
"(",
")",
"self",
".",
"user",
"=",
"user",
"self",
".",
"database",
"=",
"mongodb_config",
".",
"pop",
"(",
"'database'",
",",
"database",
")",
"self",
".",
"_db",
"=",
"connect",
"(",
"database",
",",
"*",
"*",
"mongodb_config",
")",
"self",
".",
"_fs",
"=",
"GridFS",
"(",
"Database",
"(",
"self",
".",
"_db",
",",
"self",
".",
"database",
")",
")"
] | [
73,
4
] | [
106,
60
] | python | en | ['en', 'la', 'en'] | True |
OrionDBExplorer.drop_database | (self) | Drop the database.
This method is used for development purposes and will
most likely be removed in the future.
| Drop the database. | def drop_database(self):
"""Drop the database.
This method is used for development purposes and will
most likely be removed in the future.
"""
self._db.drop_database(self.database) | [
"def",
"drop_database",
"(",
"self",
")",
":",
"self",
".",
"_db",
".",
"drop_database",
"(",
"self",
".",
"database",
")"
] | [
108,
4
] | [
114,
45
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.add_dataset | (self, name, entity=None) | Add a new Dataset object to the database.
The Dataset needs to be given a name and, optionally, an identitifier,
name or ID, of the entity which produced the Dataset.
Args:
name (str):
Name of the Dataset
entity (str):
Name or Id of the entity which this Dataset is associated to.
Defaults to ``None``.
Raises:
NotUniqueError:
If a Dataset with the same name and entity values already exists.
Returns:
Dataset
| Add a new Dataset object to the database. | def add_dataset(self, name, entity=None):
"""Add a new Dataset object to the database.
The Dataset needs to be given a name and, optionally, an identitifier,
name or ID, of the entity which produced the Dataset.
Args:
name (str):
Name of the Dataset
entity (str):
Name or Id of the entity which this Dataset is associated to.
Defaults to ``None``.
Raises:
NotUniqueError:
If a Dataset with the same name and entity values already exists.
Returns:
Dataset
"""
return schema.Dataset.insert(
name=name,
entity=entity,
created_by=self.user
) | [
"def",
"add_dataset",
"(",
"self",
",",
"name",
",",
"entity",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Dataset",
".",
"insert",
"(",
"name",
"=",
"name",
",",
"entity",
"=",
"entity",
",",
"created_by",
"=",
"self",
".",
"user",
")"
] | [
120,
4
] | [
144,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_datasets | (self, name=None, entity=None, created_by=None) | Query the Datasets collection.
All the details about the matching Datasets will be returned in
a ``pandas.DataFrame``.
All the arguments are optional, so a call without arguments will
return a table with information about all the Datasets availabe.
Args:
name (str):
Name of the Dataset.
entity (str):
Name or Id of the entity which returned Datasets need to be
associated to.
created_by (str):
Unique identifier of the user that created the Datasets.
Returns:
pandas.DataFrame
| Query the Datasets collection. | def get_datasets(self, name=None, entity=None, created_by=None):
"""Query the Datasets collection.
All the details about the matching Datasets will be returned in
a ``pandas.DataFrame``.
All the arguments are optional, so a call without arguments will
return a table with information about all the Datasets availabe.
Args:
name (str):
Name of the Dataset.
entity (str):
Name or Id of the entity which returned Datasets need to be
associated to.
created_by (str):
Unique identifier of the user that created the Datasets.
Returns:
pandas.DataFrame
"""
return schema.Dataset.find(
as_df_=True,
name=name,
entity=entity,
created_by=created_by
) | [
"def",
"get_datasets",
"(",
"self",
",",
"name",
"=",
"None",
",",
"entity",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Dataset",
".",
"find",
"(",
"as_df_",
"=",
"True",
",",
"name",
"=",
"name",
",",
"entity",
"=",
"entity",
",",
"created_by",
"=",
"created_by",
")"
] | [
146,
4
] | [
172,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_dataset | (self, dataset=None, name=None, entity=None, created_by=None) | Get a Dataset object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Dataset.
entity (str):
Name or Id of the entity which this Dataset is associated to.
created_by (str):
Unique identifier of the user that created the Dataset.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Dataset
| Get a Dataset object from the database. | def get_dataset(self, dataset=None, name=None, entity=None, created_by=None):
"""Get a Dataset object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Dataset.
entity (str):
Name or Id of the entity which this Dataset is associated to.
created_by (str):
Unique identifier of the user that created the Dataset.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Dataset
"""
return schema.Dataset.get(
dataset=dataset,
name=name,
entity=entity,
created_by=created_by
) | [
"def",
"get_dataset",
"(",
"self",
",",
"dataset",
"=",
"None",
",",
"name",
"=",
"None",
",",
"entity",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Dataset",
".",
"get",
"(",
"dataset",
"=",
"dataset",
",",
"name",
"=",
"name",
",",
"entity",
"=",
"entity",
",",
"created_by",
"=",
"created_by",
")"
] | [
174,
4
] | [
204,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.add_signal | (self, name, dataset, data_location=None, start_time=None,
stop_time=None, timestamp_column=None, value_column=None) | Add a new Signal object to the database.
The signal needs to be given a name and be associated to a Dataset.
Args:
name (str):
Name of the Signal.
dataset (Dataset or ObjectID or str):
Dataset object which the created Signal belongs to or the
corresponding ObjectId.
data_location (str):
Path to the CSV containing the Signal data. If the signal is
one of the signals provided by Orion, this can be omitted and
the signal will be loaded based on the signal name.
start_time (int):
Optional. Minimum timestamp to use for this signal. If not provided
this defaults to the minimum timestamp found in the signal data.
stop_time (int):
Optional. Maximum timestamp to use for this signal. If not provided
this defaults to the maximum timestamp found in the signal data.
timestamp_column (int):
Optional. Index of the timestamp column.
value_column (int):
Optional. Index of the value column.
Raises:
NotUniqueError:
If a Signal with the same name already exists for this Dataset.
Returns:
Signal
| Add a new Signal object to the database. | def add_signal(self, name, dataset, data_location=None, start_time=None,
stop_time=None, timestamp_column=None, value_column=None):
"""Add a new Signal object to the database.
The signal needs to be given a name and be associated to a Dataset.
Args:
name (str):
Name of the Signal.
dataset (Dataset or ObjectID or str):
Dataset object which the created Signal belongs to or the
corresponding ObjectId.
data_location (str):
Path to the CSV containing the Signal data. If the signal is
one of the signals provided by Orion, this can be omitted and
the signal will be loaded based on the signal name.
start_time (int):
Optional. Minimum timestamp to use for this signal. If not provided
this defaults to the minimum timestamp found in the signal data.
stop_time (int):
Optional. Maximum timestamp to use for this signal. If not provided
this defaults to the maximum timestamp found in the signal data.
timestamp_column (int):
Optional. Index of the timestamp column.
value_column (int):
Optional. Index of the value column.
Raises:
NotUniqueError:
If a Signal with the same name already exists for this Dataset.
Returns:
Signal
"""
data_location = data_location or name
data = load_signal(data_location, None, timestamp_column, value_column)
timestamps = data['timestamp']
if not start_time:
start_time = timestamps.min()
if not stop_time:
stop_time = timestamps.max()
dataset = self.get_dataset(dataset)
return schema.Signal.insert(
name=name,
dataset=dataset,
start_time=start_time,
stop_time=stop_time,
data_location=data_location,
timestamp_column=timestamp_column,
value_column=value_column,
created_by=self.user
) | [
"def",
"add_signal",
"(",
"self",
",",
"name",
",",
"dataset",
",",
"data_location",
"=",
"None",
",",
"start_time",
"=",
"None",
",",
"stop_time",
"=",
"None",
",",
"timestamp_column",
"=",
"None",
",",
"value_column",
"=",
"None",
")",
":",
"data_location",
"=",
"data_location",
"or",
"name",
"data",
"=",
"load_signal",
"(",
"data_location",
",",
"None",
",",
"timestamp_column",
",",
"value_column",
")",
"timestamps",
"=",
"data",
"[",
"'timestamp'",
"]",
"if",
"not",
"start_time",
":",
"start_time",
"=",
"timestamps",
".",
"min",
"(",
")",
"if",
"not",
"stop_time",
":",
"stop_time",
"=",
"timestamps",
".",
"max",
"(",
")",
"dataset",
"=",
"self",
".",
"get_dataset",
"(",
"dataset",
")",
"return",
"schema",
".",
"Signal",
".",
"insert",
"(",
"name",
"=",
"name",
",",
"dataset",
"=",
"dataset",
",",
"start_time",
"=",
"start_time",
",",
"stop_time",
"=",
"stop_time",
",",
"data_location",
"=",
"data_location",
",",
"timestamp_column",
"=",
"timestamp_column",
",",
"value_column",
"=",
"value_column",
",",
"created_by",
"=",
"self",
".",
"user",
")"
] | [
210,
4
] | [
264,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.add_signals | (self, dataset, signals_path=None, start_time=None,
stop_time=None, timestamp_column=None, value_column=None) | Add a multiple Signal objects to the database.
All the signals will be added to the Dataset using the CSV filename
as their name.
Args:
dataset (Dataset or ObjectID or str):
Dataset object which the created Signals belongs to or the
corresponding ObjectId.
signals_path (str):
Path to the folder where the signals can be found. All the CSV
files in this folder will be added.
start_time (int):
Optional. Minimum timestamp to use for these signals. If not provided
this defaults to the minimum timestamp found in the signal data.
stop_time (int):
Optional. Maximum timestamp to use for these signals. If not provided
this defaults to the maximum timestamp found in the signal data.
timestamp_column (int):
Optional. Index of the timestamp column.
value_column (int):
Optional. Index of the value column.
| Add a multiple Signal objects to the database. | def add_signals(self, dataset, signals_path=None, start_time=None,
stop_time=None, timestamp_column=None, value_column=None):
"""Add a multiple Signal objects to the database.
All the signals will be added to the Dataset using the CSV filename
as their name.
Args:
dataset (Dataset or ObjectID or str):
Dataset object which the created Signals belongs to or the
corresponding ObjectId.
signals_path (str):
Path to the folder where the signals can be found. All the CSV
files in this folder will be added.
start_time (int):
Optional. Minimum timestamp to use for these signals. If not provided
this defaults to the minimum timestamp found in the signal data.
stop_time (int):
Optional. Maximum timestamp to use for these signals. If not provided
this defaults to the maximum timestamp found in the signal data.
timestamp_column (int):
Optional. Index of the timestamp column.
value_column (int):
Optional. Index of the value column.
"""
for filename in os.listdir(signals_path):
if filename.endswith('.csv'):
signal_name = filename[:-4] # remove from filename .csv
try:
self.add_signal(
name=signal_name,
dataset=dataset,
data_location=os.path.join(signals_path, filename),
start_time=start_time,
stop_time=stop_time,
timestamp_column=timestamp_column,
value_column=value_column,
)
except NotUniqueError:
pass | [
"def",
"add_signals",
"(",
"self",
",",
"dataset",
",",
"signals_path",
"=",
"None",
",",
"start_time",
"=",
"None",
",",
"stop_time",
"=",
"None",
",",
"timestamp_column",
"=",
"None",
",",
"value_column",
"=",
"None",
")",
":",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"signals_path",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.csv'",
")",
":",
"signal_name",
"=",
"filename",
"[",
":",
"-",
"4",
"]",
"# remove from filename .csv",
"try",
":",
"self",
".",
"add_signal",
"(",
"name",
"=",
"signal_name",
",",
"dataset",
"=",
"dataset",
",",
"data_location",
"=",
"os",
".",
"path",
".",
"join",
"(",
"signals_path",
",",
"filename",
")",
",",
"start_time",
"=",
"start_time",
",",
"stop_time",
"=",
"stop_time",
",",
"timestamp_column",
"=",
"timestamp_column",
",",
"value_column",
"=",
"value_column",
",",
")",
"except",
"NotUniqueError",
":",
"pass"
] | [
266,
4
] | [
305,
24
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_signals | (self, name=None, dataset=None, created_by=None) | Query the Signals collection.
All the details about the matching Signals will be returned in
a ``pandas.DataFrame``.
All the arguments are optional, so a call without arguments will
return a table with information about all the Signals availabe.
Args:
name (str):
Name of the Signal.
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) to which the Signals have to belong.
created_by (str):
Unique identifier of the user that created the Signals.
Returns:
pandas.DataFrame
| Query the Signals collection. | def get_signals(self, name=None, dataset=None, created_by=None):
"""Query the Signals collection.
All the details about the matching Signals will be returned in
a ``pandas.DataFrame``.
All the arguments are optional, so a call without arguments will
return a table with information about all the Signals availabe.
Args:
name (str):
Name of the Signal.
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) to which the Signals have to belong.
created_by (str):
Unique identifier of the user that created the Signals.
Returns:
pandas.DataFrame
"""
return schema.Signal.find(
as_df_=True,
name=name,
dataset=dataset,
created_by=created_by
) | [
"def",
"get_signals",
"(",
"self",
",",
"name",
"=",
"None",
",",
"dataset",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Signal",
".",
"find",
"(",
"as_df_",
"=",
"True",
",",
"name",
"=",
"name",
",",
"dataset",
"=",
"dataset",
",",
"created_by",
"=",
"created_by",
")"
] | [
307,
4
] | [
333,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_signal | (self, signal=None, name=None, dataset=None, created_by=None) | Get a Signal object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
signal (Signal, ObjectID or str):
Signal object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Signal.
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) to which the Signal has to belong.
created_by (str):
Unique identifier of the user that created the Signals.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Signal
| Get a Signal object from the database. | def get_signal(self, signal=None, name=None, dataset=None, created_by=None):
"""Get a Signal object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
signal (Signal, ObjectID or str):
Signal object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Signal.
dataset (Dataset, ObjectID or str):
Dataset object (or the corresponding ObjectID, or its string
representation) to which the Signal has to belong.
created_by (str):
Unique identifier of the user that created the Signals.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Signal
"""
return schema.Signal.get(
signal=signal,
name=name,
dataset=dataset,
created_by=created_by
) | [
"def",
"get_signal",
"(",
"self",
",",
"signal",
"=",
"None",
",",
"name",
"=",
"None",
",",
"dataset",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Signal",
".",
"get",
"(",
"signal",
"=",
"signal",
",",
"name",
"=",
"name",
",",
"dataset",
"=",
"dataset",
",",
"created_by",
"=",
"created_by",
")"
] | [
335,
4
] | [
366,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.add_template | (self, name, template=None) | Add a new Template object to the database.
The template can be passed as a name of a registered MLPipeline,
or as a path to an MLPipeline JSON specification, or as a full
dictionary specification of an MLPipeline or directly as an
MLPipeline instance.
If the ``template`` argument is not passed, the given ``name`` will
be used to load an MLPipeline.
During this step, apart from the Template object, a new Pipeline object
using the default hyperparameters and with the same name as the
Template will also be created.
Args:
name (str):
Name of the Template.
template (str, dict or MLPipeline):
Name of the MLBlocks template to load or path to its JSON
file or dictionary specification or MLPipeline instance.
If not given, the ``name`` of the template is used.
Raises:
NotUniqueError:
If a Template with the same name already exists.
Returns:
Template
| Add a new Template object to the database. | def add_template(self, name, template=None):
"""Add a new Template object to the database.
The template can be passed as a name of a registered MLPipeline,
or as a path to an MLPipeline JSON specification, or as a full
dictionary specification of an MLPipeline or directly as an
MLPipeline instance.
If the ``template`` argument is not passed, the given ``name`` will
be used to load an MLPipeline.
During this step, apart from the Template object, a new Pipeline object
using the default hyperparameters and with the same name as the
Template will also be created.
Args:
name (str):
Name of the Template.
template (str, dict or MLPipeline):
Name of the MLBlocks template to load or path to its JSON
file or dictionary specification or MLPipeline instance.
If not given, the ``name`` of the template is used.
Raises:
NotUniqueError:
If a Template with the same name already exists.
Returns:
Template
"""
template = template or name
if isinstance(template, str) and os.path.isfile(template):
with open(template, 'r') as f:
template = json.load(f)
pipeline_dict = MLPipeline(template).to_dict()
template = schema.Template.insert(
name=name,
json=pipeline_dict,
created_by=self.user
)
schema.Pipeline.insert(
name=name,
template=template,
json=pipeline_dict,
created_by=self.user
)
return template | [
"def",
"add_template",
"(",
"self",
",",
"name",
",",
"template",
"=",
"None",
")",
":",
"template",
"=",
"template",
"or",
"name",
"if",
"isinstance",
"(",
"template",
",",
"str",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"template",
")",
":",
"with",
"open",
"(",
"template",
",",
"'r'",
")",
"as",
"f",
":",
"template",
"=",
"json",
".",
"load",
"(",
"f",
")",
"pipeline_dict",
"=",
"MLPipeline",
"(",
"template",
")",
".",
"to_dict",
"(",
")",
"template",
"=",
"schema",
".",
"Template",
".",
"insert",
"(",
"name",
"=",
"name",
",",
"json",
"=",
"pipeline_dict",
",",
"created_by",
"=",
"self",
".",
"user",
")",
"schema",
".",
"Pipeline",
".",
"insert",
"(",
"name",
"=",
"name",
",",
"template",
"=",
"template",
",",
"json",
"=",
"pipeline_dict",
",",
"created_by",
"=",
"self",
".",
"user",
")",
"return",
"template"
] | [
372,
4
] | [
421,
23
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_templates | (self, name=None, created_by=None) | Query the Templates collection.
All the details about the matching Templates will be returned in
a ``pandas.DataFrame``, except for the JSON specification of the
template, which will be removed from the table for readability.
In order to access the JSON specification of each Template, please
retreive them using the ``get_template`` method.
All the arguments are optional, so a call without arguments will
return a table with information about all the Templates availabe.
Args:
name (str):
Name of the Template.
created_by (str):
Unique identifier of the user that created the Templates.
Returns:
pandas.DataFrame
| Query the Templates collection. | def get_templates(self, name=None, created_by=None):
"""Query the Templates collection.
All the details about the matching Templates will be returned in
a ``pandas.DataFrame``, except for the JSON specification of the
template, which will be removed from the table for readability.
In order to access the JSON specification of each Template, please
retreive them using the ``get_template`` method.
All the arguments are optional, so a call without arguments will
return a table with information about all the Templates availabe.
Args:
name (str):
Name of the Template.
created_by (str):
Unique identifier of the user that created the Templates.
Returns:
pandas.DataFrame
"""
return schema.Template.find(
as_df_=True,
name=name,
created_by=created_by,
exclude_=['json']
) | [
"def",
"get_templates",
"(",
"self",
",",
"name",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Template",
".",
"find",
"(",
"as_df_",
"=",
"True",
",",
"name",
"=",
"name",
",",
"created_by",
"=",
"created_by",
",",
"exclude_",
"=",
"[",
"'json'",
"]",
")"
] | [
423,
4
] | [
450,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_template | (self, template=None, name=None, created_by=None) | Get a Template object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
template (Template, ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Template.
created_by (str):
Unique identifier of the user that created the Templates.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Template
| Get a Template object from the database. | def get_template(self, template=None, name=None, created_by=None):
"""Get a Template object from the database.
All the arguments are optional but empty queries are not allowed, so at
least one argument needs to be passed with a value different than ``None``.
Args:
template (Template, ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) that we want to retreive.
name (str):
Name of the Template.
created_by (str):
Unique identifier of the user that created the Templates.
Raises:
ValueError:
If the no arguments are passed with a value different than
``None`` or the query resolves to more than one object.
Returns:
Template
"""
return schema.Template.get(
template=template,
name=name,
created_by=created_by
) | [
"def",
"get_template",
"(",
"self",
",",
"template",
"=",
"None",
",",
"name",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Template",
".",
"get",
"(",
"template",
"=",
"template",
",",
"name",
"=",
"name",
",",
"created_by",
"=",
"created_by",
")"
] | [
452,
4
] | [
479,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.add_pipeline | (self, name, template, hyperparameters) | Add a new Pipeline object to the database.
The Pipeline will consist on a copy of the given Template using
the indicated hyperparameters.
The hyperparameters can be passed as a dictionary containing the
hyperparameter values following the MLBlocks specification format,
or a path to a JSON file containing the corresponding values.
Args:
name (str):
Name of the Pipeline.
template (Template or ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) that we want to use to create this Pipeline.
hyperparamers (dict or str):
dict containing the hyperparameter values following the MLBlocks
specification format, or a path to a JSON file containing the
corresponding values.
Raises:
NotUniqueError:
If a Pipeline with the same name for this Template already exists.
Returns:
Pipeline
| Add a new Pipeline object to the database. | def add_pipeline(self, name, template, hyperparameters):
"""Add a new Pipeline object to the database.
The Pipeline will consist on a copy of the given Template using
the indicated hyperparameters.
The hyperparameters can be passed as a dictionary containing the
hyperparameter values following the MLBlocks specification format,
or a path to a JSON file containing the corresponding values.
Args:
name (str):
Name of the Pipeline.
template (Template or ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) that we want to use to create this Pipeline.
hyperparamers (dict or str):
dict containing the hyperparameter values following the MLBlocks
specification format, or a path to a JSON file containing the
corresponding values.
Raises:
NotUniqueError:
If a Pipeline with the same name for this Template already exists.
Returns:
Pipeline
"""
pipeline = self.get_template(template).load()
if isinstance(hyperparameters, str):
with open(hyperparameters, 'r') as f:
hyperparameters = json.load(f)
pipeline.set_hyperparameters(hyperparameters)
return schema.Pipeline.insert(
name=name,
template=template,
json=pipeline.to_dict(),
created_by=self.user
) | [
"def",
"add_pipeline",
"(",
"self",
",",
"name",
",",
"template",
",",
"hyperparameters",
")",
":",
"pipeline",
"=",
"self",
".",
"get_template",
"(",
"template",
")",
".",
"load",
"(",
")",
"if",
"isinstance",
"(",
"hyperparameters",
",",
"str",
")",
":",
"with",
"open",
"(",
"hyperparameters",
",",
"'r'",
")",
"as",
"f",
":",
"hyperparameters",
"=",
"json",
".",
"load",
"(",
"f",
")",
"pipeline",
".",
"set_hyperparameters",
"(",
"hyperparameters",
")",
"return",
"schema",
".",
"Pipeline",
".",
"insert",
"(",
"name",
"=",
"name",
",",
"template",
"=",
"template",
",",
"json",
"=",
"pipeline",
".",
"to_dict",
"(",
")",
",",
"created_by",
"=",
"self",
".",
"user",
")"
] | [
485,
4
] | [
525,
9
] | python | en | ['en', 'en', 'en'] | True |
OrionDBExplorer.get_pipelines | (self, name=None, template=None, created_by=None) | Query the Pipelines collection.
All the details about the matching Pipelines will be returned in
a ``pandas.DataFrame``, except for the JSON specification of the
pipeline, which will be removed from the table for readability.
In order to access the JSON specification of each Pipeline, please
retreive them using the ``get_pipeline`` method.
All the arguments are optional, so a call without arguments will
return a table with information about all the Pipelines availabe.
Args:
name (str):
Name of the Pipeline.
template (Template or ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) from which the Pipelines have to be derived.
created_by (str):
Unique identifier of the user that created the Pipelines.
Returns:
pandas.DataFrame
| Query the Pipelines collection. | def get_pipelines(self, name=None, template=None, created_by=None):
"""Query the Pipelines collection.
All the details about the matching Pipelines will be returned in
a ``pandas.DataFrame``, except for the JSON specification of the
pipeline, which will be removed from the table for readability.
In order to access the JSON specification of each Pipeline, please
retreive them using the ``get_pipeline`` method.
All the arguments are optional, so a call without arguments will
return a table with information about all the Pipelines availabe.
Args:
name (str):
Name of the Pipeline.
template (Template or ObjectID or str):
Template object (or the corresponding ObjectID, or its string
representation) from which the Pipelines have to be derived.
created_by (str):
Unique identifier of the user that created the Pipelines.
Returns:
pandas.DataFrame
"""
return schema.Pipeline.find(
as_df_=True,
name=name,
template=template,
created_by=created_by,
exclude_=['json']
) | [
"def",
"get_pipelines",
"(",
"self",
",",
"name",
"=",
"None",
",",
"template",
"=",
"None",
",",
"created_by",
"=",
"None",
")",
":",
"return",
"schema",
".",
"Pipeline",
".",
"find",
"(",
"as_df_",
"=",
"True",
",",
"name",
"=",
"name",
",",
"template",
"=",
"template",
",",
"created_by",
"=",
"created_by",
",",
"exclude_",
"=",
"[",
"'json'",
"]",
")"
] | [
527,
4
] | [
558,
9
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.