repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jic-dtool/dtool-config
dtool_config/cli.py
email
def email(email_address): """Display / set / update the user email.""" if not email_address: click.secho(dtool_config.utils.get_user_email(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_user_email( CONFIG_PATH, email_address ))
python
def email(email_address): """Display / set / update the user email.""" if not email_address: click.secho(dtool_config.utils.get_user_email(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_user_email( CONFIG_PATH, email_address ))
[ "def", "email", "(", "email_address", ")", ":", "if", "not", "email_address", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_user_email", "(", "CONFIG_PATH", ")", ")", "else", ":", "click", ".", "secho", "(", "dtool_config", ".", ...
Display / set / update the user email.
[ "Display", "/", "set", "/", "update", "the", "user", "email", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L36-L44
jic-dtool/dtool-config
dtool_config/cli.py
readme_template
def readme_template(readme_template_file): """Display / set / update the readme template file.""" if not readme_template_file: click.secho(dtool_config.utils.get_readme_template_fpath( CONFIG_PATH, )) else: click.secho(dtool_config.utils.set_readme_template_fpath( ...
python
def readme_template(readme_template_file): """Display / set / update the readme template file.""" if not readme_template_file: click.secho(dtool_config.utils.get_readme_template_fpath( CONFIG_PATH, )) else: click.secho(dtool_config.utils.set_readme_template_fpath( ...
[ "def", "readme_template", "(", "readme_template_file", ")", ":", "if", "not", "readme_template_file", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_readme_template_fpath", "(", "CONFIG_PATH", ",", ")", ")", "else", ":", "click", ".", ...
Display / set / update the readme template file.
[ "Display", "/", "set", "/", "update", "the", "readme", "template", "file", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L53-L63
jic-dtool/dtool-config
dtool_config/cli.py
endpoint
def endpoint(url): """Display / set / update the ECS endpoint URL.""" if not url: click.secho(dtool_config.utils.get_ecs_endpoint(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_endpoint(CONFIG_PATH, url))
python
def endpoint(url): """Display / set / update the ECS endpoint URL.""" if not url: click.secho(dtool_config.utils.get_ecs_endpoint(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_endpoint(CONFIG_PATH, url))
[ "def", "endpoint", "(", "url", ")", ":", "if", "not", "url", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_ecs_endpoint", "(", "CONFIG_PATH", ")", ")", "else", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", "....
Display / set / update the ECS endpoint URL.
[ "Display", "/", "set", "/", "update", "the", "ECS", "endpoint", "URL", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L73-L78
jic-dtool/dtool-config
dtool_config/cli.py
access_key_id
def access_key_id(ecs_access_key_id): """Display / set / update the ECS access key id.""" if not ecs_access_key_id: click.secho(dtool_config.utils.get_ecs_access_key_id(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_access_key_id( CONFIG_PATH, ecs_access_k...
python
def access_key_id(ecs_access_key_id): """Display / set / update the ECS access key id.""" if not ecs_access_key_id: click.secho(dtool_config.utils.get_ecs_access_key_id(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_access_key_id( CONFIG_PATH, ecs_access_k...
[ "def", "access_key_id", "(", "ecs_access_key_id", ")", ":", "if", "not", "ecs_access_key_id", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_ecs_access_key_id", "(", "CONFIG_PATH", ")", ")", "else", ":", "click", ".", "secho", "(", ...
Display / set / update the ECS access key id.
[ "Display", "/", "set", "/", "update", "the", "ECS", "access", "key", "id", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L83-L91
jic-dtool/dtool-config
dtool_config/cli.py
secret_access_key
def secret_access_key(ecs_secret_access_key): """Display / set / update the ECS secret access key.""" if not ecs_secret_access_key: click.secho(dtool_config.utils.get_ecs_secret_access_key(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_secret_access_key( CONFIG_PATH, ...
python
def secret_access_key(ecs_secret_access_key): """Display / set / update the ECS secret access key.""" if not ecs_secret_access_key: click.secho(dtool_config.utils.get_ecs_secret_access_key(CONFIG_PATH)) else: click.secho(dtool_config.utils.set_ecs_secret_access_key( CONFIG_PATH, ...
[ "def", "secret_access_key", "(", "ecs_secret_access_key", ")", ":", "if", "not", "ecs_secret_access_key", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_ecs_secret_access_key", "(", "CONFIG_PATH", ")", ")", "else", ":", "click", ".", "s...
Display / set / update the ECS secret access key.
[ "Display", "/", "set", "/", "update", "the", "ECS", "secret", "access", "key", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L96-L104
jic-dtool/dtool-config
dtool_config/cli.py
cache
def cache(cache_directory_path): """Display / set / update the dtool cache directory.""" if not cache_directory_path: click.secho(dtool_config.utils.get_cache( CONFIG_PATH, )) else: click.secho(dtool_config.utils.set_cache( CONFIG_PATH, cache_direc...
python
def cache(cache_directory_path): """Display / set / update the dtool cache directory.""" if not cache_directory_path: click.secho(dtool_config.utils.get_cache( CONFIG_PATH, )) else: click.secho(dtool_config.utils.set_cache( CONFIG_PATH, cache_direc...
[ "def", "cache", "(", "cache_directory_path", ")", ":", "if", "not", "cache_directory_path", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "get_cache", "(", "CONFIG_PATH", ",", ")", ")", "else", ":", "click", ".", "secho", "(", "dtool_...
Display / set / update the dtool cache directory.
[ "Display", "/", "set", "/", "update", "the", "dtool", "cache", "directory", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L113-L123
jic-dtool/dtool-config
dtool_config/cli.py
set
def set(container, azure_secret_access_key): """Set/update the access key for the specified Azure storage container.""" click.secho(dtool_config.utils.set_azure_secret_access_key( CONFIG_PATH, container, azure_secret_access_key ))
python
def set(container, azure_secret_access_key): """Set/update the access key for the specified Azure storage container.""" click.secho(dtool_config.utils.set_azure_secret_access_key( CONFIG_PATH, container, azure_secret_access_key ))
[ "def", "set", "(", "container", ",", "azure_secret_access_key", ")", ":", "click", ".", "secho", "(", "dtool_config", ".", "utils", ".", "set_azure_secret_access_key", "(", "CONFIG_PATH", ",", "container", ",", "azure_secret_access_key", ")", ")" ]
Set/update the access key for the specified Azure storage container.
[ "Set", "/", "update", "the", "access", "key", "for", "the", "specified", "Azure", "storage", "container", "." ]
train
https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L144-L150
lqdc/pysimstr
pysimstr.py
make_unique_ngrams
def make_unique_ngrams(s, n): """Make a set of unique n-grams from a string.""" return set(s[i:i + n] for i in range(len(s) - n + 1))
python
def make_unique_ngrams(s, n): """Make a set of unique n-grams from a string.""" return set(s[i:i + n] for i in range(len(s) - n + 1))
[ "def", "make_unique_ngrams", "(", "s", ",", "n", ")", ":", "return", "set", "(", "s", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "range", "(", "len", "(", "s", ")", "-", "n", "+", "1", ")", ")" ]
Make a set of unique n-grams from a string.
[ "Make", "a", "set", "of", "unique", "n", "-", "grams", "from", "a", "string", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L15-L17
lqdc/pysimstr
pysimstr.py
SimStr.check
def check(self, s, instant_exact=True): """Check if a string is in the DB. :param s: str, string to check against the DB. :param instant_exact: bool, look up exact matches with a hash lookup. :return: True or False :rtype: bool """ all_sets = self._get_compariso...
python
def check(self, s, instant_exact=True): """Check if a string is in the DB. :param s: str, string to check against the DB. :param instant_exact: bool, look up exact matches with a hash lookup. :return: True or False :rtype: bool """ all_sets = self._get_compariso...
[ "def", "check", "(", "self", ",", "s", ",", "instant_exact", "=", "True", ")", ":", "all_sets", "=", "self", ".", "_get_comparison_strings", "(", "s", ")", "if", "instant_exact", "and", "s", "in", "all_sets", ":", "# exact match", "return", "True", "for", ...
Check if a string is in the DB. :param s: str, string to check against the DB. :param instant_exact: bool, look up exact matches with a hash lookup. :return: True or False :rtype: bool
[ "Check", "if", "a", "string", "is", "in", "the", "DB", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L84-L100
lqdc/pysimstr
pysimstr.py
SimStr.retrieve
def retrieve(self, s): """Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of all similar strings. :rtype: list """ all_sim = [] use_max_n = self.max_n is not None for comparison_string in self._get_c...
python
def retrieve(self, s): """Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of all similar strings. :rtype: list """ all_sim = [] use_max_n = self.max_n is not None for comparison_string in self._get_c...
[ "def", "retrieve", "(", "self", ",", "s", ")", ":", "all_sim", "=", "[", "]", "use_max_n", "=", "self", ".", "max_n", "is", "not", "None", "for", "comparison_string", "in", "self", ".", "_get_comparison_strings", "(", "s", ")", ":", "if", "self", ".", ...
Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of all similar strings. :rtype: list
[ "Retrieve", "all", "similar", "strings", "from", "the", "DB", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L102-L117
lqdc/pysimstr
pysimstr.py
SimStr.retrieve_with_score
def retrieve_with_score(self, s): """Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of tuples - [(simlar_string, score)]. Empty list if not found. :rtype: list """ all_sim = [] use_max_n = ...
python
def retrieve_with_score(self, s): """Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of tuples - [(simlar_string, score)]. Empty list if not found. :rtype: list """ all_sim = [] use_max_n = ...
[ "def", "retrieve_with_score", "(", "self", ",", "s", ")", ":", "all_sim", "=", "[", "]", "use_max_n", "=", "self", ".", "max_n", "is", "not", "None", "for", "comparison_string", "in", "self", ".", "_get_comparison_strings", "(", "s", ")", ":", "score", "...
Retrieve all similar strings from the DB. :param s: str, string to check against the DB. :return: list of tuples - [(simlar_string, score)]. Empty list if not found. :rtype: list
[ "Retrieve", "all", "similar", "strings", "from", "the", "DB", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L119-L136
lqdc/pysimstr
pysimstr.py
SimStr.insert
def insert(self, seq): """ Populates the DB from a sequence of strings, ERASING PREVIOUS STATE. :param seq: an iterable """ # erase previous elements and make defaultdict for easier insertion. self._els_idxed = defaultdict(lambda: defaultdict(set)) if type(seq) ...
python
def insert(self, seq): """ Populates the DB from a sequence of strings, ERASING PREVIOUS STATE. :param seq: an iterable """ # erase previous elements and make defaultdict for easier insertion. self._els_idxed = defaultdict(lambda: defaultdict(set)) if type(seq) ...
[ "def", "insert", "(", "self", ",", "seq", ")", ":", "# erase previous elements and make defaultdict for easier insertion.", "self", ".", "_els_idxed", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "set", ")", ")", "if", "type", "(", "seq", ")", "is...
Populates the DB from a sequence of strings, ERASING PREVIOUS STATE. :param seq: an iterable
[ "Populates", "the", "DB", "from", "a", "sequence", "of", "strings", "ERASING", "PREVIOUS", "STATE", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L138-L158
lqdc/pysimstr
pysimstr.py
SimStr._finalize_db
def _finalize_db(self): """Convert defaultdicts to regular dicts.""" for k, v in self._els_idxed.items(): self._els_idxed[k] = dict(v) self._els_idxed = dict(self._els_idxed)
python
def _finalize_db(self): """Convert defaultdicts to regular dicts.""" for k, v in self._els_idxed.items(): self._els_idxed[k] = dict(v) self._els_idxed = dict(self._els_idxed)
[ "def", "_finalize_db", "(", "self", ")", ":", "for", "k", ",", "v", "in", "self", ".", "_els_idxed", ".", "items", "(", ")", ":", "self", ".", "_els_idxed", "[", "k", "]", "=", "dict", "(", "v", ")", "self", ".", "_els_idxed", "=", "dict", "(", ...
Convert defaultdicts to regular dicts.
[ "Convert", "defaultdicts", "to", "regular", "dicts", "." ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L160-L164
lqdc/pysimstr
pysimstr.py
SimStr._get_comparison_strings
def _get_comparison_strings(self, s): """Find all similar strings""" str_len = len(s) comparison_idxs = make_unique_ngrams(s, self.idx_size) min_len = len(s) - self.plus_minus if min_len < 0: min_len = 0 if self._els_idxed is None: raise Unintiti...
python
def _get_comparison_strings(self, s): """Find all similar strings""" str_len = len(s) comparison_idxs = make_unique_ngrams(s, self.idx_size) min_len = len(s) - self.plus_minus if min_len < 0: min_len = 0 if self._els_idxed is None: raise Unintiti...
[ "def", "_get_comparison_strings", "(", "self", ",", "s", ")", ":", "str_len", "=", "len", "(", "s", ")", "comparison_idxs", "=", "make_unique_ngrams", "(", "s", ",", "self", ".", "idx_size", ")", "min_len", "=", "len", "(", "s", ")", "-", "self", ".", ...
Find all similar strings
[ "Find", "all", "similar", "strings" ]
train
https://github.com/lqdc/pysimstr/blob/0475005402c8efc7c3eb4f56660639e505d8986d/pysimstr.py#L166-L187
frank2/hotmic
lib/__init__.py
lfsr
def lfsr(size, seed=None): '''Creates a generator using the Galois linear feedback shift register algorithm. The *size* corresponds to the entries in :py:class:`hotmic.polynomials.all_polys`, which represents the bitspace of the shift register. The *seed* is the initial value to pass to the algorithm.''' i...
python
def lfsr(size, seed=None): '''Creates a generator using the Galois linear feedback shift register algorithm. The *size* corresponds to the entries in :py:class:`hotmic.polynomials.all_polys`, which represents the bitspace of the shift register. The *seed* is the initial value to pass to the algorithm.''' i...
[ "def", "lfsr", "(", "size", ",", "seed", "=", "None", ")", ":", "if", "not", "size", "in", "polynomials", ".", "all_polys", ":", "raise", "ValueError", "(", "'bitsize not found in polynomial map'", ")", "poly", "=", "polynomials", ".", "all_polys", "[", "siz...
Creates a generator using the Galois linear feedback shift register algorithm. The *size* corresponds to the entries in :py:class:`hotmic.polynomials.all_polys`, which represents the bitspace of the shift register. The *seed* is the initial value to pass to the algorithm.
[ "Creates", "a", "generator", "using", "the", "Galois", "linear", "feedback", "shift", "register", "algorithm", ".", "The", "*", "size", "*", "corresponds", "to", "the", "entries", "in", ":", "py", ":", "class", ":", "hotmic", ".", "polynomials", ".", "all_...
train
https://github.com/frank2/hotmic/blob/5d4eb3252b0608d19cce6a1f1673b552f51bd351/lib/__init__.py#L9-L32
frank2/hotmic
lib/__init__.py
xrandrange
def xrandrange(start=None, stop=None): ''' Produces an iterator similiar to xrange with the interface of range. The iterator yields random numbers from 0 <= x < *start* if *stop* is not specified, or *start* <= x < *stop* if it is. Here's an example of xrandrange:: >>> list(xrandrange(10)) [2, 1, 0, 7, 4, 3...
python
def xrandrange(start=None, stop=None): ''' Produces an iterator similiar to xrange with the interface of range. The iterator yields random numbers from 0 <= x < *start* if *stop* is not specified, or *start* <= x < *stop* if it is. Here's an example of xrandrange:: >>> list(xrandrange(10)) [2, 1, 0, 7, 4, 3...
[ "def", "xrandrange", "(", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "if", "start", "is", "None", "and", "stop", "is", "None", ":", "raise", "ValueError", "(", "'no stop point specified'", ")", "if", "not", "start", "is", "None", "and", ...
Produces an iterator similiar to xrange with the interface of range. The iterator yields random numbers from 0 <= x < *start* if *stop* is not specified, or *start* <= x < *stop* if it is. Here's an example of xrandrange:: >>> list(xrandrange(10)) [2, 1, 0, 7, 4, 3, 8, 5, 9, 6] >>> list(xrandrange(10, 20)) ...
[ "Produces", "an", "iterator", "similiar", "to", "xrange", "with", "the", "interface", "of", "range", ".", "The", "iterator", "yields", "random", "numbers", "from", "0", "<", "=", "x", "<", "*", "start", "*", "if", "*", "stop", "*", "is", "not", "specif...
train
https://github.com/frank2/hotmic/blob/5d4eb3252b0608d19cce6a1f1673b552f51bd351/lib/__init__.py#L34-L72
frank2/hotmic
lib/__init__.py
randiter
def randiter(iterable): ''' Create an iterator that yields random elements from the iterable object *iterable*. It expects the iterable object to implement __getitem__ and __len__.''' iter_len = len(iterable) for index in xrandrange(iter_len): yield iterable[index]
python
def randiter(iterable): ''' Create an iterator that yields random elements from the iterable object *iterable*. It expects the iterable object to implement __getitem__ and __len__.''' iter_len = len(iterable) for index in xrandrange(iter_len): yield iterable[index]
[ "def", "randiter", "(", "iterable", ")", ":", "iter_len", "=", "len", "(", "iterable", ")", "for", "index", "in", "xrandrange", "(", "iter_len", ")", ":", "yield", "iterable", "[", "index", "]" ]
Create an iterator that yields random elements from the iterable object *iterable*. It expects the iterable object to implement __getitem__ and __len__.
[ "Create", "an", "iterator", "that", "yields", "random", "elements", "from", "the", "iterable", "object", "*", "iterable", "*", ".", "It", "expects", "the", "iterable", "object", "to", "implement", "__getitem__", "and", "__len__", "." ]
train
https://github.com/frank2/hotmic/blob/5d4eb3252b0608d19cce6a1f1673b552f51bd351/lib/__init__.py#L74-L82
rosenbrockc/acorn
acorn/logging/analysis.py
_load_methods
def _load_methods(package): """Loads the mappings from method call result to analysis. Args: package (str): name of the package to load for. """ global _methods _methods[package] = None from acorn.config import settings from acorn.logging.descriptors import _obj_getattr spa...
python
def _load_methods(package): """Loads the mappings from method call result to analysis. Args: package (str): name of the package to load for. """ global _methods _methods[package] = None from acorn.config import settings from acorn.logging.descriptors import _obj_getattr spa...
[ "def", "_load_methods", "(", "package", ")", ":", "global", "_methods", "_methods", "[", "package", "]", "=", "None", "from", "acorn", ".", "config", "import", "settings", "from", "acorn", ".", "logging", ".", "descriptors", "import", "_obj_getattr", "spack", ...
Loads the mappings from method call result to analysis. Args: package (str): name of the package to load for.
[ "Loads", "the", "mappings", "from", "method", "call", "result", "to", "analysis", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/analysis.py#L8-L30
rosenbrockc/acorn
acorn/logging/analysis.py
analyze
def analyze(fqdn, result, argl, argd): """Analyzes the result from calling the method with the specified FQDN. Args: fqdn (str): full-qualified name of the method that was called. result: result of calling the method with `fqdn`. argl (tuple): positional arguments passed to the method c...
python
def analyze(fqdn, result, argl, argd): """Analyzes the result from calling the method with the specified FQDN. Args: fqdn (str): full-qualified name of the method that was called. result: result of calling the method with `fqdn`. argl (tuple): positional arguments passed to the method c...
[ "def", "analyze", "(", "fqdn", ",", "result", ",", "argl", ",", "argd", ")", ":", "package", "=", "fqdn", ".", "split", "(", "'.'", ")", "[", "0", "]", "if", "package", "not", "in", "_methods", ":", "_load_methods", "(", "package", ")", "if", "_met...
Analyzes the result from calling the method with the specified FQDN. Args: fqdn (str): full-qualified name of the method that was called. result: result of calling the method with `fqdn`. argl (tuple): positional arguments passed to the method call. argd (dict): keyword arguments pa...
[ "Analyzes", "the", "result", "from", "calling", "the", "method", "with", "the", "specified", "FQDN", "." ]
train
https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/analysis.py#L32-L46
etcher-be/emiz
emiz/avwx/taf.py
parse
def parse(station: str, txt: str) -> TafData: """ Returns TafData and Units dataclasses with parsed data and their associated units """ core.valid_station(station) while len(txt) > 3 and txt[:4] in ('TAF ', 'AMD ', 'COR '): txt = txt[4:] _, station, time = core.get_station_and_time(txt[:...
python
def parse(station: str, txt: str) -> TafData: """ Returns TafData and Units dataclasses with parsed data and their associated units """ core.valid_station(station) while len(txt) > 3 and txt[:4] in ('TAF ', 'AMD ', 'COR '): txt = txt[4:] _, station, time = core.get_station_and_time(txt[:...
[ "def", "parse", "(", "station", ":", "str", ",", "txt", ":", "str", ")", "->", "TafData", ":", "core", ".", "valid_station", "(", "station", ")", "while", "len", "(", "txt", ")", ">", "3", "and", "txt", "[", ":", "4", "]", "in", "(", "'TAF '", ...
Returns TafData and Units dataclasses with parsed data and their associated units
[ "Returns", "TafData", "and", "Units", "dataclasses", "with", "parsed", "data", "and", "their", "associated", "units" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/taf.py#L22-L70
etcher-be/emiz
emiz/avwx/taf.py
parse_lines
def parse_lines(lines: [str], units: Units, use_na: bool = True) -> [dict]: # type: ignore """ Returns a list of parsed line dictionaries """ parsed_lines = [] prob = '' while lines: raw_line = lines[0].strip() line = core.sanitize_line(raw_line) # Remove prob from the b...
python
def parse_lines(lines: [str], units: Units, use_na: bool = True) -> [dict]: # type: ignore """ Returns a list of parsed line dictionaries """ parsed_lines = [] prob = '' while lines: raw_line = lines[0].strip() line = core.sanitize_line(raw_line) # Remove prob from the b...
[ "def", "parse_lines", "(", "lines", ":", "[", "str", "]", ",", "units", ":", "Units", ",", "use_na", ":", "bool", "=", "True", ")", "->", "[", "dict", "]", ":", "# type: ignore", "parsed_lines", "=", "[", "]", "prob", "=", "''", "while", "lines", "...
Returns a list of parsed line dictionaries
[ "Returns", "a", "list", "of", "parsed", "line", "dictionaries" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/taf.py#L73-L102
etcher-be/emiz
emiz/avwx/taf.py
parse_na_line
def parse_na_line(txt: str, units: Units) -> typing.Dict[str, str]: """ Parser for the North American TAF forcast varient """ retwx = {} wxdata = txt.split(' ') wxdata, _, retwx['wind_shear'] = core.sanitize_report_list(wxdata) wxdata, retwx['type'], retwx['start_time'], retwx['end_time'] = ...
python
def parse_na_line(txt: str, units: Units) -> typing.Dict[str, str]: """ Parser for the North American TAF forcast varient """ retwx = {} wxdata = txt.split(' ') wxdata, _, retwx['wind_shear'] = core.sanitize_report_list(wxdata) wxdata, retwx['type'], retwx['start_time'], retwx['end_time'] = ...
[ "def", "parse_na_line", "(", "txt", ":", "str", ",", "units", ":", "Units", ")", "->", "typing", ".", "Dict", "[", "str", ",", "str", "]", ":", "retwx", "=", "{", "}", "wxdata", "=", "txt", ".", "split", "(", "' '", ")", "wxdata", ",", "_", ","...
Parser for the North American TAF forcast varient
[ "Parser", "for", "the", "North", "American", "TAF", "forcast", "varient" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/taf.py#L105-L119
etcher-be/emiz
emiz/avwx/taf.py
parse_in_line
def parse_in_line(txt: str, units: Units) -> typing.Dict[str, str]: """ Parser for the International TAF forcast varient """ retwx = {} wxdata = txt.split(' ') wxdata, _, retwx['wind_shear'] = core.sanitize_report_list(wxdata) wxdata, retwx['type'], retwx['start_time'], retwx['end_time'] = c...
python
def parse_in_line(txt: str, units: Units) -> typing.Dict[str, str]: """ Parser for the International TAF forcast varient """ retwx = {} wxdata = txt.split(' ') wxdata, _, retwx['wind_shear'] = core.sanitize_report_list(wxdata) wxdata, retwx['type'], retwx['start_time'], retwx['end_time'] = c...
[ "def", "parse_in_line", "(", "txt", ":", "str", ",", "units", ":", "Units", ")", "->", "typing", ".", "Dict", "[", "str", ",", "str", "]", ":", "retwx", "=", "{", "}", "wxdata", "=", "txt", ".", "split", "(", "' '", ")", "wxdata", ",", "_", ","...
Parser for the International TAF forcast varient
[ "Parser", "for", "the", "International", "TAF", "forcast", "varient" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/taf.py#L122-L141
metagriffin/secpass
secpass/api.py
Store.modify
def modify(self, entry_id, **kw): ''' Incremental version of :meth:`update`: instead of updating all attributes of the entry to the specified values, this method only updates the specified keywords. Returns True on success, or raises an exception on failure. Note: the default implementation ass...
python
def modify(self, entry_id, **kw): ''' Incremental version of :meth:`update`: instead of updating all attributes of the entry to the specified values, this method only updates the specified keywords. Returns True on success, or raises an exception on failure. Note: the default implementation ass...
[ "def", "modify", "(", "self", ",", "entry_id", ",", "*", "*", "kw", ")", ":", "entry", "=", "self", ".", "read", "(", "entry_id", ")", "for", "k", ",", "v", "in", "kw", ".", "items", "(", ")", ":", "setattr", "(", "entry", ",", "k", ",", "v",...
Incremental version of :meth:`update`: instead of updating all attributes of the entry to the specified values, this method only updates the specified keywords. Returns True on success, or raises an exception on failure. Note: the default implementation assumes fast and sequential access and reads ...
[ "Incremental", "version", "of", ":", "meth", ":", "update", ":", "instead", "of", "updating", "all", "attributes", "of", "the", "entry", "to", "the", "specified", "values", "this", "method", "only", "updates", "the", "specified", "keywords", ".", "Returns", ...
train
https://github.com/metagriffin/secpass/blob/7ec29666e82cb8900e5c36552ab2ee3403021a6a/secpass/api.py#L146-L161
PyMLGame/pymlgame
pymlgame/screen.py
Screen.reset
def reset(self): """ Fill the screen with black pixels """ surface = Surface(self.width, self.height) surface.fill(BLACK) self.matrix = surface.matrix
python
def reset(self): """ Fill the screen with black pixels """ surface = Surface(self.width, self.height) surface.fill(BLACK) self.matrix = surface.matrix
[ "def", "reset", "(", "self", ")", ":", "surface", "=", "Surface", "(", "self", ".", "width", ",", "self", ".", "height", ")", "surface", ".", "fill", "(", "BLACK", ")", "self", ".", "matrix", "=", "surface", ".", "matrix" ]
Fill the screen with black pixels
[ "Fill", "the", "screen", "with", "black", "pixels" ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/screen.py#L29-L35
PyMLGame/pymlgame
pymlgame/screen.py
Screen.update
def update(self): """ Sends the current screen contents to Mate Light """ display_data = [] for y in range(self.height): for x in range(self.width): for color in self.matrix[x][y]: display_data.append(int(color)) checksum =...
python
def update(self): """ Sends the current screen contents to Mate Light """ display_data = [] for y in range(self.height): for x in range(self.width): for color in self.matrix[x][y]: display_data.append(int(color)) checksum =...
[ "def", "update", "(", "self", ")", ":", "display_data", "=", "[", "]", "for", "y", "in", "range", "(", "self", ".", "height", ")", ":", "for", "x", "in", "range", "(", "self", ".", "width", ")", ":", "for", "color", "in", "self", ".", "matrix", ...
Sends the current screen contents to Mate Light
[ "Sends", "the", "current", "screen", "contents", "to", "Mate", "Light" ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/screen.py#L37-L51
PyMLGame/pymlgame
pymlgame/screen.py
Screen.blit
def blit(self, surface, pos=(0, 0)): """ Blits a surface on the screen at pos :param surface: Surface to blit :param pos: Top left corner to start blitting :type surface: Surface :type pos: tuple """ for x in range(surface.width): for y in ran...
python
def blit(self, surface, pos=(0, 0)): """ Blits a surface on the screen at pos :param surface: Surface to blit :param pos: Top left corner to start blitting :type surface: Surface :type pos: tuple """ for x in range(surface.width): for y in ran...
[ "def", "blit", "(", "self", ",", "surface", ",", "pos", "=", "(", "0", ",", "0", ")", ")", ":", "for", "x", "in", "range", "(", "surface", ".", "width", ")", ":", "for", "y", "in", "range", "(", "surface", ".", "height", ")", ":", "point", "=...
Blits a surface on the screen at pos :param surface: Surface to blit :param pos: Top left corner to start blitting :type surface: Surface :type pos: tuple
[ "Blits", "a", "surface", "on", "the", "screen", "at", "pos" ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/screen.py#L53-L66
PyMLGame/pymlgame
pymlgame/screen.py
Screen.point_on_screen
def point_on_screen(self, pos): """ Is the point still on the screen? :param pos: Point :type pos: tuple :return: Is it? :rtype: bool """ if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height: return True else: return F...
python
def point_on_screen(self, pos): """ Is the point still on the screen? :param pos: Point :type pos: tuple :return: Is it? :rtype: bool """ if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height: return True else: return F...
[ "def", "point_on_screen", "(", "self", ",", "pos", ")", ":", "if", "0", "<=", "pos", "[", "0", "]", "<", "self", ".", "width", "and", "0", "<=", "pos", "[", "1", "]", "<", "self", ".", "height", ":", "return", "True", "else", ":", "return", "Fa...
Is the point still on the screen? :param pos: Point :type pos: tuple :return: Is it? :rtype: bool
[ "Is", "the", "point", "still", "on", "the", "screen?" ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/screen.py#L68-L80
chrisvoncsefalvay/urbanpyctionary
urbanpyctionary/client.py
Client.get
def get(self, word): """ Obtains the definition of a word from Urban Dictionary. :param word: word to be searched for :type word: str :return: a result set with all definitions for the word """ url = "https://mashape-community-urban-dictionary.p.mashape.com/defi...
python
def get(self, word): """ Obtains the definition of a word from Urban Dictionary. :param word: word to be searched for :type word: str :return: a result set with all definitions for the word """ url = "https://mashape-community-urban-dictionary.p.mashape.com/defi...
[ "def", "get", "(", "self", ",", "word", ")", ":", "url", "=", "\"https://mashape-community-urban-dictionary.p.mashape.com/define?term=%s\"", "%", "word", "try", ":", "res", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "{", "\"X-Mashape-Key\"", "...
Obtains the definition of a word from Urban Dictionary. :param word: word to be searched for :type word: str :return: a result set with all definitions for the word
[ "Obtains", "the", "definition", "of", "a", "word", "from", "Urban", "Dictionary", "." ]
train
https://github.com/chrisvoncsefalvay/urbanpyctionary/blob/77ce3262d25d16ae9179909a34197c102adb2f06/urbanpyctionary/client.py#L115-L140
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.estimate
def estimate(self, upgrades): """Estimate the time needed to apply upgrades. If an upgrades does not specify and estimate it is assumed to be in the order of 1 second. :param upgrades: List of upgrades sorted in topological order. """ val = 0 for u in upgrades: ...
python
def estimate(self, upgrades): """Estimate the time needed to apply upgrades. If an upgrades does not specify and estimate it is assumed to be in the order of 1 second. :param upgrades: List of upgrades sorted in topological order. """ val = 0 for u in upgrades: ...
[ "def", "estimate", "(", "self", ",", "upgrades", ")", ":", "val", "=", "0", "for", "u", "in", "upgrades", ":", "val", "+=", "u", ".", "estimate", "(", ")", "return", "val" ]
Estimate the time needed to apply upgrades. If an upgrades does not specify and estimate it is assumed to be in the order of 1 second. :param upgrades: List of upgrades sorted in topological order.
[ "Estimate", "the", "time", "needed", "to", "apply", "upgrades", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L81-L92
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.human_estimate
def human_estimate(self, upgrades): """Make a human readable estimated time to completion string. :param upgrades: List of upgrades sorted in topological order. """ val = self.estimate(upgrades) if val < 60: return "less than 1 minute" elif val < 300: ...
python
def human_estimate(self, upgrades): """Make a human readable estimated time to completion string. :param upgrades: List of upgrades sorted in topological order. """ val = self.estimate(upgrades) if val < 60: return "less than 1 minute" elif val < 300: ...
[ "def", "human_estimate", "(", "self", ",", "upgrades", ")", ":", "val", "=", "self", ".", "estimate", "(", "upgrades", ")", "if", "val", "<", "60", ":", "return", "\"less than 1 minute\"", "elif", "val", "<", "300", ":", "return", "\"less than 5 minutes\"", ...
Make a human readable estimated time to completion string. :param upgrades: List of upgrades sorted in topological order.
[ "Make", "a", "human", "readable", "estimated", "time", "to", "completion", "string", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L94-L119
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._setup_log_prefix
def _setup_log_prefix(self, plugin_id=''): """Setup custom warning notification.""" self._logger_console_fmtter.prefix = '%s: ' % plugin_id self._logger_console_fmtter.plugin_id = plugin_id self._logger_file_fmtter.prefix = '*' self._logger_file_fmtter.plugin_id = '%s: ' % plugin...
python
def _setup_log_prefix(self, plugin_id=''): """Setup custom warning notification.""" self._logger_console_fmtter.prefix = '%s: ' % plugin_id self._logger_console_fmtter.plugin_id = plugin_id self._logger_file_fmtter.prefix = '*' self._logger_file_fmtter.plugin_id = '%s: ' % plugin...
[ "def", "_setup_log_prefix", "(", "self", ",", "plugin_id", "=", "''", ")", ":", "self", ".", "_logger_console_fmtter", ".", "prefix", "=", "'%s: '", "%", "plugin_id", "self", ".", "_logger_console_fmtter", ".", "plugin_id", "=", "plugin_id", "self", ".", "_log...
Setup custom warning notification.
[ "Setup", "custom", "warning", "notification", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L121-L126
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._teardown_log_prefix
def _teardown_log_prefix(self): """Tear down custom warning notification.""" self._logger_console_fmtter.prefix = '' self._logger_console_fmtter.plugin_id = '' self._logger_file_fmtter.prefix = ' ' self._logger_file_fmtter.plugin_id = ''
python
def _teardown_log_prefix(self): """Tear down custom warning notification.""" self._logger_console_fmtter.prefix = '' self._logger_console_fmtter.plugin_id = '' self._logger_file_fmtter.prefix = ' ' self._logger_file_fmtter.plugin_id = ''
[ "def", "_teardown_log_prefix", "(", "self", ")", ":", "self", ".", "_logger_console_fmtter", ".", "prefix", "=", "''", "self", ".", "_logger_console_fmtter", ".", "plugin_id", "=", "''", "self", ".", "_logger_file_fmtter", ".", "prefix", "=", "' '", "self", "....
Tear down custom warning notification.
[ "Tear", "down", "custom", "warning", "notification", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L128-L133
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.get_logger
def get_logger(self, logfilename=None): """Setup logger. Allow outputting to both a log file and console at the same time. """ if self._logger is None: self._logger = logging.getLogger('invenio_upgrader') self._logger.setLevel(logging.INFO) i...
python
def get_logger(self, logfilename=None): """Setup logger. Allow outputting to both a log file and console at the same time. """ if self._logger is None: self._logger = logging.getLogger('invenio_upgrader') self._logger.setLevel(logging.INFO) i...
[ "def", "get_logger", "(", "self", ",", "logfilename", "=", "None", ")", ":", "if", "self", ".", "_logger", "is", "None", ":", "self", ".", "_logger", "=", "logging", ".", "getLogger", "(", "'invenio_upgrader'", ")", "self", ".", "_logger", ".", "setLevel...
Setup logger. Allow outputting to both a log file and console at the same time.
[ "Setup", "logger", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L135-L167
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.pre_upgrade_checks
def pre_upgrade_checks(self, upgrades): """Run upgrade pre-checks prior to applying upgrades. Pre-checks should in general be fast to execute. Pre-checks may the use the wait_for_user function, to query the user for confirmation, but should respect the --yes-i-know option to run...
python
def pre_upgrade_checks(self, upgrades): """Run upgrade pre-checks prior to applying upgrades. Pre-checks should in general be fast to execute. Pre-checks may the use the wait_for_user function, to query the user for confirmation, but should respect the --yes-i-know option to run...
[ "def", "pre_upgrade_checks", "(", "self", ",", "upgrades", ")", ":", "errors", "=", "[", "]", "for", "check", "in", "self", ".", "global_pre_upgrade", ":", "self", ".", "_setup_log_prefix", "(", "plugin_id", "=", "check", ".", "__name__", ")", "try", ":", ...
Run upgrade pre-checks prior to applying upgrades. Pre-checks should in general be fast to execute. Pre-checks may the use the wait_for_user function, to query the user for confirmation, but should respect the --yes-i-know option to run unattended. All pre-checks will be execut...
[ "Run", "upgrade", "pre", "-", "checks", "prior", "to", "applying", "upgrades", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L177-L209
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._check_errors
def _check_errors(self, errors, prefix): """Check for errors and possible raise and format an error message. :param errors: List of error messages. :param prefix: str, Prefix message for error messages """ args = [] for uid, messages in errors: error_msg = [...
python
def _check_errors(self, errors, prefix): """Check for errors and possible raise and format an error message. :param errors: List of error messages. :param prefix: str, Prefix message for error messages """ args = [] for uid, messages in errors: error_msg = [...
[ "def", "_check_errors", "(", "self", ",", "errors", ",", "prefix", ")", ":", "args", "=", "[", "]", "for", "uid", ",", "messages", "in", "errors", ":", "error_msg", "=", "[", "]", "error_msg", ".", "append", "(", "prefix", "%", "uid", ")", "for", "...
Check for errors and possible raise and format an error message. :param errors: List of error messages. :param prefix: str, Prefix message for error messages
[ "Check", "for", "errors", "and", "possible", "raise", "and", "format", "an", "error", "message", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L211-L227
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.post_upgrade_checks
def post_upgrade_checks(self, upgrades): """Run post-upgrade checks after applying all pending upgrades. Post checks may be used to emit warnings encountered when applying an upgrade, but post-checks can also be used to advice the user to run re-indexing or similar long running processe...
python
def post_upgrade_checks(self, upgrades): """Run post-upgrade checks after applying all pending upgrades. Post checks may be used to emit warnings encountered when applying an upgrade, but post-checks can also be used to advice the user to run re-indexing or similar long running processe...
[ "def", "post_upgrade_checks", "(", "self", ",", "upgrades", ")", ":", "errors", "=", "[", "]", "for", "u", "in", "upgrades", ":", "self", ".", "_setup_log_prefix", "(", "plugin_id", "=", "u", ".", "name", ")", "try", ":", "u", ".", "post_upgrade", "(",...
Run post-upgrade checks after applying all pending upgrades. Post checks may be used to emit warnings encountered when applying an upgrade, but post-checks can also be used to advice the user to run re-indexing or similar long running processes. Post-checks may query for user-input, bu...
[ "Run", "post", "-", "upgrade", "checks", "after", "applying", "all", "pending", "upgrades", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L229-L262
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.apply_upgrade
def apply_upgrade(self, upgrade): """Apply a upgrade and register that it was successful. A upgrade may throw a RuntimeError, if an unrecoverable error happens. :param upgrade: A single upgrade """ self._setup_log_prefix(plugin_id=upgrade.name) try: # Nested due to Py...
python
def apply_upgrade(self, upgrade): """Apply a upgrade and register that it was successful. A upgrade may throw a RuntimeError, if an unrecoverable error happens. :param upgrade: A single upgrade """ self._setup_log_prefix(plugin_id=upgrade.name) try: # Nested due to Py...
[ "def", "apply_upgrade", "(", "self", ",", "upgrade", ")", ":", "self", ".", "_setup_log_prefix", "(", "plugin_id", "=", "upgrade", ".", "name", ")", "try", ":", "# Nested due to Python 2.4", "try", ":", "upgrade", ".", "do_upgrade", "(", ")", "self", ".", ...
Apply a upgrade and register that it was successful. A upgrade may throw a RuntimeError, if an unrecoverable error happens. :param upgrade: A single upgrade
[ "Apply", "a", "upgrade", "and", "register", "that", "it", "was", "successful", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L264-L292
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.load_history
def load_history(self): """Load upgrade history from database table. If upgrade table does not exists, the history is assumed to be empty. """ if not self.history: query = Upgrade.query.order_by(desc(Upgrade.applied)) for u in query.all(): self.h...
python
def load_history(self): """Load upgrade history from database table. If upgrade table does not exists, the history is assumed to be empty. """ if not self.history: query = Upgrade.query.order_by(desc(Upgrade.applied)) for u in query.all(): self.h...
[ "def", "load_history", "(", "self", ")", ":", "if", "not", "self", ".", "history", ":", "query", "=", "Upgrade", ".", "query", ".", "order_by", "(", "desc", "(", "Upgrade", ".", "applied", ")", ")", "for", "u", "in", "query", ".", "all", "(", ")", ...
Load upgrade history from database table. If upgrade table does not exists, the history is assumed to be empty.
[ "Load", "upgrade", "history", "from", "database", "table", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L294-L304
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.register_success
def register_success(self, upgrade): """Register a successful upgrade.""" u = Upgrade(upgrade=upgrade.name, applied=datetime.now()) db.session.add(u) db.session.commit()
python
def register_success(self, upgrade): """Register a successful upgrade.""" u = Upgrade(upgrade=upgrade.name, applied=datetime.now()) db.session.add(u) db.session.commit()
[ "def", "register_success", "(", "self", ",", "upgrade", ")", ":", "u", "=", "Upgrade", "(", "upgrade", "=", "upgrade", ".", "name", ",", "applied", "=", "datetime", ".", "now", "(", ")", ")", "db", ".", "session", ".", "add", "(", "u", ")", "db", ...
Register a successful upgrade.
[ "Register", "a", "successful", "upgrade", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L314-L318
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.get_history
def get_history(self): """Get history of applied upgrades.""" self.load_history() return map(lambda x: (x, self.history[x]), self.ordered_history)
python
def get_history(self): """Get history of applied upgrades.""" self.load_history() return map(lambda x: (x, self.history[x]), self.ordered_history)
[ "def", "get_history", "(", "self", ")", ":", "self", ".", "load_history", "(", ")", "return", "map", "(", "lambda", "x", ":", "(", "x", ",", "self", ".", "history", "[", "x", "]", ")", ",", "self", ".", "ordered_history", ")" ]
Get history of applied upgrades.
[ "Get", "history", "of", "applied", "upgrades", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L320-L323
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._load_upgrades
def _load_upgrades(self, remove_applied=True): """Load upgrade modules. :param remove_applied: if True, already applied upgrades will not be included, if False the entire upgrade graph will be returned. """ if remove_applied: self.load_history() ...
python
def _load_upgrades(self, remove_applied=True): """Load upgrade modules. :param remove_applied: if True, already applied upgrades will not be included, if False the entire upgrade graph will be returned. """ if remove_applied: self.load_history() ...
[ "def", "_load_upgrades", "(", "self", ",", "remove_applied", "=", "True", ")", ":", "if", "remove_applied", ":", "self", ".", "load_history", "(", ")", "for", "entry_point", "in", "iter_entry_points", "(", "'invenio_upgrader.upgrades'", ")", ":", "upgrade", "=",...
Load upgrade modules. :param remove_applied: if True, already applied upgrades will not be included, if False the entire upgrade graph will be returned.
[ "Load", "upgrade", "modules", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L325-L339
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.get_upgrades
def get_upgrades(self, remove_applied=True): """Get upgrades (ordered according to their dependencies). :param remove_applied: Set to false to return all upgrades, otherwise already applied upgrades are removed from their graph (incl. all their dependencies. """ ...
python
def get_upgrades(self, remove_applied=True): """Get upgrades (ordered according to their dependencies). :param remove_applied: Set to false to return all upgrades, otherwise already applied upgrades are removed from their graph (incl. all their dependencies. """ ...
[ "def", "get_upgrades", "(", "self", ",", "remove_applied", "=", "True", ")", ":", "if", "self", ".", "upgrades", "is", "None", ":", "plugins", "=", "self", ".", "_load_upgrades", "(", "remove_applied", "=", "remove_applied", ")", "# List of un-applied upgrades i...
Get upgrades (ordered according to their dependencies). :param remove_applied: Set to false to return all upgrades, otherwise already applied upgrades are removed from their graph (incl. all their dependencies.
[ "Get", "upgrades", "(", "ordered", "according", "to", "their", "dependencies", ")", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L341-L353
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._create_graph
def _create_graph(self, upgrades, history=None): """Create dependency graph from upgrades. :param upgrades: Dict of upgrades :param history: Dict of applied upgrades """ history = history or {} graph_incoming = {} # nodes their incoming edges graph_outgoing = {}...
python
def _create_graph(self, upgrades, history=None): """Create dependency graph from upgrades. :param upgrades: Dict of upgrades :param history: Dict of applied upgrades """ history = history or {} graph_incoming = {} # nodes their incoming edges graph_outgoing = {}...
[ "def", "_create_graph", "(", "self", ",", "upgrades", ",", "history", "=", "None", ")", ":", "history", "=", "history", "or", "{", "}", "graph_incoming", "=", "{", "}", "# nodes their incoming edges", "graph_outgoing", "=", "{", "}", "# nodes their outgoing edge...
Create dependency graph from upgrades. :param upgrades: Dict of upgrades :param history: Dict of applied upgrades
[ "Create", "dependency", "graph", "from", "upgrades", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L355-L378
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.find_endpoints
def find_endpoints(self): """Find upgrade end-points (i.e nodes without dependents).""" plugins = self._load_upgrades(remove_applied=False) dummy_graph_incoming, graph_outgoing = self._create_graph(plugins, {}) endpoints = {} for node, outgoing in six.iteritems(graph_outgoing):...
python
def find_endpoints(self): """Find upgrade end-points (i.e nodes without dependents).""" plugins = self._load_upgrades(remove_applied=False) dummy_graph_incoming, graph_outgoing = self._create_graph(plugins, {}) endpoints = {} for node, outgoing in six.iteritems(graph_outgoing):...
[ "def", "find_endpoints", "(", "self", ")", ":", "plugins", "=", "self", ".", "_load_upgrades", "(", "remove_applied", "=", "False", ")", "dummy_graph_incoming", ",", "graph_outgoing", "=", "self", ".", "_create_graph", "(", "plugins", ",", "{", "}", ")", "en...
Find upgrade end-points (i.e nodes without dependents).
[ "Find", "upgrade", "end", "-", "points", "(", "i", ".", "e", "nodes", "without", "dependents", ")", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L380-L394
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader.order_upgrades
def order_upgrades(self, upgrades, history=None): """Order upgrades according to their dependencies. (topological sort using Kahn's algorithm - http://en.wikipedia.org/wiki/Topological_sorting). :param upgrades: Dict of upgrades :param history: Dict of applied upgrades ...
python
def order_upgrades(self, upgrades, history=None): """Order upgrades according to their dependencies. (topological sort using Kahn's algorithm - http://en.wikipedia.org/wiki/Topological_sorting). :param upgrades: Dict of upgrades :param history: Dict of applied upgrades ...
[ "def", "order_upgrades", "(", "self", ",", "upgrades", ",", "history", "=", "None", ")", ":", "history", "=", "history", "or", "{", "}", "graph_incoming", ",", "graph_outgoing", "=", "self", ".", "_create_graph", "(", "upgrades", ",", "history", ")", "# Re...
Order upgrades according to their dependencies. (topological sort using Kahn's algorithm - http://en.wikipedia.org/wiki/Topological_sorting). :param upgrades: Dict of upgrades :param history: Dict of applied upgrades
[ "Order", "upgrades", "according", "to", "their", "dependencies", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L396-L467
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
InvenioUpgrader._parse_plugin_id
def _parse_plugin_id(self, plugin_id): """Determine repository from plugin id.""" m = re.match("(.+)(_\d{4}_\d{2}_\d{2}_)(.+)", plugin_id) if m: return m.group(1) m = re.match("(.+)(_release_)(.+)", plugin_id) if m: return m.group(1) raise Runtime...
python
def _parse_plugin_id(self, plugin_id): """Determine repository from plugin id.""" m = re.match("(.+)(_\d{4}_\d{2}_\d{2}_)(.+)", plugin_id) if m: return m.group(1) m = re.match("(.+)(_release_)(.+)", plugin_id) if m: return m.group(1) raise Runtime...
[ "def", "_parse_plugin_id", "(", "self", ",", "plugin_id", ")", ":", "m", "=", "re", ".", "match", "(", "\"(.+)(_\\d{4}_\\d{2}_\\d{2}_)(.+)\"", ",", "plugin_id", ")", "if", "m", ":", "return", "m", ".", "group", "(", "1", ")", "m", "=", "re", ".", "matc...
Determine repository from plugin id.
[ "Determine", "repository", "from", "plugin", "id", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L469-L479
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/engine.py
UpgradeBase.repository
def repository(self): """Repository.""" m = re.match("(.+)(_\d{4}_\d{2}_\d{2}_)(.+)", self.__module__) if m: return m.group(1) m = re.match("(.+)(_release_)(.+)", self.__module__) if m: return m.group(1)
python
def repository(self): """Repository.""" m = re.match("(.+)(_\d{4}_\d{2}_\d{2}_)(.+)", self.__module__) if m: return m.group(1) m = re.match("(.+)(_release_)(.+)", self.__module__) if m: return m.group(1)
[ "def", "repository", "(", "self", ")", ":", "m", "=", "re", ".", "match", "(", "\"(.+)(_\\d{4}_\\d{2}_\\d{2}_)(.+)\"", ",", "self", ".", "__module__", ")", "if", "m", ":", "return", "m", ".", "group", "(", "1", ")", "m", "=", "re", ".", "match", "(",...
Repository.
[ "Repository", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/engine.py#L507-L514
etcher-be/emiz
emiz/weather/mizfile/mizfile_get_metar.py
get_metar_from_mission
def get_metar_from_mission( mission_file: str, icao: str = 'XXXX', time: str = None, ) -> str: """ Builds a dummy METAR string from a mission file Args: mission_file: input mission file icao: dummy ICAO (defaults to XXXX) time: dummy time (defaults to now()) ...
python
def get_metar_from_mission( mission_file: str, icao: str = 'XXXX', time: str = None, ) -> str: """ Builds a dummy METAR string from a mission file Args: mission_file: input mission file icao: dummy ICAO (defaults to XXXX) time: dummy time (defaults to now()) ...
[ "def", "get_metar_from_mission", "(", "mission_file", ":", "str", ",", "icao", ":", "str", "=", "'XXXX'", ",", "time", ":", "str", "=", "None", ",", ")", "->", "str", ":", "return", "_MetarFromMission", "(", "mission_file", "=", "mission_file", ",", "icao"...
Builds a dummy METAR string from a mission file Args: mission_file: input mission file icao: dummy ICAO (defaults to XXXX) time: dummy time (defaults to now()) Returns: METAR str
[ "Builds", "a", "dummy", "METAR", "string", "from", "a", "mission", "file" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/mizfile/mizfile_get_metar.py#L138-L158
etcher-be/emiz
emiz/weather/mizfile/mizfile_get_metar.py
_MetarFromMission.metar
def metar(self) -> str: """ Builds a METAR string from a MIZ file A lots of information is inferred from what information we have available in DCS. There constraints in the way MIZ files are built, with precipitations for example. Returns: METAR string """ metar...
python
def metar(self) -> str: """ Builds a METAR string from a MIZ file A lots of information is inferred from what information we have available in DCS. There constraints in the way MIZ files are built, with precipitations for example. Returns: METAR string """ metar...
[ "def", "metar", "(", "self", ")", "->", "str", ":", "metar", "=", "f'{self._icao} '", "f'{self._time} '", "f'{self._wind} '", "f'{self._visibility} '", "f'{self._precipitations} '", "f'{self._clouds} '", "f'{self._temperature} '", "f'{self._pressure} '", "f'{self._qualifier}'", ...
Builds a METAR string from a MIZ file A lots of information is inferred from what information we have available in DCS. There constraints in the way MIZ files are built, with precipitations for example. Returns: METAR string
[ "Builds", "a", "METAR", "string", "from", "a", "MIZ", "file" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/mizfile/mizfile_get_metar.py#L115-L133
dossier/dossier.models
dossier/models/subtopic.py
subtopics
def subtopics(store, folders, folder_id, subfolder_id, ann_id=None): '''Yields an unordered generator of subtopics in a subfolder. Each item of the generator is a 4-tuple of ``content_id``, ``subtopic_id``, ``subtopic_type`` and ``data``. Subtopic type is one of the following Unicode strings: ``text``,...
python
def subtopics(store, folders, folder_id, subfolder_id, ann_id=None): '''Yields an unordered generator of subtopics in a subfolder. Each item of the generator is a 4-tuple of ``content_id``, ``subtopic_id``, ``subtopic_type`` and ``data``. Subtopic type is one of the following Unicode strings: ``text``,...
[ "def", "subtopics", "(", "store", ",", "folders", ",", "folder_id", ",", "subfolder_id", ",", "ann_id", "=", "None", ")", ":", "# This code will be changed soon. In essence, it implements the", "# convention established in SortingDesk for storing subtopic data.", "# Currently, su...
Yields an unordered generator of subtopics in a subfolder. Each item of the generator is a 4-tuple of ``content_id``, ``subtopic_id``, ``subtopic_type`` and ``data``. Subtopic type is one of the following Unicode strings: ``text``, ``image`` or ``manual``. The type of ``data`` is dependent on the s...
[ "Yields", "an", "unordered", "generator", "of", "subtopics", "in", "a", "subfolder", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/subtopic.py#L9-L46
dossier/dossier.models
dossier/models/subtopic.py
typed_subtopic_data
def typed_subtopic_data(fc, subid): '''Returns typed subtopic data from an FC.''' # I don't think this code will change after we fix the data race bug. ---AG ty = subtopic_type(subid) data = get_unicode_feature(fc, subid) assert isinstance(data, unicode), \ 'data should be `unicode` but is %...
python
def typed_subtopic_data(fc, subid): '''Returns typed subtopic data from an FC.''' # I don't think this code will change after we fix the data race bug. ---AG ty = subtopic_type(subid) data = get_unicode_feature(fc, subid) assert isinstance(data, unicode), \ 'data should be `unicode` but is %...
[ "def", "typed_subtopic_data", "(", "fc", ",", "subid", ")", ":", "# I don't think this code will change after we fix the data race bug. ---AG", "ty", "=", "subtopic_type", "(", "subid", ")", "data", "=", "get_unicode_feature", "(", "fc", ",", "subid", ")", "assert", "...
Returns typed subtopic data from an FC.
[ "Returns", "typed", "subtopic", "data", "from", "an", "FC", "." ]
train
https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/subtopic.py#L49-L63
ch3pjw/junction
jcn/root.py
Root.run
def run(self): '''The main entry point of a :mod:`jcn`-based application. :meth:`run` sets up the terminal and then runs then event loop, continually responding to user input and drawing UI element to the screen when required. Specifically, :mod:`jcn` applications run the termin...
python
def run(self): '''The main entry point of a :mod:`jcn`-based application. :meth:`run` sets up the terminal and then runs then event loop, continually responding to user input and drawing UI element to the screen when required. Specifically, :mod:`jcn` applications run the termin...
[ "def", "run", "(", "self", ")", ":", "with", "self", ".", "terminal", ".", "fullscreen", "(", ")", ",", "self", ".", "terminal", ".", "hidden_cursor", "(", ")", ",", "(", "self", ".", "terminal", ".", "unbuffered_input", "(", ")", ")", ",", "(", "s...
The main entry point of a :mod:`jcn`-based application. :meth:`run` sets up the terminal and then runs then event loop, continually responding to user input and drawing UI element to the screen when required. Specifically, :mod:`jcn` applications run the terminal full-screen and ...
[ "The", "main", "entry", "point", "of", "a", ":", "mod", ":", "jcn", "-", "based", "application", ".", ":", "meth", ":", "run", "sets", "up", "the", "terminal", "and", "then", "runs", "then", "event", "loop", "continually", "responding", "to", "user", "...
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/root.py#L108-L137
ch3pjw/junction
jcn/root.py
Root.draw
def draw(self): '''Draw the tree of UI elements once directly to the terminal. The root element of the UI is referenced by this instance's :attr:`element` attribute. Layout is automatically calculated by the UI elements in the tree in reponse ultimately to the :attr:`width` and :attr:`he...
python
def draw(self): '''Draw the tree of UI elements once directly to the terminal. The root element of the UI is referenced by this instance's :attr:`element` attribute. Layout is automatically calculated by the UI elements in the tree in reponse ultimately to the :attr:`width` and :attr:`he...
[ "def", "draw", "(", "self", ")", ":", "super", "(", ")", ".", "draw", "(", "self", ".", "terminal", ".", "width", ",", "self", ".", "terminal", ".", "height", ",", "terminal", "=", "self", ".", "terminal", ",", "styles", "=", "self", ".", "style", ...
Draw the tree of UI elements once directly to the terminal. The root element of the UI is referenced by this instance's :attr:`element` attribute. Layout is automatically calculated by the UI elements in the tree in reponse ultimately to the :attr:`width` and :attr:`height` attributes of...
[ "Draw", "the", "tree", "of", "UI", "elements", "once", "directly", "to", "the", "terminal", ".", "The", "root", "element", "of", "the", "UI", "is", "referenced", "by", "this", "instance", "s", ":", "attr", ":", "element", "attribute", ".", "Layout", "is"...
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/root.py#L139-L150
ch3pjw/junction
jcn/root.py
Root.update
def update(self): '''Draws directly to the terminal any UI elements in the tree that are marked as having been updated. UI elements may have marked themselves as updated if, for example, notable attributes have been altered, or the :attr:`updated` element may be set to ``True`` explicitl...
python
def update(self): '''Draws directly to the terminal any UI elements in the tree that are marked as having been updated. UI elements may have marked themselves as updated if, for example, notable attributes have been altered, or the :attr:`updated` element may be set to ``True`` explicitl...
[ "def", "update", "(", "self", ")", ":", "super", "(", ")", ".", "update", "(", "self", ".", "default_format", ",", "terminal", "=", "self", ".", "terminal", ",", "styles", "=", "self", ".", "style", ")" ]
Draws directly to the terminal any UI elements in the tree that are marked as having been updated. UI elements may have marked themselves as updated if, for example, notable attributes have been altered, or the :attr:`updated` element may be set to ``True`` explicitly by your program. Th...
[ "Draws", "directly", "to", "the", "terminal", "any", "UI", "elements", "in", "the", "tree", "that", "are", "marked", "as", "having", "been", "updated", ".", "UI", "elements", "may", "have", "marked", "themselves", "as", "updated", "if", "for", "example", "...
train
https://github.com/ch3pjw/junction/blob/7d0c4d279589bee8ae7b3ac4dee2ab425c0b1b0e/jcn/root.py#L152-L161
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/structures.py
MetadataFile._parse
def _parse(self): """ Parse :attr:`raw_data`. Returns: MetadataFile: New MetadataFile with parsed data inside (namedtuples are immutable). """ return MetadataFile( self.filename, self.raw_data, decoders.pa...
python
def _parse(self): """ Parse :attr:`raw_data`. Returns: MetadataFile: New MetadataFile with parsed data inside (namedtuples are immutable). """ return MetadataFile( self.filename, self.raw_data, decoders.pa...
[ "def", "_parse", "(", "self", ")", ":", "return", "MetadataFile", "(", "self", ".", "filename", ",", "self", ".", "raw_data", ",", "decoders", ".", "parse_meta", "(", "self", ".", "filename", ",", "self", ".", "raw_data", ")", ")" ]
Parse :attr:`raw_data`. Returns: MetadataFile: New MetadataFile with parsed data inside (namedtuples are immutable).
[ "Parse", ":", "attr", ":", "raw_data", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/structures.py#L149-L161
bfontaine/p7magma
magma/souputils.py
text
def text(el, strip=True): """ Return the text of a ``BeautifulSoup`` element """ if not el: return "" text = el.text if strip: text = text.strip() return text
python
def text(el, strip=True): """ Return the text of a ``BeautifulSoup`` element """ if not el: return "" text = el.text if strip: text = text.strip() return text
[ "def", "text", "(", "el", ",", "strip", "=", "True", ")", ":", "if", "not", "el", ":", "return", "\"\"", "text", "=", "el", ".", "text", "if", "strip", ":", "text", "=", "text", ".", "strip", "(", ")", "return", "text" ]
Return the text of a ``BeautifulSoup`` element
[ "Return", "the", "text", "of", "a", "BeautifulSoup", "element" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/souputils.py#L8-L18
bfontaine/p7magma
magma/souputils.py
coursecode
def coursecode(el): """ Return the text of a ``BeautifulSoup`` element, assuming it's a course code (it strips any square-brackets-surrounded number at its end). """ txt = text(el) return re.sub(r"\s*\[\d+\]$", "", txt, re.UNICODE)
python
def coursecode(el): """ Return the text of a ``BeautifulSoup`` element, assuming it's a course code (it strips any square-brackets-surrounded number at its end). """ txt = text(el) return re.sub(r"\s*\[\d+\]$", "", txt, re.UNICODE)
[ "def", "coursecode", "(", "el", ")", ":", "txt", "=", "text", "(", "el", ")", "return", "re", ".", "sub", "(", "r\"\\s*\\[\\d+\\]$\"", ",", "\"\"", ",", "txt", ",", "re", ".", "UNICODE", ")" ]
Return the text of a ``BeautifulSoup`` element, assuming it's a course code (it strips any square-brackets-surrounded number at its end).
[ "Return", "the", "text", "of", "a", "BeautifulSoup", "element", "assuming", "it", "s", "a", "course", "code", "(", "it", "strips", "any", "square", "-", "brackets", "-", "surrounded", "number", "at", "its", "end", ")", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/souputils.py#L21-L27
bfontaine/p7magma
magma/souputils.py
parse
def parse(el, typ): """ Parse a ``BeautifulSoup`` element as the given type. """ if not el: return typ() txt = text(el) if not txt: return typ() return typ(txt)
python
def parse(el, typ): """ Parse a ``BeautifulSoup`` element as the given type. """ if not el: return typ() txt = text(el) if not txt: return typ() return typ(txt)
[ "def", "parse", "(", "el", ",", "typ", ")", ":", "if", "not", "el", ":", "return", "typ", "(", ")", "txt", "=", "text", "(", "el", ")", "if", "not", "txt", ":", "return", "typ", "(", ")", "return", "typ", "(", "txt", ")" ]
Parse a ``BeautifulSoup`` element as the given type.
[ "Parse", "a", "BeautifulSoup", "element", "as", "the", "given", "type", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/souputils.py#L30-L39
bfontaine/p7magma
magma/souputils.py
parsebool
def parsebool(el): """ Parse a ``BeautifulSoup`` element as a bool """ txt = text(el) up = txt.upper() if up == "OUI": return True if up == "NON": return False return bool(parseint(el))
python
def parsebool(el): """ Parse a ``BeautifulSoup`` element as a bool """ txt = text(el) up = txt.upper() if up == "OUI": return True if up == "NON": return False return bool(parseint(el))
[ "def", "parsebool", "(", "el", ")", ":", "txt", "=", "text", "(", "el", ")", "up", "=", "txt", ".", "upper", "(", ")", "if", "up", "==", "\"OUI\"", ":", "return", "True", "if", "up", "==", "\"NON\"", ":", "return", "False", "return", "bool", "(",...
Parse a ``BeautifulSoup`` element as a bool
[ "Parse", "a", "BeautifulSoup", "element", "as", "a", "bool" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/souputils.py#L63-L74
radjkarl/fancyTools
fancytools/math/findPeaks.py
findMax
def findMax(arr): """ in comparison to argrelmax() more simple and reliable peak finder """ out = np.zeros(shape=arr.shape, dtype=bool) _calcMax(arr, out) return out
python
def findMax(arr): """ in comparison to argrelmax() more simple and reliable peak finder """ out = np.zeros(shape=arr.shape, dtype=bool) _calcMax(arr, out) return out
[ "def", "findMax", "(", "arr", ")", ":", "out", "=", "np", ".", "zeros", "(", "shape", "=", "arr", ".", "shape", ",", "dtype", "=", "bool", ")", "_calcMax", "(", "arr", ",", "out", ")", "return", "out" ]
in comparison to argrelmax() more simple and reliable peak finder
[ "in", "comparison", "to", "argrelmax", "()", "more", "simple", "and", "reliable", "peak", "finder" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/findPeaks.py#L6-L12
radjkarl/fancyTools
fancytools/math/findPeaks.py
findMin
def findMin(arr): """ in comparison to argrelmax() more simple and reliable peak finder """ out = np.zeros(shape=arr.shape, dtype=bool) _calcMin(arr, out) return out
python
def findMin(arr): """ in comparison to argrelmax() more simple and reliable peak finder """ out = np.zeros(shape=arr.shape, dtype=bool) _calcMin(arr, out) return out
[ "def", "findMin", "(", "arr", ")", ":", "out", "=", "np", ".", "zeros", "(", "shape", "=", "arr", ".", "shape", ",", "dtype", "=", "bool", ")", "_calcMin", "(", "arr", ",", "out", ")", "return", "out" ]
in comparison to argrelmax() more simple and reliable peak finder
[ "in", "comparison", "to", "argrelmax", "()", "more", "simple", "and", "reliable", "peak", "finder" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/findPeaks.py#L32-L38
GemHQ/round-py
round/client.py
Client.authenticate_application
def authenticate_application(self, api_token, admin_token, override=False, fetch=True): """Set credentials for Application authentication. Important Note: Do not use Application auth on any end-user device. Application auth provides read-access to all Users who h...
python
def authenticate_application(self, api_token, admin_token, override=False, fetch=True): """Set credentials for Application authentication. Important Note: Do not use Application auth on any end-user device. Application auth provides read-access to all Users who h...
[ "def", "authenticate_application", "(", "self", ",", "api_token", ",", "admin_token", ",", "override", "=", "False", ",", "fetch", "=", "True", ")", ":", "if", "(", "self", ".", "context", ".", "has_auth_params", "(", "'Gem-Application'", ")", "and", "not", ...
Set credentials for Application authentication. Important Note: Do not use Application auth on any end-user device. Application auth provides read-access to all Users who have authorized an Application. Use on a secure application server only. Args: api_token (str): Token issu...
[ "Set", "credentials", "for", "Application", "authentication", ".", "Important", "Note", ":", "Do", "not", "use", "Application", "auth", "on", "any", "end", "-", "user", "device", ".", "Application", "auth", "provides", "read", "-", "access", "to", "all", "Us...
train
https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/client.py#L42-L69
GemHQ/round-py
round/client.py
Client.authenticate_device
def authenticate_device(self, api_token, device_token, email=None, user_url=None, override=False, fetch=True): """Set credentials for Device authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. ...
python
def authenticate_device(self, api_token, device_token, email=None, user_url=None, override=False, fetch=True): """Set credentials for Device authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. ...
[ "def", "authenticate_device", "(", "self", ",", "api_token", ",", "device_token", ",", "email", "=", "None", ",", "user_url", "=", "None", ",", "override", "=", "False", ",", "fetch", "=", "True", ")", ":", "if", "(", "self", ".", "context", ".", "has_...
Set credentials for Device authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. device_token (str): Physical device identifier. You will receive this from a user.devices.create call or from users.create. ...
[ "Set", "credentials", "for", "Device", "authentication", "." ]
train
https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/client.py#L71-L106
GemHQ/round-py
round/client.py
Client.authenticate_identify
def authenticate_identify(self, api_token, override=True): """Set credentials for Identify authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. override (boolean): Replace existing Application credentials. """...
python
def authenticate_identify(self, api_token, override=True): """Set credentials for Identify authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. override (boolean): Replace existing Application credentials. """...
[ "def", "authenticate_identify", "(", "self", ",", "api_token", ",", "override", "=", "True", ")", ":", "if", "(", "self", ".", "context", ".", "has_auth_params", "(", "'Gem-Identify'", ")", "and", "not", "override", ")", ":", "raise", "OverrideError", "(", ...
Set credentials for Identify authentication. Args: api_token (str): Token issued to your Application through the Gem Developer Console. override (boolean): Replace existing Application credentials.
[ "Set", "credentials", "for", "Identify", "authentication", "." ]
train
https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/client.py#L108-L123
nkmathew/yasi-sexp-indenter
yasi.py
create_args_parser
def create_args_parser(): """ Return command line parser """ parser = argparse.ArgumentParser( description='Dialect-aware s-expression indenter', prog='yasi') parser.add_argument('files', help='List of files to be indented. ' 'Will indent from standard input if no files are s...
python
def create_args_parser(): """ Return command line parser """ parser = argparse.ArgumentParser( description='Dialect-aware s-expression indenter', prog='yasi') parser.add_argument('files', help='List of files to be indented. ' 'Will indent from standard input if no files are s...
[ "def", "create_args_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Dialect-aware s-expression indenter'", ",", "prog", "=", "'yasi'", ")", "parser", ".", "add_argument", "(", "'files'", ",", "help", "=", "'Li...
Return command line parser
[ "Return", "command", "line", "parser" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L31-L106
nkmathew/yasi-sexp-indenter
yasi.py
parse_options
def parse_options(arguments=None): """ Reads command-line arguments >>> parse_options('--indent-comments') """ if arguments is None: arguments = sys.argv[1:] if isinstance(arguments, str): arguments = arguments.split() if isinstance(arguments, argparse.Namespace): return...
python
def parse_options(arguments=None): """ Reads command-line arguments >>> parse_options('--indent-comments') """ if arguments is None: arguments = sys.argv[1:] if isinstance(arguments, str): arguments = arguments.split() if isinstance(arguments, argparse.Namespace): return...
[ "def", "parse_options", "(", "arguments", "=", "None", ")", ":", "if", "arguments", "is", "None", ":", "arguments", "=", "sys", ".", "argv", "[", "1", ":", "]", "if", "isinstance", "(", "arguments", ",", "str", ")", ":", "arguments", "=", "arguments", ...
Reads command-line arguments >>> parse_options('--indent-comments')
[ "Reads", "command", "-", "line", "arguments" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L109-L147
nkmathew/yasi-sexp-indenter
yasi.py
read_file
def read_file(fname): """ read_file(fname : str) -> str >>> read_file(r'C:\\mine\\test.lisp') r'(print "No, no, there\'s \\r\\nlife in him!. ")\\r\\n\\r\\n' The file is read in binary mode in order to preserve original line endings. Line ending Binary mode Text mode CRLF ...
python
def read_file(fname): """ read_file(fname : str) -> str >>> read_file(r'C:\\mine\\test.lisp') r'(print "No, no, there\'s \\r\\nlife in him!. ")\\r\\n\\r\\n' The file is read in binary mode in order to preserve original line endings. Line ending Binary mode Text mode CRLF ...
[ "def", "read_file", "(", "fname", ")", ":", "assert", "os", ".", "path", ".", "exists", "(", "fname", ")", ",", "\"\\n--%s-- Warning: File `%s' does not exist. . .\"", "%", "(", "current_time", "(", ")", ",", "fname", ")", "with", "open", "(", "fname", ",", ...
read_file(fname : str) -> str >>> read_file(r'C:\\mine\\test.lisp') r'(print "No, no, there\'s \\r\\nlife in him!. ")\\r\\n\\r\\n' The file is read in binary mode in order to preserve original line endings. Line ending Binary mode Text mode CRLF CRLF LF CR ...
[ "read_file", "(", "fname", ":", "str", ")", "-", ">", "str" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L150-L164
nkmathew/yasi-sexp-indenter
yasi.py
backup_source_file
def backup_source_file(fname, options=None): """ backup_source_file(fname : str) >>> backup_source_file('~/Desktop/lisp/test.lisp') Create a backup copy of the source file. """ opts = parse_options(options) backup_dir = opts.backup_dir assert os.path.exists(fname), \ ("\n--%s-- War...
python
def backup_source_file(fname, options=None): """ backup_source_file(fname : str) >>> backup_source_file('~/Desktop/lisp/test.lisp') Create a backup copy of the source file. """ opts = parse_options(options) backup_dir = opts.backup_dir assert os.path.exists(fname), \ ("\n--%s-- War...
[ "def", "backup_source_file", "(", "fname", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "backup_dir", "=", "opts", ".", "backup_dir", "assert", "os", ".", "path", ".", "exists", "(", "fname", ")", ",", "(", ...
backup_source_file(fname : str) >>> backup_source_file('~/Desktop/lisp/test.lisp') Create a backup copy of the source file.
[ "backup_source_file", "(", "fname", ":", "str", ")" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L178-L197
nkmathew/yasi-sexp-indenter
yasi.py
trim
def trim(string): """ trim(string : str) -> str Uses every usefull hack to try and reduce extra whitespace without messing with character literals """ # Trailing whitespace string = re.sub('[ \t]*$', '', string) # turn '(print(+ 1 1))' to '(print (+ 1 1))' string = re.sub(r'''([^\\(\[, ...
python
def trim(string): """ trim(string : str) -> str Uses every usefull hack to try and reduce extra whitespace without messing with character literals """ # Trailing whitespace string = re.sub('[ \t]*$', '', string) # turn '(print(+ 1 1))' to '(print (+ 1 1))' string = re.sub(r'''([^\\(\[, ...
[ "def", "trim", "(", "string", ")", ":", "# Trailing whitespace", "string", "=", "re", ".", "sub", "(", "'[ \\t]*$'", ",", "''", ",", "string", ")", "# turn '(print(+ 1 1))' to '(print (+ 1 1))'", "string", "=", "re", ".", "sub", "(", "r'''([^\\\\(\\[, {@~`'#^])(\\...
trim(string : str) -> str Uses every usefull hack to try and reduce extra whitespace without messing with character literals
[ "trim", "(", "string", ":", "str", ")", "-", ">", "str" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L228-L256
nkmathew/yasi-sexp-indenter
yasi.py
find_trim_limit
def find_trim_limit(string, options=None): """ find_trim_limit(string : str) -> int >>> find_trim_limit(r'(list #\; #\")') 14 >>> find_trim_limit(r'(list ; ")') 6 >>> find_trim_limit(r'(list " ;)') 7 The function attempts to identify upto which point we are supposed to trim so that...
python
def find_trim_limit(string, options=None): """ find_trim_limit(string : str) -> int >>> find_trim_limit(r'(list #\; #\")') 14 >>> find_trim_limit(r'(list ; ")') 6 >>> find_trim_limit(r'(list " ;)') 7 The function attempts to identify upto which point we are supposed to trim so that...
[ "def", "find_trim_limit", "(", "string", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "# Find position of the first unescaped semi colon", "comment_start", "=", "re", ".", "search", "(", "r'([^\\\\];)|(^;)'", ",", "string...
find_trim_limit(string : str) -> int >>> find_trim_limit(r'(list #\; #\")') 14 >>> find_trim_limit(r'(list ; ")') 6 >>> find_trim_limit(r'(list " ;)') 7 The function attempts to identify upto which point we are supposed to trim so that we don't mess with strings or any aligned comments...
[ "find_trim_limit", "(", "string", ":", "str", ")", "-", ">", "int" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L259-L311
nkmathew/yasi-sexp-indenter
yasi.py
is_macro_name
def is_macro_name(func_name, dialect): """ is_macro_name(func_name : str, dialect : str) -> bool >>> is_macro_name('yacc:define-parser') True Tests if a word is a macro using the language's/dialect's convention, e.g macros in Lisp usually start with 'def' and 'with' in Scheme. Saves the effort...
python
def is_macro_name(func_name, dialect): """ is_macro_name(func_name : str, dialect : str) -> bool >>> is_macro_name('yacc:define-parser') True Tests if a word is a macro using the language's/dialect's convention, e.g macros in Lisp usually start with 'def' and 'with' in Scheme. Saves the effort...
[ "def", "is_macro_name", "(", "func_name", ",", "dialect", ")", ":", "if", "not", "func_name", ":", "return", "False", "if", "dialect", "==", "'lisp'", ":", "return", "re", ".", "search", "(", "'^(macro|def|do|with-)'", ",", "func_name", ",", "re", ".", "I"...
is_macro_name(func_name : str, dialect : str) -> bool >>> is_macro_name('yacc:define-parser') True Tests if a word is a macro using the language's/dialect's convention, e.g macros in Lisp usually start with 'def' and 'with' in Scheme. Saves the effort of finding all the macros in Lisp/Scheme/Cloju...
[ "is_macro_name", "(", "func_name", ":", "str", "dialect", ":", "str", ")", "-", ">", "bool" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L314-L336
nkmathew/yasi-sexp-indenter
yasi.py
split_preserve
def split_preserve(string, sep): """ split_preserve(string : str, sep : str) -> [str] >>> split_preserve(''' "My dear Holmes, " said I, "this is too much. You would certainly have been burned, had you lived a few centuries ago. ''', '\\n') ['\\n', ' "My dear Holmes, " said ...
python
def split_preserve(string, sep): """ split_preserve(string : str, sep : str) -> [str] >>> split_preserve(''' "My dear Holmes, " said I, "this is too much. You would certainly have been burned, had you lived a few centuries ago. ''', '\\n') ['\\n', ' "My dear Holmes, " said ...
[ "def", "split_preserve", "(", "string", ",", "sep", ")", ":", "# split the whole string into a list so that you can iterate line by line.", "str_list", "=", "string", ".", "split", "(", "sep", ")", "if", "str_list", "[", "-", "1", "]", "==", "''", ":", "# If you s...
split_preserve(string : str, sep : str) -> [str] >>> split_preserve(''' "My dear Holmes, " said I, "this is too much. You would certainly have been burned, had you lived a few centuries ago. ''', '\\n') ['\\n', ' "My dear Holmes, " said I, "this is too much. You would certainly...
[ "split_preserve", "(", "string", ":", "str", "sep", ":", "str", ")", "-", ">", "[", "str", "]" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L339-L368
nkmathew/yasi-sexp-indenter
yasi.py
detabify
def detabify(text, options): """ tabify(text : str, options : argparse.Namespace|str) -> str Expands tabs """ opts = parse_options(options) if opts.tab_size < 1: return text.expandtabs(4) else: return text.expandtabs(options.tab_size)
python
def detabify(text, options): """ tabify(text : str, options : argparse.Namespace|str) -> str Expands tabs """ opts = parse_options(options) if opts.tab_size < 1: return text.expandtabs(4) else: return text.expandtabs(options.tab_size)
[ "def", "detabify", "(", "text", ",", "options", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "if", "opts", ".", "tab_size", "<", "1", ":", "return", "text", ".", "expandtabs", "(", "4", ")", "else", ":", "return", "text", ".", "expand...
tabify(text : str, options : argparse.Namespace|str) -> str Expands tabs
[ "tabify", "(", "text", ":", "str", "options", ":", "argparse", ".", "Namespace|str", ")", "-", ">", "str" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L382-L391
nkmathew/yasi-sexp-indenter
yasi.py
tabify
def tabify(text, options): """ tabify(text : str, options : argparse.Namespace|str) -> str >>> tabify(' (println "hello world")', '--tab=3') '\t\t (println "hello world")' Replace spaces with tabs """ opts = parse_options(options) if opts.tab_size < 1: return text else...
python
def tabify(text, options): """ tabify(text : str, options : argparse.Namespace|str) -> str >>> tabify(' (println "hello world")', '--tab=3') '\t\t (println "hello world")' Replace spaces with tabs """ opts = parse_options(options) if opts.tab_size < 1: return text else...
[ "def", "tabify", "(", "text", ",", "options", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "if", "opts", ".", "tab_size", "<", "1", ":", "return", "text", "else", ":", "tab_equiv", "=", "' '", "*", "opts", ".", "tab_size", "return", "...
tabify(text : str, options : argparse.Namespace|str) -> str >>> tabify(' (println "hello world")', '--tab=3') '\t\t (println "hello world")' Replace spaces with tabs
[ "tabify", "(", "text", ":", "str", "options", ":", "argparse", ".", "Namespace|str", ")", "-", ">", "str" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L394-L407
nkmathew/yasi-sexp-indenter
yasi.py
pad_leading_whitespace
def pad_leading_whitespace(string, zero_level, blist, options=None): """ pad_leading_whitespace(string : str, current_level : int, zero_level : int) -> str >>> pad_leading_whitespace("(print 'Yello)") " (print 'Yello)" Takes a string and indents it using the curr...
python
def pad_leading_whitespace(string, zero_level, blist, options=None): """ pad_leading_whitespace(string : str, current_level : int, zero_level : int) -> str >>> pad_leading_whitespace("(print 'Yello)") " (print 'Yello)" Takes a string and indents it using the curr...
[ "def", "pad_leading_whitespace", "(", "string", ",", "zero_level", ",", "blist", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "if", "opts", ".", "compact", ":", "# if compact mode is on, split the string into two, trim th...
pad_leading_whitespace(string : str, current_level : int, zero_level : int) -> str >>> pad_leading_whitespace("(print 'Yello)") " (print 'Yello)" Takes a string and indents it using the current indentation level and the zero level.
[ "pad_leading_whitespace", "(", "string", ":", "str", "current_level", ":", "int", "zero_level", ":", "int", ")", "-", ">", "str" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L410-L442
nkmathew/yasi-sexp-indenter
yasi.py
indent_line
def indent_line(zerolevel, bracket_list, line, in_comment, in_symbol_region, options=None): """ indent_line(zerolevel : int, bracket_list : list, line : str, in_comment : bool, in_symbol_region : bool, options : string|list) Most important function in the indentation process...
python
def indent_line(zerolevel, bracket_list, line, in_comment, in_symbol_region, options=None): """ indent_line(zerolevel : int, bracket_list : list, line : str, in_comment : bool, in_symbol_region : bool, options : string|list) Most important function in the indentation process...
[ "def", "indent_line", "(", "zerolevel", ",", "bracket_list", ",", "line", ",", "in_comment", ",", "in_symbol_region", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "comment_line", "=", "re", ".", "search", "(", "...
indent_line(zerolevel : int, bracket_list : list, line : str, in_comment : bool, in_symbol_region : bool, options : string|list) Most important function in the indentation process. It uses the bracket locations stored in the list to indent the line.
[ "indent_line", "(", "zerolevel", ":", "int", "bracket_list", ":", "list", "line", ":", "str", "in_comment", ":", "bool", "in_symbol_region", ":", "bool", "options", ":", "string|list", ")" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L445-L483
nkmathew/yasi-sexp-indenter
yasi.py
parse_rc_json
def parse_rc_json(): """ Reads the json configuration file(.yasirc.json), parses it and returns the dictionary """ fname = '.yasirc.json' path = os.path.expanduser('~/' + fname) if os.path.exists(fname): path = os.path.abspath(fname) elif not os.path.exists(path): path = '' ...
python
def parse_rc_json(): """ Reads the json configuration file(.yasirc.json), parses it and returns the dictionary """ fname = '.yasirc.json' path = os.path.expanduser('~/' + fname) if os.path.exists(fname): path = os.path.abspath(fname) elif not os.path.exists(path): path = '' ...
[ "def", "parse_rc_json", "(", ")", ":", "fname", "=", "'.yasirc.json'", "path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/'", "+", "fname", ")", "if", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "path", "=", "os", ".", "path"...
Reads the json configuration file(.yasirc.json), parses it and returns the dictionary
[ "Reads", "the", "json", "configuration", "file", "(", ".", "yasirc", ".", "json", ")", "parses", "it", "and", "returns", "the", "dictionary" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L551-L568
nkmathew/yasi-sexp-indenter
yasi.py
assign_indent_numbers
def assign_indent_numbers(lst, inum, dic=collections.defaultdict(int)): """ Associate keywords with their respective indentation numbers """ for i in lst: dic[i] = inum return dic
python
def assign_indent_numbers(lst, inum, dic=collections.defaultdict(int)): """ Associate keywords with their respective indentation numbers """ for i in lst: dic[i] = inum return dic
[ "def", "assign_indent_numbers", "(", "lst", ",", "inum", ",", "dic", "=", "collections", ".", "defaultdict", "(", "int", ")", ")", ":", "for", "i", "in", "lst", ":", "dic", "[", "i", "]", "=", "inum", "return", "dic" ]
Associate keywords with their respective indentation numbers
[ "Associate", "keywords", "with", "their", "respective", "indentation", "numbers" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L571-L576
nkmathew/yasi-sexp-indenter
yasi.py
add_keywords
def add_keywords(opts): """ add_keywords(dialect : str) -> [str, str] Takens a lisp dialect name and returns a list of keywords that increase indentation by two spaces and those that can be one-armed like 'if' """ dialect = opts.dialect keywords = collections.defaultdict(int) two_spacers = ...
python
def add_keywords(opts): """ add_keywords(dialect : str) -> [str, str] Takens a lisp dialect name and returns a list of keywords that increase indentation by two spaces and those that can be one-armed like 'if' """ dialect = opts.dialect keywords = collections.defaultdict(int) two_spacers = ...
[ "def", "add_keywords", "(", "opts", ")", ":", "dialect", "=", "opts", ".", "dialect", "keywords", "=", "collections", ".", "defaultdict", "(", "int", ")", "two_spacers", "=", "[", "]", "two_armed", "=", "IF_LIKE", "local_binders", "=", "[", "]", "if", "d...
add_keywords(dialect : str) -> [str, str] Takens a lisp dialect name and returns a list of keywords that increase indentation by two spaces and those that can be one-armed like 'if'
[ "add_keywords", "(", "dialect", ":", "str", ")", "-", ">", "[", "str", "str", "]" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L579-L615
nkmathew/yasi-sexp-indenter
yasi.py
find_first_arg_pos
def find_first_arg_pos(bracket_offset, curr_line, options=None): """ find_first_arg_pos(bracket_offset : int, curr_line : str) -> [int, int] Arguments: bracket_offset - The position of the bracket in the current line e.g " ( list 'timey 'wimey )" --> 4 " ( list 'timey 'wimey )" --...
python
def find_first_arg_pos(bracket_offset, curr_line, options=None): """ find_first_arg_pos(bracket_offset : int, curr_line : str) -> [int, int] Arguments: bracket_offset - The position of the bracket in the current line e.g " ( list 'timey 'wimey )" --> 4 " ( list 'timey 'wimey )" --...
[ "def", "find_first_arg_pos", "(", "bracket_offset", ",", "curr_line", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "spaces_before_func", "=", "0", "subline", "=", "curr_line", "[", "bracket_offset", "+", "1", ":", ...
find_first_arg_pos(bracket_offset : int, curr_line : str) -> [int, int] Arguments: bracket_offset - The position of the bracket in the current line e.g " ( list 'timey 'wimey )" --> 4 " ( list 'timey 'wimey )" --> 1 "( list 'timey 'wimey )" --> 0 >>> find_first_arg_...
[ "find_first_arg_pos", "(", "bracket_offset", ":", "int", "curr_line", ":", "str", ")", "-", ">", "[", "int", "int", "]" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L620-L678
nkmathew/yasi-sexp-indenter
yasi.py
_pop_from_list
def _pop_from_list(bracket, lst, line, real_pos, offset, msg_stack): """ _pop_from_list(char : str, lst : [str], line : str, real_pos : int, offset : int) The function is called when a closing bracket is encountered. The function simply pops the last pushed item and issues a warning...
python
def _pop_from_list(bracket, lst, line, real_pos, offset, msg_stack): """ _pop_from_list(char : str, lst : [str], line : str, real_pos : int, offset : int) The function is called when a closing bracket is encountered. The function simply pops the last pushed item and issues a warning...
[ "def", "_pop_from_list", "(", "bracket", ",", "lst", ",", "line", ",", "real_pos", ",", "offset", ",", "msg_stack", ")", ":", "# Try to spot a case when a square bracket is used to close a round bracket", "# block", "if", "bracket", "==", "']'", ":", "correct_closer", ...
_pop_from_list(char : str, lst : [str], line : str, real_pos : int, offset : int) The function is called when a closing bracket is encountered. The function simply pops the last pushed item and issues a warning if an error is encountered.
[ "_pop_from_list", "(", "char", ":", "str", "lst", ":", "[", "str", "]", "line", ":", "str", "real_pos", ":", "int", "offset", ":", "int", ")" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L681-L723
nkmathew/yasi-sexp-indenter
yasi.py
_push_to_list
def _push_to_list(lst, func_name, char, line, offset, first_arg_pos, first_item, in_list_literal, lead_spaces, options=None): """ _push_to_list(lst : [str], func_name : str, char : str, line : int, offset : int, first_arg_pos :int , first_item : int, in_li...
python
def _push_to_list(lst, func_name, char, line, offset, first_arg_pos, first_item, in_list_literal, lead_spaces, options=None): """ _push_to_list(lst : [str], func_name : str, char : str, line : int, offset : int, first_arg_pos :int , first_item : int, in_li...
[ "def", "_push_to_list", "(", "lst", ",", "func_name", ",", "char", ",", "line", ",", "offset", ",", "first_arg_pos", ",", "first_item", ",", "in_list_literal", ",", "lead_spaces", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "o...
_push_to_list(lst : [str], func_name : str, char : str, line : int, offset : int, first_arg_pos :int , first_item : int, in_list_literal : bool, lead_spaces : int, options : str) Called when an opening bracket is encountered. A hash containing the necessary data ...
[ "_push_to_list", "(", "lst", ":", "[", "str", "]", "func_name", ":", "str", "char", ":", "str", "line", ":", "int", "offset", ":", "int", "first_arg_pos", ":", "int", "first_item", ":", "int", "in_list_literal", ":", "bool", "lead_spaces", ":", "int", "o...
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L726-L778
nkmathew/yasi-sexp-indenter
yasi.py
indent_code
def indent_code(original_code, options=None): """ indented_code(string : str, fname : str) -> [...] Arguments: fpath: Simply used in formatting the warning messages >>> indent_code("(print\n'Hello)") {'bracket_locations': [], 'comment_locations': [], 'in_comment': 0, 'in_newlisp_tag...
python
def indent_code(original_code, options=None): """ indented_code(string : str, fname : str) -> [...] Arguments: fpath: Simply used in formatting the warning messages >>> indent_code("(print\n'Hello)") {'bracket_locations': [], 'comment_locations': [], 'in_comment': 0, 'in_newlisp_tag...
[ "def", "indent_code", "(", "original_code", ",", "options", "=", "None", ")", ":", "opts", "=", "parse_options", "(", "options", ")", "keywords", "=", "add_keywords", "(", "opts", ")", "# Safeguards against processing brackets inside strings", "in_string", "=", "Fal...
indented_code(string : str, fname : str) -> [...] Arguments: fpath: Simply used in formatting the warning messages >>> indent_code("(print\n'Hello)") {'bracket_locations': [], 'comment_locations': [], 'in_comment': 0, 'in_newlisp_tag_string': False, 'in_string': False, 'in_sym...
[ "indented_code", "(", "string", ":", "str", "fname", ":", "str", ")", "-", ">", "[", "...", "]" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L781-L1060
nkmathew/yasi-sexp-indenter
yasi.py
colour_diff
def colour_diff(diff_lines): """ colour_diff(diff_lines : lst) Print diff text to terminal in color """ try: import colorama except ImportError: # colorama is not available, print plain diff print(''.join(list(diff_lines))) return colorama.init() def p_gre...
python
def colour_diff(diff_lines): """ colour_diff(diff_lines : lst) Print diff text to terminal in color """ try: import colorama except ImportError: # colorama is not available, print plain diff print(''.join(list(diff_lines))) return colorama.init() def p_gre...
[ "def", "colour_diff", "(", "diff_lines", ")", ":", "try", ":", "import", "colorama", "except", "ImportError", ":", "# colorama is not available, print plain diff", "print", "(", "''", ".", "join", "(", "list", "(", "diff_lines", ")", ")", ")", "return", "coloram...
colour_diff(diff_lines : lst) Print diff text to terminal in color
[ "colour_diff", "(", "diff_lines", ":", "lst", ")" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L1063-L1098
nkmathew/yasi-sexp-indenter
yasi.py
_after_indentation
def _after_indentation(res, options=None, fpath=''): """ _after_indentation(res : dict): Called after the string has been indented appropriately. It takes care of writing the file and checking for unclosed strings or comments. """ fname = os.path.basename(fpath) opts = parse_options(options...
python
def _after_indentation(res, options=None, fpath=''): """ _after_indentation(res : dict): Called after the string has been indented appropriately. It takes care of writing the file and checking for unclosed strings or comments. """ fname = os.path.basename(fpath) opts = parse_options(options...
[ "def", "_after_indentation", "(", "res", ",", "options", "=", "None", ",", "fpath", "=", "''", ")", ":", "fname", "=", "os", ".", "path", ".", "basename", "(", "fpath", ")", "opts", "=", "parse_options", "(", "options", ")", "for", "msg", "in", "res"...
_after_indentation(res : dict): Called after the string has been indented appropriately. It takes care of writing the file and checking for unclosed strings or comments.
[ "_after_indentation", "(", "res", ":", "dict", ")", ":" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L1101-L1190
nkmathew/yasi-sexp-indenter
yasi.py
indent_files
def indent_files(arguments): """ indent_files(fname : str) 1. Creates a backup of the source file(backup_source_file()) 2. Reads the files contents(read_file()) 3. Indents the code(indent_code()) 4. Writes the file or print the indented code(_after_indentation()) """ opts = parse_options(ar...
python
def indent_files(arguments): """ indent_files(fname : str) 1. Creates a backup of the source file(backup_source_file()) 2. Reads the files contents(read_file()) 3. Indents the code(indent_code()) 4. Writes the file or print the indented code(_after_indentation()) """ opts = parse_options(ar...
[ "def", "indent_files", "(", "arguments", ")", ":", "opts", "=", "parse_options", "(", "arguments", ")", "if", "not", "opts", ".", "files", ":", "# Indent from stdin", "code", "=", "sys", ".", "stdin", ".", "read", "(", ")", "indent_result", "=", "indent_co...
indent_files(fname : str) 1. Creates a backup of the source file(backup_source_file()) 2. Reads the files contents(read_file()) 3. Indents the code(indent_code()) 4. Writes the file or print the indented code(_after_indentation())
[ "indent_files", "(", "fname", ":", "str", ")" ]
train
https://github.com/nkmathew/yasi-sexp-indenter/blob/6ec2a4675e79606c555bcb67494a0ba994b05805/yasi.py#L1193-L1229
datadesk/django-greeking
greeking/placeholdit.py
get_url
def get_url( width, height=None, background_color="cccccc", text_color="969696", text=None, random_background_color=False ): """ Craft the URL for a placeholder image. You can customize the background color, text color and text using the optional keyword arguments If you want to use a rand...
python
def get_url( width, height=None, background_color="cccccc", text_color="969696", text=None, random_background_color=False ): """ Craft the URL for a placeholder image. You can customize the background color, text color and text using the optional keyword arguments If you want to use a rand...
[ "def", "get_url", "(", "width", ",", "height", "=", "None", ",", "background_color", "=", "\"cccccc\"", ",", "text_color", "=", "\"969696\"", ",", "text", "=", "None", ",", "random_background_color", "=", "False", ")", ":", "if", "random_background_color", ":"...
Craft the URL for a placeholder image. You can customize the background color, text color and text using the optional keyword arguments If you want to use a random color pass in random_background_color as True.
[ "Craft", "the", "URL", "for", "a", "placeholder", "image", "." ]
train
https://github.com/datadesk/django-greeking/blob/72509c94952279503bbe8d5a710c1fd344da0670/greeking/placeholdit.py#L20-L48
ronaldguillen/wave
wave/reverse.py
preserve_builtin_query_params
def preserve_builtin_query_params(url, request=None): """ Given an incoming request, and an outgoing URL representation, append the value of any built-in query parameters. """ if request is None: return url overrides = [ api_settings.URL_FORMAT_OVERRIDE, ] for param in ...
python
def preserve_builtin_query_params(url, request=None): """ Given an incoming request, and an outgoing URL representation, append the value of any built-in query parameters. """ if request is None: return url overrides = [ api_settings.URL_FORMAT_OVERRIDE, ] for param in ...
[ "def", "preserve_builtin_query_params", "(", "url", ",", "request", "=", "None", ")", ":", "if", "request", "is", "None", ":", "return", "url", "overrides", "=", "[", "api_settings", ".", "URL_FORMAT_OVERRIDE", ",", "]", "for", "param", "in", "overrides", ":...
Given an incoming request, and an outgoing URL representation, append the value of any built-in query parameters.
[ "Given", "an", "incoming", "request", "and", "an", "outgoing", "URL", "representation", "append", "the", "value", "of", "any", "built", "-", "in", "query", "parameters", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/reverse.py#L15-L32
ronaldguillen/wave
wave/reverse.py
reverse
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ If versioning is being used then we pass any `reverse` calls through to the versioning scheme instance, so that the resulting URL can be modified if needed. """ scheme = getattr(request, 'versioning_scheme', N...
python
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ If versioning is being used then we pass any `reverse` calls through to the versioning scheme instance, so that the resulting URL can be modified if needed. """ scheme = getattr(request, 'versioning_scheme', N...
[ "def", "reverse", "(", "viewname", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "request", "=", "None", ",", "format", "=", "None", ",", "*", "*", "extra", ")", ":", "scheme", "=", "getattr", "(", "request", ",", "'versioning_scheme'", ...
If versioning is being used then we pass any `reverse` calls through to the versioning scheme instance, so that the resulting URL can be modified if needed.
[ "If", "versioning", "is", "being", "used", "then", "we", "pass", "any", "reverse", "calls", "through", "to", "the", "versioning", "scheme", "instance", "so", "that", "the", "resulting", "URL", "can", "be", "modified", "if", "needed", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/reverse.py#L35-L52
ronaldguillen/wave
wave/reverse.py
_reverse
def _reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ Same as `django.core.urlresolvers.reverse`, but optionally takes a request and returns a fully qualified URL, using the request to get the base URL. """ if format is not None: kwargs = kwargs or {} ...
python
def _reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ Same as `django.core.urlresolvers.reverse`, but optionally takes a request and returns a fully qualified URL, using the request to get the base URL. """ if format is not None: kwargs = kwargs or {} ...
[ "def", "_reverse", "(", "viewname", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "request", "=", "None", ",", "format", "=", "None", ",", "*", "*", "extra", ")", ":", "if", "format", "is", "not", "None", ":", "kwargs", "=", "kwargs", ...
Same as `django.core.urlresolvers.reverse`, but optionally takes a request and returns a fully qualified URL, using the request to get the base URL.
[ "Same", "as", "django", ".", "core", ".", "urlresolvers", ".", "reverse", "but", "optionally", "takes", "a", "request", "and", "returns", "a", "fully", "qualified", "URL", "using", "the", "request", "to", "get", "the", "base", "URL", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/reverse.py#L55-L66
etcher-be/emiz
emiz/new_miz.py
NewMiz.decompose
def decompose(miz_file: Path, output_folder: Path): """ Decompose this Miz into json Args: output_folder: folder to output the json structure as a Path miz_file: MIZ file path as a Path """ mission_folder, assets_folder = NewMiz._get_subfolders(output_fol...
python
def decompose(miz_file: Path, output_folder: Path): """ Decompose this Miz into json Args: output_folder: folder to output the json structure as a Path miz_file: MIZ file path as a Path """ mission_folder, assets_folder = NewMiz._get_subfolders(output_fol...
[ "def", "decompose", "(", "miz_file", ":", "Path", ",", "output_folder", ":", "Path", ")", ":", "mission_folder", ",", "assets_folder", "=", "NewMiz", ".", "_get_subfolders", "(", "output_folder", ")", "NewMiz", ".", "_wipe_folders", "(", "mission_folder", ",", ...
Decompose this Miz into json Args: output_folder: folder to output the json structure as a Path miz_file: MIZ file path as a Path
[ "Decompose", "this", "Miz", "into", "json" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/new_miz.py#L259-L281
etcher-be/emiz
emiz/new_miz.py
NewMiz.recompose
def recompose(src: Path, target_file: Path): """ Recompose a Miz from json object Args: src: folder containing the json structure target_file: target Miz file """ mission_folder, assets_folder = NewMiz._get_subfolders(src) # pylint: disable=c-exte...
python
def recompose(src: Path, target_file: Path): """ Recompose a Miz from json object Args: src: folder containing the json structure target_file: target Miz file """ mission_folder, assets_folder = NewMiz._get_subfolders(src) # pylint: disable=c-exte...
[ "def", "recompose", "(", "src", ":", "Path", ",", "target_file", ":", "Path", ")", ":", "mission_folder", ",", "assets_folder", "=", "NewMiz", ".", "_get_subfolders", "(", "src", ")", "# pylint: disable=c-extension-no-member", "base_info", "=", "ujson", ".", "lo...
Recompose a Miz from json object Args: src: folder containing the json structure target_file: target Miz file
[ "Recompose", "a", "Miz", "from", "json", "object" ]
train
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/new_miz.py#L284-L307
sahilchinoy/django-irs-filings
irs/management/commands/__init__.py
IRSCommand.handle
def handle(self, *args, **options): """ Sets options common to all commands. Any command subclassing this object should implement its own handle method, as is standard in Django, and run this method via a super call to inherit its functionality. """ # Create a da...
python
def handle(self, *args, **options): """ Sets options common to all commands. Any command subclassing this object should implement its own handle method, as is standard in Django, and run this method via a super call to inherit its functionality. """ # Create a da...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "# Create a data directory", "self", ".", "data_dir", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "BASE_DIR", ",", "'data'", ")", "if", "not", "os", "....
Sets options common to all commands. Any command subclassing this object should implement its own handle method, as is standard in Django, and run this method via a super call to inherit its functionality.
[ "Sets", "options", "common", "to", "all", "commands", ".", "Any", "command", "subclassing", "this", "object", "should", "implement", "its", "own", "handle", "method", "as", "is", "standard", "in", "Django", "and", "run", "this", "method", "via", "a", "super"...
train
https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/__init__.py#L14-L30
tlatsas/wigiki
wigiki/generator.py
SiteGenerator._save_file
def _save_file(self, filename, contents): """write the html file contents to disk""" with open(filename, 'w') as f: f.write(contents)
python
def _save_file(self, filename, contents): """write the html file contents to disk""" with open(filename, 'w') as f: f.write(contents)
[ "def", "_save_file", "(", "self", ",", "filename", ",", "contents", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "contents", ")" ]
write the html file contents to disk
[ "write", "the", "html", "file", "contents", "to", "disk" ]
train
https://github.com/tlatsas/wigiki/blob/baf9c5a6523a9b90db7572330d04e3e199391273/wigiki/generator.py#L49-L52
jeroyang/txttk
txttk/feature.py
lexical
def lexical(token): """ Extract lexical features from given token There are 3 kinds of lexical features, take 'Hello' as an example: 1. lowercase: 'hello' 2. first4: 'hell' 3. last4: 'ello' """ lowercase = token.lower() first4 = lowercase[:4] last4 = lowercase[-4:] return Or...
python
def lexical(token): """ Extract lexical features from given token There are 3 kinds of lexical features, take 'Hello' as an example: 1. lowercase: 'hello' 2. first4: 'hell' 3. last4: 'ello' """ lowercase = token.lower() first4 = lowercase[:4] last4 = lowercase[-4:] return Or...
[ "def", "lexical", "(", "token", ")", ":", "lowercase", "=", "token", ".", "lower", "(", ")", "first4", "=", "lowercase", "[", ":", "4", "]", "last4", "=", "lowercase", "[", "-", "4", ":", "]", "return", "OrderedDict", "(", "[", "(", "'lowercase'", ...
Extract lexical features from given token There are 3 kinds of lexical features, take 'Hello' as an example: 1. lowercase: 'hello' 2. first4: 'hell' 3. last4: 'ello'
[ "Extract", "lexical", "features", "from", "given", "token", "There", "are", "3", "kinds", "of", "lexical", "features", "take", "Hello", "as", "an", "example", ":" ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/feature.py#L12-L28
jeroyang/txttk
txttk/feature.py
orthographic
def orthographic(token): """ Extract orthographic features from a given token There are 11 kinds of orthographic features, take 'Windows10' as an example: 1. shape: 'Aaaaaaa00' 2. length: 9 3. contains_a_letter: True 4. contains_a_capital: True 5. begins_with_capital: True 6. a...
python
def orthographic(token): """ Extract orthographic features from a given token There are 11 kinds of orthographic features, take 'Windows10' as an example: 1. shape: 'Aaaaaaa00' 2. length: 9 3. contains_a_letter: True 4. contains_a_capital: True 5. begins_with_capital: True 6. a...
[ "def", "orthographic", "(", "token", ")", ":", "return", "OrderedDict", "(", "[", "(", "'shape'", ",", "_shape", "(", "token", ")", ")", ",", "(", "'length'", ",", "len", "(", "token", ")", ")", ",", "(", "'contains_a_letter'", ",", "_contains_a_letter",...
Extract orthographic features from a given token There are 11 kinds of orthographic features, take 'Windows10' as an example: 1. shape: 'Aaaaaaa00' 2. length: 9 3. contains_a_letter: True 4. contains_a_capital: True 5. begins_with_capital: True 6. all_capital: False 7. contains_a_d...
[ "Extract", "orthographic", "features", "from", "a", "given", "token", "There", "are", "11", "kinds", "of", "orthographic", "features", "take", "Windows10", "as", "an", "example", ":" ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/feature.py#L93-L124
Kjwon15/autotweet
autotweet/database.py
get_session
def get_session(url): """Get db session. :param url: URL for connect with DB :type url: :class:`str` :returns: A sqlalchemy db session :rtype: :class:`sqlalchemy.orm.Session` """ engine = create_engine(url) db_session = scoped_session(sessionmaker(engine)) Base.metadata.create_all...
python
def get_session(url): """Get db session. :param url: URL for connect with DB :type url: :class:`str` :returns: A sqlalchemy db session :rtype: :class:`sqlalchemy.orm.Session` """ engine = create_engine(url) db_session = scoped_session(sessionmaker(engine)) Base.metadata.create_all...
[ "def", "get_session", "(", "url", ")", ":", "engine", "=", "create_engine", "(", "url", ")", "db_session", "=", "scoped_session", "(", "sessionmaker", "(", "engine", ")", ")", "Base", ".", "metadata", ".", "create_all", "(", "engine", ")", "return", "db_se...
Get db session. :param url: URL for connect with DB :type url: :class:`str` :returns: A sqlalchemy db session :rtype: :class:`sqlalchemy.orm.Session`
[ "Get", "db", "session", "." ]
train
https://github.com/Kjwon15/autotweet/blob/c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e/autotweet/database.py#L24-L37
jasonfharris/sysexecute
sysexecute/execute.py
getBindings
def getBindings(varList, startLevel=0): """Given a list of identifiers as strings, construct the dictonary of the identifiers as keys and the evaluated values of the ientifiers as the values. Ie something like {id:full_lookup(id) for id in identifiers}. full_lookup here is looking up the value of an identif...
python
def getBindings(varList, startLevel=0): """Given a list of identifiers as strings, construct the dictonary of the identifiers as keys and the evaluated values of the ientifiers as the values. Ie something like {id:full_lookup(id) for id in identifiers}. full_lookup here is looking up the value of an identif...
[ "def", "getBindings", "(", "varList", ",", "startLevel", "=", "0", ")", ":", "varsToFind", "=", "set", "(", "varList", ")", "bindings", "=", "{", "}", "# We start at the level of the caller of getBindings", "frame", "=", "inspect", ".", "currentframe", "(", ")",...
Given a list of identifiers as strings, construct the dictonary of the identifiers as keys and the evaluated values of the ientifiers as the values. Ie something like {id:full_lookup(id) for id in identifiers}. full_lookup here is looking up the value of an identifier by looking at all the bindings at every lev...
[ "Given", "a", "list", "of", "identifiers", "as", "strings", "construct", "the", "dictonary", "of", "the", "identifiers", "as", "keys", "and", "the", "evaluated", "values", "of", "the", "ientifiers", "as", "the", "values", ".", "Ie", "something", "like", "{",...
train
https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/execute.py#L61-L97
jasonfharris/sysexecute
sysexecute/execute.py
_AsynchronouslyGetProcessOutput
def _AsynchronouslyGetProcessOutput(formattedCmd, printStdOut, printStdErr, **kwargs): ''' Asynchronously read the process ''' opts = filterKWArgsForFunc(kwargs, subprocess.Popen) opts['stdout'] = subprocess.PIPE opts['stderr'] = subprocess.PIPE process = subprocess.Popen(formattedCmd, **opts) ...
python
def _AsynchronouslyGetProcessOutput(formattedCmd, printStdOut, printStdErr, **kwargs): ''' Asynchronously read the process ''' opts = filterKWArgsForFunc(kwargs, subprocess.Popen) opts['stdout'] = subprocess.PIPE opts['stderr'] = subprocess.PIPE process = subprocess.Popen(formattedCmd, **opts) ...
[ "def", "_AsynchronouslyGetProcessOutput", "(", "formattedCmd", ",", "printStdOut", ",", "printStdErr", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "filterKWArgsForFunc", "(", "kwargs", ",", "subprocess", ".", "Popen", ")", "opts", "[", "'stdout'", "]", "="...
Asynchronously read the process
[ "Asynchronously", "read", "the", "process" ]
train
https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/execute.py#L139-L186