partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | SQLAdapter.add_query | Add a query to the current transaction. A thin wrapper around
ConnectionManager.add_query.
:param str sql: The SQL query to add
:param bool auto_begin: If set and there is no transaction in progress,
begin a new one.
:param Optional[List[object]]: An optional list of binding... | core/dbt/adapters/sql/impl.py | def add_query(self, sql, auto_begin=True, bindings=None,
abridge_sql_log=False):
"""Add a query to the current transaction. A thin wrapper around
ConnectionManager.add_query.
:param str sql: The SQL query to add
:param bool auto_begin: If set and there is no transactio... | def add_query(self, sql, auto_begin=True, bindings=None,
abridge_sql_log=False):
"""Add a query to the current transaction. A thin wrapper around
ConnectionManager.add_query.
:param str sql: The SQL query to add
:param bool auto_begin: If set and there is no transactio... | [
"Add",
"a",
"query",
"to",
"the",
"current",
"transaction",
".",
"A",
"thin",
"wrapper",
"around",
"ConnectionManager",
".",
"add_query",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/sql/impl.py#L39-L53 | [
"def",
"add_query",
"(",
"self",
",",
"sql",
",",
"auto_begin",
"=",
"True",
",",
"bindings",
"=",
"None",
",",
"abridge_sql_log",
"=",
"False",
")",
":",
"return",
"self",
".",
"connections",
".",
"add_query",
"(",
"sql",
",",
"auto_begin",
",",
"bindin... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | SQLAdapter.alter_column_type | 1. Create a new column (w/ temp name and correct type)
2. Copy data over to it
3. Drop the existing column (cascade!)
4. Rename the new column to existing column | core/dbt/adapters/sql/impl.py | def alter_column_type(self, relation, column_name, new_column_type):
"""
1. Create a new column (w/ temp name and correct type)
2. Copy data over to it
3. Drop the existing column (cascade!)
4. Rename the new column to existing column
"""
kwargs = {
'r... | def alter_column_type(self, relation, column_name, new_column_type):
"""
1. Create a new column (w/ temp name and correct type)
2. Copy data over to it
3. Drop the existing column (cascade!)
4. Rename the new column to existing column
"""
kwargs = {
'r... | [
"1",
".",
"Create",
"a",
"new",
"column",
"(",
"w",
"/",
"temp",
"name",
"and",
"correct",
"type",
")",
"2",
".",
"Copy",
"data",
"over",
"to",
"it",
"3",
".",
"Drop",
"the",
"existing",
"column",
"(",
"cascade!",
")",
"4",
".",
"Rename",
"the",
... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/sql/impl.py#L107-L122 | [
"def",
"alter_column_type",
"(",
"self",
",",
"relation",
",",
"column_name",
",",
"new_column_type",
")",
":",
"kwargs",
"=",
"{",
"'relation'",
":",
"relation",
",",
"'column_name'",
":",
"column_name",
",",
"'new_column_type'",
":",
"new_column_type",
",",
"}... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | id_matches | Return True if the unique ID matches the given name, package, and type.
If package is None, any package is allowed.
nodetypes should be a container of NodeTypes that implements the 'in'
operator. | core/dbt/utils.py | def id_matches(unique_id, target_name, target_package, nodetypes, model):
"""Return True if the unique ID matches the given name, package, and type.
If package is None, any package is allowed.
nodetypes should be a container of NodeTypes that implements the 'in'
operator.
"""
node_type = model.... | def id_matches(unique_id, target_name, target_package, nodetypes, model):
"""Return True if the unique ID matches the given name, package, and type.
If package is None, any package is allowed.
nodetypes should be a container of NodeTypes that implements the 'in'
operator.
"""
node_type = model.... | [
"Return",
"True",
"if",
"the",
"unique",
"ID",
"matches",
"the",
"given",
"name",
"package",
"and",
"type",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L66-L96 | [
"def",
"id_matches",
"(",
"unique_id",
",",
"target_name",
",",
"target_package",
",",
"nodetypes",
",",
"model",
")",
":",
"node_type",
"=",
"model",
".",
"get",
"(",
"'resource_type'",
",",
"'node'",
")",
"node_parts",
"=",
"unique_id",
".",
"split",
"(",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | find_in_subgraph_by_name | Find an entry in a subgraph by name. Any mapping that implements
.items() and maps unique id -> something can be used as the subgraph.
Names are like:
'{nodetype}.{target_package}.{target_name}'
You can use `None` for the package name as a wildcard. | core/dbt/utils.py | def find_in_subgraph_by_name(subgraph, target_name, target_package, nodetype):
"""Find an entry in a subgraph by name. Any mapping that implements
.items() and maps unique id -> something can be used as the subgraph.
Names are like:
'{nodetype}.{target_package}.{target_name}'
You can use `None... | def find_in_subgraph_by_name(subgraph, target_name, target_package, nodetype):
"""Find an entry in a subgraph by name. Any mapping that implements
.items() and maps unique id -> something can be used as the subgraph.
Names are like:
'{nodetype}.{target_package}.{target_name}'
You can use `None... | [
"Find",
"an",
"entry",
"in",
"a",
"subgraph",
"by",
"name",
".",
"Any",
"mapping",
"that",
"implements",
".",
"items",
"()",
"and",
"maps",
"unique",
"id",
"-",
">",
"something",
"can",
"be",
"used",
"as",
"the",
"subgraph",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L99-L112 | [
"def",
"find_in_subgraph_by_name",
"(",
"subgraph",
",",
"target_name",
",",
"target_package",
",",
"nodetype",
")",
":",
"for",
"name",
",",
"model",
"in",
"subgraph",
".",
"items",
"(",
")",
":",
"if",
"id_matches",
"(",
"name",
",",
"target_name",
",",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | find_in_list_by_name | Find an entry in the given list by name. | core/dbt/utils.py | def find_in_list_by_name(haystack, target_name, target_package, nodetype):
"""Find an entry in the given list by name."""
for model in haystack:
name = model.get('unique_id')
if id_matches(name, target_name, target_package, nodetype, model):
return model
return None | def find_in_list_by_name(haystack, target_name, target_package, nodetype):
"""Find an entry in the given list by name."""
for model in haystack:
name = model.get('unique_id')
if id_matches(name, target_name, target_package, nodetype, model):
return model
return None | [
"Find",
"an",
"entry",
"in",
"the",
"given",
"list",
"by",
"name",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L115-L122 | [
"def",
"find_in_list_by_name",
"(",
"haystack",
",",
"target_name",
",",
"target_package",
",",
"nodetype",
")",
":",
"for",
"model",
"in",
"haystack",
":",
"name",
"=",
"model",
".",
"get",
"(",
"'unique_id'",
")",
"if",
"id_matches",
"(",
"name",
",",
"t... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | deep_merge | >>> dbt.utils.deep_merge({'a': 1, 'b': 2, 'c': 3}, {'a': 2}, {'a': 3, 'b': 1}) # noqa
{'a': 3, 'b': 1, 'c': 3} | core/dbt/utils.py | def deep_merge(*args):
"""
>>> dbt.utils.deep_merge({'a': 1, 'b': 2, 'c': 3}, {'a': 2}, {'a': 3, 'b': 1}) # noqa
{'a': 3, 'b': 1, 'c': 3}
"""
if len(args) == 0:
return None
if len(args) == 1:
return copy.deepcopy(args[0])
lst = list(args)
last = copy.deepcopy(lst.pop(l... | def deep_merge(*args):
"""
>>> dbt.utils.deep_merge({'a': 1, 'b': 2, 'c': 3}, {'a': 2}, {'a': 3, 'b': 1}) # noqa
{'a': 3, 'b': 1, 'c': 3}
"""
if len(args) == 0:
return None
if len(args) == 1:
return copy.deepcopy(args[0])
lst = list(args)
last = copy.deepcopy(lst.pop(l... | [
">>>",
"dbt",
".",
"utils",
".",
"deep_merge",
"(",
"{",
"a",
":",
"1",
"b",
":",
"2",
"c",
":",
"3",
"}",
"{",
"a",
":",
"2",
"}",
"{",
"a",
":",
"3",
"b",
":",
"1",
"}",
")",
"#",
"noqa",
"{",
"a",
":",
"3",
"b",
":",
"1",
"c",
":... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L181-L195 | [
"def",
"deep_merge",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"return",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"copy",
".",
"deepcopy",
"(",
"args",
"[",
"0",
"]",
")",
"lst",
"=",
"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | deep_map | map the function func() onto each non-container value in 'value'
recursively, returning a new value. As long as func does not manipulate
value, then deep_map will also not manipulate it.
value should be a value returned by `yaml.safe_load` or `json.load` - the
only expected types are list, dict, native... | core/dbt/utils.py | def deep_map(func, value):
"""map the function func() onto each non-container value in 'value'
recursively, returning a new value. As long as func does not manipulate
value, then deep_map will also not manipulate it.
value should be a value returned by `yaml.safe_load` or `json.load` - the
only exp... | def deep_map(func, value):
"""map the function func() onto each non-container value in 'value'
recursively, returning a new value. As long as func does not manipulate
value, then deep_map will also not manipulate it.
value should be a value returned by `yaml.safe_load` or `json.load` - the
only exp... | [
"map",
"the",
"function",
"func",
"()",
"onto",
"each",
"non",
"-",
"container",
"value",
"in",
"value",
"recursively",
"returning",
"a",
"new",
"value",
".",
"As",
"long",
"as",
"func",
"does",
"not",
"manipulate",
"value",
"then",
"deep_map",
"will",
"al... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L243-L266 | [
"def",
"deep_map",
"(",
"func",
",",
"value",
")",
":",
"try",
":",
"return",
"_deep_map",
"(",
"func",
",",
"value",
",",
"(",
")",
")",
"except",
"RuntimeError",
"as",
"exc",
":",
"if",
"'maximum recursion depth exceeded'",
"in",
"str",
"(",
"exc",
")"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | translate_aliases | Given a dict of keyword arguments and a dict mapping aliases to their
canonical values, canonicalize the keys in the kwargs dict.
:return: A dict continaing all the values in kwargs referenced by their
canonical key.
:raises: `AliasException`, if a canonical key is defined more than once. | core/dbt/utils.py | def translate_aliases(kwargs, aliases):
"""Given a dict of keyword arguments and a dict mapping aliases to their
canonical values, canonicalize the keys in the kwargs dict.
:return: A dict continaing all the values in kwargs referenced by their
canonical key.
:raises: `AliasException`, if a can... | def translate_aliases(kwargs, aliases):
"""Given a dict of keyword arguments and a dict mapping aliases to their
canonical values, canonicalize the keys in the kwargs dict.
:return: A dict continaing all the values in kwargs referenced by their
canonical key.
:raises: `AliasException`, if a can... | [
"Given",
"a",
"dict",
"of",
"keyword",
"arguments",
"and",
"a",
"dict",
"mapping",
"aliases",
"to",
"their",
"canonical",
"values",
"canonicalize",
"the",
"keys",
"in",
"the",
"kwargs",
"dict",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/utils.py#L459-L483 | [
"def",
"translate_aliases",
"(",
"kwargs",
",",
"aliases",
")",
":",
"result",
"=",
"{",
"}",
"for",
"given_key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"canonical_key",
"=",
"aliases",
".",
"get",
"(",
"given_key",
",",
"given_key",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | GitPackage._checkout | Performs a shallow clone of the repository into the downloads
directory. This function can be called repeatedly. If the project has
already been checked out at this version, it will be a no-op. Returns
the path to the checked out directory. | core/dbt/task/deps.py | def _checkout(self, project):
"""Performs a shallow clone of the repository into the downloads
directory. This function can be called repeatedly. If the project has
already been checked out at this version, it will be a no-op. Returns
the path to the checked out directory."""
if ... | def _checkout(self, project):
"""Performs a shallow clone of the repository into the downloads
directory. This function can be called repeatedly. If the project has
already been checked out at this version, it will be a no-op. Returns
the path to the checked out directory."""
if ... | [
"Performs",
"a",
"shallow",
"clone",
"of",
"the",
"repository",
"into",
"the",
"downloads",
"directory",
".",
"This",
"function",
"can",
"be",
"called",
"repeatedly",
".",
"If",
"the",
"project",
"has",
"already",
"been",
"checked",
"out",
"at",
"this",
"ver... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/deps.py#L259-L279 | [
"def",
"_checkout",
"(",
"self",
",",
"project",
")",
":",
"if",
"len",
"(",
"self",
".",
"version",
")",
"!=",
"1",
":",
"dbt",
".",
"exceptions",
".",
"raise_dependency_error",
"(",
"'Cannot checkout repository until the version is pinned.'",
")",
"try",
":",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | RedshiftAdapter.drop_relation | In Redshift, DROP TABLE ... CASCADE should not be used
inside a transaction. Redshift doesn't prevent the CASCADE
part from conflicting with concurrent transactions. If we do
attempt to drop two tables with CASCADE at once, we'll often
get the dreaded:
table was dropped by a... | plugins/redshift/dbt/adapters/redshift/impl.py | def drop_relation(self, relation):
"""
In Redshift, DROP TABLE ... CASCADE should not be used
inside a transaction. Redshift doesn't prevent the CASCADE
part from conflicting with concurrent transactions. If we do
attempt to drop two tables with CASCADE at once, we'll often
... | def drop_relation(self, relation):
"""
In Redshift, DROP TABLE ... CASCADE should not be used
inside a transaction. Redshift doesn't prevent the CASCADE
part from conflicting with concurrent transactions. If we do
attempt to drop two tables with CASCADE at once, we'll often
... | [
"In",
"Redshift",
"DROP",
"TABLE",
"...",
"CASCADE",
"should",
"not",
"be",
"used",
"inside",
"a",
"transaction",
".",
"Redshift",
"doesn",
"t",
"prevent",
"the",
"CASCADE",
"part",
"from",
"conflicting",
"with",
"concurrent",
"transactions",
".",
"If",
"we",
... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/redshift/dbt/adapters/redshift/impl.py#L15-L32 | [
"def",
"drop_relation",
"(",
"self",
",",
"relation",
")",
":",
"with",
"self",
".",
"connections",
".",
"fresh_transaction",
"(",
")",
":",
"parent",
"=",
"super",
"(",
"RedshiftAdapter",
",",
"self",
")",
"return",
"parent",
".",
"drop_relation",
"(",
"r... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | DocumentationParser.load_file | Load and parse documentation in a list of projects. Returns a list
of ParsedNodes. | core/dbt/parser/docs.py | def load_file(cls, package_name, root_dir, relative_dirs):
"""Load and parse documentation in a list of projects. Returns a list
of ParsedNodes.
"""
extension = "[!.#~]*.md"
file_matches = dbt.clients.system.find_matching(
root_dir,
relative_dirs,
... | def load_file(cls, package_name, root_dir, relative_dirs):
"""Load and parse documentation in a list of projects. Returns a list
of ParsedNodes.
"""
extension = "[!.#~]*.md"
file_matches = dbt.clients.system.find_matching(
root_dir,
relative_dirs,
... | [
"Load",
"and",
"parse",
"documentation",
"in",
"a",
"list",
"of",
"projects",
".",
"Returns",
"a",
"list",
"of",
"ParsedNodes",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/docs.py#L13-L43 | [
"def",
"load_file",
"(",
"cls",
",",
"package_name",
",",
"root_dir",
",",
"relative_dirs",
")",
":",
"extension",
"=",
"\"[!.#~]*.md\"",
"file_matches",
"=",
"dbt",
".",
"clients",
".",
"system",
".",
"find_matching",
"(",
"root_dir",
",",
"relative_dirs",
",... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | SourceConfig.config | Config resolution order:
if this is a dependency model:
- own project config
- in-model config
- active project config
if this is a top-level model:
- active project config
- in-model config | core/dbt/parser/source_config.py | def config(self):
"""
Config resolution order:
if this is a dependency model:
- own project config
- in-model config
- active project config
if this is a top-level model:
- active project config
- in-model config
"""
... | def config(self):
"""
Config resolution order:
if this is a dependency model:
- own project config
- in-model config
- active project config
if this is a top-level model:
- active project config
- in-model config
"""
... | [
"Config",
"resolution",
"order",
":"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/source_config.py#L51-L83 | [
"def",
"config",
"(",
"self",
")",
":",
"defaults",
"=",
"{",
"\"enabled\"",
":",
"True",
",",
"\"materialized\"",
":",
"\"view\"",
"}",
"if",
"self",
".",
"node_type",
"==",
"NodeType",
".",
"Seed",
":",
"defaults",
"[",
"'materialized'",
"]",
"=",
"'se... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BlockIterator.expect_comment_end | Expect a comment end and return the match object. | core/dbt/clients/_jinja_blocks.py | def expect_comment_end(self):
"""Expect a comment end and return the match object.
"""
match = self._expect_match('#}', COMMENT_END_PATTERN)
self.advance(match.end()) | def expect_comment_end(self):
"""Expect a comment end and return the match object.
"""
match = self._expect_match('#}', COMMENT_END_PATTERN)
self.advance(match.end()) | [
"Expect",
"a",
"comment",
"end",
"and",
"return",
"the",
"match",
"object",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/_jinja_blocks.py#L142-L146 | [
"def",
"expect_comment_end",
"(",
"self",
")",
":",
"match",
"=",
"self",
".",
"_expect_match",
"(",
"'#}'",
",",
"COMMENT_END_PATTERN",
")",
"self",
".",
"advance",
"(",
"match",
".",
"end",
"(",
")",
")"
] | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BlockIterator.handle_block | Handle a block. The current state of the parser should be after the
open block is completed:
{% blk foo %}my data {% endblk %}
^ right here | core/dbt/clients/_jinja_blocks.py | def handle_block(self, match, block_start=None):
"""Handle a block. The current state of the parser should be after the
open block is completed:
{% blk foo %}my data {% endblk %}
^ right here
"""
# we have to handle comments inside blocks because you ... | def handle_block(self, match, block_start=None):
"""Handle a block. The current state of the parser should be after the
open block is completed:
{% blk foo %}my data {% endblk %}
^ right here
"""
# we have to handle comments inside blocks because you ... | [
"Handle",
"a",
"block",
".",
"The",
"current",
"state",
"of",
"the",
"parser",
"should",
"be",
"after",
"the",
"open",
"block",
"is",
"completed",
":",
"{",
"%",
"blk",
"foo",
"%",
"}",
"my",
"data",
"{",
"%",
"endblk",
"%",
"}",
"^",
"right",
"her... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/_jinja_blocks.py#L182-L235 | [
"def",
"handle_block",
"(",
"self",
",",
"match",
",",
"block_start",
"=",
"None",
")",
":",
"# we have to handle comments inside blocks because you could do this:",
"# {% blk foo %}asdf {# {% endblk %} #} {%endblk%}",
"# they still end up in the data/raw_data of the block itself, but we... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BlockIterator._process_rval_components | This is suspiciously similar to _process_macro_default_arg, probably
want to figure out how to merge the two.
Process the rval of an assignment statement or a do-block | core/dbt/clients/_jinja_blocks.py | def _process_rval_components(self):
"""This is suspiciously similar to _process_macro_default_arg, probably
want to figure out how to merge the two.
Process the rval of an assignment statement or a do-block
"""
while True:
match = self._expect_match(
... | def _process_rval_components(self):
"""This is suspiciously similar to _process_macro_default_arg, probably
want to figure out how to merge the two.
Process the rval of an assignment statement or a do-block
"""
while True:
match = self._expect_match(
... | [
"This",
"is",
"suspiciously",
"similar",
"to",
"_process_macro_default_arg",
"probably",
"want",
"to",
"figure",
"out",
"how",
"to",
"merge",
"the",
"two",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/_jinja_blocks.py#L355-L388 | [
"def",
"_process_rval_components",
"(",
"self",
")",
":",
"while",
"True",
":",
"match",
"=",
"self",
".",
"_expect_match",
"(",
"'do block component'",
",",
"# you could have a string, though that would be weird",
"STRING_PATTERN",
",",
"# a quote or an open/close parenthesi... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BlockIterator._process_macro_default_arg | Handle the bit after an '=' in a macro default argument. This is
probably the trickiest thing. The goal here is to accept all strings
jinja would accept and always handle block start/end correctly: It's
fine to have false positives, jinja can fail later.
Return True if there are more ar... | core/dbt/clients/_jinja_blocks.py | def _process_macro_default_arg(self):
"""Handle the bit after an '=' in a macro default argument. This is
probably the trickiest thing. The goal here is to accept all strings
jinja would accept and always handle block start/end correctly: It's
fine to have false positives, jinja can fail... | def _process_macro_default_arg(self):
"""Handle the bit after an '=' in a macro default argument. This is
probably the trickiest thing. The goal here is to accept all strings
jinja would accept and always handle block start/end correctly: It's
fine to have false positives, jinja can fail... | [
"Handle",
"the",
"bit",
"after",
"an",
"=",
"in",
"a",
"macro",
"default",
"argument",
".",
"This",
"is",
"probably",
"the",
"trickiest",
"thing",
".",
"The",
"goal",
"here",
"is",
"to",
"accept",
"all",
"strings",
"jinja",
"would",
"accept",
"and",
"alw... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/_jinja_blocks.py#L391-L435 | [
"def",
"_process_macro_default_arg",
"(",
"self",
")",
":",
"while",
"self",
".",
"_parenthesis_stack",
":",
"match",
"=",
"self",
".",
"_expect_match",
"(",
"'macro argument'",
",",
"# you could have a string",
"STRING_PATTERN",
",",
"# a quote, a comma, or a open/close ... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BlockIterator._process_macro_args | Macro args are pretty tricky! Arg names themselves are simple, but
you can set arbitrary default values, including doing stuff like:
{% macro my_macro(arg="x" + ("}% {# {% endmacro %}" * 2)) %}
Which makes you a jerk, but is valid jinja. | core/dbt/clients/_jinja_blocks.py | def _process_macro_args(self):
"""Macro args are pretty tricky! Arg names themselves are simple, but
you can set arbitrary default values, including doing stuff like:
{% macro my_macro(arg="x" + ("}% {# {% endmacro %}" * 2)) %}
Which makes you a jerk, but is valid jinja.
"""
... | def _process_macro_args(self):
"""Macro args are pretty tricky! Arg names themselves are simple, but
you can set arbitrary default values, including doing stuff like:
{% macro my_macro(arg="x" + ("}% {# {% endmacro %}" * 2)) %}
Which makes you a jerk, but is valid jinja.
"""
... | [
"Macro",
"args",
"are",
"pretty",
"tricky!",
"Arg",
"names",
"themselves",
"are",
"simple",
"but",
"you",
"can",
"set",
"arbitrary",
"default",
"values",
"including",
"doing",
"stuff",
"like",
":",
"{",
"%",
"macro",
"my_macro",
"(",
"arg",
"=",
"x",
"+",
... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/clients/_jinja_blocks.py#L437-L467 | [
"def",
"_process_macro_args",
"(",
"self",
")",
":",
"# we are currently after the first parenthesis (+ any whitespace) after",
"# the macro args started. You can either have the close paren, or a",
"# name.",
"while",
"self",
".",
"_parenthesis_stack",
":",
"match",
"=",
"self",
"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ConfigRenderer._render_project_entry | Render an entry, in case it's jinja. This is meant to be passed to
deep_map.
If the parsed entry is a string and has the name 'port', this will
attempt to cast it to an int, and on failure will return the parsed
string.
:param value Any: The value to potentially render
... | core/dbt/config/renderer.py | def _render_project_entry(self, value, keypath):
"""Render an entry, in case it's jinja. This is meant to be passed to
deep_map.
If the parsed entry is a string and has the name 'port', this will
attempt to cast it to an int, and on failure will return the parsed
string.
... | def _render_project_entry(self, value, keypath):
"""Render an entry, in case it's jinja. This is meant to be passed to
deep_map.
If the parsed entry is a string and has the name 'port', this will
attempt to cast it to an int, and on failure will return the parsed
string.
... | [
"Render",
"an",
"entry",
"in",
"case",
"it",
"s",
"jinja",
".",
"This",
"is",
"meant",
"to",
"be",
"passed",
"to",
"deep_map",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/renderer.py#L39-L56 | [
"def",
"_render_project_entry",
"(",
"self",
",",
"value",
",",
"keypath",
")",
":",
"# hooks should be treated as raw sql, they'll get rendered later.",
"# Same goes for 'vars' declarations inside 'models'/'seeds'.",
"if",
"self",
".",
"_is_hook_or_model_vars_path",
"(",
"keypath"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ConfigRenderer.render_project | Render the parsed data, returning a new dict (or whatever was read). | core/dbt/config/renderer.py | def render_project(self, as_parsed):
"""Render the parsed data, returning a new dict (or whatever was read).
"""
try:
return deep_map(self._render_project_entry, as_parsed)
except RecursionException:
raise DbtProjectError(
'Cycle detected: Project ... | def render_project(self, as_parsed):
"""Render the parsed data, returning a new dict (or whatever was read).
"""
try:
return deep_map(self._render_project_entry, as_parsed)
except RecursionException:
raise DbtProjectError(
'Cycle detected: Project ... | [
"Render",
"the",
"parsed",
"data",
"returning",
"a",
"new",
"dict",
"(",
"or",
"whatever",
"was",
"read",
")",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/renderer.py#L85-L94 | [
"def",
"render_project",
"(",
"self",
",",
"as_parsed",
")",
":",
"try",
":",
"return",
"deep_map",
"(",
"self",
".",
"_render_project_entry",
",",
"as_parsed",
")",
"except",
"RecursionException",
":",
"raise",
"DbtProjectError",
"(",
"'Cycle detected: Project inpu... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ConfigRenderer.render_profile_data | Render the chosen profile entry, as it was parsed. | core/dbt/config/renderer.py | def render_profile_data(self, as_parsed):
"""Render the chosen profile entry, as it was parsed."""
try:
return deep_map(self._render_profile_data, as_parsed)
except RecursionException:
raise DbtProfileError(
'Cycle detected: Profile input has a reference t... | def render_profile_data(self, as_parsed):
"""Render the chosen profile entry, as it was parsed."""
try:
return deep_map(self._render_profile_data, as_parsed)
except RecursionException:
raise DbtProfileError(
'Cycle detected: Profile input has a reference t... | [
"Render",
"the",
"chosen",
"profile",
"entry",
"as",
"it",
"was",
"parsed",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/renderer.py#L96-L104 | [
"def",
"render_profile_data",
"(",
"self",
",",
"as_parsed",
")",
":",
"try",
":",
"return",
"deep_map",
"(",
"self",
".",
"_render_profile_data",
",",
"as_parsed",
")",
"except",
"RecursionException",
":",
"raise",
"DbtProfileError",
"(",
"'Cycle detected: Profile ... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ArchiveParser.load_and_parse | Load and parse archives in a list of projects. Returns a dict
that maps unique ids onto ParsedNodes | core/dbt/parser/archives.py | def load_and_parse(self):
"""Load and parse archives in a list of projects. Returns a dict
that maps unique ids onto ParsedNodes"""
archives = []
to_return = {}
for name, project in self.all_projects.items():
archives = archives + self.parse_archives_from_project... | def load_and_parse(self):
"""Load and parse archives in a list of projects. Returns a dict
that maps unique ids onto ParsedNodes"""
archives = []
to_return = {}
for name, project in self.all_projects.items():
archives = archives + self.parse_archives_from_project... | [
"Load",
"and",
"parse",
"archives",
"in",
"a",
"list",
"of",
"projects",
".",
"Returns",
"a",
"dict",
"that",
"maps",
"unique",
"ids",
"onto",
"ParsedNodes"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/archives.py#L68-L96 | [
"def",
"load_and_parse",
"(",
"self",
")",
":",
"archives",
"=",
"[",
"]",
"to_return",
"=",
"{",
"}",
"for",
"name",
",",
"project",
"in",
"self",
".",
"all_projects",
".",
"items",
"(",
")",
":",
"archives",
"=",
"archives",
"+",
"self",
".",
"pars... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.to_profile_info | Unlike to_project_config, this dict is not a mirror of any existing
on-disk data structure. It's used when creating a new profile from an
existing one.
:param serialize_credentials bool: If True, serialize the credentials.
Otherwise, the Credentials object will be copied.
:r... | core/dbt/config/profile.py | def to_profile_info(self, serialize_credentials=False):
"""Unlike to_project_config, this dict is not a mirror of any existing
on-disk data structure. It's used when creating a new profile from an
existing one.
:param serialize_credentials bool: If True, serialize the credentials.
... | def to_profile_info(self, serialize_credentials=False):
"""Unlike to_project_config, this dict is not a mirror of any existing
on-disk data structure. It's used when creating a new profile from an
existing one.
:param serialize_credentials bool: If True, serialize the credentials.
... | [
"Unlike",
"to_project_config",
"this",
"dict",
"is",
"not",
"a",
"mirror",
"of",
"any",
"existing",
"on",
"-",
"disk",
"data",
"structure",
".",
"It",
"s",
"used",
"when",
"creating",
"a",
"new",
"profile",
"from",
"an",
"existing",
"one",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L106-L124 | [
"def",
"to_profile_info",
"(",
"self",
",",
"serialize_credentials",
"=",
"False",
")",
":",
"result",
"=",
"{",
"'profile_name'",
":",
"self",
".",
"profile_name",
",",
"'target_name'",
":",
"self",
".",
"target_name",
",",
"'config'",
":",
"self",
".",
"co... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.from_credentials | Create a profile from an existing set of Credentials and the
remaining information.
:param credentials dict: The credentials dict for this profile.
:param threads int: The number of threads to use for connections.
:param profile_name str: The profile name used for this profile.
... | core/dbt/config/profile.py | def from_credentials(cls, credentials, threads, profile_name, target_name,
user_cfg=None):
"""Create a profile from an existing set of Credentials and the
remaining information.
:param credentials dict: The credentials dict for this profile.
:param threads int: ... | def from_credentials(cls, credentials, threads, profile_name, target_name,
user_cfg=None):
"""Create a profile from an existing set of Credentials and the
remaining information.
:param credentials dict: The credentials dict for this profile.
:param threads int: ... | [
"Create",
"a",
"profile",
"from",
"an",
"existing",
"set",
"of",
"Credentials",
"and",
"the",
"remaining",
"information",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L193-L216 | [
"def",
"from_credentials",
"(",
"cls",
",",
"credentials",
",",
"threads",
",",
"profile_name",
",",
"target_name",
",",
"user_cfg",
"=",
"None",
")",
":",
"config",
"=",
"UserConfig",
".",
"from_dict",
"(",
"user_cfg",
")",
"profile",
"=",
"cls",
"(",
"pr... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.render_profile | This is a containment zone for the hateful way we're rendering
profiles. | core/dbt/config/profile.py | def render_profile(cls, raw_profile, profile_name, target_override,
cli_vars):
"""This is a containment zone for the hateful way we're rendering
profiles.
"""
renderer = ConfigRenderer(cli_vars=cli_vars)
# rendering profiles is a bit complex. Two constrain... | def render_profile(cls, raw_profile, profile_name, target_override,
cli_vars):
"""This is a containment zone for the hateful way we're rendering
profiles.
"""
renderer = ConfigRenderer(cli_vars=cli_vars)
# rendering profiles is a bit complex. Two constrain... | [
"This",
"is",
"a",
"containment",
"zone",
"for",
"the",
"hateful",
"way",
"we",
"re",
"rendering",
"profiles",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L219-L250 | [
"def",
"render_profile",
"(",
"cls",
",",
"raw_profile",
",",
"profile_name",
",",
"target_override",
",",
"cli_vars",
")",
":",
"renderer",
"=",
"ConfigRenderer",
"(",
"cli_vars",
"=",
"cli_vars",
")",
"# rendering profiles is a bit complex. Two constraints cause trouble... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.from_raw_profile_info | Create a profile from its raw profile information.
(this is an intermediate step, mostly useful for unit testing)
:param raw_profile dict: The profile data for a single profile, from
disk as yaml and its values rendered with jinja.
:param profile_name str: The profile name used.
... | core/dbt/config/profile.py | def from_raw_profile_info(cls, raw_profile, profile_name, cli_vars,
user_cfg=None, target_override=None,
threads_override=None):
"""Create a profile from its raw profile information.
(this is an intermediate step, mostly useful for unit testi... | def from_raw_profile_info(cls, raw_profile, profile_name, cli_vars,
user_cfg=None, target_override=None,
threads_override=None):
"""Create a profile from its raw profile information.
(this is an intermediate step, mostly useful for unit testi... | [
"Create",
"a",
"profile",
"from",
"its",
"raw",
"profile",
"information",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L253-L297 | [
"def",
"from_raw_profile_info",
"(",
"cls",
",",
"raw_profile",
",",
"profile_name",
",",
"cli_vars",
",",
"user_cfg",
"=",
"None",
",",
"target_override",
"=",
"None",
",",
"threads_override",
"=",
"None",
")",
":",
"# user_cfg is not rendered since it only contains ... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.from_raw_profiles | :param raw_profiles dict: The profile data, from disk as yaml.
:param profile_name str: The profile name to use.
:param cli_vars dict: The command-line variables passed as arguments,
as a dict.
:param target_override Optional[str]: The target to use, if provided on
the co... | core/dbt/config/profile.py | def from_raw_profiles(cls, raw_profiles, profile_name, cli_vars,
target_override=None, threads_override=None):
"""
:param raw_profiles dict: The profile data, from disk as yaml.
:param profile_name str: The profile name to use.
:param cli_vars dict: The command-... | def from_raw_profiles(cls, raw_profiles, profile_name, cli_vars,
target_override=None, threads_override=None):
"""
:param raw_profiles dict: The profile data, from disk as yaml.
:param profile_name str: The profile name to use.
:param cli_vars dict: The command-... | [
":",
"param",
"raw_profiles",
"dict",
":",
"The",
"profile",
"data",
"from",
"disk",
"as",
"yaml",
".",
":",
"param",
"profile_name",
"str",
":",
"The",
"profile",
"name",
"to",
"use",
".",
":",
"param",
"cli_vars",
"dict",
":",
"The",
"command",
"-",
... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L300-L335 | [
"def",
"from_raw_profiles",
"(",
"cls",
",",
"raw_profiles",
",",
"profile_name",
",",
"cli_vars",
",",
"target_override",
"=",
"None",
",",
"threads_override",
"=",
"None",
")",
":",
"if",
"profile_name",
"not",
"in",
"raw_profiles",
":",
"raise",
"DbtProjectEr... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Profile.from_args | Given the raw profiles as read from disk and the name of the desired
profile if specified, return the profile component of the runtime
config.
:param args argparse.Namespace: The arguments as parsed from the cli.
:param project_profile_name Optional[str]: The profile name, if
... | core/dbt/config/profile.py | def from_args(cls, args, project_profile_name=None):
"""Given the raw profiles as read from disk and the name of the desired
profile if specified, return the profile component of the runtime
config.
:param args argparse.Namespace: The arguments as parsed from the cli.
:param pro... | def from_args(cls, args, project_profile_name=None):
"""Given the raw profiles as read from disk and the name of the desired
profile if specified, return the profile component of the runtime
config.
:param args argparse.Namespace: The arguments as parsed from the cli.
:param pro... | [
"Given",
"the",
"raw",
"profiles",
"as",
"read",
"from",
"disk",
"and",
"the",
"name",
"of",
"the",
"desired",
"profile",
"if",
"specified",
"return",
"the",
"profile",
"component",
"of",
"the",
"runtime",
"config",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/profile.py#L338-L366 | [
"def",
"from_args",
"(",
"cls",
",",
"args",
",",
"project_profile_name",
"=",
"None",
")",
":",
"cli_vars",
"=",
"parse_cli_vars",
"(",
"getattr",
"(",
"args",
",",
"'vars'",
",",
"'{}'",
")",
")",
"threads_override",
"=",
"getattr",
"(",
"args",
",",
"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | docs | Return a function that will process `doc()` references in jinja, look
them up in the manifest, and return the appropriate block contents. | core/dbt/parser/util.py | def docs(node, manifest, config, column_name=None):
"""Return a function that will process `doc()` references in jinja, look
them up in the manifest, and return the appropriate block contents.
"""
current_project = config.project_name
def do_docs(*args):
if len(args) == 1:
doc_p... | def docs(node, manifest, config, column_name=None):
"""Return a function that will process `doc()` references in jinja, look
them up in the manifest, and return the appropriate block contents.
"""
current_project = config.project_name
def do_docs(*args):
if len(args) == 1:
doc_p... | [
"Return",
"a",
"function",
"that",
"will",
"process",
"doc",
"()",
"references",
"in",
"jinja",
"look",
"them",
"up",
"in",
"the",
"manifest",
"and",
"return",
"the",
"appropriate",
"block",
"contents",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/util.py#L6-L32 | [
"def",
"docs",
"(",
"node",
",",
"manifest",
",",
"config",
",",
"column_name",
"=",
"None",
")",
":",
"current_project",
"=",
"config",
".",
"project_name",
"def",
"do_docs",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ParserUtils.resolve_doc | Resolve the given documentation. This follows the same algorithm as
resolve_ref except the is_enabled checks are unnecessary as docs are
always enabled. | core/dbt/parser/util.py | def resolve_doc(cls, manifest, target_doc_name, target_doc_package,
current_project, node_package):
"""Resolve the given documentation. This follows the same algorithm as
resolve_ref except the is_enabled checks are unnecessary as docs are
always enabled.
"""
... | def resolve_doc(cls, manifest, target_doc_name, target_doc_package,
current_project, node_package):
"""Resolve the given documentation. This follows the same algorithm as
resolve_ref except the is_enabled checks are unnecessary as docs are
always enabled.
"""
... | [
"Resolve",
"the",
"given",
"documentation",
".",
"This",
"follows",
"the",
"same",
"algorithm",
"as",
"resolve_ref",
"except",
"the",
"is_enabled",
"checks",
"are",
"unnecessary",
"as",
"docs",
"are",
"always",
"enabled",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/util.py#L90-L106 | [
"def",
"resolve_doc",
"(",
"cls",
",",
"manifest",
",",
"target_doc_name",
",",
"target_doc_package",
",",
"current_project",
",",
"node_package",
")",
":",
"if",
"target_doc_package",
"is",
"not",
"None",
":",
"return",
"manifest",
".",
"find_docs_by_name",
"(",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ParserUtils._get_node_column | Given a ParsedNode, add some fields that might be missing. Return a
reference to the dict that refers to the given column, creating it if
it doesn't yet exist. | core/dbt/parser/util.py | def _get_node_column(cls, node, column_name):
"""Given a ParsedNode, add some fields that might be missing. Return a
reference to the dict that refers to the given column, creating it if
it doesn't yet exist.
"""
if not hasattr(node, 'columns'):
node.set('columns', {}... | def _get_node_column(cls, node, column_name):
"""Given a ParsedNode, add some fields that might be missing. Return a
reference to the dict that refers to the given column, creating it if
it doesn't yet exist.
"""
if not hasattr(node, 'columns'):
node.set('columns', {}... | [
"Given",
"a",
"ParsedNode",
"add",
"some",
"fields",
"that",
"might",
"be",
"missing",
".",
"Return",
"a",
"reference",
"to",
"the",
"dict",
"that",
"refers",
"to",
"the",
"given",
"column",
"creating",
"it",
"if",
"it",
"doesn",
"t",
"yet",
"exist",
"."... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/util.py#L109-L123 | [
"def",
"_get_node_column",
"(",
"cls",
",",
"node",
",",
"column_name",
")",
":",
"if",
"not",
"hasattr",
"(",
"node",
",",
"'columns'",
")",
":",
"node",
".",
"set",
"(",
"'columns'",
",",
"{",
"}",
")",
"if",
"column_name",
"in",
"node",
".",
"colu... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ParserUtils.process_refs_for_node | Given a manifest and a node in that manifest, process its refs | core/dbt/parser/util.py | def process_refs_for_node(cls, manifest, current_project, node):
"""Given a manifest and a node in that manifest, process its refs"""
target_model = None
target_model_name = None
target_model_package = None
for ref in node.refs:
if len(ref) == 1:
targ... | def process_refs_for_node(cls, manifest, current_project, node):
"""Given a manifest and a node in that manifest, process its refs"""
target_model = None
target_model_name = None
target_model_package = None
for ref in node.refs:
if len(ref) == 1:
targ... | [
"Given",
"a",
"manifest",
"and",
"a",
"node",
"in",
"that",
"manifest",
"process",
"its",
"refs"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/util.py#L156-L189 | [
"def",
"process_refs_for_node",
"(",
"cls",
",",
"manifest",
",",
"current_project",
",",
"node",
")",
":",
"target_model",
"=",
"None",
"target_model_name",
"=",
"None",
"target_model_package",
"=",
"None",
"for",
"ref",
"in",
"node",
".",
"refs",
":",
"if",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | ParserUtils.add_new_refs | Given a new node that is not in the manifest, copy the manifest and
insert the new node into it as if it were part of regular ref
processing | core/dbt/parser/util.py | def add_new_refs(cls, manifest, current_project, node, macros):
"""Given a new node that is not in the manifest, copy the manifest and
insert the new node into it as if it were part of regular ref
processing
"""
manifest = manifest.deepcopy(config=current_project)
# it's ... | def add_new_refs(cls, manifest, current_project, node, macros):
"""Given a new node that is not in the manifest, copy the manifest and
insert the new node into it as if it were part of regular ref
processing
"""
manifest = manifest.deepcopy(config=current_project)
# it's ... | [
"Given",
"a",
"new",
"node",
"that",
"is",
"not",
"in",
"the",
"manifest",
"copy",
"the",
"manifest",
"and",
"insert",
"the",
"new",
"node",
"into",
"it",
"as",
"if",
"it",
"were",
"part",
"of",
"regular",
"ref",
"processing"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/util.py#L227-L246 | [
"def",
"add_new_refs",
"(",
"cls",
",",
"manifest",
",",
"current_project",
",",
"node",
",",
"macros",
")",
":",
"manifest",
"=",
"manifest",
".",
"deepcopy",
"(",
"config",
"=",
"current_project",
")",
"# it's ok for macros to silently override a local project macro... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | _parse_versions | Parse multiple versions as read from disk. The versions value may be any
one of:
- a single version string ('>0.12.1')
- a single string specifying multiple comma-separated versions
('>0.11.1,<=0.12.2')
- an array of single-version strings (['>0.11.1', '<=0.12.2'])
Regardles... | core/dbt/config/project.py | def _parse_versions(versions):
"""Parse multiple versions as read from disk. The versions value may be any
one of:
- a single version string ('>0.12.1')
- a single string specifying multiple comma-separated versions
('>0.11.1,<=0.12.2')
- an array of single-version strings ([... | def _parse_versions(versions):
"""Parse multiple versions as read from disk. The versions value may be any
one of:
- a single version string ('>0.12.1')
- a single string specifying multiple comma-separated versions
('>0.11.1,<=0.12.2')
- an array of single-version strings ([... | [
"Parse",
"multiple",
"versions",
"as",
"read",
"from",
"disk",
".",
"The",
"versions",
"value",
"may",
"be",
"any",
"one",
"of",
":",
"-",
"a",
"single",
"version",
"string",
"(",
">",
"0",
".",
"12",
".",
"1",
")",
"-",
"a",
"single",
"string",
"s... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L128-L140 | [
"def",
"_parse_versions",
"(",
"versions",
")",
":",
"if",
"isinstance",
"(",
"versions",
",",
"compat",
".",
"basestring",
")",
":",
"versions",
"=",
"versions",
".",
"split",
"(",
"','",
")",
"return",
"[",
"VersionSpecifier",
".",
"from_version_string",
"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project._preprocess | Pre-process certain special keys to convert them from None values
into empty containers, and to turn strings into arrays of strings. | core/dbt/config/project.py | def _preprocess(project_dict):
"""Pre-process certain special keys to convert them from None values
into empty containers, and to turn strings into arrays of strings.
"""
handlers = {
('archive',): _list_if_none,
('on-run-start',): _list_if_none_or_string,
... | def _preprocess(project_dict):
"""Pre-process certain special keys to convert them from None values
into empty containers, and to turn strings into arrays of strings.
"""
handlers = {
('archive',): _list_if_none,
('on-run-start',): _list_if_none_or_string,
... | [
"Pre",
"-",
"process",
"certain",
"special",
"keys",
"to",
"convert",
"them",
"from",
"None",
"values",
"into",
"empty",
"containers",
"and",
"to",
"turn",
"strings",
"into",
"arrays",
"of",
"strings",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L175-L199 | [
"def",
"_preprocess",
"(",
"project_dict",
")",
":",
"handlers",
"=",
"{",
"(",
"'archive'",
",",
")",
":",
"_list_if_none",
",",
"(",
"'on-run-start'",
",",
")",
":",
"_list_if_none_or_string",
",",
"(",
"'on-run-end'",
",",
")",
":",
"_list_if_none_or_string... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project.from_project_config | Create a project from its project and package configuration, as read
by yaml.safe_load().
:param project_dict dict: The dictionary as read from disk
:param packages_dict Optional[dict]: If it exists, the packages file as
read from disk.
:raises DbtProjectError: If the projec... | core/dbt/config/project.py | def from_project_config(cls, project_dict, packages_dict=None):
"""Create a project from its project and package configuration, as read
by yaml.safe_load().
:param project_dict dict: The dictionary as read from disk
:param packages_dict Optional[dict]: If it exists, the packages file as... | def from_project_config(cls, project_dict, packages_dict=None):
"""Create a project from its project and package configuration, as read
by yaml.safe_load().
:param project_dict dict: The dictionary as read from disk
:param packages_dict Optional[dict]: If it exists, the packages file as... | [
"Create",
"a",
"project",
"from",
"its",
"project",
"and",
"package",
"configuration",
"as",
"read",
"by",
"yaml",
".",
"safe_load",
"()",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L202-L293 | [
"def",
"from_project_config",
"(",
"cls",
",",
"project_dict",
",",
"packages_dict",
"=",
"None",
")",
":",
"try",
":",
"project_dict",
"=",
"cls",
".",
"_preprocess",
"(",
"project_dict",
")",
"except",
"RecursionException",
":",
"raise",
"DbtProjectError",
"("... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project.to_project_config | Return a dict representation of the config that could be written to
disk with `yaml.safe_dump` to get this configuration.
:param with_packages bool: If True, include the serialized packages
file in the root.
:returns dict: The serialized profile. | core/dbt/config/project.py | def to_project_config(self, with_packages=False):
"""Return a dict representation of the config that could be written to
disk with `yaml.safe_dump` to get this configuration.
:param with_packages bool: If True, include the serialized packages
file in the root.
:returns dict:... | def to_project_config(self, with_packages=False):
"""Return a dict representation of the config that could be written to
disk with `yaml.safe_dump` to get this configuration.
:param with_packages bool: If True, include the serialized packages
file in the root.
:returns dict:... | [
"Return",
"a",
"dict",
"representation",
"of",
"the",
"config",
"that",
"could",
"be",
"written",
"to",
"disk",
"with",
"yaml",
".",
"safe_dump",
"to",
"get",
"this",
"configuration",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L306-L341 | [
"def",
"to_project_config",
"(",
"self",
",",
"with_packages",
"=",
"False",
")",
":",
"result",
"=",
"deepcopy",
"(",
"{",
"'name'",
":",
"self",
".",
"project_name",
",",
"'version'",
":",
"self",
".",
"version",
",",
"'project-root'",
":",
"self",
".",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project.from_project_root | Create a project from a root directory. Reads in dbt_project.yml and
packages.yml, if it exists.
:param project_root str: The path to the project root to load.
:raises DbtProjectError: If the project is missing or invalid, or if
the packages file exists and is invalid.
:retu... | core/dbt/config/project.py | def from_project_root(cls, project_root, cli_vars):
"""Create a project from a root directory. Reads in dbt_project.yml and
packages.yml, if it exists.
:param project_root str: The path to the project root to load.
:raises DbtProjectError: If the project is missing or invalid, or if
... | def from_project_root(cls, project_root, cli_vars):
"""Create a project from a root directory. Reads in dbt_project.yml and
packages.yml, if it exists.
:param project_root str: The path to the project root to load.
:raises DbtProjectError: If the project is missing or invalid, or if
... | [
"Create",
"a",
"project",
"from",
"a",
"root",
"directory",
".",
"Reads",
"in",
"dbt_project",
".",
"yml",
"and",
"packages",
".",
"yml",
"if",
"it",
"exists",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L350-L377 | [
"def",
"from_project_root",
"(",
"cls",
",",
"project_root",
",",
"cli_vars",
")",
":",
"project_root",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"project_root",
")",
"project_yaml_filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_root",
",",... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project.get_unused_resource_config_paths | Return a list of lists of strings, where each inner list of strings
represents a type + FQN path of a resource configuration that is not
used. | core/dbt/config/project.py | def get_unused_resource_config_paths(self, resource_fqns, disabled):
"""Return a list of lists of strings, where each inner list of strings
represents a type + FQN path of a resource configuration that is not
used.
"""
disabled_fqns = frozenset(tuple(fqn) for fqn in disabled)
... | def get_unused_resource_config_paths(self, resource_fqns, disabled):
"""Return a list of lists of strings, where each inner list of strings
represents a type + FQN path of a resource configuration that is not
used.
"""
disabled_fqns = frozenset(tuple(fqn) for fqn in disabled)
... | [
"Return",
"a",
"list",
"of",
"lists",
"of",
"strings",
"where",
"each",
"inner",
"list",
"of",
"strings",
"represents",
"a",
"type",
"+",
"FQN",
"path",
"of",
"a",
"resource",
"configuration",
"that",
"is",
"not",
"used",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L400-L417 | [
"def",
"get_unused_resource_config_paths",
"(",
"self",
",",
"resource_fqns",
",",
"disabled",
")",
":",
"disabled_fqns",
"=",
"frozenset",
"(",
"tuple",
"(",
"fqn",
")",
"for",
"fqn",
"in",
"disabled",
")",
"resource_config_paths",
"=",
"self",
".",
"get_resour... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Project.validate_version | Ensure this package works with the installed version of dbt. | core/dbt/config/project.py | def validate_version(self):
"""Ensure this package works with the installed version of dbt."""
installed = get_installed_version()
if not versions_compatible(*self.dbt_version):
msg = IMPOSSIBLE_VERSION_ERROR.format(
package=self.project_name,
version_... | def validate_version(self):
"""Ensure this package works with the installed version of dbt."""
installed = get_installed_version()
if not versions_compatible(*self.dbt_version):
msg = IMPOSSIBLE_VERSION_ERROR.format(
package=self.project_name,
version_... | [
"Ensure",
"this",
"package",
"works",
"with",
"the",
"installed",
"version",
"of",
"dbt",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/project.py#L430-L450 | [
"def",
"validate_version",
"(",
"self",
")",
":",
"installed",
"=",
"get_installed_version",
"(",
")",
"if",
"not",
"versions_compatible",
"(",
"*",
"self",
".",
"dbt_version",
")",
":",
"msg",
"=",
"IMPOSSIBLE_VERSION_ERROR",
".",
"format",
"(",
"package",
"=... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Column.can_expand_to | returns True if this column can be expanded to the size of the
other column | core/dbt/adapters/base/relation.py | def can_expand_to(self, other_column):
"""returns True if this column can be expanded to the size of the
other column"""
if not self.is_string() or not other_column.is_string():
return False
return other_column.string_size() > self.string_size() | def can_expand_to(self, other_column):
"""returns True if this column can be expanded to the size of the
other column"""
if not self.is_string() or not other_column.is_string():
return False
return other_column.string_size() > self.string_size() | [
"returns",
"True",
"if",
"this",
"column",
"can",
"be",
"expanded",
"to",
"the",
"size",
"of",
"the",
"other",
"column"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/base/relation.py#L368-L374 | [
"def",
"can_expand_to",
"(",
"self",
",",
"other_column",
")",
":",
"if",
"not",
"self",
".",
"is_string",
"(",
")",
"or",
"not",
"other_column",
".",
"is_string",
"(",
")",
":",
"return",
"False",
"return",
"other_column",
".",
"string_size",
"(",
")",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | RedshiftConnectionManager.fresh_transaction | On entrance to this context manager, hold an exclusive lock and
create a fresh transaction for redshift, then commit and begin a new
one before releasing the lock on exit.
See drop_relation in RedshiftAdapter for more information.
:param Optional[str] name: The name of the connection t... | plugins/redshift/dbt/adapters/redshift/connections.py | def fresh_transaction(self, name=None):
"""On entrance to this context manager, hold an exclusive lock and
create a fresh transaction for redshift, then commit and begin a new
one before releasing the lock on exit.
See drop_relation in RedshiftAdapter for more information.
:par... | def fresh_transaction(self, name=None):
"""On entrance to this context manager, hold an exclusive lock and
create a fresh transaction for redshift, then commit and begin a new
one before releasing the lock on exit.
See drop_relation in RedshiftAdapter for more information.
:par... | [
"On",
"entrance",
"to",
"this",
"context",
"manager",
"hold",
"an",
"exclusive",
"lock",
"and",
"create",
"a",
"fresh",
"transaction",
"for",
"redshift",
"then",
"commit",
"and",
"begin",
"a",
"new",
"one",
"before",
"releasing",
"the",
"lock",
"on",
"exit",... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/redshift/dbt/adapters/redshift/connections.py#L86-L107 | [
"def",
"fresh_transaction",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"with",
"drop_lock",
":",
"connection",
"=",
"self",
".",
"get_thread_connection",
"(",
")",
"if",
"connection",
".",
"transaction_open",
":",
"self",
".",
"commit",
"(",
")",
"se... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | RedshiftConnectionManager.fetch_cluster_credentials | Fetches temporary login credentials from AWS. The specified user
must already exist in the database, or else an error will occur | plugins/redshift/dbt/adapters/redshift/connections.py | def fetch_cluster_credentials(cls, db_user, db_name, cluster_id,
duration_s):
"""Fetches temporary login credentials from AWS. The specified user
must already exist in the database, or else an error will occur"""
boto_client = boto3.client('redshift')
t... | def fetch_cluster_credentials(cls, db_user, db_name, cluster_id,
duration_s):
"""Fetches temporary login credentials from AWS. The specified user
must already exist in the database, or else an error will occur"""
boto_client = boto3.client('redshift')
t... | [
"Fetches",
"temporary",
"login",
"credentials",
"from",
"AWS",
".",
"The",
"specified",
"user",
"must",
"already",
"exist",
"in",
"the",
"database",
"or",
"else",
"an",
"error",
"will",
"occur"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/redshift/dbt/adapters/redshift/connections.py#L110-L127 | [
"def",
"fetch_cluster_credentials",
"(",
"cls",
",",
"db_user",
",",
"db_name",
",",
"cluster_id",
",",
"duration_s",
")",
":",
"boto_client",
"=",
"boto3",
".",
"client",
"(",
"'redshift'",
")",
"try",
":",
"return",
"boto_client",
".",
"get_cluster_credentials... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BaseSqlParser.load_and_parse | Load and parse models in a list of directories. Returns a dict
that maps unique ids onto ParsedNodes | core/dbt/parser/base_sql.py | def load_and_parse(self, package_name, root_dir, relative_dirs,
resource_type, tags=None):
"""Load and parse models in a list of directories. Returns a dict
that maps unique ids onto ParsedNodes"""
extension = "[!.#~]*.sql"
if tags is None:
tags = ... | def load_and_parse(self, package_name, root_dir, relative_dirs,
resource_type, tags=None):
"""Load and parse models in a list of directories. Returns a dict
that maps unique ids onto ParsedNodes"""
extension = "[!.#~]*.sql"
if tags is None:
tags = ... | [
"Load",
"and",
"parse",
"models",
"in",
"a",
"list",
"of",
"directories",
".",
"Returns",
"a",
"dict",
"that",
"maps",
"unique",
"ids",
"onto",
"ParsedNodes"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/parser/base_sql.py#L20-L64 | [
"def",
"load_and_parse",
"(",
"self",
",",
"package_name",
",",
"root_dir",
",",
"relative_dirs",
",",
"resource_type",
",",
"tags",
"=",
"None",
")",
":",
"extension",
"=",
"\"[!.#~]*.sql\"",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"]",
"if",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | RequestTaskHandler._wait_for_results | Wait for results off the queue. If there is a timeout set, and it is
exceeded, raise an RPCTimeoutException. | core/dbt/rpc.py | def _wait_for_results(self):
"""Wait for results off the queue. If there is a timeout set, and it is
exceeded, raise an RPCTimeoutException.
"""
while True:
get_timeout = self._next_timeout()
try:
msgtype, value = self.queue.get(timeout=get_timeout... | def _wait_for_results(self):
"""Wait for results off the queue. If there is a timeout set, and it is
exceeded, raise an RPCTimeoutException.
"""
while True:
get_timeout = self._next_timeout()
try:
msgtype, value = self.queue.get(timeout=get_timeout... | [
"Wait",
"for",
"results",
"off",
"the",
"queue",
".",
"If",
"there",
"is",
"a",
"timeout",
"set",
"and",
"it",
"is",
"exceeded",
"raise",
"an",
"RPCTimeoutException",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/rpc.py#L166-L184 | [
"def",
"_wait_for_results",
"(",
"self",
")",
":",
"while",
"True",
":",
"get_timeout",
"=",
"self",
".",
"_next_timeout",
"(",
")",
"try",
":",
"msgtype",
",",
"value",
"=",
"self",
".",
"queue",
".",
"get",
"(",
"timeout",
"=",
"get_timeout",
")",
"e... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | add_queue_handler | Add a queue log handler to the global logger. | core/dbt/logger.py | def add_queue_handler(queue):
"""Add a queue log handler to the global logger."""
handler = QueueLogHandler(queue)
handler.setFormatter(QueueFormatter())
handler.setLevel(DEBUG)
GLOBAL_LOGGER.addHandler(handler) | def add_queue_handler(queue):
"""Add a queue log handler to the global logger."""
handler = QueueLogHandler(queue)
handler.setFormatter(QueueFormatter())
handler.setLevel(DEBUG)
GLOBAL_LOGGER.addHandler(handler) | [
"Add",
"a",
"queue",
"log",
"handler",
"to",
"the",
"global",
"logger",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/logger.py#L197-L202 | [
"def",
"add_queue_handler",
"(",
"queue",
")",
":",
"handler",
"=",
"QueueLogHandler",
"(",
"queue",
")",
"handler",
".",
"setFormatter",
"(",
"QueueFormatter",
"(",
")",
")",
"handler",
".",
"setLevel",
"(",
"DEBUG",
")",
"GLOBAL_LOGGER",
".",
"addHandler",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | invalid_type_error | Raise a CompilationException when an adapter method available to macros
has changed. | core/dbt/exceptions.py | def invalid_type_error(method_name, arg_name, got_value, expected_type,
version='0.13.0'):
"""Raise a CompilationException when an adapter method available to macros
has changed.
"""
got_type = type(got_value)
msg = ("As of {version}, 'adapter.{method_name}' expects argument "... | def invalid_type_error(method_name, arg_name, got_value, expected_type,
version='0.13.0'):
"""Raise a CompilationException when an adapter method available to macros
has changed.
"""
got_type = type(got_value)
msg = ("As of {version}, 'adapter.{method_name}' expects argument "... | [
"Raise",
"a",
"CompilationException",
"when",
"an",
"adapter",
"method",
"available",
"to",
"macros",
"has",
"changed",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/exceptions.py#L297-L308 | [
"def",
"invalid_type_error",
"(",
"method_name",
",",
"arg_name",
",",
"got_value",
",",
"expected_type",
",",
"version",
"=",
"'0.13.0'",
")",
":",
"got_type",
"=",
"type",
"(",
"got_value",
")",
"msg",
"=",
"(",
"\"As of {version}, 'adapter.{method_name}' expects ... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | _inject_ctes_into_sql | `ctes` is a dict of CTEs in the form:
{
"cte_id_1": "__dbt__CTE__ephemeral as (select * from table)",
"cte_id_2": "__dbt__CTE__events as (select id, type from events)"
}
Given `sql` like:
"with internal_cte as (select * from sessions)
select * from internal_cte"
This... | core/dbt/contracts/graph/compiled.py | def _inject_ctes_into_sql(sql, ctes):
"""
`ctes` is a dict of CTEs in the form:
{
"cte_id_1": "__dbt__CTE__ephemeral as (select * from table)",
"cte_id_2": "__dbt__CTE__events as (select id, type from events)"
}
Given `sql` like:
"with internal_cte as (select * from sess... | def _inject_ctes_into_sql(sql, ctes):
"""
`ctes` is a dict of CTEs in the form:
{
"cte_id_1": "__dbt__CTE__ephemeral as (select * from table)",
"cte_id_2": "__dbt__CTE__events as (select id, type from events)"
}
Given `sql` like:
"with internal_cte as (select * from sess... | [
"ctes",
"is",
"a",
"dict",
"of",
"CTEs",
"in",
"the",
"form",
":"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/contracts/graph/compiled.py#L119-L170 | [
"def",
"_inject_ctes_into_sql",
"(",
"sql",
",",
"ctes",
")",
":",
"if",
"len",
"(",
"ctes",
")",
"==",
"0",
":",
"return",
"sql",
"parsed_stmts",
"=",
"sqlparse",
".",
"parse",
"(",
"sql",
")",
"parsed",
"=",
"parsed_stmts",
"[",
"0",
"]",
"with_stmt"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | CompiledNode.set_cte | This is the equivalent of what self.extra_ctes[cte_id] = sql would
do if extra_ctes were an OrderedDict | core/dbt/contracts/graph/compiled.py | def set_cte(self, cte_id, sql):
"""This is the equivalent of what self.extra_ctes[cte_id] = sql would
do if extra_ctes were an OrderedDict
"""
for cte in self.extra_ctes:
if cte['id'] == cte_id:
cte['sql'] = sql
break
else:
... | def set_cte(self, cte_id, sql):
"""This is the equivalent of what self.extra_ctes[cte_id] = sql would
do if extra_ctes were an OrderedDict
"""
for cte in self.extra_ctes:
if cte['id'] == cte_id:
cte['sql'] = sql
break
else:
... | [
"This",
"is",
"the",
"equivalent",
"of",
"what",
"self",
".",
"extra_ctes",
"[",
"cte_id",
"]",
"=",
"sql",
"would",
"do",
"if",
"extra_ctes",
"were",
"an",
"OrderedDict"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/contracts/graph/compiled.py#L221-L232 | [
"def",
"set_cte",
"(",
"self",
",",
"cte_id",
",",
"sql",
")",
":",
"for",
"cte",
"in",
"self",
".",
"extra_ctes",
":",
"if",
"cte",
"[",
"'id'",
"]",
"==",
"cte_id",
":",
"cte",
"[",
"'sql'",
"]",
"=",
"sql",
"break",
"else",
":",
"self",
".",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Builder.build_namespace | Build out the directory skeleton and python namespace files:
dbt/
__init__.py
adapters/
${adapter_name}
__init__.py
include/
${adapter_name}
__init__.py | core/scripts/create_adapter_plugins.py | def build_namespace(self):
"""Build out the directory skeleton and python namespace files:
dbt/
__init__.py
adapters/
${adapter_name}
__init__.py
include/
${adapter_name}
... | def build_namespace(self):
"""Build out the directory skeleton and python namespace files:
dbt/
__init__.py
adapters/
${adapter_name}
__init__.py
include/
${adapter_name}
... | [
"Build",
"out",
"the",
"directory",
"skeleton",
"and",
"python",
"namespace",
"files",
":"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/scripts/create_adapter_plugins.py#L142-L161 | [
"def",
"build_namespace",
"(",
"self",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"adapters_path",
")",
"os",
".",
"makedirs",
"(",
"pj",
"(",
"self",
".",
"include_path",
",",
"'macros'",
")",
")",
"with",
"open",
"(",
"pj",
"(",
"self",
"."... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | available_deprecated | A decorator that marks a function as available, but also prints a
deprecation warning. Use like
@available_deprecated('my_new_method')
def my_old_method(self, arg, model_name=None):
args = compatability_shim(arg)
return self.my_new_method(*args, model_name=None)
To make `adapter.my_old... | core/dbt/adapters/base/meta.py | def available_deprecated(supported_name):
"""A decorator that marks a function as available, but also prints a
deprecation warning. Use like
@available_deprecated('my_new_method')
def my_old_method(self, arg, model_name=None):
args = compatability_shim(arg)
return self.my_new_method(*ar... | def available_deprecated(supported_name):
"""A decorator that marks a function as available, but also prints a
deprecation warning. Use like
@available_deprecated('my_new_method')
def my_old_method(self, arg, model_name=None):
args = compatability_shim(arg)
return self.my_new_method(*ar... | [
"A",
"decorator",
"that",
"marks",
"a",
"function",
"as",
"available",
"but",
"also",
"prints",
"a",
"deprecation",
"warning",
".",
"Use",
"like"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/base/meta.py#L15-L36 | [
"def",
"available_deprecated",
"(",
"supported_name",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"func_name",
"=",
"func",
".",
"__name__",
"renamed_method",
"(",
"func_name",
",",
"supported_name",
")",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryAdapter._get_dbt_columns_from_bq_table | Translates BQ SchemaField dicts into dbt BigQueryColumn objects | plugins/bigquery/dbt/adapters/bigquery/impl.py | def _get_dbt_columns_from_bq_table(self, table):
"Translates BQ SchemaField dicts into dbt BigQueryColumn objects"
columns = []
for col in table.schema:
# BigQuery returns type labels that are not valid type specifiers
dtype = self.Column.translate_type(col.field_type)
... | def _get_dbt_columns_from_bq_table(self, table):
"Translates BQ SchemaField dicts into dbt BigQueryColumn objects"
columns = []
for col in table.schema:
# BigQuery returns type labels that are not valid type specifiers
dtype = self.Column.translate_type(col.field_type)
... | [
"Translates",
"BQ",
"SchemaField",
"dicts",
"into",
"dbt",
"BigQueryColumn",
"objects"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/impl.py#L196-L207 | [
"def",
"_get_dbt_columns_from_bq_table",
"(",
"self",
",",
"table",
")",
":",
"columns",
"=",
"[",
"]",
"for",
"col",
"in",
"table",
".",
"schema",
":",
"# BigQuery returns type labels that are not valid type specifiers",
"dtype",
"=",
"self",
".",
"Column",
".",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryAdapter._agate_to_schema | Convert agate.Table with column names to a list of bigquery schemas. | plugins/bigquery/dbt/adapters/bigquery/impl.py | def _agate_to_schema(self, agate_table, column_override):
"""Convert agate.Table with column names to a list of bigquery schemas.
"""
bq_schema = []
for idx, col_name in enumerate(agate_table.column_names):
inferred_type = self.convert_agate_type(agate_table, idx)
... | def _agate_to_schema(self, agate_table, column_override):
"""Convert agate.Table with column names to a list of bigquery schemas.
"""
bq_schema = []
for idx, col_name in enumerate(agate_table.column_names):
inferred_type = self.convert_agate_type(agate_table, idx)
... | [
"Convert",
"agate",
".",
"Table",
"with",
"column",
"names",
"to",
"a",
"list",
"of",
"bigquery",
"schemas",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/impl.py#L209-L219 | [
"def",
"_agate_to_schema",
"(",
"self",
",",
"agate_table",
",",
"column_override",
")",
":",
"bq_schema",
"=",
"[",
"]",
"for",
"idx",
",",
"col_name",
"in",
"enumerate",
"(",
"agate_table",
".",
"column_names",
")",
":",
"inferred_type",
"=",
"self",
".",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryAdapter._flat_columns_in_table | An iterator over the flattened columns for a given schema and table.
Resolves child columns as having the name "parent.child". | plugins/bigquery/dbt/adapters/bigquery/impl.py | def _flat_columns_in_table(self, table):
"""An iterator over the flattened columns for a given schema and table.
Resolves child columns as having the name "parent.child".
"""
for col in self._get_dbt_columns_from_bq_table(table):
flattened = col.flatten()
for subc... | def _flat_columns_in_table(self, table):
"""An iterator over the flattened columns for a given schema and table.
Resolves child columns as having the name "parent.child".
"""
for col in self._get_dbt_columns_from_bq_table(table):
flattened = col.flatten()
for subc... | [
"An",
"iterator",
"over",
"the",
"flattened",
"columns",
"for",
"a",
"given",
"schema",
"and",
"table",
".",
"Resolves",
"child",
"columns",
"as",
"having",
"the",
"name",
"parent",
".",
"child",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/impl.py#L397-L404 | [
"def",
"_flat_columns_in_table",
"(",
"self",
",",
"table",
")",
":",
"for",
"col",
"in",
"self",
".",
"_get_dbt_columns_from_bq_table",
"(",
"table",
")",
":",
"flattened",
"=",
"col",
".",
"flatten",
"(",
")",
"for",
"subcol",
"in",
"flattened",
":",
"yi... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryAdapter._get_stats_column_names | Construct a tuple of the column names for stats. Each stat has 4
columns of data. | plugins/bigquery/dbt/adapters/bigquery/impl.py | def _get_stats_column_names(cls):
"""Construct a tuple of the column names for stats. Each stat has 4
columns of data.
"""
columns = []
stats = ('num_bytes', 'num_rows', 'location', 'partitioning_type',
'clustering_fields')
stat_components = ('label', 'va... | def _get_stats_column_names(cls):
"""Construct a tuple of the column names for stats. Each stat has 4
columns of data.
"""
columns = []
stats = ('num_bytes', 'num_rows', 'location', 'partitioning_type',
'clustering_fields')
stat_components = ('label', 'va... | [
"Construct",
"a",
"tuple",
"of",
"the",
"column",
"names",
"for",
"stats",
".",
"Each",
"stat",
"has",
"4",
"columns",
"of",
"data",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/impl.py#L407-L418 | [
"def",
"_get_stats_column_names",
"(",
"cls",
")",
":",
"columns",
"=",
"[",
"]",
"stats",
"=",
"(",
"'num_bytes'",
",",
"'num_rows'",
",",
"'location'",
",",
"'partitioning_type'",
",",
"'clustering_fields'",
")",
"stat_components",
"=",
"(",
"'label'",
",",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryAdapter._get_stats_columns | Given a table, return an iterator of key/value pairs for stats
column names/values. | plugins/bigquery/dbt/adapters/bigquery/impl.py | def _get_stats_columns(cls, table, relation_type):
"""Given a table, return an iterator of key/value pairs for stats
column names/values.
"""
column_names = cls._get_stats_column_names()
# agate does not handle the array of column names gracefully
clustering_value = None... | def _get_stats_columns(cls, table, relation_type):
"""Given a table, return an iterator of key/value pairs for stats
column names/values.
"""
column_names = cls._get_stats_column_names()
# agate does not handle the array of column names gracefully
clustering_value = None... | [
"Given",
"a",
"table",
"return",
"an",
"iterator",
"of",
"key",
"/",
"value",
"pairs",
"for",
"stats",
"column",
"names",
"/",
"values",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/impl.py#L421-L459 | [
"def",
"_get_stats_columns",
"(",
"cls",
",",
"table",
",",
"relation_type",
")",
":",
"column_names",
"=",
"cls",
".",
"_get_stats_column_names",
"(",
")",
"# agate does not handle the array of column names gracefully",
"clustering_value",
"=",
"None",
"if",
"table",
"... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | GraphRunnableTask._submit | If the caller has passed the magic 'single-threaded' flag, call the
function directly instead of pool.apply_async. The single-threaded flag
is intended for gathering more useful performance information about
what appens beneath `call_runner`, since python's default profiling
tools ignor... | core/dbt/task/runnable.py | def _submit(self, pool, args, callback):
"""If the caller has passed the magic 'single-threaded' flag, call the
function directly instead of pool.apply_async. The single-threaded flag
is intended for gathering more useful performance information about
what appens beneath `call_runner`, ... | def _submit(self, pool, args, callback):
"""If the caller has passed the magic 'single-threaded' flag, call the
function directly instead of pool.apply_async. The single-threaded flag
is intended for gathering more useful performance information about
what appens beneath `call_runner`, ... | [
"If",
"the",
"caller",
"has",
"passed",
"the",
"magic",
"single",
"-",
"threaded",
"flag",
"call",
"the",
"function",
"directly",
"instead",
"of",
"pool",
".",
"apply_async",
".",
"The",
"single",
"-",
"threaded",
"flag",
"is",
"intended",
"for",
"gathering"... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L121-L133 | [
"def",
"_submit",
"(",
"self",
",",
"pool",
",",
"args",
",",
"callback",
")",
":",
"if",
"self",
".",
"config",
".",
"args",
".",
"single_threaded",
":",
"callback",
"(",
"self",
".",
"call_runner",
"(",
"*",
"args",
")",
")",
"else",
":",
"pool",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | GraphRunnableTask.run_queue | Given a pool, submit jobs from the queue to the pool. | core/dbt/task/runnable.py | def run_queue(self, pool):
"""Given a pool, submit jobs from the queue to the pool.
"""
def callback(result):
"""Note: mark_done, at a minimum, must happen here or dbt will
deadlock during ephemeral result error handling!
"""
self._handle_result(re... | def run_queue(self, pool):
"""Given a pool, submit jobs from the queue to the pool.
"""
def callback(result):
"""Note: mark_done, at a minimum, must happen here or dbt will
deadlock during ephemeral result error handling!
"""
self._handle_result(re... | [
"Given",
"a",
"pool",
"submit",
"jobs",
"from",
"the",
"queue",
"to",
"the",
"pool",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L139-L166 | [
"def",
"run_queue",
"(",
"self",
",",
"pool",
")",
":",
"def",
"callback",
"(",
"result",
")",
":",
"\"\"\"Note: mark_done, at a minimum, must happen here or dbt will\n deadlock during ephemeral result error handling!\n \"\"\"",
"self",
".",
"_handle_result",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | GraphRunnableTask._handle_result | Mark the result as completed, insert the `CompiledResultNode` into
the manifest, and mark any descendants (potentially with a 'cause' if
the result was an ephemeral model) as skipped. | core/dbt/task/runnable.py | def _handle_result(self, result):
"""Mark the result as completed, insert the `CompiledResultNode` into
the manifest, and mark any descendants (potentially with a 'cause' if
the result was an ephemeral model) as skipped.
"""
is_ephemeral = result.node.is_ephemeral_model
i... | def _handle_result(self, result):
"""Mark the result as completed, insert the `CompiledResultNode` into
the manifest, and mark any descendants (potentially with a 'cause' if
the result was an ephemeral model) as skipped.
"""
is_ephemeral = result.node.is_ephemeral_model
i... | [
"Mark",
"the",
"result",
"as",
"completed",
"insert",
"the",
"CompiledResultNode",
"into",
"the",
"manifest",
"and",
"mark",
"any",
"descendants",
"(",
"potentially",
"with",
"a",
"cause",
"if",
"the",
"result",
"was",
"an",
"ephemeral",
"model",
")",
"as",
... | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L168-L186 | [
"def",
"_handle_result",
"(",
"self",
",",
"result",
")",
":",
"is_ephemeral",
"=",
"result",
".",
"node",
".",
"is_ephemeral_model",
"if",
"not",
"is_ephemeral",
":",
"self",
".",
"node_results",
".",
"append",
"(",
"result",
")",
"node",
"=",
"CompileResul... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | GraphRunnableTask.run | Run dbt for the query, based on the graph. | core/dbt/task/runnable.py | def run(self):
"""
Run dbt for the query, based on the graph.
"""
self._runtime_initialize()
if len(self._flattened_nodes) == 0:
logger.warning("WARNING: Nothing to do. Try checking your model "
"configs and model specification args")
... | def run(self):
"""
Run dbt for the query, based on the graph.
"""
self._runtime_initialize()
if len(self._flattened_nodes) == 0:
logger.warning("WARNING: Nothing to do. Try checking your model "
"configs and model specification args")
... | [
"Run",
"dbt",
"for",
"the",
"query",
"based",
"on",
"the",
"graph",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L268-L287 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_runtime_initialize",
"(",
")",
"if",
"len",
"(",
"self",
".",
"_flattened_nodes",
")",
"==",
"0",
":",
"logger",
".",
"warning",
"(",
"\"WARNING: Nothing to do. Try checking your model \"",
"\"configs and model s... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | RemoteCallable.decode_sql | Base64 decode a string. This should only be used for sql in calls.
:param str sql: The base64 encoded form of the original utf-8 string
:return str: The decoded utf-8 string | core/dbt/task/runnable.py | def decode_sql(self, sql):
"""Base64 decode a string. This should only be used for sql in calls.
:param str sql: The base64 encoded form of the original utf-8 string
:return str: The decoded utf-8 string
"""
# JSON is defined as using "unicode", we'll go a step further and
... | def decode_sql(self, sql):
"""Base64 decode a string. This should only be used for sql in calls.
:param str sql: The base64 encoded form of the original utf-8 string
:return str: The decoded utf-8 string
"""
# JSON is defined as using "unicode", we'll go a step further and
... | [
"Base64",
"decode",
"a",
"string",
".",
"This",
"should",
"only",
"be",
"used",
"for",
"sql",
"in",
"calls",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/runnable.py#L347-L366 | [
"def",
"decode_sql",
"(",
"self",
",",
"sql",
")",
":",
"# JSON is defined as using \"unicode\", we'll go a step further and",
"# mandate utf-8 (though for the base64 part, it doesn't really matter!)",
"base64_sql_bytes",
"=",
"to_unicode",
"(",
"sql",
")",
".",
"encode",
"(",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryConnectionManager.create_bigquery_table | Create a bigquery table. The caller must supply a callback
that takes one argument, a `google.cloud.bigquery.Table`, and mutates
it. | plugins/bigquery/dbt/adapters/bigquery/connections.py | def create_bigquery_table(self, database, schema, table_name, callback,
sql):
"""Create a bigquery table. The caller must supply a callback
that takes one argument, a `google.cloud.bigquery.Table`, and mutates
it.
"""
conn = self.get_thread_connectio... | def create_bigquery_table(self, database, schema, table_name, callback,
sql):
"""Create a bigquery table. The caller must supply a callback
that takes one argument, a `google.cloud.bigquery.Table`, and mutates
it.
"""
conn = self.get_thread_connectio... | [
"Create",
"a",
"bigquery",
"table",
".",
"The",
"caller",
"must",
"supply",
"a",
"callback",
"that",
"takes",
"one",
"argument",
"a",
"google",
".",
"cloud",
".",
"bigquery",
".",
"Table",
"and",
"mutates",
"it",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/connections.py#L216-L230 | [
"def",
"create_bigquery_table",
"(",
"self",
",",
"database",
",",
"schema",
",",
"table_name",
",",
"callback",
",",
"sql",
")",
":",
"conn",
"=",
"self",
".",
"get_thread_connection",
"(",
")",
"client",
"=",
"conn",
".",
"handle",
"view_ref",
"=",
"self... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | BigQueryConnectionManager.get_bq_table | Get a bigquery table for a schema/model. | plugins/bigquery/dbt/adapters/bigquery/connections.py | def get_bq_table(self, database, schema, identifier):
"""Get a bigquery table for a schema/model."""
conn = self.get_thread_connection()
table_ref = self.table_ref(database, schema, identifier, conn)
return conn.handle.get_table(table_ref) | def get_bq_table(self, database, schema, identifier):
"""Get a bigquery table for a schema/model."""
conn = self.get_thread_connection()
table_ref = self.table_ref(database, schema, identifier, conn)
return conn.handle.get_table(table_ref) | [
"Get",
"a",
"bigquery",
"table",
"for",
"a",
"schema",
"/",
"model",
"."
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/plugins/bigquery/dbt/adapters/bigquery/connections.py#L270-L274 | [
"def",
"get_bq_table",
"(",
"self",
",",
"database",
",",
"schema",
",",
"identifier",
")",
":",
"conn",
"=",
"self",
".",
"get_thread_connection",
"(",
")",
"table_ref",
"=",
"self",
".",
"table_ref",
"(",
"database",
",",
"schema",
",",
"identifier",
","... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | read_profiles | This is only used for some error handling | core/dbt/task/base.py | def read_profiles(profiles_dir=None):
"""This is only used for some error handling"""
if profiles_dir is None:
profiles_dir = PROFILES_DIR
raw_profiles = read_profile(profiles_dir)
if raw_profiles is None:
profiles = {}
else:
profiles = {k: v for (k, v) in raw_profiles.item... | def read_profiles(profiles_dir=None):
"""This is only used for some error handling"""
if profiles_dir is None:
profiles_dir = PROFILES_DIR
raw_profiles = read_profile(profiles_dir)
if raw_profiles is None:
profiles = {}
else:
profiles = {k: v for (k, v) in raw_profiles.item... | [
"This",
"is",
"only",
"used",
"for",
"some",
"error",
"handling"
] | fishtown-analytics/dbt | python | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/base.py#L19-L31 | [
"def",
"read_profiles",
"(",
"profiles_dir",
"=",
"None",
")",
":",
"if",
"profiles_dir",
"is",
"None",
":",
"profiles_dir",
"=",
"PROFILES_DIR",
"raw_profiles",
"=",
"read_profile",
"(",
"profiles_dir",
")",
"if",
"raw_profiles",
"is",
"None",
":",
"profiles",
... | aa4f771df28b307af0cf9fe2fc24432f10a8236b |
train | Answerer.answer | Create a task that calls ``compute fn`` (along with additional arguments
``*compute_args`` and ``**compute_kwargs``), then applies the returned value to
:meth:`.Bot.answerInlineQuery` to answer the inline query.
If a preceding task is already working for a user, that task is cancelled,
t... | telepot/aio/helper.py | def answer(self, inline_query, compute_fn, *compute_args, **compute_kwargs):
"""
Create a task that calls ``compute fn`` (along with additional arguments
``*compute_args`` and ``**compute_kwargs``), then applies the returned value to
:meth:`.Bot.answerInlineQuery` to answer the inline qu... | def answer(self, inline_query, compute_fn, *compute_args, **compute_kwargs):
"""
Create a task that calls ``compute fn`` (along with additional arguments
``*compute_args`` and ``**compute_kwargs``), then applies the returned value to
:meth:`.Bot.answerInlineQuery` to answer the inline qu... | [
"Create",
"a",
"task",
"that",
"calls",
"compute",
"fn",
"(",
"along",
"with",
"additional",
"arguments",
"*",
"compute_args",
"and",
"**",
"compute_kwargs",
")",
"then",
"applies",
"the",
"returned",
"value",
"to",
":",
"meth",
":",
".",
"Bot",
".",
"answ... | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/aio/helper.py#L74-L129 | [
"def",
"answer",
"(",
"self",
",",
"inline_query",
",",
"compute_fn",
",",
"*",
"compute_args",
",",
"*",
"*",
"compute_kwargs",
")",
":",
"from_id",
"=",
"inline_query",
"[",
"'from'",
"]",
"[",
"'id'",
"]",
"async",
"def",
"compute_and_answer",
"(",
")",... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | GetUpdatesLoop.run_forever | Process new updates in infinity loop
:param relax: float
:param offset: int
:param timeout: int
:param allowed_updates: bool | telepot/aio/loop.py | async def run_forever(self, relax=0.1, offset=None, timeout=20, allowed_updates=None):
"""
Process new updates in infinity loop
:param relax: float
:param offset: int
:param timeout: int
:param allowed_updates: bool
"""
while 1:
try:
... | async def run_forever(self, relax=0.1, offset=None, timeout=20, allowed_updates=None):
"""
Process new updates in infinity loop
:param relax: float
:param offset: int
:param timeout: int
:param allowed_updates: bool
"""
while 1:
try:
... | [
"Process",
"new",
"updates",
"in",
"infinity",
"loop"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/aio/loop.py#L18-L53 | [
"async",
"def",
"run_forever",
"(",
"self",
",",
"relax",
"=",
"0.1",
",",
"offset",
"=",
"None",
",",
"timeout",
"=",
"20",
",",
"allowed_updates",
"=",
"None",
")",
":",
"while",
"1",
":",
"try",
":",
"result",
"=",
"await",
"self",
".",
"_bot",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | flavor | Return flavor of message or event.
A message's flavor may be one of these:
- ``chat``
- ``callback_query``
- ``inline_query``
- ``chosen_inline_result``
- ``shipping_query``
- ``pre_checkout_query``
An event's flavor is determined by the single top-level key. | telepot/__init__.py | def flavor(msg):
"""
Return flavor of message or event.
A message's flavor may be one of these:
- ``chat``
- ``callback_query``
- ``inline_query``
- ``chosen_inline_result``
- ``shipping_query``
- ``pre_checkout_query``
An event's flavor is determined by the single top-level k... | def flavor(msg):
"""
Return flavor of message or event.
A message's flavor may be one of these:
- ``chat``
- ``callback_query``
- ``inline_query``
- ``chosen_inline_result``
- ``shipping_query``
- ``pre_checkout_query``
An event's flavor is determined by the single top-level k... | [
"Return",
"flavor",
"of",
"message",
"or",
"event",
"."
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L25-L57 | [
"def",
"flavor",
"(",
"msg",
")",
":",
"if",
"'message_id'",
"in",
"msg",
":",
"return",
"'chat'",
"elif",
"'id'",
"in",
"msg",
"and",
"'chat_instance'",
"in",
"msg",
":",
"return",
"'callback_query'",
"elif",
"'id'",
"in",
"msg",
"and",
"'query'",
"in",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | glance | Extract "headline" info about a message.
Use parameter ``long`` to control whether a short or long tuple is returned.
When ``flavor`` is ``chat``
(``msg`` being a `Message <https://core.telegram.org/bots/api#message>`_ object):
- short: (content_type, ``msg['chat']['type']``, ``msg['chat']['id']``)
... | telepot/__init__.py | def glance(msg, flavor='chat', long=False):
"""
Extract "headline" info about a message.
Use parameter ``long`` to control whether a short or long tuple is returned.
When ``flavor`` is ``chat``
(``msg`` being a `Message <https://core.telegram.org/bots/api#message>`_ object):
- short: (content_... | def glance(msg, flavor='chat', long=False):
"""
Extract "headline" info about a message.
Use parameter ``long`` to control whether a short or long tuple is returned.
When ``flavor`` is ``chat``
(``msg`` being a `Message <https://core.telegram.org/bots/api#message>`_ object):
- short: (content_... | [
"Extract",
"headline",
"info",
"about",
"a",
"message",
".",
"Use",
"parameter",
"long",
"to",
"control",
"whether",
"a",
"short",
"or",
"long",
"tuple",
"is",
"returned",
"."
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L79-L162 | [
"def",
"glance",
"(",
"msg",
",",
"flavor",
"=",
"'chat'",
",",
"long",
"=",
"False",
")",
":",
"def",
"gl_chat",
"(",
")",
":",
"content_type",
"=",
"_find_first_key",
"(",
"msg",
",",
"all_content_types",
")",
"if",
"long",
":",
"return",
"content_type... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | flance | A combination of :meth:`telepot.flavor` and :meth:`telepot.glance`,
return a 2-tuple (flavor, headline_info), where *headline_info* is whatever extracted by
:meth:`telepot.glance` depending on the message flavor and the ``long`` parameter. | telepot/__init__.py | def flance(msg, long=False):
"""
A combination of :meth:`telepot.flavor` and :meth:`telepot.glance`,
return a 2-tuple (flavor, headline_info), where *headline_info* is whatever extracted by
:meth:`telepot.glance` depending on the message flavor and the ``long`` parameter.
"""
f = flavor(msg)
... | def flance(msg, long=False):
"""
A combination of :meth:`telepot.flavor` and :meth:`telepot.glance`,
return a 2-tuple (flavor, headline_info), where *headline_info* is whatever extracted by
:meth:`telepot.glance` depending on the message flavor and the ``long`` parameter.
"""
f = flavor(msg)
... | [
"A",
"combination",
"of",
":",
"meth",
":",
"telepot",
".",
"flavor",
"and",
":",
"meth",
":",
"telepot",
".",
"glance",
"return",
"a",
"2",
"-",
"tuple",
"(",
"flavor",
"headline_info",
")",
"where",
"*",
"headline_info",
"*",
"is",
"whatever",
"extract... | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L165-L173 | [
"def",
"flance",
"(",
"msg",
",",
"long",
"=",
"False",
")",
":",
"f",
"=",
"flavor",
"(",
"msg",
")",
"g",
"=",
"glance",
"(",
"msg",
",",
"flavor",
"=",
"f",
",",
"long",
"=",
"long",
")",
"return",
"f",
",",
"g"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendMessage | See: https://core.telegram.org/bots/api#sendmessage | telepot/__init__.py | def sendMessage(self, chat_id, text,
parse_mode=None,
disable_web_page_preview=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendmessag... | def sendMessage(self, chat_id, text,
parse_mode=None,
disable_web_page_preview=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendmessag... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendmessage"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L505-L513 | [
"def",
"sendMessage",
"(",
"self",
",",
"chat_id",
",",
"text",
",",
"parse_mode",
"=",
"None",
",",
"disable_web_page_preview",
"=",
"None",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
",",
"reply_markup",
"=",
"None",
"... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.forwardMessage | See: https://core.telegram.org/bots/api#forwardmessage | telepot/__init__.py | def forwardMessage(self, chat_id, from_chat_id, message_id,
disable_notification=None):
""" See: https://core.telegram.org/bots/api#forwardmessage """
p = _strip(locals())
return self._api_request('forwardMessage', _rectify(p)) | def forwardMessage(self, chat_id, from_chat_id, message_id,
disable_notification=None):
""" See: https://core.telegram.org/bots/api#forwardmessage """
p = _strip(locals())
return self._api_request('forwardMessage', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#forwardmessage"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L515-L519 | [
"def",
"forwardMessage",
"(",
"self",
",",
"chat_id",
",",
"from_chat_id",
",",
"message_id",
",",
"disable_notification",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'forwardMessage'"... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendVoice | See: https://core.telegram.org/bots/api#sendvoice
:param voice: Same as ``photo`` in :meth:`telepot.Bot.sendPhoto` | telepot/__init__.py | def sendVoice(self, chat_id, voice,
caption=None,
parse_mode=None,
duration=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/a... | def sendVoice(self, chat_id, voice,
caption=None,
parse_mode=None,
duration=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/a... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendvoice"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L590-L603 | [
"def",
"sendVoice",
"(",
"self",
",",
"chat_id",
",",
"voice",
",",
"caption",
"=",
"None",
",",
"parse_mode",
"=",
"None",
",",
"duration",
"=",
"None",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
",",
"reply_markup",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendVideoNote | See: https://core.telegram.org/bots/api#sendvideonote
:param video_note: Same as ``photo`` in :meth:`telepot.Bot.sendPhoto`
:param length:
Although marked as optional, this method does not seem to work without
it being specified. Supply any integer you want. It seems to have no... | telepot/__init__.py | def sendVideoNote(self, chat_id, video_note,
duration=None,
length=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#send... | def sendVideoNote(self, chat_id, video_note,
duration=None,
length=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#send... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendvideonote"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L605-L622 | [
"def",
"sendVideoNote",
"(",
"self",
",",
"chat_id",
",",
"video_note",
",",
"duration",
"=",
"None",
",",
"length",
"=",
"None",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
",",
"reply_markup",
"=",
"None",
")",
":",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendMediaGroup | See: https://core.telegram.org/bots/api#sendmediagroup
:type media: array of `InputMedia <https://core.telegram.org/bots/api#inputmedia>`_ objects
:param media:
To indicate media locations, each InputMedia object's ``media`` field
should be one of these:
- string: `... | telepot/__init__.py | def sendMediaGroup(self, chat_id, media,
disable_notification=None,
reply_to_message_id=None):
"""
See: https://core.telegram.org/bots/api#sendmediagroup
:type media: array of `InputMedia <https://core.telegram.org/bots/api#inputmedia>`_ objects
... | def sendMediaGroup(self, chat_id, media,
disable_notification=None,
reply_to_message_id=None):
"""
See: https://core.telegram.org/bots/api#sendmediagroup
:type media: array of `InputMedia <https://core.telegram.org/bots/api#inputmedia>`_ objects
... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendmediagroup"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L624-L650 | [
"def",
"sendMediaGroup",
"(",
"self",
",",
"chat_id",
",",
"media",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'media'",
"]",
")",
"l... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendLocation | See: https://core.telegram.org/bots/api#sendlocation | telepot/__init__.py | def sendLocation(self, chat_id, latitude, longitude,
live_period=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendlocation """
p = _strip(loca... | def sendLocation(self, chat_id, latitude, longitude,
live_period=None,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendlocation """
p = _strip(loca... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendlocation"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L652-L659 | [
"def",
"sendLocation",
"(",
"self",
",",
"chat_id",
",",
"latitude",
",",
"longitude",
",",
"live_period",
"=",
"None",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
",",
"reply_markup",
"=",
"None",
")",
":",
"p",
"=",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendGame | See: https://core.telegram.org/bots/api#sendgame | telepot/__init__.py | def sendGame(self, chat_id, game_short_name,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendgame """
p = _strip(locals())
return self._api_request('sendGame', _rectify(p)) | def sendGame(self, chat_id, game_short_name,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#sendgame """
p = _strip(locals())
return self._api_request('sendGame', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendgame"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L701-L707 | [
"def",
"sendGame",
"(",
"self",
",",
"chat_id",
",",
"game_short_name",
",",
"disable_notification",
"=",
"None",
",",
"reply_to_message_id",
"=",
"None",
",",
"reply_markup",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendInvoice | See: https://core.telegram.org/bots/api#sendinvoice | telepot/__init__.py | def sendInvoice(self, chat_id, title, description, payload,
provider_token, start_parameter, currency, prices,
provider_data=None,
photo_url=None,
photo_size=None,
photo_width=None,
photo_height=None,... | def sendInvoice(self, chat_id, title, description, payload,
provider_token, start_parameter, currency, prices,
provider_data=None,
photo_url=None,
photo_size=None,
photo_width=None,
photo_height=None,... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendinvoice"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L709-L726 | [
"def",
"sendInvoice",
"(",
"self",
",",
"chat_id",
",",
"title",
",",
"description",
",",
"payload",
",",
"provider_token",
",",
"start_parameter",
",",
"currency",
",",
"prices",
",",
"provider_data",
"=",
"None",
",",
"photo_url",
"=",
"None",
",",
"photo_... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.sendChatAction | See: https://core.telegram.org/bots/api#sendchataction | telepot/__init__.py | def sendChatAction(self, chat_id, action):
""" See: https://core.telegram.org/bots/api#sendchataction """
p = _strip(locals())
return self._api_request('sendChatAction', _rectify(p)) | def sendChatAction(self, chat_id, action):
""" See: https://core.telegram.org/bots/api#sendchataction """
p = _strip(locals())
return self._api_request('sendChatAction', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendchataction"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L728-L731 | [
"def",
"sendChatAction",
"(",
"self",
",",
"chat_id",
",",
"action",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'sendChatAction'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.getUserProfilePhotos | See: https://core.telegram.org/bots/api#getuserprofilephotos | telepot/__init__.py | def getUserProfilePhotos(self, user_id,
offset=None,
limit=None):
""" See: https://core.telegram.org/bots/api#getuserprofilephotos """
p = _strip(locals())
return self._api_request('getUserProfilePhotos', _rectify(p)) | def getUserProfilePhotos(self, user_id,
offset=None,
limit=None):
""" See: https://core.telegram.org/bots/api#getuserprofilephotos """
p = _strip(locals())
return self._api_request('getUserProfilePhotos', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#getuserprofilephotos"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L733-L738 | [
"def",
"getUserProfilePhotos",
"(",
"self",
",",
"user_id",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'getUserProfilePhotos'",
",",
"_re... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.promoteChatMember | See: https://core.telegram.org/bots/api#promotechatmember | telepot/__init__.py | def promoteChatMember(self, chat_id, user_id,
can_change_info=None,
can_post_messages=None,
can_edit_messages=None,
can_delete_messages=None,
can_invite_users=None,
... | def promoteChatMember(self, chat_id, user_id,
can_change_info=None,
can_post_messages=None,
can_edit_messages=None,
can_delete_messages=None,
can_invite_users=None,
... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#promotechatmember"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L766-L777 | [
"def",
"promoteChatMember",
"(",
"self",
",",
"chat_id",
",",
"user_id",
",",
"can_change_info",
"=",
"None",
",",
"can_post_messages",
"=",
"None",
",",
"can_edit_messages",
"=",
"None",
",",
"can_delete_messages",
"=",
"None",
",",
"can_invite_users",
"=",
"No... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.exportChatInviteLink | See: https://core.telegram.org/bots/api#exportchatinvitelink | telepot/__init__.py | def exportChatInviteLink(self, chat_id):
""" See: https://core.telegram.org/bots/api#exportchatinvitelink """
p = _strip(locals())
return self._api_request('exportChatInviteLink', _rectify(p)) | def exportChatInviteLink(self, chat_id):
""" See: https://core.telegram.org/bots/api#exportchatinvitelink """
p = _strip(locals())
return self._api_request('exportChatInviteLink', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#exportchatinvitelink"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L779-L782 | [
"def",
"exportChatInviteLink",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'exportChatInviteLink'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.setChatPhoto | See: https://core.telegram.org/bots/api#setchatphoto | telepot/__init__.py | def setChatPhoto(self, chat_id, photo):
""" See: https://core.telegram.org/bots/api#setchatphoto """
p = _strip(locals(), more=['photo'])
return self._api_request_with_file('setChatPhoto', _rectify(p), 'photo', photo) | def setChatPhoto(self, chat_id, photo):
""" See: https://core.telegram.org/bots/api#setchatphoto """
p = _strip(locals(), more=['photo'])
return self._api_request_with_file('setChatPhoto', _rectify(p), 'photo', photo) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#setchatphoto"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L784-L787 | [
"def",
"setChatPhoto",
"(",
"self",
",",
"chat_id",
",",
"photo",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'photo'",
"]",
")",
"return",
"self",
".",
"_api_request_with_file",
"(",
"'setChatPhoto'",
",",
"_rectify",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.deleteChatPhoto | See: https://core.telegram.org/bots/api#deletechatphoto | telepot/__init__.py | def deleteChatPhoto(self, chat_id):
""" See: https://core.telegram.org/bots/api#deletechatphoto """
p = _strip(locals())
return self._api_request('deleteChatPhoto', _rectify(p)) | def deleteChatPhoto(self, chat_id):
""" See: https://core.telegram.org/bots/api#deletechatphoto """
p = _strip(locals())
return self._api_request('deleteChatPhoto', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#deletechatphoto"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L789-L792 | [
"def",
"deleteChatPhoto",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'deleteChatPhoto'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.leaveChat | See: https://core.telegram.org/bots/api#leavechat | telepot/__init__.py | def leaveChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#leavechat """
p = _strip(locals())
return self._api_request('leaveChat', _rectify(p)) | def leaveChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#leavechat """
p = _strip(locals())
return self._api_request('leaveChat', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#leavechat"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L816-L819 | [
"def",
"leaveChat",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'leaveChat'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.getChat | See: https://core.telegram.org/bots/api#getchat | telepot/__init__.py | def getChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchat """
p = _strip(locals())
return self._api_request('getChat', _rectify(p)) | def getChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchat """
p = _strip(locals())
return self._api_request('getChat', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#getchat"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L821-L824 | [
"def",
"getChat",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'getChat'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.getChatAdministrators | See: https://core.telegram.org/bots/api#getchatadministrators | telepot/__init__.py | def getChatAdministrators(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatadministrators """
p = _strip(locals())
return self._api_request('getChatAdministrators', _rectify(p)) | def getChatAdministrators(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatadministrators """
p = _strip(locals())
return self._api_request('getChatAdministrators', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#getchatadministrators"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L826-L829 | [
"def",
"getChatAdministrators",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'getChatAdministrators'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.getChatMembersCount | See: https://core.telegram.org/bots/api#getchatmemberscount | telepot/__init__.py | def getChatMembersCount(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatmemberscount """
p = _strip(locals())
return self._api_request('getChatMembersCount', _rectify(p)) | def getChatMembersCount(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatmemberscount """
p = _strip(locals())
return self._api_request('getChatMembersCount', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#getchatmemberscount"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L831-L834 | [
"def",
"getChatMembersCount",
"(",
"self",
",",
"chat_id",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'getChatMembersCount'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.answerShippingQuery | See: https://core.telegram.org/bots/api#answershippingquery | telepot/__init__.py | def answerShippingQuery(self, shipping_query_id, ok,
shipping_options=None,
error_message=None):
""" See: https://core.telegram.org/bots/api#answershippingquery """
p = _strip(locals())
return self._api_request('answerShippingQuery', _recti... | def answerShippingQuery(self, shipping_query_id, ok,
shipping_options=None,
error_message=None):
""" See: https://core.telegram.org/bots/api#answershippingquery """
p = _strip(locals())
return self._api_request('answerShippingQuery', _recti... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#answershippingquery"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L860-L865 | [
"def",
"answerShippingQuery",
"(",
"self",
",",
"shipping_query_id",
",",
"ok",
",",
"shipping_options",
"=",
"None",
",",
"error_message",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.answerPreCheckoutQuery | See: https://core.telegram.org/bots/api#answerprecheckoutquery | telepot/__init__.py | def answerPreCheckoutQuery(self, pre_checkout_query_id, ok,
error_message=None):
""" See: https://core.telegram.org/bots/api#answerprecheckoutquery """
p = _strip(locals())
return self._api_request('answerPreCheckoutQuery', _rectify(p)) | def answerPreCheckoutQuery(self, pre_checkout_query_id, ok,
error_message=None):
""" See: https://core.telegram.org/bots/api#answerprecheckoutquery """
p = _strip(locals())
return self._api_request('answerPreCheckoutQuery', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#answerprecheckoutquery"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L867-L871 | [
"def",
"answerPreCheckoutQuery",
"(",
"self",
",",
"pre_checkout_query_id",
",",
"ok",
",",
"error_message",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'answerPreCheckoutQuery'",
",",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.editMessageText | See: https://core.telegram.org/bots/api#editmessagetext
:param msg_identifier:
a 2-tuple (``chat_id``, ``message_id``),
a 1-tuple (``inline_message_id``),
or simply ``inline_message_id``.
You may extract this value easily with :meth:`telepot.message_identifier` | telepot/__init__.py | def editMessageText(self, msg_identifier, text,
parse_mode=None,
disable_web_page_preview=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#editmessagetext
:param msg_identifier:
a 2-tuple (`... | def editMessageText(self, msg_identifier, text,
parse_mode=None,
disable_web_page_preview=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#editmessagetext
:param msg_identifier:
a 2-tuple (`... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#editmessagetext"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L873-L888 | [
"def",
"editMessageText",
"(",
"self",
",",
"msg_identifier",
",",
"text",
",",
"parse_mode",
"=",
"None",
",",
"disable_web_page_preview",
"=",
"None",
",",
"reply_markup",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.editMessageCaption | See: https://core.telegram.org/bots/api#editmessagecaption
:param msg_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText` | telepot/__init__.py | def editMessageCaption(self, msg_identifier,
caption=None,
parse_mode=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#editmessagecaption
:param msg_identifier: Same as ``msg_identifier`` in :m... | def editMessageCaption(self, msg_identifier,
caption=None,
parse_mode=None,
reply_markup=None):
"""
See: https://core.telegram.org/bots/api#editmessagecaption
:param msg_identifier: Same as ``msg_identifier`` in :m... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#editmessagecaption"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L890-L901 | [
"def",
"editMessageCaption",
"(",
"self",
",",
"msg_identifier",
",",
"caption",
"=",
"None",
",",
"parse_mode",
"=",
"None",
",",
"reply_markup",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'msg_identifier... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.uploadStickerFile | See: https://core.telegram.org/bots/api#uploadstickerfile | telepot/__init__.py | def uploadStickerFile(self, user_id, png_sticker):
"""
See: https://core.telegram.org/bots/api#uploadstickerfile
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rectify(p), 'png_sticker', png_sticker) | def uploadStickerFile(self, user_id, png_sticker):
"""
See: https://core.telegram.org/bots/api#uploadstickerfile
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rectify(p), 'png_sticker', png_sticker) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#uploadstickerfile"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L945-L950 | [
"def",
"uploadStickerFile",
"(",
"self",
",",
"user_id",
",",
"png_sticker",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'png_sticker'",
"]",
")",
"return",
"self",
".",
"_api_request_with_file",
"(",
"'uploadStickerFile'",... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.createNewStickerSet | See: https://core.telegram.org/bots/api#createnewstickerset | telepot/__init__.py | def createNewStickerSet(self, user_id, name, title, png_sticker, emojis,
contains_masks=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#createnewstickerset
"""
p = _strip(locals(), more=['png_sticker'])
... | def createNewStickerSet(self, user_id, name, title, png_sticker, emojis,
contains_masks=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#createnewstickerset
"""
p = _strip(locals(), more=['png_sticker'])
... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#createnewstickerset"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L952-L959 | [
"def",
"createNewStickerSet",
"(",
"self",
",",
"user_id",
",",
"name",
",",
"title",
",",
"png_sticker",
",",
"emojis",
",",
"contains_masks",
"=",
"None",
",",
"mask_position",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.addStickerToSet | See: https://core.telegram.org/bots/api#addstickertoset | telepot/__init__.py | def addStickerToSet(self, user_id, name, png_sticker, emojis,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#addstickertoset
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('addStickerToSet', _rectify(p),... | def addStickerToSet(self, user_id, name, png_sticker, emojis,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#addstickertoset
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('addStickerToSet', _rectify(p),... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#addstickertoset"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L961-L967 | [
"def",
"addStickerToSet",
"(",
"self",
",",
"user_id",
",",
"name",
",",
"png_sticker",
",",
"emojis",
",",
"mask_position",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'png_sticker'",
"]",
")",
"return",... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.setStickerPositionInSet | See: https://core.telegram.org/bots/api#setstickerpositioninset | telepot/__init__.py | def setStickerPositionInSet(self, sticker, position):
"""
See: https://core.telegram.org/bots/api#setstickerpositioninset
"""
p = _strip(locals())
return self._api_request('setStickerPositionInSet', _rectify(p)) | def setStickerPositionInSet(self, sticker, position):
"""
See: https://core.telegram.org/bots/api#setstickerpositioninset
"""
p = _strip(locals())
return self._api_request('setStickerPositionInSet', _rectify(p)) | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#setstickerpositioninset"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L969-L974 | [
"def",
"setStickerPositionInSet",
"(",
"self",
",",
"sticker",
",",
"position",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'setStickerPositionInSet'",
",",
"_rectify",
"(",
"p",
")",
")"
] | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.setGameScore | See: https://core.telegram.org/bots/api#setgamescore
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText` | telepot/__init__.py | def setGameScore(self, user_id, score, game_message_identifier,
force=None,
disable_edit_message=None):
"""
See: https://core.telegram.org/bots/api#setgamescore
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessage... | def setGameScore(self, user_id, score, game_message_identifier,
force=None,
disable_edit_message=None):
"""
See: https://core.telegram.org/bots/api#setgamescore
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessage... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#setgamescore"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L1024-L1034 | [
"def",
"setGameScore",
"(",
"self",
",",
"user_id",
",",
"score",
",",
"game_message_identifier",
",",
"force",
"=",
"None",
",",
"disable_edit_message",
"=",
"None",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'game_me... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.getGameHighScores | See: https://core.telegram.org/bots/api#getgamehighscores
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText` | telepot/__init__.py | def getGameHighScores(self, user_id, game_message_identifier):
"""
See: https://core.telegram.org/bots/api#getgamehighscores
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText`
"""
p = _strip(locals(), more=['game_message_identifier'... | def getGameHighScores(self, user_id, game_message_identifier):
"""
See: https://core.telegram.org/bots/api#getgamehighscores
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText`
"""
p = _strip(locals(), more=['game_message_identifier'... | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#getgamehighscores"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L1036-L1044 | [
"def",
"getGameHighScores",
"(",
"self",
",",
"user_id",
",",
"game_message_identifier",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
",",
"more",
"=",
"[",
"'game_message_identifier'",
"]",
")",
"p",
".",
"update",
"(",
"_dismantle_message_identifie... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | Bot.download_file | Download a file to local disk.
:param dest: a path or a ``file`` object | telepot/__init__.py | def download_file(self, file_id, dest):
"""
Download a file to local disk.
:param dest: a path or a ``file`` object
"""
f = self.getFile(file_id)
try:
d = dest if _isfile(dest) else open(dest, 'wb')
r = api.download((self._token, f['file_path']),... | def download_file(self, file_id, dest):
"""
Download a file to local disk.
:param dest: a path or a ``file`` object
"""
f = self.getFile(file_id)
try:
d = dest if _isfile(dest) else open(dest, 'wb')
r = api.download((self._token, f['file_path']),... | [
"Download",
"a",
"file",
"to",
"local",
"disk",
"."
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L1046-L1068 | [
"def",
"download_file",
"(",
"self",
",",
"file_id",
",",
"dest",
")",
":",
"f",
"=",
"self",
".",
"getFile",
"(",
"file_id",
")",
"try",
":",
"d",
"=",
"dest",
"if",
"_isfile",
"(",
"dest",
")",
"else",
"open",
"(",
"dest",
",",
"'wb'",
")",
"r"... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | per_chat_id_in | :param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is in ``s``
and chat type is in ``types``. | telepot/delegate.py | def per_chat_id_in(s, types='all'):
"""
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is in ``s``
and chat type is in ``types... | def per_chat_id_in(s, types='all'):
"""
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is in ``s``
and chat type is in ``types... | [
":",
"param",
"s",
":",
"a",
"list",
"or",
"set",
"of",
"chat",
"id"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/delegate.py#L27-L42 | [
"def",
"per_chat_id_in",
"(",
"s",
",",
"types",
"=",
"'all'",
")",
":",
"return",
"_wrap_none",
"(",
"lambda",
"msg",
":",
"msg",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
"if",
"(",
"types",
"==",
"'all'",
"or",
"msg",
"[",
"'chat'",
"]",
"[",
"'type... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | per_chat_id_except | :param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is *not* in ``s``
and chat type is in ``types``. | telepot/delegate.py | def per_chat_id_except(s, types='all'):
"""
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is *not* in ``s``
and chat type is ... | def per_chat_id_except(s, types='all'):
"""
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is *not* in ``s``
and chat type is ... | [
":",
"param",
"s",
":",
"a",
"list",
"or",
"set",
"of",
"chat",
"id"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/delegate.py#L44-L59 | [
"def",
"per_chat_id_except",
"(",
"s",
",",
"types",
"=",
"'all'",
")",
":",
"return",
"_wrap_none",
"(",
"lambda",
"msg",
":",
"msg",
"[",
"'chat'",
"]",
"[",
"'id'",
"]",
"if",
"(",
"types",
"==",
"'all'",
"or",
"msg",
"[",
"'chat'",
"]",
"[",
"'... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
train | per_from_id | :param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the message flavor is
in ``flavors``. | telepot/delegate.py | def per_from_id(flavors=chat_flavors+inline_flavors):
"""
:param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the message flavor is
in ``flavors``.
"""
return _wrap_none(lambda msg:
msg['from']['i... | def per_from_id(flavors=chat_flavors+inline_flavors):
"""
:param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the message flavor is
in ``flavors``.
"""
return _wrap_none(lambda msg:
msg['from']['i... | [
":",
"param",
"flavors",
":",
"all",
"or",
"a",
"list",
"of",
"flavors"
] | nickoala/telepot | python | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/delegate.py#L61-L73 | [
"def",
"per_from_id",
"(",
"flavors",
"=",
"chat_flavors",
"+",
"inline_flavors",
")",
":",
"return",
"_wrap_none",
"(",
"lambda",
"msg",
":",
"msg",
"[",
"'from'",
"]",
"[",
"'id'",
"]",
"if",
"flavors",
"==",
"'all'",
"or",
"flavor",
"(",
"msg",
")",
... | 3792fde251d0f1d5a6ca16c8ad1a71f89360c41d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.