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 | Compare._pct_diff | Calculates and colorizes the percent difference between @best
and @other | vital/debug/__init__.py | def _pct_diff(self, best, other):
""" Calculates and colorizes the percent difference between @best
and @other
"""
return colorize("{}%".format(
round(((best-other)/best)*100, 2)).rjust(10), "red") | def _pct_diff(self, best, other):
""" Calculates and colorizes the percent difference between @best
and @other
"""
return colorize("{}%".format(
round(((best-other)/best)*100, 2)).rjust(10), "red") | [
"Calculates",
"and",
"colorizes",
"the",
"percent",
"difference",
"between"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2367-L2372 | [
"def",
"_pct_diff",
"(",
"self",
",",
"best",
",",
"other",
")",
":",
"return",
"colorize",
"(",
"\"{}%\"",
".",
"format",
"(",
"round",
"(",
"(",
"(",
"best",
"-",
"other",
")",
"/",
"best",
")",
"*",
"100",
",",
"2",
")",
")",
".",
"rjust",
"... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | Compare.info | Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results | vital/debug/__init__.py | def info(self, verbose=None):
""" Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results
"""
if se... | def info(self, verbose=None):
""" Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results
"""
if se... | [
"Prints",
"and",
"formats",
"the",
"results",
"of",
"the",
"timing"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2374-L2408 | [
"def",
"info",
"(",
"self",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"self",
".",
"name",
":",
"flag",
"(",
"bold",
"(",
"self",
".",
"name",
")",
")",
"flag",
"(",
"\"Results after {} intervals\"",
".",
"format",
"(",
"bold",
"(",
"self",
".",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | fi_iban_load_map | Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file name of the BIC definitions. Columns: National ID, BIC C... | jutil/management/commands/bank_const_fi.py | def fi_iban_load_map(filename: str) -> dict:
"""
Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file... | def fi_iban_load_map(filename: str) -> dict:
"""
Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file... | [
"Loads",
"Finnish",
"monetary",
"institution",
"codes",
"and",
"BICs",
"in",
"CSV",
"format",
".",
"Map",
"which",
"is",
"based",
"on",
"3",
"digits",
"as",
"in",
"FIXX<3",
"digits",
">",
".",
"Can",
"be",
"used",
"to",
"map",
"Finnish",
"IBAN",
"number"... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/management/commands/bank_const_fi.py#L9-L30 | [
"def",
"fi_iban_load_map",
"(",
"filename",
":",
"str",
")",
"->",
"dict",
":",
"out",
"=",
"{",
"}",
"with",
"open",
"(",
"filename",
",",
"'rt'",
")",
"as",
"fp",
":",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"','",... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | async_lru | An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
.. | vital/cache/async_decorators.py | def async_lru(size=100):
""" An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
..
"""
cache = collections.OrderedDict()
def decorator(fn):
... | def async_lru(size=100):
""" An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
..
"""
cache = collections.OrderedDict()
def decorator(fn):
... | [
"An",
"LRU",
"cache",
"for",
"asyncio",
"coroutines",
"in",
"Python",
"3",
".",
"5",
".."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/async_decorators.py#L7-L31 | [
"def",
"async_lru",
"(",
"size",
"=",
"100",
")",
":",
"cache",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"@",
"asyncio",
".",
"coroutine",
"def",
"memoizer",
"(",
"*",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | choices_label | Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None | jutil/dict.py | def choices_label(choices: tuple, value) -> str:
"""
Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None
"""
for key, label in choices:
if key == value:
... | def choices_label(choices: tuple, value) -> str:
"""
Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None
"""
for key, label in choices:
if key == value:
... | [
"Iterates",
"(",
"value",
"label",
")",
"list",
"and",
"returns",
"label",
"matching",
"the",
"choice",
":",
"param",
"choices",
":",
"[",
"(",
"choice1",
"label1",
")",
"(",
"choice2",
"label2",
")",
"...",
"]",
":",
"param",
"value",
":",
"Value",
"t... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/dict.py#L13-L23 | [
"def",
"choices_label",
"(",
"choices",
":",
"tuple",
",",
"value",
")",
"->",
"str",
":",
"for",
"key",
",",
"label",
"in",
"choices",
":",
"if",
"key",
"==",
"value",
":",
"return",
"label",
"return",
"''"
] | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | info | Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build. | src/peltak/core/log.py | def info(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-... | def info(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-... | [
"Print",
"sys",
"message",
"to",
"stdout",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L28-L38 | [
"def",
"info",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> None",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | err | Per step status messages
Use this locally in a command definition to highlight more important
information. | src/peltak/core/log.py | def err(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Per step status messages
Use this locally in a command definition to highlight more important
information.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-- <31>{}<0>'.format(msg)) | def err(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Per step status messages
Use this locally in a command definition to highlight more important
information.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-- <31>{}<0>'.format(msg)) | [
"Per",
"step",
"status",
"messages"
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L41-L51 | [
"def",
"err",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> None",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | is_username | Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool | vital/tools/strings.py | def is_username(string, minlen=1, maxlen=15):
""" Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool
"""
if string:
string = string.strip()
ret... | def is_username(string, minlen=1, maxlen=15):
""" Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool
"""
if string:
string = string.strip()
ret... | [
"Determines",
"whether",
"the",
"@string",
"pattern",
"is",
"username",
"-",
"like",
"@string",
":",
"#str",
"being",
"tested",
"@minlen",
":",
"minimum",
"required",
"username",
"length",
"@maxlen",
":",
"maximum",
"username",
"length"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L61-L72 | [
"def",
"is_username",
"(",
"string",
",",
"minlen",
"=",
"1",
",",
"maxlen",
"=",
"15",
")",
":",
"if",
"string",
":",
"string",
"=",
"string",
".",
"strip",
"(",
")",
"return",
"username_re",
".",
"match",
"(",
"string",
")",
"and",
"(",
"minlen",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | bigint_to_string | Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val | vital/tools/strings.py | def bigint_to_string(val):
""" Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val
"""
if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1:
return str(val)
return val | def bigint_to_string(val):
""" Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val
"""
if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1:
return str(val)
return val | [
"Converts",
"@val",
"to",
"a",
"string",
"if",
"it",
"is",
"a",
"big",
"integer",
"(",
"|",
">",
"2",
"**",
"53",
"-",
"1|",
")"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L91-L100 | [
"def",
"bigint_to_string",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"_NUMBERS",
")",
"and",
"not",
"abs",
"(",
"val",
")",
"<=",
"2",
"**",
"53",
"-",
"1",
":",
"return",
"str",
"(",
"val",
")",
"return",
"val"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | rbigint_to_string | Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects | vital/tools/strings.py | def rbigint_to_string(obj):
""" Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects
"""
if isinstance(obj, (str, bytes)) or not obj:
# the input is the desired one, return as is
return ob... | def rbigint_to_string(obj):
""" Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects
"""
if isinstance(obj, (str, bytes)) or not obj:
# the input is the desired one, return as is
return ob... | [
"Recursively",
"converts",
"big",
"integers",
"(",
"|",
">",
"2",
"**",
"53",
"-",
"1|",
")",
"to",
"strings"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L104-L127 | [
"def",
"rbigint_to_string",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"str",
",",
"bytes",
")",
")",
"or",
"not",
"obj",
":",
"# the input is the desired one, return as is",
"return",
"obj",
"elif",
"hasattr",
"(",
"obj",
",",
"'items'"... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | remove_blank_lines | Removes all blank lines in @string
-> #str without blank lines | vital/tools/strings.py | def remove_blank_lines(string):
""" Removes all blank lines in @string
-> #str without blank lines
"""
return "\n".join(line
for line in string.split("\n")
if len(line.strip())) | def remove_blank_lines(string):
""" Removes all blank lines in @string
-> #str without blank lines
"""
return "\n".join(line
for line in string.split("\n")
if len(line.strip())) | [
"Removes",
"all",
"blank",
"lines",
"in",
"@string"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L214-L221 | [
"def",
"remove_blank_lines",
"(",
"string",
")",
":",
"return",
"\"\\n\"",
".",
"join",
"(",
"line",
"for",
"line",
"in",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"len",
"(",
"line",
".",
"strip",
"(",
")",
")",
")"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | _manage_cmd | Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter). | src/peltak_django/cli.py | def _manage_cmd(cmd, settings=None):
# type: () -> None
""" Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter).
"""
import sys
from os import environ
from peltak.core import conf
from peltak.core import context
... | def _manage_cmd(cmd, settings=None):
# type: () -> None
""" Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter).
"""
import sys
from os import environ
from peltak.core import conf
from peltak.core import context
... | [
"Run",
"django",
".",
"/",
"manage",
".",
"py",
"command",
"manually",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_django/cli.py#L172-L196 | [
"def",
"_manage_cmd",
"(",
"cmd",
",",
"settings",
"=",
"None",
")",
":",
"# type: () -> None",
"import",
"sys",
"from",
"os",
"import",
"environ",
"from",
"peltak",
".",
"core",
"import",
"conf",
"from",
"peltak",
".",
"core",
"import",
"context",
"from",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | current_branch | Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch. | src/peltak/core/git.py | def current_branch():
# type: () -> BranchDetails
""" Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch.
"""
cmd = 'git symbolic-ref --short HEAD'
branch_name = shell.run(
cmd,
capture=True,
never_pretend=Tr... | def current_branch():
# type: () -> BranchDetails
""" Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch.
"""
cmd = 'git symbolic-ref --short HEAD'
branch_name = shell.run(
cmd,
capture=True,
never_pretend=Tr... | [
"Return",
"the",
"BranchDetails",
"for",
"the",
"current",
"branch",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L181-L195 | [
"def",
"current_branch",
"(",
")",
":",
"# type: () -> BranchDetails",
"cmd",
"=",
"'git symbolic-ref --short HEAD'",
"branch_name",
"=",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | commit_branches | Get the name of the branches that this commit belongs to. | src/peltak/core/git.py | def commit_branches(sha1):
# type: (str) -> List[str]
""" Get the name of the branches that this commit belongs to. """
cmd = 'git branch --contains {}'.format(sha1)
return shell.run(
cmd,
capture=True,
never_pretend=True
).stdout.strip().split() | def commit_branches(sha1):
# type: (str) -> List[str]
""" Get the name of the branches that this commit belongs to. """
cmd = 'git branch --contains {}'.format(sha1)
return shell.run(
cmd,
capture=True,
never_pretend=True
).stdout.strip().split() | [
"Get",
"the",
"name",
"of",
"the",
"branches",
"that",
"this",
"commit",
"belongs",
"to",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L226-L234 | [
"def",
"commit_branches",
"(",
"sha1",
")",
":",
"# type: (str) -> List[str]",
"cmd",
"=",
"'git branch --contains {}'",
".",
"format",
"(",
"sha1",
")",
"return",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | guess_base_branch | Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases but anything a bit crazy will probably
trip this function.
Returns:... | src/peltak/core/git.py | def guess_base_branch():
# type: (str) -> Optional[str, None]
""" Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases bu... | def guess_base_branch():
# type: (str) -> Optional[str, None]
""" Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases bu... | [
"Try",
"to",
"guess",
"the",
"base",
"branch",
"for",
"the",
"current",
"branch",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L238-L291 | [
"def",
"guess_base_branch",
"(",
")",
":",
"# type: (str) -> Optional[str, None]",
"my_branch",
"=",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
".",
"name",
"curr",
"=",
"latest_commit",
"(",
")",
"if",
"len",
"(",
"curr",
".",
"branches",
")",
">",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | commit_author | Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with the commit author details. | src/peltak/core/git.py | def commit_author(sha1=''):
# type: (str) -> Author
""" Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with t... | def commit_author(sha1=''):
# type: (str) -> Author
""" Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with t... | [
"Return",
"the",
"author",
"of",
"the",
"given",
"commit",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L295-L314 | [
"def",
"commit_author",
"(",
"sha1",
"=",
"''",
")",
":",
"# type: (str) -> Author",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"cmd",
"=",
"'git show -s --format=\"%an||%ae\" {}'",
".",
"format",
"(",
"sha1",
")",
"result",
"=",
"shell",
".",
"run... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | unstaged | Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo. | src/peltak/core/git.py | def unstaged():
# type: () -> List[str]
""" Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo.
"""
with conf.within_proj_dir():
status = shell.run(
'git status --porcelain',
captur... | def unstaged():
# type: () -> List[str]
""" Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo.
"""
with conf.within_proj_dir():
status = shell.run(
'git status --porcelain',
captur... | [
"Return",
"a",
"list",
"of",
"unstaged",
"files",
"in",
"the",
"project",
"repository",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L341-L360 | [
"def",
"unstaged",
"(",
")",
":",
"# type: () -> List[str]",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"status",
"=",
"shell",
".",
"run",
"(",
"'git status --porcelain'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | ignore | Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git. | src/peltak/core/git.py | def ignore():
# type: () -> List[str]
""" Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git.
"""
def parse_line(line): # pylint: disable=missing-docstring
# Decode if necessary
if not isinstance(line, string_... | def ignore():
# type: () -> List[str]
""" Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git.
"""
def parse_line(line): # pylint: disable=missing-docstring
# Decode if necessary
if not isinstance(line, string_... | [
"Return",
"a",
"list",
"of",
"patterns",
"in",
"the",
"project",
".",
"gitignore"
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L387-L420 | [
"def",
"ignore",
"(",
")",
":",
"# type: () -> List[str]",
"def",
"parse_line",
"(",
"line",
")",
":",
"# pylint: disable=missing-docstring",
"# Decode if necessary",
"if",
"not",
"isinstance",
"(",
"line",
",",
"string_types",
")",
":",
"line",
"=",
"line",
".",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | branches | Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo. | src/peltak/core/git.py | def branches():
# type: () -> List[str]
""" Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo.
"""
out = shell.run(
'git branch',
capture=True,
never_pretend=True
).stdout.strip()
return [x.strip('* \t\n... | def branches():
# type: () -> List[str]
""" Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo.
"""
out = shell.run(
'git branch',
capture=True,
never_pretend=True
).stdout.strip()
return [x.strip('* \t\n... | [
"Return",
"a",
"list",
"of",
"branches",
"in",
"the",
"current",
"repo",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L424-L436 | [
"def",
"branches",
"(",
")",
":",
"# type: () -> List[str]",
"out",
"=",
"shell",
".",
"run",
"(",
"'git branch'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"return",
"[",
"x",
".",
"str... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | tag | Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. Will default to the author of the commit.
pretend (bool):
If set to **... | src/peltak/core/git.py | def tag(name, message, author=None):
# type: (str, str, Author, bool) -> None
""" Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. ... | def tag(name, message, author=None):
# type: (str, str, Author, bool) -> None
""" Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. ... | [
"Tag",
"the",
"current",
"commit",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L439-L462 | [
"def",
"tag",
"(",
"name",
",",
"message",
",",
"author",
"=",
"None",
")",
":",
"# type: (str, str, Author, bool) -> None",
"cmd",
"=",
"(",
"'git -c \"user.name={author.name}\" -c \"user.email={author.email}\" '",
"'tag -a \"{name}\" -m \"{message}\"'",
")",
".",
"format",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | config | Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``. | src/peltak/core/git.py | def config():
# type: () -> dict[str, Any]
""" Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``.
"""
out = shell.run(
'git config --list',
capture=True,
never_pretend=True
).stdout.strip()
... | def config():
# type: () -> dict[str, Any]
""" Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``.
"""
out = shell.run(
'git config --list',
capture=True,
never_pretend=True
).stdout.strip()
... | [
"Return",
"the",
"current",
"git",
"configuration",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L466-L484 | [
"def",
"config",
"(",
")",
":",
"# type: () -> dict[str, Any]",
"out",
"=",
"shell",
".",
"run",
"(",
"'git config --list'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"result",
"=",
"{",
"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | tags | Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting). | src/peltak/core/git.py | def tags():
# type: () -> List[str]
""" Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting).
"""
return shell.run(
'g... | def tags():
# type: () -> List[str]
""" Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting).
"""
return shell.run(
'g... | [
"Returns",
"all",
"tags",
"in",
"the",
"repo",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L488-L502 | [
"def",
"tags",
"(",
")",
":",
"# type: () -> List[str]",
"return",
"shell",
".",
"run",
"(",
"'git tag --sort=v:refname'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | verify_branch | Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise. | src/peltak/core/git.py | def verify_branch(branch_name):
# type: (str) -> bool
""" Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise.
"""
try:
sh... | def verify_branch(branch_name):
# type: (str) -> bool
""" Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise.
"""
try:
sh... | [
"Verify",
"if",
"the",
"given",
"branch",
"exists",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L505-L524 | [
"def",
"verify_branch",
"(",
"branch_name",
")",
":",
"# type: (str) -> bool",
"try",
":",
"shell",
".",
"run",
"(",
"'git rev-parse --verify {}'",
".",
"format",
"(",
"branch_name",
")",
",",
"never_pretend",
"=",
"True",
")",
"return",
"True",
"except",
"IOErr... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | protected_branches | Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted. | src/peltak/core/git.py | def protected_branches():
# type: () -> list[str]
""" Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted.
"""
master = conf.get('git.master_branch', '... | def protected_branches():
# type: () -> list[str]
""" Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted.
"""
master = conf.get('git.master_branch', '... | [
"Return",
"branches",
"protected",
"by",
"deletion",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L528-L539 | [
"def",
"protected_branches",
"(",
")",
":",
"# type: () -> list[str]",
"master",
"=",
"conf",
".",
"get",
"(",
"'git.master_branch'",
",",
"'master'",
")",
"develop",
"=",
"conf",
".",
"get",
"(",
"'git.devel_branch'",
",",
"'develop'",
")",
"return",
"conf",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | CommitDetails.branches | List of all branches this commit is a part of. | src/peltak/core/git.py | def branches(self):
# type: () -> List[str]
""" List of all branches this commit is a part of. """
if self._branches is None:
cmd = 'git branch --contains {}'.format(self.sha1)
out = shell.run(
cmd,
capture=True,
never_prete... | def branches(self):
# type: () -> List[str]
""" List of all branches this commit is a part of. """
if self._branches is None:
cmd = 'git branch --contains {}'.format(self.sha1)
out = shell.run(
cmd,
capture=True,
never_prete... | [
"List",
"of",
"all",
"branches",
"this",
"commit",
"is",
"a",
"part",
"of",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L107-L119 | [
"def",
"branches",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"if",
"self",
".",
"_branches",
"is",
"None",
":",
"cmd",
"=",
"'git branch --contains {}'",
".",
"format",
"(",
"self",
".",
"sha1",
")",
"out",
"=",
"shell",
".",
"run",
"(",
"cmd",
"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | CommitDetails.parents | Parents of the this commit. | src/peltak/core/git.py | def parents(self):
# type: () -> List[CommitDetails]
""" Parents of the this commit. """
if self._parents is None:
self._parents = [CommitDetails.get(x) for x in self.parents_sha1]
return self._parents | def parents(self):
# type: () -> List[CommitDetails]
""" Parents of the this commit. """
if self._parents is None:
self._parents = [CommitDetails.get(x) for x in self.parents_sha1]
return self._parents | [
"Parents",
"of",
"the",
"this",
"commit",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L122-L128 | [
"def",
"parents",
"(",
"self",
")",
":",
"# type: () -> List[CommitDetails]",
"if",
"self",
".",
"_parents",
"is",
"None",
":",
"self",
".",
"_parents",
"=",
"[",
"CommitDetails",
".",
"get",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"parents_sha1",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | CommitDetails.number | Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be two commits with the
same number existing on diff... | src/peltak/core/git.py | def number(self):
# type: () -> int
""" Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be t... | def number(self):
# type: () -> int
""" Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be t... | [
"Return",
"this",
"commits",
"number",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L131-L147 | [
"def",
"number",
"(",
"self",
")",
":",
"# type: () -> int",
"cmd",
"=",
"'git log --oneline {}'",
".",
"format",
"(",
"self",
".",
"sha1",
")",
"out",
"=",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | CommitDetails.get | Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetails: Commit details. You can use the instance of the
class to q... | src/peltak/core/git.py | def get(cls, sha1=''):
# type: (str) -> CommitDetails
""" Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetai... | def get(cls, sha1=''):
# type: (str) -> CommitDetails
""" Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetai... | [
"Return",
"details",
"about",
"a",
"given",
"commit",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L150-L177 | [
"def",
"get",
"(",
"cls",
",",
"sha1",
"=",
"''",
")",
":",
"# type: (str) -> CommitDetails",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"cmd",
"=",
"'git show -s --format=\"%H||%an||%ae||%s||%b||%P\" {}'",
".",
"format",
"(",
"sha1",
")",
"result",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | main | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | pycons3rt/logify.py | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(Logify.get_name() + '.logify.main')
log.info('logger name is: %s', Logify.get_name())
log.debug('This is DEBUG')
log... | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(Logify.get_name() + '.logify.main')
log.info('logger name is: %s', Logify.get_name())
log.debug('This is DEBUG')
log... | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L127-L140 | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"Logify",
".",
"get_name",
"(",
")",
"+",
"'.logify.main'",
")",
"log",
".",
"info",
"(",
"'logger name is: %s'",
",",
"Logify",
".",
"get_name",
"(",
")",
")",
"log",
".",
"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Logify.set_log_level | Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: True if log level was set, False otherwise. | pycons3rt/logify.py | def set_log_level(cls, log_level):
"""Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: Tru... | def set_log_level(cls, log_level):
"""Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: Tru... | [
"Sets",
"the",
"log",
"level",
"for",
"cons3rt",
"assets"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L83-L117 | [
"def",
"set_log_level",
"(",
"cls",
",",
"log_level",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"cls",
".",
"cls_logger",
"+",
"'.set_log_level'",
")",
"log",
".",
"info",
"(",
"'Attempting to set the log level...'",
")",
"if",
"log_level",
"is",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Connection.get_record_by_name | Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosamples).
name: `str`. The value of a document's name... | pulsarpy/elasticsearch_utils.py | def get_record_by_name(self, index, name):
"""
Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosa... | def get_record_by_name(self, index, name):
"""
Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosa... | [
"Searches",
"for",
"a",
"single",
"document",
"in",
"the",
"given",
"index",
"on",
"the",
"name",
"field",
".",
"Performs",
"a",
"case",
"-",
"insensitive",
"search",
"by",
"utilizing",
"Elasticsearch",
"s",
"match_phrase",
"query",
".",
"Args",
":",
"index"... | nathankw/pulsarpy | python | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/elasticsearch_utils.py#L38-L77 | [
"def",
"get_record_by_name",
"(",
"self",
",",
"index",
",",
"name",
")",
":",
"result",
"=",
"self",
".",
"ES",
".",
"search",
"(",
"index",
"=",
"index",
",",
"body",
"=",
"{",
"\"query\"",
":",
"{",
"\"match_phrase\"",
":",
"{",
"\"name\"",
":",
"... | 359b040c0f2383b88c0b5548715fefd35f5f634c |
train | getattr_in | Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'| | vital/tools/__init__.py | def getattr_in(obj, name):
""" Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'|
"""
for p... | def getattr_in(obj, name):
""" Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'|
"""
for p... | [
"Finds",
"an",
"in"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L20-L32 | [
"def",
"getattr_in",
"(",
"obj",
",",
"name",
")",
":",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"part",
")",
"return",
"obj"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | import_from | Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object | vital/tools/__init__.py | def import_from(name):
""" Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object
"""
obj = name
if isinstance(name, str) and len(name):
try:
obj = locate(name)
... | def import_from(name):
""" Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object
"""
obj = name
if isinstance(name, str) and len(name):
try:
obj = locate(name)
... | [
"Imports",
"a",
"module",
"class",
"or",
"method",
"from",
"string",
"and",
"unwraps",
"it",
"if",
"wrapped",
"by",
"functools"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L35-L67 | [
"def",
"import_from",
"(",
"name",
")",
":",
"obj",
"=",
"name",
"if",
"isinstance",
"(",
"name",
",",
"str",
")",
"and",
"len",
"(",
"name",
")",
":",
"try",
":",
"obj",
"=",
"locate",
"(",
"name",
")",
"assert",
"obj",
"is",
"not",
"None",
"exc... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | unwrap_obj | Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap | vital/tools/__init__.py | def unwrap_obj(obj):
""" Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap
"""
try:
obj = obj.fget
except (AttributeError, TypeError):
pass
try:
# Cached properties
if obj.func.__doc__ == obj.__doc__:
... | def unwrap_obj(obj):
""" Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap
"""
try:
obj = obj.fget
except (AttributeError, TypeError):
pass
try:
# Cached properties
if obj.func.__doc__ == obj.__doc__:
... | [
"Gets",
"the",
"actual",
"object",
"from",
"a",
"decorated",
"or",
"wrapped",
"function"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L70-L94 | [
"def",
"unwrap_obj",
"(",
"obj",
")",
":",
"try",
":",
"obj",
"=",
"obj",
".",
"fget",
"except",
"(",
"AttributeError",
",",
"TypeError",
")",
":",
"pass",
"try",
":",
"# Cached properties",
"if",
"obj",
".",
"func",
".",
"__doc__",
"==",
"obj",
".",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | add_modality | Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name. | bidso/utils.py | def add_modality(output_path, modality):
"""Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name.
"""
if modality is None:
return output_path
el... | def add_modality(output_path, modality):
"""Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name.
"""
if modality is None:
return output_path
el... | [
"Modality",
"can",
"be",
"appended",
"to",
"the",
"file",
"name",
"(",
"such",
"as",
"bold",
")",
"or",
"use",
"in",
"the",
"folder",
"(",
"such",
"as",
"func",
")",
".",
"You",
"should",
"always",
"use",
"the",
"specific",
"modality",
"(",
"bold",
"... | gpiantoni/bidso | python | https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/utils.py#L92-L115 | [
"def",
"add_modality",
"(",
"output_path",
",",
"modality",
")",
":",
"if",
"modality",
"is",
"None",
":",
"return",
"output_path",
"else",
":",
"if",
"modality",
"in",
"(",
"'T1w'",
",",
"'T2star'",
",",
"'FLAIR'",
",",
"'PD'",
")",
":",
"modality",
"="... | af163b921ec4e3d70802de07f174de184491cfce |
train | load | Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf.init()` function).
You can also have ... | src/peltak/core/conf.py | def load():
# type: () -> None
""" Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf... | def load():
# type: () -> None
""" Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf... | [
"Load",
"configuration",
"from",
"file",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L91-L109 | [
"def",
"load",
"(",
")",
":",
"# type: () -> None",
"with",
"within_proj_dir",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"'pelconf.yaml'",
")",
":",
"load_yaml_config",
"(",
"'pelconf.yaml'",
")",
"if",
"os",
".",
"path",
".",
"exists",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | load_yaml_config | Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just crash if the given file does not exist or
is not a valid ... | src/peltak/core/conf.py | def load_yaml_config(conf_file):
# type: (str) -> None
""" Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just cr... | def load_yaml_config(conf_file):
# type: (str) -> None
""" Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just cr... | [
"Load",
"a",
"YAML",
"configuration",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L112-L137 | [
"def",
"load_yaml_config",
"(",
"conf_file",
")",
":",
"# type: (str) -> None",
"global",
"g_config",
"with",
"open",
"(",
"conf_file",
")",
"as",
"fp",
":",
"# Initialize config",
"g_config",
"=",
"util",
".",
"yaml_load",
"(",
"fp",
")",
"# Add src_dir to sys.pa... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | load_py_config | Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.paths if it's not the
current working directory. This is done aut... | src/peltak/core/conf.py | def load_py_config(conf_file):
# type: (str) -> None
""" Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.path... | def load_py_config(conf_file):
# type: (str) -> None
""" Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.path... | [
"Import",
"configuration",
"from",
"a",
"python",
"file",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L140-L171 | [
"def",
"load_py_config",
"(",
"conf_file",
")",
":",
"# type: (str) -> None",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"5",
")",
":",
"from",
"importlib",
"import",
"util",
"spec",
"=",
"util",
".",
"spec_from_file_location",
"(",
"'pelconf'",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | load_template | Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
str: The content of the chosen template. | src/peltak/core/conf.py | def load_template(filename):
# type: (str) -> str
""" Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
... | def load_template(filename):
# type: (str) -> str
""" Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
... | [
"Load",
"template",
"from",
"file",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L174-L190 | [
"def",
"load_template",
"(",
"filename",
")",
":",
"# type: (str) -> str",
"template_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"PKG_DIR",
",",
"'templates'",
",",
"filename",
")",
"with",
"open",
"(",
"template_file",
")",
"as",
"fp",
":",
"return",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | proj_path | Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path. | src/peltak/core/conf.py | def proj_path(*path_parts):
# type: (str) -> str
""" Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path.
"""
path_parts = p... | def proj_path(*path_parts):
# type: (str) -> str
""" Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path.
"""
path_parts = p... | [
"Return",
"absolute",
"path",
"to",
"the",
"repo",
"dir",
"(",
"root",
"project",
"directory",
")",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L204-L224 | [
"def",
"proj_path",
"(",
"*",
"path_parts",
")",
":",
"# type: (str) -> str",
"path_parts",
"=",
"path_parts",
"or",
"[",
"'.'",
"]",
"# If path represented by path_parts is absolute, do not modify it.",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"path_parts",... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | within_proj_dir | Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path. | src/peltak/core/conf.py | def within_proj_dir(path='.'):
# type: (Optional[str]) -> str
""" Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path.
"""
curr_dir = os.getcwd()
... | def within_proj_dir(path='.'):
# type: (Optional[str]) -> str
""" Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path.
"""
curr_dir = os.getcwd()
... | [
"Return",
"an",
"absolute",
"path",
"to",
"the",
"given",
"project",
"relative",
"path",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L228-L244 | [
"def",
"within_proj_dir",
"(",
"path",
"=",
"'.'",
")",
":",
"# type: (Optional[str]) -> str",
"curr_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"proj_path",
"(",
"path",
")",
")",
"yield",
"os",
".",
"chdir",
"(",
"curr_dir",
")"
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | get | Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it's not given and the config value does not exist,
At... | src/peltak/core/conf.py | def get(name, *default):
# type: (str, Any) -> Any
""" Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it'... | def get(name, *default):
# type: (str, Any) -> Any
""" Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it'... | [
"Get",
"config",
"value",
"with",
"the",
"given",
"name",
"and",
"optional",
"default",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L247-L280 | [
"def",
"get",
"(",
"name",
",",
"*",
"default",
")",
":",
"# type: (str, Any) -> Any",
"global",
"g_config",
"curr",
"=",
"g_config",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"if",
"part",
"in",
"curr",
":",
"curr",
"=",
"curr",... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | get_path | Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value containing the path.
*default (Any):
If given and ... | src/peltak/core/conf.py | def get_path(name, *default):
# type: (str, Any) -> Any
""" Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value co... | def get_path(name, *default):
# type: (str, Any) -> Any
""" Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value co... | [
"Get",
"config",
"value",
"as",
"path",
"relative",
"to",
"the",
"project",
"directory",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L283-L313 | [
"def",
"get_path",
"(",
"name",
",",
"*",
"default",
")",
":",
"# type: (str, Any) -> Any",
"global",
"g_config",
"value",
"=",
"get",
"(",
"name",
",",
"*",
"default",
")",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"proj_path",
"(",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | _find_proj_root | Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py) | src/peltak/core/conf.py | def _find_proj_root():
# type: () -> Optional[str]
""" Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py)
"""
proj_files = frozenset(('pelconf.py', 'pelconf.yaml'))
curr = os.getcwd()
while curr.start... | def _find_proj_root():
# type: () -> Optional[str]
""" Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py)
"""
proj_files = frozenset(('pelconf.py', 'pelconf.yaml'))
curr = os.getcwd()
while curr.start... | [
"Find",
"the",
"project",
"path",
"by",
"going",
"up",
"the",
"file",
"tree",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L317-L333 | [
"def",
"_find_proj_root",
"(",
")",
":",
"# type: () -> Optional[str]",
"proj_files",
"=",
"frozenset",
"(",
"(",
"'pelconf.py'",
",",
"'pelconf.yaml'",
")",
")",
"curr",
"=",
"os",
".",
"getcwd",
"(",
")",
"while",
"curr",
".",
"startswith",
"(",
"'/'",
")"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | VerificationHandler.verify | Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return: | tornkts/modules/verification/verification_handler.py | def verify(verified_entity, verification_key):
"""
Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return:
"""
verification = get_object_or_none(Verification, verified_entity=verified_entity)
if verification is ... | def verify(verified_entity, verification_key):
"""
Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return:
"""
verification = get_object_or_none(Verification, verified_entity=verified_entity)
if verification is ... | [
"Метод",
"должен",
"райзить",
"ошибки",
":",
"param",
"verified_entity",
":",
"сущность",
":",
"param",
"verification_key",
":",
"ключ",
":",
"return",
":"
] | ktsstudio/tornkts | python | https://github.com/ktsstudio/tornkts/blob/db47e4550426282960a7e4486dcc4399c8d52e02/tornkts/modules/verification/verification_handler.py#L59-L74 | [
"def",
"verify",
"(",
"verified_entity",
",",
"verification_key",
")",
":",
"verification",
"=",
"get_object_or_none",
"(",
"Verification",
",",
"verified_entity",
"=",
"verified_entity",
")",
"if",
"verification",
"is",
"None",
":",
"raise",
"ServerError",
"(",
"... | db47e4550426282960a7e4486dcc4399c8d52e02 |
train | _xml_element_value | Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str) | jutil/xml.py | def _xml_element_value(el: Element, int_tags: list):
"""
Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str)
"""
# None
if el.text is None:
return None
# int
try:
if el.tag... | def _xml_element_value(el: Element, int_tags: list):
"""
Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str)
"""
# None
if el.text is None:
return None
# int
try:
if el.tag... | [
"Gets",
"XML",
"Element",
"value",
".",
":",
"param",
"el",
":",
"Element",
":",
"param",
"int_tags",
":",
"List",
"of",
"tags",
"that",
"should",
"be",
"treated",
"as",
"ints",
":",
"return",
":",
"value",
"of",
"the",
"element",
"(",
"int",
"/",
"s... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L6-L24 | [
"def",
"_xml_element_value",
"(",
"el",
":",
"Element",
",",
"int_tags",
":",
"list",
")",
":",
"# None",
"if",
"el",
".",
"text",
"is",
"None",
":",
"return",
"None",
"# int",
"try",
":",
"if",
"el",
".",
"tag",
"in",
"int_tags",
":",
"return",
"int... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | _xml_tag_filter | Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str | jutil/xml.py | def _xml_tag_filter(s: str, strip_namespaces: bool) -> str:
"""
Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str
"""
if strip_namespaces:
ns_end = s.find('}')
if ns_end != -1:
s = s[... | def _xml_tag_filter(s: str, strip_namespaces: bool) -> str:
"""
Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str
"""
if strip_namespaces:
ns_end = s.find('}')
if ns_end != -1:
s = s[... | [
"Returns",
"tag",
"name",
"and",
"optionally",
"strips",
"namespaces",
".",
":",
"param",
"el",
":",
"Element",
":",
"param",
"strip_namespaces",
":",
"Strip",
"namespace",
"prefix",
":",
"return",
":",
"str"
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L27-L42 | [
"def",
"_xml_tag_filter",
"(",
"s",
":",
"str",
",",
"strip_namespaces",
":",
"bool",
")",
"->",
"str",
":",
"if",
"strip_namespaces",
":",
"ns_end",
"=",
"s",
".",
"find",
"(",
"'}'",
")",
"if",
"ns_end",
"!=",
"-",
"1",
":",
"s",
"=",
"s",
"[",
... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | xml_to_dict | Parses XML string to dict. In case of simple elements (no children, no attributes) value is stored as is.
For complex elements value is stored in key '@', attributes '@xxx' and children as sub-dicts.
Optionally strips namespaces.
For example:
<Doc version="1.2">
<A class="x">
... | jutil/xml.py | def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[],
strip_namespaces: bool=True, parse_attributes: bool=True,
value_key: str='@', attribute_prefix: str='@',
document_tag: bool=False) -> dict:
"""
Parses XML string to dict. In c... | def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[],
strip_namespaces: bool=True, parse_attributes: bool=True,
value_key: str='@', attribute_prefix: str='@',
document_tag: bool=False) -> dict:
"""
Parses XML string to dict. In c... | [
"Parses",
"XML",
"string",
"to",
"dict",
".",
"In",
"case",
"of",
"simple",
"elements",
"(",
"no",
"children",
"no",
"attributes",
")",
"value",
"is",
"stored",
"as",
"is",
".",
"For",
"complex",
"elements",
"value",
"is",
"stored",
"in",
"key",
"@",
"... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L87-L148 | [
"def",
"xml_to_dict",
"(",
"xml_bytes",
":",
"bytes",
",",
"tags",
":",
"list",
"=",
"[",
"]",
",",
"array_tags",
":",
"list",
"=",
"[",
"]",
",",
"int_tags",
":",
"list",
"=",
"[",
"]",
",",
"strip_namespaces",
":",
"bool",
"=",
"True",
",",
"pars... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | dict_to_element | Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For example:
{
'Doc': {
'@version': '1.2',
'A': [{'@clas... | jutil/xml.py | def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element:
"""
Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For ex... | def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element:
"""
Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For ex... | [
"Generates",
"XML",
"Element",
"from",
"dict",
".",
"Generates",
"complex",
"elements",
"by",
"assuming",
"element",
"attributes",
"are",
"prefixed",
"with",
"@",
"and",
"value",
"is",
"stored",
"to",
"plain",
"@",
"in",
"case",
"of",
"complex",
"element",
"... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L175-L218 | [
"def",
"dict_to_element",
"(",
"doc",
":",
"dict",
",",
"value_key",
":",
"str",
"=",
"'@'",
",",
"attribute_prefix",
":",
"str",
"=",
"'@'",
")",
"->",
"Element",
":",
"from",
"xml",
".",
"etree",
"import",
"ElementTree",
"as",
"ET",
"if",
"len",
"(",... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | local_property | Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp | vital/cache/__init__.py | def local_property():
""" Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp
"""
ls = local()
def fget(self):
try:
return ls.var
except AttributeError:
raise RuntimeError("Request context not initialized.")
def fse... | def local_property():
""" Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp
"""
ls = local()
def fget(self):
try:
return ls.var
except AttributeError:
raise RuntimeError("Request context not initialized.")
def fse... | [
"Property",
"structure",
"which",
"maps",
"within",
"the",
":",
"func",
":",
"local",
"()",
"thread",
"(",
"c",
")",
"2014",
"Marcel",
"Hellkamp"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/__init__.py#L37-L55 | [
"def",
"local_property",
"(",
")",
":",
"ls",
"=",
"local",
"(",
")",
"def",
"fget",
"(",
"self",
")",
":",
"try",
":",
"return",
"ls",
".",
"var",
"except",
"AttributeError",
":",
"raise",
"RuntimeError",
"(",
"\"Request context not initialized.\"",
")",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | download | Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:param download_info: (dict) Contains the... | pycons3rt/awsapi/s3util.py | def download(download_info):
"""Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:para... | def download(download_info):
"""Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:para... | [
"Module",
"method",
"for",
"downloading",
"from",
"S3"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L363-L467 | [
"def",
"download",
"(",
"download_info",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.download'",
")",
"# Ensure the passed arg is a dict",
"if",
"not",
"isinstance",
"(",
"download_info",
",",
"dict",
")",
":",
"msg",
"=",
"'d... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | find_bucket_keys | Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: (str) Regular expression to use is the key search
:param bucket_name:... | pycons3rt/awsapi/s3util.py | def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an emp... | def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an emp... | [
"Finds",
"a",
"list",
"of",
"S3",
"keys",
"matching",
"the",
"passed",
"regex"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L470-L505 | [
"def",
"find_bucket_keys",
"(",
"bucket_name",
",",
"regex",
",",
"region_name",
"=",
"None",
",",
"aws_access_key_id",
"=",
"None",
",",
"aws_secret_access_key",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.find_b... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | main | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | pycons3rt/awsapi/s3util.py | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
log.debug('This is DEBUG!')
log.info('This is INFO!')
log.warning('This is WARNING!')
log.... | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
log.debug('This is DEBUG!')
log.info('This is INFO!')
log.warning('This is WARNING!')
log.... | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L508-L537 | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.main'",
")",
"log",
".",
"debug",
"(",
"'This is DEBUG!'",
")",
"log",
".",
"info",
"(",
"'This is INFO!'",
")",
"log",
".",
"warning",
"(",
"'This is WARNI... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.validate_bucket | Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None | pycons3rt/awsapi/s3util.py | def validate_bucket(self):
"""Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None
"""
log = logging.getLogger(self.cls_logger + '.validate_bucket')
log.info('Attempting to ... | def validate_bucket(self):
"""Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None
"""
log = logging.getLogger(self.cls_logger + '.validate_bucket')
log.info('Attempting to ... | [
"Verify",
"the",
"specified",
"bucket",
"exists"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L85-L131 | [
"def",
"validate_bucket",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.validate_bucket'",
")",
"log",
".",
"info",
"(",
"'Attempting to get bucket: {b}'",
".",
"format",
"(",
"b",
"=",
"self",
".",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.__download_from_s3 | Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:param key: (str) S3... | pycons3rt/awsapi/s3util.py | def __download_from_s3(self, key, dest_dir):
"""Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the spec... | def __download_from_s3(self, key, dest_dir):
"""Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the spec... | [
"Private",
"method",
"for",
"downloading",
"from",
"S3"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L133-L179 | [
"def",
"__download_from_s3",
"(",
"self",
",",
"key",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.__download_from_s3'",
")",
"filename",
"=",
"key",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.download_file_by_key | Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be the
same as it is on S3.
:param key: (str) ... | pycons3rt/awsapi/s3util.py | def download_file_by_key(self, key, dest_dir):
"""Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be th... | def download_file_by_key(self, key, dest_dir):
"""Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be th... | [
"Downloads",
"a",
"file",
"by",
"key",
"from",
"the",
"specified",
"S3",
"bucket"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L181-L208 | [
"def",
"download_file_by_key",
"(",
"self",
",",
"key",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.download_file_by_key'",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"basestring",
")",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.download_file | Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
to be the same as it is on S3.
:param reg... | pycons3rt/awsapi/s3util.py | def download_file(self, regex, dest_dir):
"""Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
... | def download_file(self, regex, dest_dir):
"""Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
... | [
"Downloads",
"a",
"file",
"by",
"regex",
"from",
"the",
"specified",
"S3",
"bucket"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L210-L238 | [
"def",
"download_file",
"(",
"self",
",",
"regex",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.download_file'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"lo... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.find_key | Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expression for an S3 key
:return: (str... | pycons3rt/awsapi/s3util.py | def find_key(self, regex):
"""Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expressi... | def find_key(self, regex):
"""Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expressi... | [
"Attempts",
"to",
"find",
"a",
"single",
"S3",
"key",
"based",
"on",
"the",
"passed",
"regex"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L240-L270 | [
"def",
"find_key",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.find_key'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"log",
".",
"error",
"(",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.find_keys | Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: (str) Regular expression to use is the key search
... | pycons3rt/awsapi/s3util.py | def find_keys(self, regex, bucket_name=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: ... | def find_keys(self, regex, bucket_name=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: ... | [
"Finds",
"a",
"list",
"of",
"S3",
"keys",
"matching",
"the",
"passed",
"regex"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L272-L303 | [
"def",
"find_keys",
"(",
"self",
",",
"regex",
",",
"bucket_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.find_keys'",
")",
"matched_keys",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.upload_file | Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
:return: True if upload is successful, Fals... | pycons3rt/awsapi/s3util.py | def upload_file(self, filepath, key):
"""Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
... | def upload_file(self, filepath, key):
"""Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
... | [
"Uploads",
"a",
"file",
"using",
"the",
"passed",
"S3",
"key"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L305-L341 | [
"def",
"upload_file",
"(",
"self",
",",
"filepath",
",",
"key",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.upload_file'",
")",
"log",
".",
"info",
"(",
"'Attempting to upload file %s to S3 bucket %s as key %s...'",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | S3Util.delete_key | Deletes the specified key
:param key_to_delete:
:return: | pycons3rt/awsapi/s3util.py | def delete_key(self, key_to_delete):
"""Deletes the specified key
:param key_to_delete:
:return:
"""
log = logging.getLogger(self.cls_logger + '.delete_key')
log.info('Attempting to delete key: {k}'.format(k=key_to_delete))
try:
self.s3client.delete_... | def delete_key(self, key_to_delete):
"""Deletes the specified key
:param key_to_delete:
:return:
"""
log = logging.getLogger(self.cls_logger + '.delete_key')
log.info('Attempting to delete key: {k}'.format(k=key_to_delete))
try:
self.s3client.delete_... | [
"Deletes",
"the",
"specified",
"key"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L343-L360 | [
"def",
"delete_key",
"(",
"self",
",",
"key_to_delete",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.delete_key'",
")",
"log",
".",
"info",
"(",
"'Attempting to delete key: {k}'",
".",
"format",
"(",
"k",
"=",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | assert_branch_type | Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format. | src/peltak/extra/gitflow/logic/common.py | def assert_branch_type(branch_type):
# type: (str) -> None
""" Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format.
"""
branch = git.current_branch(refr... | def assert_branch_type(branch_type):
# type: (str) -> None
""" Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format.
"""
branch = git.current_branch(refr... | [
"Print",
"error",
"and",
"exit",
"if",
"the",
"current",
"branch",
"is",
"not",
"of",
"a",
"given",
"type",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L38-L58 | [
"def",
"assert_branch_type",
"(",
"branch_type",
")",
":",
"# type: (str) -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"if",
"branch",
".",
"type",
"!=",
"branch_type",
":",
"if",
"context",
".",
"get",
"(",
"'pret... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | assert_on_branch | Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch. | src/peltak/extra/gitflow/logic/common.py | def assert_on_branch(branch_name):
# type: (str) -> None
""" Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch.
"""
branch = git.current_branch(refresh=True)
if branch.name != branch_name:
... | def assert_on_branch(branch_name):
# type: (str) -> None
""" Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch.
"""
branch = git.current_branch(refresh=True)
if branch.name != branch_name:
... | [
"Print",
"error",
"and",
"exit",
"if",
"*",
"branch_name",
"*",
"is",
"not",
"the",
"current",
"branch",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L61-L77 | [
"def",
"assert_on_branch",
"(",
"branch_name",
")",
":",
"# type: (str) -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"if",
"branch",
".",
"name",
"!=",
"branch_name",
":",
"if",
"context",
".",
"get",
"(",
"'preten... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | git_branch_delete | Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete. | src/peltak/extra/gitflow/logic/common.py | def git_branch_delete(branch_name):
# type: (str) -> None
""" Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete.
"""
if branch_name not in git.protected_branches():
log.info("Deleting branch <33>{}", branch_name)
shell.run('git branch... | def git_branch_delete(branch_name):
# type: (str) -> None
""" Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete.
"""
if branch_name not in git.protected_branches():
log.info("Deleting branch <33>{}", branch_name)
shell.run('git branch... | [
"Delete",
"the",
"given",
"branch",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L80-L90 | [
"def",
"git_branch_delete",
"(",
"branch_name",
")",
":",
"# type: (str) -> None",
"if",
"branch_name",
"not",
"in",
"git",
".",
"protected_branches",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"Deleting branch <33>{}\"",
",",
"branch_name",
")",
"shell",
".",
"r... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | git_branch_rename | Rename the current branch
Args:
new_name (str):
New name for the current branch. | src/peltak/extra/gitflow/logic/common.py | def git_branch_rename(new_name):
# type: (str) -> None
""" Rename the current branch
Args:
new_name (str):
New name for the current branch.
"""
curr_name = git.current_branch(refresh=True).name
if curr_name not in git.protected_branches():
log.info("Renaming branch ... | def git_branch_rename(new_name):
# type: (str) -> None
""" Rename the current branch
Args:
new_name (str):
New name for the current branch.
"""
curr_name = git.current_branch(refresh=True).name
if curr_name not in git.protected_branches():
log.info("Renaming branch ... | [
"Rename",
"the",
"current",
"branch"
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L93-L107 | [
"def",
"git_branch_rename",
"(",
"new_name",
")",
":",
"# type: (str) -> None",
"curr_name",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
".",
"name",
"if",
"curr_name",
"not",
"in",
"git",
".",
"protected_branches",
"(",
")",
":",
"l... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | git_checkout | Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
out. | src/peltak/extra/gitflow/logic/common.py | def git_checkout(branch_name, create=False):
# type: (str, bool) -> None
""" Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
... | def git_checkout(branch_name, create=False):
# type: (str, bool) -> None
""" Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
... | [
"Checkout",
"or",
"create",
"a",
"given",
"branch"
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L110-L122 | [
"def",
"git_checkout",
"(",
"branch_name",
",",
"create",
"=",
"False",
")",
":",
"# type: (str, bool) -> None",
"log",
".",
"info",
"(",
"\"Checking out <33>{}\"",
".",
"format",
"(",
"branch_name",
")",
")",
"shell",
".",
"run",
"(",
"'git checkout {} {}'",
".... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | git_merge | Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
If set to **True** it will force git to create merge commit. If set
to *... | src/peltak/extra/gitflow/logic/common.py | def git_merge(base, head, no_ff=False):
# type: (str, str, bool) -> None
""" Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
... | def git_merge(base, head, no_ff=False):
# type: (str, str, bool) -> None
""" Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
... | [
"Merge",
"*",
"head",
"*",
"into",
"*",
"base",
"*",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L137-L168 | [
"def",
"git_merge",
"(",
"base",
",",
"head",
",",
"no_ff",
"=",
"False",
")",
":",
"# type: (str, str, bool) -> None",
"pretend",
"=",
"context",
".",
"get",
"(",
"'pretend'",
",",
"False",
")",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | get_base_branch | Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current branch is based on. | src/peltak/extra/gitflow/logic/common.py | def get_base_branch():
# type: () -> str
""" Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current bra... | def get_base_branch():
# type: () -> str
""" Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current bra... | [
"Return",
"the",
"base",
"branch",
"for",
"the",
"current",
"branch",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L178-L194 | [
"def",
"get_base_branch",
"(",
")",
":",
"# type: () -> str",
"base_branch",
"=",
"git",
".",
"guess_base_branch",
"(",
")",
"if",
"base_branch",
"is",
"None",
":",
"log",
".",
"info",
"(",
"\"Can't guess the base branch, you have to pick one yourself:\"",
")",
"base_... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | choose_branch | Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branches pass an
empty array here.
Returns:
str: The n... | src/peltak/extra/gitflow/logic/common.py | def choose_branch(exclude=None):
# type: (List[str]) -> str
""" Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branche... | def choose_branch(exclude=None):
# type: (List[str]) -> str
""" Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branche... | [
"Show",
"the",
"user",
"a",
"menu",
"to",
"pick",
"a",
"branch",
"from",
"the",
"existing",
"ones",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L197-L234 | [
"def",
"choose_branch",
"(",
"exclude",
"=",
"None",
")",
":",
"# type: (List[str]) -> str",
"if",
"exclude",
"is",
"None",
":",
"master",
"=",
"conf",
".",
"get",
"(",
"'git.master_branch'",
",",
"'master'",
")",
"develop",
"=",
"conf",
".",
"get",
"(",
"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | autorun | Call the run method of the decorated class if the current file is the main file | chuda/decorators.py | def autorun():
'''
Call the run method of the decorated class if the current file is the main file
'''
def wrapper(cls):
import inspect
if inspect.getmodule(cls).__name__ == "__main__":
cls().run()
return cls
return wrapper | def autorun():
'''
Call the run method of the decorated class if the current file is the main file
'''
def wrapper(cls):
import inspect
if inspect.getmodule(cls).__name__ == "__main__":
cls().run()
return cls
return wrapper | [
"Call",
"the",
"run",
"method",
"of",
"the",
"decorated",
"class",
"if",
"the",
"current",
"file",
"is",
"the",
"main",
"file"
] | Varkal/chuda | python | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/decorators.py#L1-L12 | [
"def",
"autorun",
"(",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"import",
"inspect",
"if",
"inspect",
".",
"getmodule",
"(",
"cls",
")",
".",
"__name__",
"==",
"\"__main__\"",
":",
"cls",
"(",
")",
".",
"run",
"(",
")",
"return",
"cls",
"r... | 0d93b716dede35231c21be97bcc19a656655983f |
train | unique_list | Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list | vital/tools/lists.py | def unique_list(seq):
""" Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list
"""
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))] | def unique_list(seq):
""" Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list
"""
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))] | [
"Removes",
"duplicate",
"elements",
"from",
"given",
"@seq"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L17-L26 | [
"def",
"unique_list",
"(",
"seq",
")",
":",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"return",
"[",
"x",
"for",
"x",
"in",
"seq",
"if",
"not",
"(",
"x",
"in",
"seen",
"or",
"seen_add",
"(",
"x",
")",
")",
"]"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | flatten | Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
.. | vital/tools/lists.py | def flatten(*seqs):
""" Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
..
"""
for seq in seqs:
... | def flatten(*seqs):
""" Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
..
"""
for seq in seqs:
... | [
"Flattens",
"a",
"sequence",
"e",
".",
"g",
".",
"|",
"[",
"(",
"1",
"2",
")",
"(",
"3",
"(",
"4",
"5",
"))",
"]",
"-",
">",
"[",
"1",
"2",
"3",
"4",
"5",
"]",
"|"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L59-L78 | [
"def",
"flatten",
"(",
"*",
"seqs",
")",
":",
"for",
"seq",
"in",
"seqs",
":",
"for",
"item",
"in",
"seq",
":",
"if",
"isinstance",
"(",
"item",
",",
"(",
"tuple",
",",
"list",
",",
"UserList",
")",
")",
":",
"for",
"subitem",
"in",
"flatten",
"(... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | randrange | Yields random values from @seq until @seq is empty | vital/tools/lists.py | def randrange(seq):
""" Yields random values from @seq until @seq is empty """
seq = seq.copy()
choose = rng().choice
remove = seq.remove
for x in range(len(seq)):
y = choose(seq)
remove(y)
yield y | def randrange(seq):
""" Yields random values from @seq until @seq is empty """
seq = seq.copy()
choose = rng().choice
remove = seq.remove
for x in range(len(seq)):
y = choose(seq)
remove(y)
yield y | [
"Yields",
"random",
"values",
"from"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L91-L99 | [
"def",
"randrange",
"(",
"seq",
")",
":",
"seq",
"=",
"seq",
".",
"copy",
"(",
")",
"choose",
"=",
"rng",
"(",
")",
".",
"choice",
"remove",
"=",
"seq",
".",
"remove",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"seq",
")",
")",
":",
"y",
"="... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | linear_least_squares | Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number of
linearly independent rows of `a` can be less than, eq... | bin/lib/ssp_functions/ssp_Hector_Fit3D_tools.py | def linear_least_squares(a, b, residuals=False):
"""
Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number... | def linear_least_squares(a, b, residuals=False):
"""
Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number... | [
"Return",
"the",
"least",
"-",
"squares",
"solution",
"to",
"a",
"linear",
"matrix",
"equation",
".",
"Solves",
"the",
"equation",
"a",
"x",
"=",
"b",
"by",
"computing",
"a",
"vector",
"x",
"that",
"minimizes",
"the",
"Euclidean",
"2",
"-",
"norm",
"||",... | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/ssp_functions/ssp_Hector_Fit3D_tools.py#L14-L55 | [
"def",
"linear_least_squares",
"(",
"a",
",",
"b",
",",
"residuals",
"=",
"False",
")",
":",
"# Copyright (c) 2013 Alexandre Drouin. All rights reserved.",
"# From https://gist.github.com/aldro61/5889795",
"from",
"warnings",
"import",
"warn",
"# from scipy.linalg.fblas impo... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | validate_ip_address | Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid | pycons3rt/aliasip.py | def validate_ip_address(ip_address):
"""Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid
"""
# Validate the IP address
log = logging.getLogger(mod_logger + '.validate_ip_address')
if not isinstance(ip_address, basestring):
l... | def validate_ip_address(ip_address):
"""Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid
"""
# Validate the IP address
log = logging.getLogger(mod_logger + '.validate_ip_address')
if not isinstance(ip_address, basestring):
l... | [
"Validate",
"the",
"ip_address"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L32-L61 | [
"def",
"validate_ip_address",
"(",
"ip_address",
")",
":",
"# Validate the IP address",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.validate_ip_address'",
")",
"if",
"not",
"isinstance",
"(",
"ip_address",
",",
"basestring",
")",
":",
"log"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | ip_addr | Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address | pycons3rt/aliasip.py | def ip_addr():
"""Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address
"""
log = logging.getLogger(mod_logger + '.ip_addr')
log.debug('Running the ip addr command...')
ip_addr_output = {}
command = ['ip', 'addr']
try:
ip_add... | def ip_addr():
"""Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address
"""
log = logging.getLogger(mod_logger + '.ip_addr')
log.debug('Running the ip addr command...')
ip_addr_output = {}
command = ['ip', 'addr']
try:
ip_add... | [
"Uses",
"the",
"ip",
"addr",
"command",
"to",
"enumerate",
"IP",
"addresses",
"by",
"device"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L64-L103 | [
"def",
"ip_addr",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.ip_addr'",
")",
"log",
".",
"debug",
"(",
"'Running the ip addr command...'",
")",
"ip_addr_output",
"=",
"{",
"}",
"command",
"=",
"[",
"'ip'",
",",
"'add... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | alias_ip_address | Adds an IP alias to a specific interface
Adds an ip address as an alias to the specified interface on
Linux systems.
:param ip_address: (str) IP address to set as an alias
:param interface: (str) The interface number or full device name, if
an int is provided assumes the device name is eth<i>
... | pycons3rt/aliasip.py | def alias_ip_address(ip_address, interface, aws=False):
"""Adds an IP alias to a specific interface
Adds an ip address as an alias to the specified interface on
Linux systems.
:param ip_address: (str) IP address to set as an alias
:param interface: (str) The interface number or full device name, i... | def alias_ip_address(ip_address, interface, aws=False):
"""Adds an IP alias to a specific interface
Adds an ip address as an alias to the specified interface on
Linux systems.
:param ip_address: (str) IP address to set as an alias
:param interface: (str) The interface number or full device name, i... | [
"Adds",
"an",
"IP",
"alias",
"to",
"a",
"specific",
"interface"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L106-L263 | [
"def",
"alias_ip_address",
"(",
"ip_address",
",",
"interface",
",",
"aws",
"=",
"False",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.alias_ip_address'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"ip_address",
",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | set_source_ip_for_interface | Configures the source IP address for a Linux interface
:param source_ip_address: (str) Source IP address to change
:param desired_source_ip_address: (str) IP address to configure as the source in outgoing packets
:param device_num: (int) Integer interface device number to configure
:return: None
:r... | pycons3rt/aliasip.py | def set_source_ip_for_interface(source_ip_address, desired_source_ip_address, device_num=0):
"""Configures the source IP address for a Linux interface
:param source_ip_address: (str) Source IP address to change
:param desired_source_ip_address: (str) IP address to configure as the source in outgoing packet... | def set_source_ip_for_interface(source_ip_address, desired_source_ip_address, device_num=0):
"""Configures the source IP address for a Linux interface
:param source_ip_address: (str) Source IP address to change
:param desired_source_ip_address: (str) IP address to configure as the source in outgoing packet... | [
"Configures",
"the",
"source",
"IP",
"address",
"for",
"a",
"Linux",
"interface"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L266-L328 | [
"def",
"set_source_ip_for_interface",
"(",
"source_ip_address",
",",
"desired_source_ip_address",
",",
"device_num",
"=",
"0",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.set_source_ip_for_interface'",
")",
"if",
"not",
"isinstance",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | ObjectHandler.save_logic | Перед сохранением в методе save вызывается этот метод
:param some_object: сохраненный объект | tornkts/handlers/object_handler.py | def save_logic(self, some_object):
"""
Перед сохранением в методе save вызывается этот метод
:param some_object: сохраненный объект
"""
some_object.validate_model()
some_object.save()
self.send_success_response(data=some_object.to_dict()) | def save_logic(self, some_object):
"""
Перед сохранением в методе save вызывается этот метод
:param some_object: сохраненный объект
"""
some_object.validate_model()
some_object.save()
self.send_success_response(data=some_object.to_dict()) | [
"Перед",
"сохранением",
"в",
"методе",
"save",
"вызывается",
"этот",
"метод",
":",
"param",
"some_object",
":",
"сохраненный",
"объект"
] | ktsstudio/tornkts | python | https://github.com/ktsstudio/tornkts/blob/db47e4550426282960a7e4486dcc4399c8d52e02/tornkts/handlers/object_handler.py#L80-L87 | [
"def",
"save_logic",
"(",
"self",
",",
"some_object",
")",
":",
"some_object",
".",
"validate_model",
"(",
")",
"some_object",
".",
"save",
"(",
")",
"self",
".",
"send_success_response",
"(",
"data",
"=",
"some_object",
".",
"to_dict",
"(",
")",
")"
] | db47e4550426282960a7e4486dcc4399c8d52e02 |
train | fmt | Generate shell color opcodes from a pretty coloring syntax. | src/peltak/core/shell.py | def fmt(msg, *args, **kw):
# type: (str, *Any, **Any) -> str
""" Generate shell color opcodes from a pretty coloring syntax. """
global is_tty
if len(args) or len(kw):
msg = msg.format(*args, **kw)
opcode_subst = '\x1b[\\1m' if is_tty else ''
return re.sub(r'<(\d{1,2})>', opcode_subst,... | def fmt(msg, *args, **kw):
# type: (str, *Any, **Any) -> str
""" Generate shell color opcodes from a pretty coloring syntax. """
global is_tty
if len(args) or len(kw):
msg = msg.format(*args, **kw)
opcode_subst = '\x1b[\\1m' if is_tty else ''
return re.sub(r'<(\d{1,2})>', opcode_subst,... | [
"Generate",
"shell",
"color",
"opcodes",
"from",
"a",
"pretty",
"coloring",
"syntax",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/shell.py#L55-L64 | [
"def",
"fmt",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> str",
"global",
"is_tty",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | cprint | Print colored message to stdout. | src/peltak/core/shell.py | def cprint(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print colored message to stdout. """
if len(args) or len(kw):
msg = msg.format(*args, **kw)
print(fmt('{}<0>'.format(msg))) | def cprint(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print colored message to stdout. """
if len(args) or len(kw):
msg = msg.format(*args, **kw)
print(fmt('{}<0>'.format(msg))) | [
"Print",
"colored",
"message",
"to",
"stdout",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/shell.py#L67-L73 | [
"def",
"cprint",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> None",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*"... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | run | Run a shell command.
Args:
cmd (str):
The shell command to execute.
shell (bool):
Same as in `subprocess.Popen`.
capture (bool):
If set to True, it will capture the standard input/error instead of
just piping it to the caller stdout/stderr.
... | src/peltak/core/shell.py | def run(cmd,
capture=False,
shell=True,
env=None,
exit_on_error=None,
never_pretend=False):
# type: (str, bool, bool, Dict[str, str], bool) -> ExecResult
""" Run a shell command.
Args:
cmd (str):
The shell command to execute.
shell (bool):... | def run(cmd,
capture=False,
shell=True,
env=None,
exit_on_error=None,
never_pretend=False):
# type: (str, bool, bool, Dict[str, str], bool) -> ExecResult
""" Run a shell command.
Args:
cmd (str):
The shell command to execute.
shell (bool):... | [
"Run",
"a",
"shell",
"command",
"."
] | novopl/peltak | python | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/shell.py#L76-L164 | [
"def",
"run",
"(",
"cmd",
",",
"capture",
"=",
"False",
",",
"shell",
"=",
"True",
",",
"env",
"=",
"None",
",",
"exit_on_error",
"=",
"None",
",",
"never_pretend",
"=",
"False",
")",
":",
"# type: (str, bool, bool, Dict[str, str], bool) -> ExecResult",
"if",
... | b627acc019e3665875fe76cdca0a14773b69beaa |
train | get_payload | Extracts the request's payload information.
This method will merge the URL parameter information
and the JSON body of the request together to generate
a dictionary of key<->value pairings.
This method assumes that the JSON body being provided
is also a key-value map, if it is not, then an HTTPBadRe... | pyramid_restful/utils.py | def get_payload(request):
"""
Extracts the request's payload information.
This method will merge the URL parameter information
and the JSON body of the request together to generate
a dictionary of key<->value pairings.
This method assumes that the JSON body being provided
is also a key-valu... | def get_payload(request):
"""
Extracts the request's payload information.
This method will merge the URL parameter information
and the JSON body of the request together to generate
a dictionary of key<->value pairings.
This method assumes that the JSON body being provided
is also a key-valu... | [
"Extracts",
"the",
"request",
"s",
"payload",
"information",
".",
"This",
"method",
"will",
"merge",
"the",
"URL",
"parameter",
"information",
"and",
"the",
"JSON",
"body",
"of",
"the",
"request",
"together",
"to",
"generate",
"a",
"dictionary",
"of",
"key<",
... | bitesofcode/pyramid_restful | python | https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/utils.py#L4-L37 | [
"def",
"get_payload",
"(",
"request",
")",
":",
"# always extract values from the URL",
"payload",
"=",
"dict",
"(",
"request",
".",
"params",
".",
"mixed",
"(",
")",
")",
"# provide override capability from the JSON body",
"try",
":",
"json_data",
"=",
"request",
"... | 0f1eccb2c61b9bd6add03b461d4e4d7901c957da |
train | main | Handles external calling for this module
Execute this python module and provide the args shown below to
external call this module to send email messages!
:return: None | pycons3rt/assetmailer.py | def main():
"""Handles external calling for this module
Execute this python module and provide the args shown below to
external call this module to send email messages!
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='This module... | def main():
"""Handles external calling for this module
Execute this python module and provide the args shown below to
external call this module to send email messages!
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='This module... | [
"Handles",
"external",
"calling",
"for",
"this",
"module"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/assetmailer.py#L178-L212 | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.main'",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'This module allows sending email messages.'",
")",
"parser",
".",
"add_arg... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | AssetMailer.send_cons3rt_agent_logs | Send the cons3rt agent log file
:return: | pycons3rt/assetmailer.py | def send_cons3rt_agent_logs(self):
"""Send the cons3rt agent log file
:return:
"""
log = logging.getLogger(self.cls_logger + '.send_cons3rt_agent_logs')
if self.cons3rt_agent_log_dir is None:
log.warn('There is not CONS3RT agent log directory on this system')
... | def send_cons3rt_agent_logs(self):
"""Send the cons3rt agent log file
:return:
"""
log = logging.getLogger(self.cls_logger + '.send_cons3rt_agent_logs')
if self.cons3rt_agent_log_dir is None:
log.warn('There is not CONS3RT agent log directory on this system')
... | [
"Send",
"the",
"cons3rt",
"agent",
"log",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/assetmailer.py#L63-L87 | [
"def",
"send_cons3rt_agent_logs",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.send_cons3rt_agent_logs'",
")",
"if",
"self",
".",
"cons3rt_agent_log_dir",
"is",
"None",
":",
"log",
".",
"warn",
"(",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | AssetMailer.send_text_file | Sends an email with the contents of the provided text file
:return: None | pycons3rt/assetmailer.py | def send_text_file(self, text_file, sender=None, recipient=None):
"""Sends an email with the contents of the provided text file
:return: None
"""
log = logging.getLogger(self.cls_logger + '.send_text_file')
if not isinstance(text_file, basestring):
msg = 'arg text_f... | def send_text_file(self, text_file, sender=None, recipient=None):
"""Sends an email with the contents of the provided text file
:return: None
"""
log = logging.getLogger(self.cls_logger + '.send_text_file')
if not isinstance(text_file, basestring):
msg = 'arg text_f... | [
"Sends",
"an",
"email",
"with",
"the",
"contents",
"of",
"the",
"provided",
"text",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/assetmailer.py#L89-L175 | [
"def",
"send_text_file",
"(",
"self",
",",
"text_file",
",",
"sender",
"=",
"None",
",",
"recipient",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.send_text_file'",
")",
"if",
"not",
"isinstance",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_date_range_by_name | :param name: yesterday, last_month
:param today: Optional current datetime. Default is now().
:param tz: Optional timezone. Default is UTC.
:return: datetime (begin, end) | jutil/command.py | def get_date_range_by_name(name: str, today: datetime=None, tz=None) -> (datetime, datetime):
"""
:param name: yesterday, last_month
:param today: Optional current datetime. Default is now().
:param tz: Optional timezone. Default is UTC.
:return: datetime (begin, end)
"""
if today is None:
... | def get_date_range_by_name(name: str, today: datetime=None, tz=None) -> (datetime, datetime):
"""
:param name: yesterday, last_month
:param today: Optional current datetime. Default is now().
:param tz: Optional timezone. Default is UTC.
:return: datetime (begin, end)
"""
if today is None:
... | [
":",
"param",
"name",
":",
"yesterday",
"last_month",
":",
"param",
"today",
":",
"Optional",
"current",
"datetime",
".",
"Default",
"is",
"now",
"()",
".",
":",
"param",
"tz",
":",
"Optional",
"timezone",
".",
"Default",
"is",
"UTC",
".",
":",
"return",... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/command.py#L50-L86 | [
"def",
"get_date_range_by_name",
"(",
"name",
":",
"str",
",",
"today",
":",
"datetime",
"=",
"None",
",",
"tz",
"=",
"None",
")",
"->",
"(",
"datetime",
",",
"datetime",
")",
":",
"if",
"today",
"is",
"None",
":",
"today",
"=",
"datetime",
".",
"utc... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | parse_date_range_arguments | :param options:
:param default_range: Default datetime range to return if no other selected
:return: begin, end, [(begin1,end1), (begin2,end2), ...] | jutil/command.py | def parse_date_range_arguments(options: dict, default_range='last_month') -> (datetime, datetime, list):
"""
:param options:
:param default_range: Default datetime range to return if no other selected
:return: begin, end, [(begin1,end1), (begin2,end2), ...]
"""
begin, end = get_date_range_by_nam... | def parse_date_range_arguments(options: dict, default_range='last_month') -> (datetime, datetime, list):
"""
:param options:
:param default_range: Default datetime range to return if no other selected
:return: begin, end, [(begin1,end1), (begin2,end2), ...]
"""
begin, end = get_date_range_by_nam... | [
":",
"param",
"options",
":",
":",
"param",
"default_range",
":",
"Default",
"datetime",
"range",
"to",
"return",
"if",
"no",
"other",
"selected",
":",
"return",
":",
"begin",
"end",
"[",
"(",
"begin1",
"end1",
")",
"(",
"begin2",
"end2",
")",
"...",
"... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/command.py#L89-L123 | [
"def",
"parse_date_range_arguments",
"(",
"options",
":",
"dict",
",",
"default_range",
"=",
"'last_month'",
")",
"->",
"(",
"datetime",
",",
"datetime",
",",
"list",
")",
":",
"begin",
",",
"end",
"=",
"get_date_range_by_name",
"(",
"default_range",
")",
"for... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | Chemical_Analysis_pyneb.load_elements | S3: All energy and A values: Podobedova, Kelleher, and Wiese 2009, J. Phys. Chem. Ref. Data, Vol. | bin/lib/Astro_Libraries/Abundances_Class.py | def load_elements(self):
#Set atomic data
#atomicData.setDataFile('he_i_rec_Pal12-Pal13.fits')
atomicData.setDataFile('s_iii_coll_HRS12.dat')
#Default: 's_iii_atom_PKW09.dat'
'S3: All energy and A values: Podobedova, Kelleher, and Wiese 2009, J. Phys. Chem. Ref. Data, Vol.'
... | def load_elements(self):
#Set atomic data
#atomicData.setDataFile('he_i_rec_Pal12-Pal13.fits')
atomicData.setDataFile('s_iii_coll_HRS12.dat')
#Default: 's_iii_atom_PKW09.dat'
'S3: All energy and A values: Podobedova, Kelleher, and Wiese 2009, J. Phys. Chem. Ref. Data, Vol.'
... | [
"S3",
":",
"All",
"energy",
"and",
"A",
"values",
":",
"Podobedova",
"Kelleher",
"and",
"Wiese",
"2009",
"J",
".",
"Phys",
".",
"Chem",
".",
"Ref",
".",
"Data",
"Vol",
"."
] | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/Abundances_Class.py#L23-L87 | [
"def",
"load_elements",
"(",
"self",
")",
":",
"#Set atomic data ",
"#atomicData.setDataFile('he_i_rec_Pal12-Pal13.fits')",
"atomicData",
".",
"setDataFile",
"(",
"'s_iii_coll_HRS12.dat'",
")",
"#Default: 's_iii_atom_PKW09.dat' ",
"'S3: collision strengths: Tayal & Gupta 1999, ApJ, 526... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | git_clone | Clones a git url
:param url: (str) Git URL in https or ssh
:param clone_dir: (str) Path to the desired destination dir
:param branch: (str) branch to clone
:param username: (str) username for the git repo
:param password: (str) password for the git repo
:param max_retries: (int) the number of a... | pycons3rt/pygit.py | def git_clone(url, clone_dir, branch='master', username=None, password=None, max_retries=10, retry_sec=30,
git_cmd=None):
"""Clones a git url
:param url: (str) Git URL in https or ssh
:param clone_dir: (str) Path to the desired destination dir
:param branch: (str) branch to clone
:par... | def git_clone(url, clone_dir, branch='master', username=None, password=None, max_retries=10, retry_sec=30,
git_cmd=None):
"""Clones a git url
:param url: (str) Git URL in https or ssh
:param clone_dir: (str) Path to the desired destination dir
:param branch: (str) branch to clone
:par... | [
"Clones",
"a",
"git",
"url"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/pygit.py#L30-L134 | [
"def",
"git_clone",
"(",
"url",
",",
"clone_dir",
",",
"branch",
"=",
"'master'",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"max_retries",
"=",
"10",
",",
"retry_sec",
"=",
"30",
",",
"git_cmd",
"=",
"None",
")",
":",
"log",
"=... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | encode_password | Performs URL encoding for passwords
:param password: (str) password to encode
:return: (str) encoded password | pycons3rt/pygit.py | def encode_password(password):
"""Performs URL encoding for passwords
:param password: (str) password to encode
:return: (str) encoded password
"""
log = logging.getLogger(mod_logger + '.password_encoder')
log.debug('Encoding password: {p}'.format(p=password))
encoded_password = ''
for ... | def encode_password(password):
"""Performs URL encoding for passwords
:param password: (str) password to encode
:return: (str) encoded password
"""
log = logging.getLogger(mod_logger + '.password_encoder')
log.debug('Encoding password: {p}'.format(p=password))
encoded_password = ''
for ... | [
"Performs",
"URL",
"encoding",
"for",
"passwords"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/pygit.py#L137-L149 | [
"def",
"encode_password",
"(",
"password",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.password_encoder'",
")",
"log",
".",
"debug",
"(",
"'Encoding password: {p}'",
".",
"format",
"(",
"p",
"=",
"password",
")",
")",
"encod... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | encode_character | Returns URL encoding for a single character
:param char (str) Single character to encode
:returns (str) URL-encoded character | pycons3rt/pygit.py | def encode_character(char):
"""Returns URL encoding for a single character
:param char (str) Single character to encode
:returns (str) URL-encoded character
"""
if char == '!': return '%21'
elif char == '"': return '%22'
elif char == '#': return '%23'
elif char == '$': return '%24'
... | def encode_character(char):
"""Returns URL encoding for a single character
:param char (str) Single character to encode
:returns (str) URL-encoded character
"""
if char == '!': return '%21'
elif char == '"': return '%22'
elif char == '#': return '%23'
elif char == '$': return '%24'
... | [
"Returns",
"URL",
"encoding",
"for",
"a",
"single",
"character"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/pygit.py#L152-L191 | [
"def",
"encode_character",
"(",
"char",
")",
":",
"if",
"char",
"==",
"'!'",
":",
"return",
"'%21'",
"elif",
"char",
"==",
"'\"'",
":",
"return",
"'%22'",
"elif",
"char",
"==",
"'#'",
":",
"return",
"'%23'",
"elif",
"char",
"==",
"'$'",
":",
"return",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | search_tags_as_filters | Get different tags as dicts ready to use as dropdown lists. | isogeo_pysdk/samples/results_parser.py | def search_tags_as_filters(tags):
"""Get different tags as dicts ready to use as dropdown lists."""
# set dicts
actions = {}
contacts = {}
formats = {}
inspire = {}
keywords = {}
licenses = {}
md_types = dict()
owners = defaultdict(str)
srs = {}
unused = {}
# 0/1 valu... | def search_tags_as_filters(tags):
"""Get different tags as dicts ready to use as dropdown lists."""
# set dicts
actions = {}
contacts = {}
formats = {}
inspire = {}
keywords = {}
licenses = {}
md_types = dict()
owners = defaultdict(str)
srs = {}
unused = {}
# 0/1 valu... | [
"Get",
"different",
"tags",
"as",
"dicts",
"ready",
"to",
"use",
"as",
"dropdown",
"lists",
"."
] | isogeo/isogeo-api-py-minsdk | python | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/samples/results_parser.py#L28-L141 | [
"def",
"search_tags_as_filters",
"(",
"tags",
")",
":",
"# set dicts",
"actions",
"=",
"{",
"}",
"contacts",
"=",
"{",
"}",
"formats",
"=",
"{",
"}",
"inspire",
"=",
"{",
"}",
"keywords",
"=",
"{",
"}",
"licenses",
"=",
"{",
"}",
"md_types",
"=",
"di... | 57a604be92c7767b26abd247012cc1a584b386a0 |
train | Verification.generate | :param verified: телефон или email (verified_entity)
:param keygen: функция генерации ключа
:return: | tornkts/modules/verification/verification_model.py | def generate(self, verified, keygen):
"""
:param verified: телефон или email (verified_entity)
:param keygen: функция генерации ключа
:return:
"""
return Verification(
verified_entity=verified,
key=keygen(),
verified=False
) | def generate(self, verified, keygen):
"""
:param verified: телефон или email (verified_entity)
:param keygen: функция генерации ключа
:return:
"""
return Verification(
verified_entity=verified,
key=keygen(),
verified=False
) | [
":",
"param",
"verified",
":",
"телефон",
"или",
"email",
"(",
"verified_entity",
")",
":",
"param",
"keygen",
":",
"функция",
"генерации",
"ключа",
":",
"return",
":"
] | ktsstudio/tornkts | python | https://github.com/ktsstudio/tornkts/blob/db47e4550426282960a7e4486dcc4399c8d52e02/tornkts/modules/verification/verification_model.py#L12-L22 | [
"def",
"generate",
"(",
"self",
",",
"verified",
",",
"keygen",
")",
":",
"return",
"Verification",
"(",
"verified_entity",
"=",
"verified",
",",
"key",
"=",
"keygen",
"(",
")",
",",
"verified",
"=",
"False",
")"
] | db47e4550426282960a7e4486dcc4399c8d52e02 |
train | iban_bank_info | Returns BIC code and bank name from IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found / unsupported country | jutil/validators.py | def iban_bank_info(v: str) -> (str, str):
"""
Returns BIC code and bank name from IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found / unsupported country
"""
v = iban_filter(v)
if v[:2] == 'FI':
return fi_iban_bank_info(v)
else:
... | def iban_bank_info(v: str) -> (str, str):
"""
Returns BIC code and bank name from IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found / unsupported country
"""
v = iban_filter(v)
if v[:2] == 'FI':
return fi_iban_bank_info(v)
else:
... | [
"Returns",
"BIC",
"code",
"and",
"bank",
"name",
"from",
"IBAN",
"number",
".",
":",
"param",
"v",
":",
"IBAN",
"account",
"number",
":",
"return",
":",
"(",
"BIC",
"code",
"bank",
"name",
")",
"or",
"(",
")",
"if",
"not",
"found",
"/",
"unsupported"... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/validators.py#L116-L126 | [
"def",
"iban_bank_info",
"(",
"v",
":",
"str",
")",
"->",
"(",
"str",
",",
"str",
")",
":",
"v",
"=",
"iban_filter",
"(",
"v",
")",
"if",
"v",
"[",
":",
"2",
"]",
"==",
"'FI'",
":",
"return",
"fi_iban_bank_info",
"(",
"v",
")",
"else",
":",
"re... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | fi_payment_reference_number | Appends Finland reference number checksum to existing number.
:param num: At least 3 digits
:return: Number plus checksum | jutil/validators.py | def fi_payment_reference_number(num: str):
"""
Appends Finland reference number checksum to existing number.
:param num: At least 3 digits
:return: Number plus checksum
"""
assert isinstance(num, str)
num = STRIP_WHITESPACE.sub('', num)
num = re.sub(r'^0+', '', num)
assert len(num) >... | def fi_payment_reference_number(num: str):
"""
Appends Finland reference number checksum to existing number.
:param num: At least 3 digits
:return: Number plus checksum
"""
assert isinstance(num, str)
num = STRIP_WHITESPACE.sub('', num)
num = re.sub(r'^0+', '', num)
assert len(num) >... | [
"Appends",
"Finland",
"reference",
"number",
"checksum",
"to",
"existing",
"number",
".",
":",
"param",
"num",
":",
"At",
"least",
"3",
"digits",
":",
"return",
":",
"Number",
"plus",
"checksum"
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/validators.py#L154-L169 | [
"def",
"fi_payment_reference_number",
"(",
"num",
":",
"str",
")",
":",
"assert",
"isinstance",
"(",
"num",
",",
"str",
")",
"num",
"=",
"STRIP_WHITESPACE",
".",
"sub",
"(",
"''",
",",
"num",
")",
"num",
"=",
"re",
".",
"sub",
"(",
"r'^0+'",
",",
"''... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | iso_payment_reference_validator | Validates ISO reference number checksum.
:param v: Reference number | jutil/validators.py | def iso_payment_reference_validator(v: str):
"""
Validates ISO reference number checksum.
:param v: Reference number
"""
num = ''
v = STRIP_WHITESPACE.sub('', v)
for ch in v[4:] + v[0:4]:
x = ord(ch)
if ord('0') <= x <= ord('9'):
num += ch
else:
... | def iso_payment_reference_validator(v: str):
"""
Validates ISO reference number checksum.
:param v: Reference number
"""
num = ''
v = STRIP_WHITESPACE.sub('', v)
for ch in v[4:] + v[0:4]:
x = ord(ch)
if ord('0') <= x <= ord('9'):
num += ch
else:
... | [
"Validates",
"ISO",
"reference",
"number",
"checksum",
".",
":",
"param",
"v",
":",
"Reference",
"number"
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/validators.py#L178-L196 | [
"def",
"iso_payment_reference_validator",
"(",
"v",
":",
"str",
")",
":",
"num",
"=",
"''",
"v",
"=",
"STRIP_WHITESPACE",
".",
"sub",
"(",
"''",
",",
"v",
")",
"for",
"ch",
"in",
"v",
"[",
"4",
":",
"]",
"+",
"v",
"[",
"0",
":",
"4",
"]",
":",
... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | fi_iban_bank_info | Returns BIC code and bank name from FI IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found | jutil/validators.py | def fi_iban_bank_info(v: str) -> (str, str):
"""
Returns BIC code and bank name from FI IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found
"""
from jutil.bank_const_fi import FI_BIC_BY_ACCOUNT_NUMBER, FI_BANK_NAME_BY_BIC
v = iban_filter(v)
... | def fi_iban_bank_info(v: str) -> (str, str):
"""
Returns BIC code and bank name from FI IBAN number.
:param v: IBAN account number
:return: (BIC code, bank name) or ('', '') if not found
"""
from jutil.bank_const_fi import FI_BIC_BY_ACCOUNT_NUMBER, FI_BANK_NAME_BY_BIC
v = iban_filter(v)
... | [
"Returns",
"BIC",
"code",
"and",
"bank",
"name",
"from",
"FI",
"IBAN",
"number",
".",
":",
"param",
"v",
":",
"IBAN",
"account",
"number",
":",
"return",
":",
"(",
"BIC",
"code",
"bank",
"name",
")",
"or",
"(",
")",
"if",
"not",
"found"
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/validators.py#L203-L212 | [
"def",
"fi_iban_bank_info",
"(",
"v",
":",
"str",
")",
"->",
"(",
"str",
",",
"str",
")",
":",
"from",
"jutil",
".",
"bank_const_fi",
"import",
"FI_BIC_BY_ACCOUNT_NUMBER",
",",
"FI_BANK_NAME_BY_BIC",
"v",
"=",
"iban_filter",
"(",
"v",
")",
"bic",
"=",
"FI_... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | se_clearing_code_bank_info | Returns Sweden bank info by clearning code.
:param clearing: 4-digit clearing code
:return: (Bank name, account digit count) or ('', None) if not found | jutil/validators.py | def se_clearing_code_bank_info(clearing: str) -> (str, int):
"""
Returns Sweden bank info by clearning code.
:param clearing: 4-digit clearing code
:return: (Bank name, account digit count) or ('', None) if not found
"""
from jutil.bank_const_se import SE_BANK_CLEARING_LIST
for name, begin, ... | def se_clearing_code_bank_info(clearing: str) -> (str, int):
"""
Returns Sweden bank info by clearning code.
:param clearing: 4-digit clearing code
:return: (Bank name, account digit count) or ('', None) if not found
"""
from jutil.bank_const_se import SE_BANK_CLEARING_LIST
for name, begin, ... | [
"Returns",
"Sweden",
"bank",
"info",
"by",
"clearning",
"code",
".",
":",
"param",
"clearing",
":",
"4",
"-",
"digit",
"clearing",
"code",
":",
"return",
":",
"(",
"Bank",
"name",
"account",
"digit",
"count",
")",
"or",
"(",
"None",
")",
"if",
"not",
... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/validators.py#L323-L333 | [
"def",
"se_clearing_code_bank_info",
"(",
"clearing",
":",
"str",
")",
"->",
"(",
"str",
",",
"int",
")",
":",
"from",
"jutil",
".",
"bank_const_se",
"import",
"SE_BANK_CLEARING_LIST",
"for",
"name",
",",
"begin",
",",
"end",
",",
"acc_digits",
"in",
"SE_BAN... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | _histplot_bins | Helper to get bins for histplot. | bin/lib/Astro_Libraries/spectrum_fitting/plot_tools.py | def _histplot_bins(column, bins=100):
"""Helper to get bins for histplot."""
col_min = np.min(column)
col_max = np.max(column)
return range(col_min, col_max + 2, max((col_max - col_min) // bins, 1)) | def _histplot_bins(column, bins=100):
"""Helper to get bins for histplot."""
col_min = np.min(column)
col_max = np.max(column)
return range(col_min, col_max + 2, max((col_max - col_min) // bins, 1)) | [
"Helper",
"to",
"get",
"bins",
"for",
"histplot",
"."
] | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/spectrum_fitting/plot_tools.py#L27-L31 | [
"def",
"_histplot_bins",
"(",
"column",
",",
"bins",
"=",
"100",
")",
":",
"col_min",
"=",
"np",
".",
"min",
"(",
"column",
")",
"col_max",
"=",
"np",
".",
"max",
"(",
"column",
")",
"return",
"range",
"(",
"col_min",
",",
"col_max",
"+",
"2",
",",... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.