id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
250,200 | refinery29/chassis | chassis/services/cache.py | set_object | def set_object(cache, template, indexes, data):
"""Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys.... | python | def set_object(cache, template, indexes, data):
"""Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys.... | [
"def",
"set_object",
"(",
"cache",
",",
"template",
",",
"indexes",
",",
"data",
")",
":",
"# TODO(mattmillr): Handle expiration times",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"key",
"in... | Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string inte... | [
"Set",
"an",
"object",
"in",
"Redis",
"using",
"a",
"pipeline",
"."
] | 1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192 | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L85-L122 |
250,201 | refinery29/chassis | chassis/services/cache.py | delete_object | def delete_object(cache, template, indexes):
"""Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
str... | python | def delete_object(cache, template, indexes):
"""Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
str... | [
"def",
"delete_object",
"(",
"cache",
",",
"template",
",",
"indexes",
")",
":",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"key",
"in",
"set",
"(",
"template",
".",
"keys",
"(",
")"... | Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format. Example:... | [
"Delete",
"an",
"object",
"in",
"Redis",
"using",
"a",
"pipeline",
"."
] | 1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192 | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L125-L154 |
250,202 | refinery29/chassis | chassis/services/cache.py | set_value | def set_value(cache, key, value):
"""Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username',
"""
with cache as redis_connection:
return redis_connection.set(key, value) | python | def set_value(cache, key, value):
"""Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username',
"""
with cache as redis_connection:
return redis_connection.set(key, value) | [
"def",
"set_value",
"(",
"cache",
",",
"key",
",",
"value",
")",
":",
"with",
"cache",
"as",
"redis_connection",
":",
"return",
"redis_connection",
".",
"set",
"(",
"key",
",",
"value",
")"
] | Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username', | [
"Set",
"a",
"value",
"by",
"key",
"."
] | 1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192 | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L175-L186 |
250,203 | heikomuller/sco-client | scocli/subject.py | SubjectHandle.create | def create(url, filename, properties):
"""Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST i... | python | def create(url, filename, properties):
"""Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST i... | [
"def",
"create",
"(",
"url",
",",
"filename",
",",
"properties",
")",
":",
"# Ensure that the file has valid suffix",
"if",
"not",
"has_tar_suffix",
"(",
"filename",
")",
":",
"raise",
"ValueError",
"(",
"'invalid file suffix: '",
"+",
"filename",
")",
"# Upload fil... | Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST image group create request
filename : strin... | [
"Create",
"new",
"subject",
"at",
"given",
"SCO",
"-",
"API",
"by",
"uploading",
"local",
"file",
".",
"Expects",
"an",
"tar",
"-",
"archive",
"containing",
"FreeSurfer",
"archive",
"file",
".",
"Allows",
"to",
"update",
"properties",
"of",
"created",
"resou... | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/subject.py#L74-L123 |
250,204 | calvinku96/labreporthelper | labreporthelper/parse.py | getdata | def getdata(inputfile, argnum=None, close=False):
"""
Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: Fa... | python | def getdata(inputfile, argnum=None, close=False):
"""
Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: Fa... | [
"def",
"getdata",
"(",
"inputfile",
",",
"argnum",
"=",
"None",
",",
"close",
"=",
"False",
")",
":",
"# get data and converts them to list",
"# outputtype - list, dict, all",
"output",
"=",
"[",
"]",
"add_data",
"=",
"{",
"}",
"line_num",
"=",
"0",
"for",
"li... | Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: False)
returns:
dictionary:
data: list o... | [
"Get",
"data",
"from",
"the",
".",
"dat",
"files"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/parse.py#L7-L51 |
250,205 | bird-house/birdhousebuilder.recipe.redis | birdhousebuilder/recipe/redis/__init__.py | Recipe.install_supervisor | def install_supervisor(self, update=False):
"""
install supervisor config for redis
"""
script = supervisor.Recipe(
self.buildout,
self.name,
{'user': self.options.get('user'),
'program': self.options.get('program'),
'command'... | python | def install_supervisor(self, update=False):
"""
install supervisor config for redis
"""
script = supervisor.Recipe(
self.buildout,
self.name,
{'user': self.options.get('user'),
'program': self.options.get('program'),
'command'... | [
"def",
"install_supervisor",
"(",
"self",
",",
"update",
"=",
"False",
")",
":",
"script",
"=",
"supervisor",
".",
"Recipe",
"(",
"self",
".",
"buildout",
",",
"self",
".",
"name",
",",
"{",
"'user'",
":",
"self",
".",
"options",
".",
"get",
"(",
"'u... | install supervisor config for redis | [
"install",
"supervisor",
"config",
"for",
"redis"
] | 3e66dd2f891547665055d807277d1c8f23c57003 | https://github.com/bird-house/birdhousebuilder.recipe.redis/blob/3e66dd2f891547665055d807277d1c8f23c57003/birdhousebuilder/recipe/redis/__init__.py#L67-L80 |
250,206 | roaet/eh | eh/mdv/tabulate.py | _format | def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
"""Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_re... | python | def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
"""Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_re... | [
"def",
"_format",
"(",
"val",
",",
"valtype",
",",
"floatfmt",
",",
"missingval",
"=",
"\"\"",
",",
"has_invisible",
"=",
"True",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"missingval",
"if",
"valtype",
"in",
"[",
"int",
",",
"_long_type",
",... | Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_result = '\\u0431\\u0443\\u043a\\u0432\\u0430 \\u0446\\u0438\\u0444\\u0440\\... | [
"Format",
"a",
"value",
"accoding",
"to",
"its",
"type",
"."
] | 9370864a9f1d65bb0f822d0aea83f1169c98f3bd | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/tabulate.py#L544-L575 |
250,207 | solocompt/plugs-filter | plugs_filter/decorators.py | get_view_model | def get_view_model(cls):
"""
Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model
"""
msg = 'When using get_queryset you must set a auto_filters_model field in the viewset'
if cls.queryset is not None:
return cls.queryset.model
... | python | def get_view_model(cls):
"""
Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model
"""
msg = 'When using get_queryset you must set a auto_filters_model field in the viewset'
if cls.queryset is not None:
return cls.queryset.model
... | [
"def",
"get_view_model",
"(",
"cls",
")",
":",
"msg",
"=",
"'When using get_queryset you must set a auto_filters_model field in the viewset'",
"if",
"cls",
".",
"queryset",
"is",
"not",
"None",
":",
"return",
"cls",
".",
"queryset",
".",
"model",
"else",
":",
"asser... | Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model | [
"Get",
"the",
"model",
"to",
"use",
"in",
"the",
"filter_class",
"by",
"inspecting",
"the",
"queryset",
"or",
"by",
"using",
"a",
"declared",
"auto_filters_model"
] | cb34c7d662d3f96c07c10b3ed0a34bafef78b52c | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/decorators.py#L8-L18 |
250,208 | solocompt/plugs-filter | plugs_filter/decorators.py | auto_filters | def auto_filters(cls):
"""
Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category')
"""
msg = 'Viewset mu... | python | def auto_filters(cls):
"""
Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category')
"""
msg = 'Viewset mu... | [
"def",
"auto_filters",
"(",
"cls",
")",
":",
"msg",
"=",
"'Viewset must have auto_filters_fields or auto_filters_exclude attribute when using auto_filters decorator'",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'auto_filters_fields'",
")",
"and",
"not",
"hasattr",
"(",
"cls"... | Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category') | [
"Adds",
"a",
"dynamic",
"filterclass",
"to",
"a",
"viewset",
"with",
"all",
"auto",
"filters",
"available",
"for",
"the",
"field",
"type",
"that",
"are",
"declared",
"in",
"a",
"tuple",
"auto_filter_fields"
] | cb34c7d662d3f96c07c10b3ed0a34bafef78b52c | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/decorators.py#L32-L58 |
250,209 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | env | def env(*_vars, **kwargs):
"""Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs.
"""
for v in _vars:
value = os.environ.get(v, None)
if value:
return value
return ... | python | def env(*_vars, **kwargs):
"""Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs.
"""
for v in _vars:
value = os.environ.get(v, None)
if value:
return value
return ... | [
"def",
"env",
"(",
"*",
"_vars",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"v",
"in",
"_vars",
":",
"value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"v",
",",
"None",
")",
"if",
"value",
":",
"return",
"value",
"return",
"kwargs",
".",
"get... | Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs. | [
"Search",
"for",
"the",
"first",
"defined",
"of",
"possibly",
"many",
"env",
"vars",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L126-L137 |
250,210 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.build_option_parser | def build_option_parser(self, description, version):
"""Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
... | python | def build_option_parser(self, description, version):
"""Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
... | [
"def",
"build_option_parser",
"(",
"self",
",",
"description",
",",
"version",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"description",
",",
"add_help",
"=",
"False",
",",
")",
"parser",
".",
"add_argument",
"(",
"'... | Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
:param version: version number for the application
... | [
"Return",
"an",
"argparse",
"option",
"parser",
"for",
"this",
"application",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L510-L557 |
250,211 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell._bash_completion | def _bash_completion(self):
"""Prints all of the commands and options for bash-completion."""
commands = set()
options = set()
for option, _action in self.parser._option_string_actions.items():
options.add(option)
for _name, _command in self.command_manager:
... | python | def _bash_completion(self):
"""Prints all of the commands and options for bash-completion."""
commands = set()
options = set()
for option, _action in self.parser._option_string_actions.items():
options.add(option)
for _name, _command in self.command_manager:
... | [
"def",
"_bash_completion",
"(",
"self",
")",
":",
"commands",
"=",
"set",
"(",
")",
"options",
"=",
"set",
"(",
")",
"for",
"option",
",",
"_action",
"in",
"self",
".",
"parser",
".",
"_option_string_actions",
".",
"items",
"(",
")",
":",
"options",
".... | Prints all of the commands and options for bash-completion. | [
"Prints",
"all",
"of",
"the",
"commands",
"and",
"options",
"for",
"bash",
"-",
"completion",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L782-L795 |
250,212 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.run | def run(self, argv):
"""Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str
"""
try:
index = 0
command_pos = -1
help_pos = -1
help_command_pos = -1
f... | python | def run(self, argv):
"""Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str
"""
try:
index = 0
command_pos = -1
help_pos = -1
help_command_pos = -1
f... | [
"def",
"run",
"(",
"self",
",",
"argv",
")",
":",
"try",
":",
"index",
"=",
"0",
"command_pos",
"=",
"-",
"1",
"help_pos",
"=",
"-",
"1",
"help_command_pos",
"=",
"-",
"1",
"for",
"arg",
"in",
"argv",
":",
"if",
"arg",
"==",
"'bash-completion'",
"a... | Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str | [
"Equivalent",
"to",
"the",
"main",
"program",
"for",
"the",
"application",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L820-L864 |
250,213 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.authenticate_user | def authenticate_user(self):
"""Confirm user authentication
Make sure the user has provided all of the authentication
info we need.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(
cloud=self.options.os_cloud, argparse=self.options,
ne... | python | def authenticate_user(self):
"""Confirm user authentication
Make sure the user has provided all of the authentication
info we need.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(
cloud=self.options.os_cloud, argparse=self.options,
ne... | [
"def",
"authenticate_user",
"(",
"self",
")",
":",
"cloud_config",
"=",
"os_client_config",
".",
"OpenStackConfig",
"(",
")",
".",
"get_one_cloud",
"(",
"cloud",
"=",
"self",
".",
"options",
".",
"os_cloud",
",",
"argparse",
"=",
"self",
".",
"options",
",",... | Confirm user authentication
Make sure the user has provided all of the authentication
info we need. | [
"Confirm",
"user",
"authentication"
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L889-L934 |
250,214 | rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.configure_logging | def configure_logging(self):
"""Create logging handlers for any log output."""
root_logger = logging.getLogger('')
# Set up logging to a file
root_logger.setLevel(logging.DEBUG)
# Send higher-level messages to the console via stderr
console = logging.StreamHandler(self.... | python | def configure_logging(self):
"""Create logging handlers for any log output."""
root_logger = logging.getLogger('')
# Set up logging to a file
root_logger.setLevel(logging.DEBUG)
# Send higher-level messages to the console via stderr
console = logging.StreamHandler(self.... | [
"def",
"configure_logging",
"(",
"self",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
"''",
")",
"# Set up logging to a file",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"# Send higher-level messages to the console via stderr",... | Create logging handlers for any log output. | [
"Create",
"logging",
"handlers",
"for",
"any",
"log",
"output",
"."
] | 5a5009a8fe078e3aa1d582176669f1b28ab26bef | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L956-L984 |
250,215 | TheOneHyer/arandomness | build/lib.linux-x86_64-3.6/arandomness/str/max_substring.py | max_substring | def max_substring(words, position=0, _last_letter=''):
"""Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
... | python | def max_substring(words, position=0, _last_letter=''):
"""Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
... | [
"def",
"max_substring",
"(",
"words",
",",
"position",
"=",
"0",
",",
"_last_letter",
"=",
"''",
")",
":",
"# If end of word is reached, begin reconstructing the substring",
"try",
":",
"letter",
"=",
"[",
"word",
"[",
"position",
"]",
"for",
"word",
"in",
"word... | Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
_last_letter (unicode): last common letter, only for use
... | [
"Finds",
"max",
"substring",
"shared",
"by",
"all",
"strings",
"starting",
"at",
"position"
] | ae9f630e9a1d67b0eb6d61644a49756de8a5268c | https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/str/max_substring.py#L31-L71 |
250,216 | abhinav/reversible | reversible/tornado/generator.py | _map_generator | def _map_generator(f, generator):
"""Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a m... | python | def _map_generator(f, generator):
"""Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a m... | [
"def",
"_map_generator",
"(",
"f",
",",
"generator",
")",
":",
"item",
"=",
"next",
"(",
"generator",
")",
"while",
"True",
":",
"try",
":",
"result",
"=",
"yield",
"f",
"(",
"item",
")",
"except",
"Exception",
":",
"item",
"=",
"generator",
".",
"th... | Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a map function for generators that sends val... | [
"Apply",
"f",
"to",
"the",
"results",
"of",
"the",
"given",
"bi",
"-",
"directional",
"generator",
"."
] | 7e28aaf0390f7d4b889c6ac14d7b340f8f314e89 | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/tornado/generator.py#L34-L51 |
250,217 | patrickayoup/md2remark | md2remark/main.py | compile_markdown_file | def compile_markdown_file(source_file):
'''Compiles a single markdown file to a remark.js slideshow.'''
template = pkg_resources.resource_string('md2remark.resources.templates', 'slideshow.mustache')
renderer = pystache.Renderer(search_dirs='./templates')
f = open(source_file, 'r')
slideshow_md = f.read()
... | python | def compile_markdown_file(source_file):
'''Compiles a single markdown file to a remark.js slideshow.'''
template = pkg_resources.resource_string('md2remark.resources.templates', 'slideshow.mustache')
renderer = pystache.Renderer(search_dirs='./templates')
f = open(source_file, 'r')
slideshow_md = f.read()
... | [
"def",
"compile_markdown_file",
"(",
"source_file",
")",
":",
"template",
"=",
"pkg_resources",
".",
"resource_string",
"(",
"'md2remark.resources.templates'",
",",
"'slideshow.mustache'",
")",
"renderer",
"=",
"pystache",
".",
"Renderer",
"(",
"search_dirs",
"=",
"'.... | Compiles a single markdown file to a remark.js slideshow. | [
"Compiles",
"a",
"single",
"markdown",
"file",
"to",
"a",
"remark",
".",
"js",
"slideshow",
"."
] | 04e66462046cd123c5b1810454d949c3a05bc057 | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L8-L26 |
250,218 | patrickayoup/md2remark | md2remark/main.py | compile_slides | def compile_slides(source):
'''Compiles the source to a remark.js slideshow.'''
# if it's a directory, do all md files.
if os.path.isdir(source):
for f in os.listdir(source):
if f.lower().endswith('.md'):
compile_markdown_file(os.path.join(source, f))
else:
compile_markdown_file(source) | python | def compile_slides(source):
'''Compiles the source to a remark.js slideshow.'''
# if it's a directory, do all md files.
if os.path.isdir(source):
for f in os.listdir(source):
if f.lower().endswith('.md'):
compile_markdown_file(os.path.join(source, f))
else:
compile_markdown_file(source) | [
"def",
"compile_slides",
"(",
"source",
")",
":",
"# if it's a directory, do all md files.",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source",
")",
":",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"source",
")",
":",
"if",
"f",
".",
"lower",
"(",
... | Compiles the source to a remark.js slideshow. | [
"Compiles",
"the",
"source",
"to",
"a",
"remark",
".",
"js",
"slideshow",
"."
] | 04e66462046cd123c5b1810454d949c3a05bc057 | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L28-L36 |
250,219 | patrickayoup/md2remark | md2remark/main.py | parse_cl_args | def parse_cl_args(arg_vector):
'''Parses the command line arguments'''
parser = argparse.ArgumentParser(description='Compiles markdown files into html files for remark.js')
parser.add_argument('source', metavar='source', help='the source to compile. If a directory is provided, all markdown files in that directory... | python | def parse_cl_args(arg_vector):
'''Parses the command line arguments'''
parser = argparse.ArgumentParser(description='Compiles markdown files into html files for remark.js')
parser.add_argument('source', metavar='source', help='the source to compile. If a directory is provided, all markdown files in that directory... | [
"def",
"parse_cl_args",
"(",
"arg_vector",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Compiles markdown files into html files for remark.js'",
")",
"parser",
".",
"add_argument",
"(",
"'source'",
",",
"metavar",
"=",
"'sourc... | Parses the command line arguments | [
"Parses",
"the",
"command",
"line",
"arguments"
] | 04e66462046cd123c5b1810454d949c3a05bc057 | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L38-L43 |
250,220 | sirrice/scorpionsql | scorpionsql/sql.py | Query.get_filter_qobj | def get_filter_qobj(self, keys=None):
"""
Return a copy of this Query object with additional where clauses for the
keys in the argument
"""
# only care about columns in aggregates right?
cols = set()
for agg in self.select.aggregates:
cols.update(agg.cols)
sels = [SelectExpr(col... | python | def get_filter_qobj(self, keys=None):
"""
Return a copy of this Query object with additional where clauses for the
keys in the argument
"""
# only care about columns in aggregates right?
cols = set()
for agg in self.select.aggregates:
cols.update(agg.cols)
sels = [SelectExpr(col... | [
"def",
"get_filter_qobj",
"(",
"self",
",",
"keys",
"=",
"None",
")",
":",
"# only care about columns in aggregates right?",
"cols",
"=",
"set",
"(",
")",
"for",
"agg",
"in",
"self",
".",
"select",
".",
"aggregates",
":",
"cols",
".",
"update",
"(",
"agg",
... | Return a copy of this Query object with additional where clauses for the
keys in the argument | [
"Return",
"a",
"copy",
"of",
"this",
"Query",
"object",
"with",
"additional",
"where",
"clauses",
"for",
"the",
"keys",
"in",
"the",
"argument"
] | baa05b745fae5df3171244c3e32160bd36c99e86 | https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sql.py#L123-L150 |
250,221 | noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.total_build_duration_for_chain | def total_build_duration_for_chain(self, build_chain_id):
"""Returns the total duration for one specific build chain run"""
return sum([
int(self.__build_duration_for_id(id))
for id in self.__build_ids_of_chain(build_chain_id)
]) | python | def total_build_duration_for_chain(self, build_chain_id):
"""Returns the total duration for one specific build chain run"""
return sum([
int(self.__build_duration_for_id(id))
for id in self.__build_ids_of_chain(build_chain_id)
]) | [
"def",
"total_build_duration_for_chain",
"(",
"self",
",",
"build_chain_id",
")",
":",
"return",
"sum",
"(",
"[",
"int",
"(",
"self",
".",
"__build_duration_for_id",
"(",
"id",
")",
")",
"for",
"id",
"in",
"self",
".",
"__build_ids_of_chain",
"(",
"build_chain... | Returns the total duration for one specific build chain run | [
"Returns",
"the",
"total",
"duration",
"for",
"one",
"specific",
"build",
"chain",
"run"
] | 54fd7194cd2b7b02dc137e7a9ed013aac96af841 | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L101-L106 |
250,222 | noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.build_cycle_time | def build_cycle_time(self, build_id):
"""Returns a BuildCycleTime object for the given build"""
json_form = self.__retrieve_as_json(self.builds_path % build_id)
return BuildCycleTime(
build_id,
json_form[u'buildTypeId'],
as_date(json_form, u'startDate'),
... | python | def build_cycle_time(self, build_id):
"""Returns a BuildCycleTime object for the given build"""
json_form = self.__retrieve_as_json(self.builds_path % build_id)
return BuildCycleTime(
build_id,
json_form[u'buildTypeId'],
as_date(json_form, u'startDate'),
... | [
"def",
"build_cycle_time",
"(",
"self",
",",
"build_id",
")",
":",
"json_form",
"=",
"self",
".",
"__retrieve_as_json",
"(",
"self",
".",
"builds_path",
"%",
"build_id",
")",
"return",
"BuildCycleTime",
"(",
"build_id",
",",
"json_form",
"[",
"u'buildTypeId'",
... | Returns a BuildCycleTime object for the given build | [
"Returns",
"a",
"BuildCycleTime",
"object",
"for",
"the",
"given",
"build"
] | 54fd7194cd2b7b02dc137e7a9ed013aac96af841 | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L123-L131 |
250,223 | noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.build_stats_for_chain | def build_stats_for_chain(self, build_chain_id):
"""Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain.
"""
json_form = self.__retrieve_as_json(self.build_chain_path % build_chain_id... | python | def build_stats_for_chain(self, build_chain_id):
"""Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain.
"""
json_form = self.__retrieve_as_json(self.build_chain_path % build_chain_id... | [
"def",
"build_stats_for_chain",
"(",
"self",
",",
"build_chain_id",
")",
":",
"json_form",
"=",
"self",
".",
"__retrieve_as_json",
"(",
"self",
".",
"build_chain_path",
"%",
"build_chain_id",
")",
"builds",
"=",
"[",
"{",
"'build_id'",
":",
"build",
"[",
"u'id... | Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain. | [
"Returns",
"a",
"list",
"of",
"Build",
"tuples",
"for",
"all",
"elements",
"in",
"the",
"build",
"chain",
"."
] | 54fd7194cd2b7b02dc137e7a9ed013aac96af841 | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L133-L148 |
250,224 | mirca/muchbettermoments | muchbettermoments.py | quadratic_2d | def quadratic_2d(data):
"""
Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively
"""
arg_data_max = np.argm... | python | def quadratic_2d(data):
"""
Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively
"""
arg_data_max = np.argm... | [
"def",
"quadratic_2d",
"(",
"data",
")",
":",
"arg_data_max",
"=",
"np",
".",
"argmax",
"(",
"data",
")",
"i",
",",
"j",
"=",
"np",
".",
"unravel_index",
"(",
"arg_data_max",
",",
"data",
".",
"shape",
")",
"z_",
"=",
"data",
"[",
"i",
"-",
"1",
... | Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively | [
"Compute",
"the",
"quadratic",
"estimate",
"of",
"the",
"centroid",
"in",
"a",
"2d",
"-",
"array",
"."
] | 8cc2bf18ff52abf86151a12358434691bea0857d | https://github.com/mirca/muchbettermoments/blob/8cc2bf18ff52abf86151a12358434691bea0857d/muchbettermoments.py#L9-L46 |
250,225 | bwesterb/mirte | src/mirteFile.py | depsOf_of_mirteFile_instance_definition | def depsOf_of_mirteFile_instance_definition(man, insts):
""" Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile """
return lambda x: [a[1] for a in six.iteritems(insts[x])
... | python | def depsOf_of_mirteFile_instance_definition(man, insts):
""" Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile """
return lambda x: [a[1] for a in six.iteritems(insts[x])
... | [
"def",
"depsOf_of_mirteFile_instance_definition",
"(",
"man",
",",
"insts",
")",
":",
"return",
"lambda",
"x",
":",
"[",
"a",
"[",
"1",
"]",
"for",
"a",
"in",
"six",
".",
"iteritems",
"(",
"insts",
"[",
"x",
"]",
")",
"if",
"a",
"[",
"0",
"]",
"in"... | Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile | [
"Returns",
"a",
"function",
"that",
"returns",
"the",
"dependencies",
"of",
"an",
"instance",
"definition",
"by",
"its",
"name",
"where",
"insts",
"is",
"a",
"dictionary",
"of",
"instance",
"definitions",
"from",
"a",
"mirteFile"
] | c58db8c993cd15ffdc64b52703cd466213913200 | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L31-L38 |
250,226 | bwesterb/mirte | src/mirteFile.py | depsOf_of_mirteFile_module_definition | def depsOf_of_mirteFile_module_definition(defs):
""" Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile """
return lambda x: (list(filter(lambda z: z is not None and z in defs,
... | python | def depsOf_of_mirteFile_module_definition(defs):
""" Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile """
return lambda x: (list(filter(lambda z: z is not None and z in defs,
... | [
"def",
"depsOf_of_mirteFile_module_definition",
"(",
"defs",
")",
":",
"return",
"lambda",
"x",
":",
"(",
"list",
"(",
"filter",
"(",
"lambda",
"z",
":",
"z",
"is",
"not",
"None",
"and",
"z",
"in",
"defs",
",",
"map",
"(",
"lambda",
"y",
":",
"y",
"[... | Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile | [
"Returns",
"a",
"function",
"that",
"returns",
"the",
"dependencies",
"of",
"a",
"module",
"definition",
"by",
"its",
"name",
"where",
"defs",
"is",
"a",
"dictionary",
"of",
"module",
"definitions",
"from",
"a",
"mirteFile"
] | c58db8c993cd15ffdc64b52703cd466213913200 | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L41-L49 |
250,227 | eranimo/nomine | nomine/generate.py | Nomine._generate | def _generate(self, size=None):
"Generates a new word"
corpus_letters = list(self.vectors.keys())
current_letter = random.choice(corpus_letters)
if size is None:
size = int(random.normalvariate(self.avg, self.std_dev))
letters = [current_letter]
for _ in ran... | python | def _generate(self, size=None):
"Generates a new word"
corpus_letters = list(self.vectors.keys())
current_letter = random.choice(corpus_letters)
if size is None:
size = int(random.normalvariate(self.avg, self.std_dev))
letters = [current_letter]
for _ in ran... | [
"def",
"_generate",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"corpus_letters",
"=",
"list",
"(",
"self",
".",
"vectors",
".",
"keys",
"(",
")",
")",
"current_letter",
"=",
"random",
".",
"choice",
"(",
"corpus_letters",
")",
"if",
"size",
"is",... | Generates a new word | [
"Generates",
"a",
"new",
"word"
] | bd6342c7c67d772d2b603d5bb081ceda432cc681 | https://github.com/eranimo/nomine/blob/bd6342c7c67d772d2b603d5bb081ceda432cc681/nomine/generate.py#L65-L82 |
250,228 | xtrementl/focus | focus/plugin/modules/tasks.py | _print_tasks | def _print_tasks(env, tasks, mark_active=False):
""" Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task.
"""
if ... | python | def _print_tasks(env, tasks, mark_active=False):
""" Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task.
"""
if ... | [
"def",
"_print_tasks",
"(",
"env",
",",
"tasks",
",",
"mark_active",
"=",
"False",
")",
":",
"if",
"env",
".",
"task",
".",
"active",
"and",
"mark_active",
":",
"active_task",
"=",
"env",
".",
"task",
".",
"name",
"else",
":",
"active_task",
"=",
"None... | Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task. | [
"Prints",
"task",
"information",
"using",
"io",
"stream",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L18-L86 |
250,229 | xtrementl/focus | focus/plugin/modules/tasks.py | _edit_task_config | def _edit_task_config(env, task_config, confirm):
""" Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, pr... | python | def _edit_task_config(env, task_config, confirm):
""" Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, pr... | [
"def",
"_edit_task_config",
"(",
"env",
",",
"task_config",
",",
"confirm",
")",
":",
"# get editor program",
"if",
"common",
".",
"IS_MACOSX",
":",
"def_editor",
"=",
"'open'",
"else",
":",
"def_editor",
"=",
"'vi'",
"editor",
"=",
"os",
".",
"environ",
"."... | Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, prompt to re-edit.
Return boolean.
* Raise... | [
"Launches",
"text",
"editor",
"to",
"edit",
"provided",
"task",
"configuration",
"file",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L89-L175 |
250,230 | xtrementl/focus | focus/plugin/modules/tasks.py | TaskStart.execute | def execute(self, env, args):
""" Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# start the task
if env.task.start(args.task_name):
env.io.success(u'Task Lo... | python | def execute(self, env, args):
""" Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# start the task
if env.task.start(args.task_name):
env.io.success(u'Task Lo... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"# start the task",
"if",
"env",
".",
"task",
".",
"start",
"(",
"args",
".",
"task_name",
")",
":",
"env",
".",
"io",
".",
"success",
"(",
"u'Task Loaded.'",
")"
] | Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Starts",
"a",
"new",
"task",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L195-L206 |
250,231 | xtrementl/focus | focus/plugin/modules/tasks.py | TaskCreate.setup_parser | def setup_parser(self, parser):
""" Setup the argument parser.
`parser`
``FocusArgParser`` object.
"""
parser.add_argument('task_name', help='task to create')
parser.add_argument('clone_task', nargs='?',
help='existing task to... | python | def setup_parser(self, parser):
""" Setup the argument parser.
`parser`
``FocusArgParser`` object.
"""
parser.add_argument('task_name', help='task to create')
parser.add_argument('clone_task', nargs='?',
help='existing task to... | [
"def",
"setup_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'task_name'",
",",
"help",
"=",
"'task to create'",
")",
"parser",
".",
"add_argument",
"(",
"'clone_task'",
",",
"nargs",
"=",
"'?'",
",",
"help",
"=",
"'exi... | Setup the argument parser.
`parser`
``FocusArgParser`` object. | [
"Setup",
"the",
"argument",
"parser",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L238-L249 |
250,232 | xtrementl/focus | focus/plugin/modules/tasks.py | TaskCreate.execute | def execute(self, env, args):
""" Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
clone_task = args.clone_task
if not env.task.create... | python | def execute(self, env, args):
""" Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
clone_task = args.clone_task
if not env.task.create... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"task_name",
"=",
"args",
".",
"task_name",
"clone_task",
"=",
"args",
".",
"clone_task",
"if",
"not",
"env",
".",
"task",
".",
"create",
"(",
"task_name",
",",
"clone_task",
")",
":",
... | Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Creates",
"a",
"new",
"task",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L251-L273 |
250,233 | xtrementl/focus | focus/plugin/modules/tasks.py | TaskEdit.execute | def execute(self, env, args):
""" Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if not env.task.exists(task_name):
raise ... | python | def execute(self, env, args):
""" Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if not env.task.exists(task_name):
raise ... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"task_name",
"=",
"args",
".",
"task_name",
"if",
"not",
"env",
".",
"task",
".",
"exists",
"(",
"task_name",
")",
":",
"raise",
"errors",
".",
"TaskNotFound",
"(",
"task_name",
")",
"... | Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Edits",
"task",
"configuration",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L293-L315 |
250,234 | xtrementl/focus | focus/plugin/modules/tasks.py | TaskList.execute | def execute(self, env, args):
""" Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
tasks = env.task.get_list_info()
if not tasks:
env.io.write("No tasks fo... | python | def execute(self, env, args):
""" Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
tasks = env.task.get_list_info()
if not tasks:
env.io.write("No tasks fo... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"tasks",
"=",
"env",
".",
"task",
".",
"get_list_info",
"(",
")",
"if",
"not",
"tasks",
":",
"env",
".",
"io",
".",
"write",
"(",
"\"No tasks found.\"",
")",
"else",
":",
"if",
"args... | Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Lists",
"all",
"valid",
"tasks",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L434-L464 |
250,235 | bruth/restlib2 | restlib2/resources.py | no_content_response | def no_content_response(response):
"Cautious assessment of the response body for no content."
if not hasattr(response, '_container'):
return True
if response._container is None:
return True
if isinstance(response._container, (list, tuple)):
if len(response._container) == 1 and ... | python | def no_content_response(response):
"Cautious assessment of the response body for no content."
if not hasattr(response, '_container'):
return True
if response._container is None:
return True
if isinstance(response._container, (list, tuple)):
if len(response._container) == 1 and ... | [
"def",
"no_content_response",
"(",
"response",
")",
":",
"if",
"not",
"hasattr",
"(",
"response",
",",
"'_container'",
")",
":",
"return",
"True",
"if",
"response",
".",
"_container",
"is",
"None",
":",
"return",
"True",
"if",
"isinstance",
"(",
"response",
... | Cautious assessment of the response body for no content. | [
"Cautious",
"assessment",
"of",
"the",
"response",
"body",
"for",
"no",
"content",
"."
] | cb147527496ddf08263364f1fb52e7c48f215667 | https://github.com/bruth/restlib2/blob/cb147527496ddf08263364f1fb52e7c48f215667/restlib2/resources.py#L32-L44 |
250,236 | melonmanchan/ResumeOS | resumeos/ResumeOs.py | render_template_file | def render_template_file(file_name, context):
""" Renders and overrides Jinja2 template files """
with open(file_name, 'r+') as f:
template = Template(f.read())
output = template.render(context)
f.seek(0)
f.write(output)
f.truncate() | python | def render_template_file(file_name, context):
""" Renders and overrides Jinja2 template files """
with open(file_name, 'r+') as f:
template = Template(f.read())
output = template.render(context)
f.seek(0)
f.write(output)
f.truncate() | [
"def",
"render_template_file",
"(",
"file_name",
",",
"context",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r+'",
")",
"as",
"f",
":",
"template",
"=",
"Template",
"(",
"f",
".",
"read",
"(",
")",
")",
"output",
"=",
"template",
".",
"render",
... | Renders and overrides Jinja2 template files | [
"Renders",
"and",
"overrides",
"Jinja2",
"template",
"files"
] | b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c | https://github.com/melonmanchan/ResumeOS/blob/b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c/resumeos/ResumeOs.py#L16-L23 |
250,237 | melonmanchan/ResumeOS | resumeos/ResumeOs.py | main | def main(name, output, font):
""" Easily bootstrap an OS project to fool HR departments and pad your resume. """
# The path of the directory where the final files will end up in
bootstrapped_directory = os.getcwd() + os.sep + name.lower().replace(' ', '-') + os.sep
# Copy the template files to the ta... | python | def main(name, output, font):
""" Easily bootstrap an OS project to fool HR departments and pad your resume. """
# The path of the directory where the final files will end up in
bootstrapped_directory = os.getcwd() + os.sep + name.lower().replace(' ', '-') + os.sep
# Copy the template files to the ta... | [
"def",
"main",
"(",
"name",
",",
"output",
",",
"font",
")",
":",
"# The path of the directory where the final files will end up in",
"bootstrapped_directory",
"=",
"os",
".",
"getcwd",
"(",
")",
"+",
"os",
".",
"sep",
"+",
"name",
".",
"lower",
"(",
")",
".",... | Easily bootstrap an OS project to fool HR departments and pad your resume. | [
"Easily",
"bootstrap",
"an",
"OS",
"project",
"to",
"fool",
"HR",
"departments",
"and",
"pad",
"your",
"resume",
"."
] | b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c | https://github.com/melonmanchan/ResumeOS/blob/b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c/resumeos/ResumeOs.py#L37-L62 |
250,238 | tomnor/channelpack | channelpack/pulldbf.py | dbfreader | def dbfreader(f):
"""Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should ... | python | def dbfreader(f):
"""Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should ... | [
"def",
"dbfreader",
"(",
"f",
")",
":",
"# See DBF format spec at:",
"# http://www.pgts.com.au/download/public/xbase.htm#DBF_STRUCT",
"numrec",
",",
"lenheader",
"=",
"struct",
".",
"unpack",
"(",
"'<xxxxLH22x'",
",",
"f",
".",
"read",
"(",
"32",
")",
")",
"numf... | Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should be opened for binary read... | [
"Returns",
"an",
"iterator",
"over",
"records",
"in",
"a",
"Xbase",
"DBF",
"file",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulldbf.py#L11-L74 |
250,239 | tomnor/channelpack | channelpack/pulldbf.py | dbf_asdict | def dbf_asdict(fn, usecols=None, keystyle='ints'):
"""Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to ... | python | def dbf_asdict(fn, usecols=None, keystyle='ints'):
"""Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to ... | [
"def",
"dbf_asdict",
"(",
"fn",
",",
"usecols",
"=",
"None",
",",
"keystyle",
"=",
"'ints'",
")",
":",
"if",
"keystyle",
"not",
"in",
"[",
"'ints'",
",",
"'names'",
"]",
":",
"raise",
"ValueError",
"(",
"'Unknown keyword: '",
"+",
"str",
"(",
"keystyle",... | Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to a ChannelPack as loadfunc. If 'names' is
used, key... | [
"Return",
"data",
"from",
"dbf",
"file",
"fn",
"as",
"a",
"dict",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulldbf.py#L77-L113 |
250,240 | sbusard/wagoner | wagoner/table.py | Table.check | def check(self):
"""
Check that this table is complete, that is, every character of this
table can be followed by a new character.
:return: True if the table is complete, False otherwise.
"""
for character, followers in self.items():
for follower in followers... | python | def check(self):
"""
Check that this table is complete, that is, every character of this
table can be followed by a new character.
:return: True if the table is complete, False otherwise.
"""
for character, followers in self.items():
for follower in followers... | [
"def",
"check",
"(",
"self",
")",
":",
"for",
"character",
",",
"followers",
"in",
"self",
".",
"items",
"(",
")",
":",
"for",
"follower",
"in",
"followers",
":",
"if",
"follower",
"not",
"in",
"self",
":",
"return",
"False",
"return",
"True"
] | Check that this table is complete, that is, every character of this
table can be followed by a new character.
:return: True if the table is complete, False otherwise. | [
"Check",
"that",
"this",
"table",
"is",
"complete",
"that",
"is",
"every",
"character",
"of",
"this",
"table",
"can",
"be",
"followed",
"by",
"a",
"new",
"character",
"."
] | 7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/table.py#L81-L92 |
250,241 | sbusard/wagoner | wagoner/table.py | Table.random_word | def random_word(self, length, prefix=0, start=False, end=False,
flatten=False):
"""
Generate a random word of length from this table.
:param length: the length of the generated word; >= 1;
:param prefix: if greater than 0, the maximum length of the prefix to
... | python | def random_word(self, length, prefix=0, start=False, end=False,
flatten=False):
"""
Generate a random word of length from this table.
:param length: the length of the generated word; >= 1;
:param prefix: if greater than 0, the maximum length of the prefix to
... | [
"def",
"random_word",
"(",
"self",
",",
"length",
",",
"prefix",
"=",
"0",
",",
"start",
"=",
"False",
",",
"end",
"=",
"False",
",",
"flatten",
"=",
"False",
")",
":",
"if",
"start",
":",
"word",
"=",
"\">\"",
"length",
"+=",
"1",
"return",
"self"... | Generate a random word of length from this table.
:param length: the length of the generated word; >= 1;
:param prefix: if greater than 0, the maximum length of the prefix to
consider to choose the next character;
:param start: if True, the generated word starts as a word... | [
"Generate",
"a",
"random",
"word",
"of",
"length",
"from",
"this",
"table",
"."
] | 7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/table.py#L129-L157 |
250,242 | sbusard/wagoner | wagoner/table.py | Table._extend_word | def _extend_word(self, word, length, prefix=0, end=False, flatten=False):
"""
Extend the given word with a random suffix up to length.
:param length: the length of the extended word; >= len(word);
:param prefix: if greater than 0, the maximum length of the prefix to
... | python | def _extend_word(self, word, length, prefix=0, end=False, flatten=False):
"""
Extend the given word with a random suffix up to length.
:param length: the length of the extended word; >= len(word);
:param prefix: if greater than 0, the maximum length of the prefix to
... | [
"def",
"_extend_word",
"(",
"self",
",",
"word",
",",
"length",
",",
"prefix",
"=",
"0",
",",
"end",
"=",
"False",
",",
"flatten",
"=",
"False",
")",
":",
"if",
"len",
"(",
"word",
")",
"==",
"length",
":",
"if",
"end",
"and",
"\"<\"",
"not",
"in... | Extend the given word with a random suffix up to length.
:param length: the length of the extended word; >= len(word);
:param prefix: if greater than 0, the maximum length of the prefix to
consider to choose the next character;
:param end: if True, the generated word ends... | [
"Extend",
"the",
"given",
"word",
"with",
"a",
"random",
"suffix",
"up",
"to",
"length",
"."
] | 7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/table.py#L159-L196 |
250,243 | exekias/droplet | droplet/util.py | import_module | def import_module(module_path):
"""
Try to import and return the given module, if it exists, None if it doesn't
exist
:raises ImportError: When imported module contains errors
"""
if six.PY2:
try:
return importlib.import_module(module_path)
except ImportError:
... | python | def import_module(module_path):
"""
Try to import and return the given module, if it exists, None if it doesn't
exist
:raises ImportError: When imported module contains errors
"""
if six.PY2:
try:
return importlib.import_module(module_path)
except ImportError:
... | [
"def",
"import_module",
"(",
"module_path",
")",
":",
"if",
"six",
".",
"PY2",
":",
"try",
":",
"return",
"importlib",
".",
"import_module",
"(",
"module_path",
")",
"except",
"ImportError",
":",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
"2",
"... | Try to import and return the given module, if it exists, None if it doesn't
exist
:raises ImportError: When imported module contains errors | [
"Try",
"to",
"import",
"and",
"return",
"the",
"given",
"module",
"if",
"it",
"exists",
"None",
"if",
"it",
"doesn",
"t",
"exist"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/util.py#L28-L46 |
250,244 | exekias/droplet | droplet/util.py | make_password | def make_password(length, chars=string.letters + string.digits + '#$%&!'):
"""
Generate and return a random password
:param length: Desired length
:param chars: Character set to use
"""
return get_random_string(length, chars) | python | def make_password(length, chars=string.letters + string.digits + '#$%&!'):
"""
Generate and return a random password
:param length: Desired length
:param chars: Character set to use
"""
return get_random_string(length, chars) | [
"def",
"make_password",
"(",
"length",
",",
"chars",
"=",
"string",
".",
"letters",
"+",
"string",
".",
"digits",
"+",
"'#$%&!'",
")",
":",
"return",
"get_random_string",
"(",
"length",
",",
"chars",
")"
] | Generate and return a random password
:param length: Desired length
:param chars: Character set to use | [
"Generate",
"and",
"return",
"a",
"random",
"password"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/util.py#L49-L56 |
250,245 | tdeck/rodong | rodong.py | RodongSinmun.__load_section | def __load_section(self, section_key):
"""
Reads the set of article links for a section if they are not cached.
"""
if self._sections[section_key] is not None: return
articles = []
for page in count(1):
if page > 50:
raise Exception('Last page... | python | def __load_section(self, section_key):
"""
Reads the set of article links for a section if they are not cached.
"""
if self._sections[section_key] is not None: return
articles = []
for page in count(1):
if page > 50:
raise Exception('Last page... | [
"def",
"__load_section",
"(",
"self",
",",
"section_key",
")",
":",
"if",
"self",
".",
"_sections",
"[",
"section_key",
"]",
"is",
"not",
"None",
":",
"return",
"articles",
"=",
"[",
"]",
"for",
"page",
"in",
"count",
"(",
"1",
")",
":",
"if",
"page"... | Reads the set of article links for a section if they are not cached. | [
"Reads",
"the",
"set",
"of",
"article",
"links",
"for",
"a",
"section",
"if",
"they",
"are",
"not",
"cached",
"."
] | 6247148e585ee323925cefb2494e9833e138e293 | https://github.com/tdeck/rodong/blob/6247148e585ee323925cefb2494e9833e138e293/rodong.py#L36-L80 |
250,246 | tdeck/rodong | rodong.py | Article.__load | def __load(self):
""" Loads text and photos if they are not cached. """
if self._text is not None: return
body = self._session.get(self.url).content
root = html.fromstring(body)
self._text = "\n".join((
p_tag.text_content()
for p_tag in root.findall('... | python | def __load(self):
""" Loads text and photos if they are not cached. """
if self._text is not None: return
body = self._session.get(self.url).content
root = html.fromstring(body)
self._text = "\n".join((
p_tag.text_content()
for p_tag in root.findall('... | [
"def",
"__load",
"(",
"self",
")",
":",
"if",
"self",
".",
"_text",
"is",
"not",
"None",
":",
"return",
"body",
"=",
"self",
".",
"_session",
".",
"get",
"(",
"self",
".",
"url",
")",
".",
"content",
"root",
"=",
"html",
".",
"fromstring",
"(",
"... | Loads text and photos if they are not cached. | [
"Loads",
"text",
"and",
"photos",
"if",
"they",
"are",
"not",
"cached",
"."
] | 6247148e585ee323925cefb2494e9833e138e293 | https://github.com/tdeck/rodong/blob/6247148e585ee323925cefb2494e9833e138e293/rodong.py#L100-L113 |
250,247 | mgagne/wafflehaus.iweb | wafflehaus/iweb/glance/image_filter/visible.py | VisibleFilter._is_whitelisted | def _is_whitelisted(self, req):
"""Return True if role is whitelisted or roles cannot be determined."""
if not self.roles_whitelist:
return False
if not hasattr(req, 'context'):
self.log.info("No context found.")
return False
if not hasattr(req.cont... | python | def _is_whitelisted(self, req):
"""Return True if role is whitelisted or roles cannot be determined."""
if not self.roles_whitelist:
return False
if not hasattr(req, 'context'):
self.log.info("No context found.")
return False
if not hasattr(req.cont... | [
"def",
"_is_whitelisted",
"(",
"self",
",",
"req",
")",
":",
"if",
"not",
"self",
".",
"roles_whitelist",
":",
"return",
"False",
"if",
"not",
"hasattr",
"(",
"req",
",",
"'context'",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"No context found.\"... | Return True if role is whitelisted or roles cannot be determined. | [
"Return",
"True",
"if",
"role",
"is",
"whitelisted",
"or",
"roles",
"cannot",
"be",
"determined",
"."
] | 8ac625582c1180391fe022d1db19f70a2dfb376a | https://github.com/mgagne/wafflehaus.iweb/blob/8ac625582c1180391fe022d1db19f70a2dfb376a/wafflehaus/iweb/glance/image_filter/visible.py#L55-L77 |
250,248 | tBaxter/django-fretboard | fretboard/views/crud.py | add_topic | def add_topic(request, forum_slug=None):
""" Adds a topic to a given forum """
forum = Forum.objects.get(slug=forum_slug)
form = AddTopicForm(request.POST or None, request.FILES or None, initial={'forum': forum})
current_time = time.time()
user = request.user
if form.is_valid():
... | python | def add_topic(request, forum_slug=None):
""" Adds a topic to a given forum """
forum = Forum.objects.get(slug=forum_slug)
form = AddTopicForm(request.POST or None, request.FILES or None, initial={'forum': forum})
current_time = time.time()
user = request.user
if form.is_valid():
... | [
"def",
"add_topic",
"(",
"request",
",",
"forum_slug",
"=",
"None",
")",
":",
"forum",
"=",
"Forum",
".",
"objects",
".",
"get",
"(",
"slug",
"=",
"forum_slug",
")",
"form",
"=",
"AddTopicForm",
"(",
"request",
".",
"POST",
"or",
"None",
",",
"request"... | Adds a topic to a given forum | [
"Adds",
"a",
"topic",
"to",
"a",
"given",
"forum"
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/views/crud.py#L19-L56 |
250,249 | tBaxter/django-fretboard | fretboard/views/crud.py | add_post | def add_post(request, t_slug, t_id, p_id = False): # topic slug, topic id, post id
"""
Creates a new post and attaches it to a topic
"""
topic = get_object_or_404(Topic, id=t_id)
topic_url = '{0}page{1}/'.format(topic.get_short_url(), topic.page_count)
user = request.user
current_t... | python | def add_post(request, t_slug, t_id, p_id = False): # topic slug, topic id, post id
"""
Creates a new post and attaches it to a topic
"""
topic = get_object_or_404(Topic, id=t_id)
topic_url = '{0}page{1}/'.format(topic.get_short_url(), topic.page_count)
user = request.user
current_t... | [
"def",
"add_post",
"(",
"request",
",",
"t_slug",
",",
"t_id",
",",
"p_id",
"=",
"False",
")",
":",
"# topic slug, topic id, post id",
"topic",
"=",
"get_object_or_404",
"(",
"Topic",
",",
"id",
"=",
"t_id",
")",
"topic_url",
"=",
"'{0}page{1}/'",
".",
"form... | Creates a new post and attaches it to a topic | [
"Creates",
"a",
"new",
"post",
"and",
"attaches",
"it",
"to",
"a",
"topic"
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/views/crud.py#L60-L104 |
250,250 | tBaxter/django-fretboard | fretboard/views/crud.py | edit_post | def edit_post(request, post_id):
"""
Allows user to edit an existing post.
This needs to be rewritten. Badly.
"""
post = get_object_or_404(Post, id=post_id)
user = request.user
topic = post.topic
# oughta build a get_absolute_url method for this, maybe.
post_url = '{0}page{1}/#... | python | def edit_post(request, post_id):
"""
Allows user to edit an existing post.
This needs to be rewritten. Badly.
"""
post = get_object_or_404(Post, id=post_id)
user = request.user
topic = post.topic
# oughta build a get_absolute_url method for this, maybe.
post_url = '{0}page{1}/#... | [
"def",
"edit_post",
"(",
"request",
",",
"post_id",
")",
":",
"post",
"=",
"get_object_or_404",
"(",
"Post",
",",
"id",
"=",
"post_id",
")",
"user",
"=",
"request",
".",
"user",
"topic",
"=",
"post",
".",
"topic",
"# oughta build a get_absolute_url method for ... | Allows user to edit an existing post.
This needs to be rewritten. Badly. | [
"Allows",
"user",
"to",
"edit",
"an",
"existing",
"post",
".",
"This",
"needs",
"to",
"be",
"rewritten",
".",
"Badly",
"."
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/views/crud.py#L108-L150 |
250,251 | tBaxter/django-fretboard | fretboard/views/crud.py | delete_post | def delete_post(request, post_id, topic_id):
"""
Deletes a post, if the user has correct permissions.
Also updates topic.post_count
"""
try:
topic = Topic.objects.get(id=topic_id)
post = Post.objects.get(id=post_id)
except:
messages.error(request, 'Sorry, but this post ca... | python | def delete_post(request, post_id, topic_id):
"""
Deletes a post, if the user has correct permissions.
Also updates topic.post_count
"""
try:
topic = Topic.objects.get(id=topic_id)
post = Post.objects.get(id=post_id)
except:
messages.error(request, 'Sorry, but this post ca... | [
"def",
"delete_post",
"(",
"request",
",",
"post_id",
",",
"topic_id",
")",
":",
"try",
":",
"topic",
"=",
"Topic",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"topic_id",
")",
"post",
"=",
"Post",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"post_... | Deletes a post, if the user has correct permissions.
Also updates topic.post_count | [
"Deletes",
"a",
"post",
"if",
"the",
"user",
"has",
"correct",
"permissions",
".",
"Also",
"updates",
"topic",
".",
"post_count"
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/views/crud.py#L153-L178 |
250,252 | 20c/twentyc.tools | twentyc/tools/syslogfix.py | UTFFixedSysLogHandler.emit | def emit(self, record):
"""
Emit a record.
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
"""
msg = self.format(record) + '\000'
"""
We need to convert record level to lowercase, maybe this will
change in the future.
... | python | def emit(self, record):
"""
Emit a record.
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
"""
msg = self.format(record) + '\000'
"""
We need to convert record level to lowercase, maybe this will
change in the future.
... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"msg",
"=",
"self",
".",
"format",
"(",
"record",
")",
"+",
"'\\000'",
"\"\"\"\n\t\tWe need to convert record level to lowercase, maybe this will\n\t\tchange in the future.\n\t\t\"\"\"",
"prio",
"=",
"'<%d>'",
"%",
"s... | Emit a record.
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server. | [
"Emit",
"a",
"record",
".",
"The",
"record",
"is",
"formatted",
"and",
"then",
"sent",
"to",
"the",
"syslog",
"server",
".",
"If",
"exception",
"information",
"is",
"present",
"it",
"is",
"NOT",
"sent",
"to",
"the",
"server",
"."
] | f8f681e64f58d449bfc32646ba8bcc57db90a233 | https://github.com/20c/twentyc.tools/blob/f8f681e64f58d449bfc32646ba8bcc57db90a233/twentyc/tools/syslogfix.py#L21-L55 |
250,253 | ulf1/oxyba | oxyba/jackknife_loop.py | jackknife_loop | def jackknife_loop(func, data, d=1, combolimit=int(1e6)):
"""Generic Jackknife Subsampling procedure
func : function
A function pointer to a python function that
- accept an <Observations x Features> matrix
as input variable, and
- returns an array/list or scalar value as
... | python | def jackknife_loop(func, data, d=1, combolimit=int(1e6)):
"""Generic Jackknife Subsampling procedure
func : function
A function pointer to a python function that
- accept an <Observations x Features> matrix
as input variable, and
- returns an array/list or scalar value as
... | [
"def",
"jackknife_loop",
"(",
"func",
",",
"data",
",",
"d",
"=",
"1",
",",
"combolimit",
"=",
"int",
"(",
"1e6",
")",
")",
":",
"# load modules",
"import",
"scipy",
".",
"special",
"import",
"warnings",
"import",
"itertools",
"import",
"numpy",
"as",
"n... | Generic Jackknife Subsampling procedure
func : function
A function pointer to a python function that
- accept an <Observations x Features> matrix
as input variable, and
- returns an array/list or scalar value as
estimate, metric, model parameter,
jackknif... | [
"Generic",
"Jackknife",
"Subsampling",
"procedure"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/jackknife_loop.py#L2-L106 |
250,254 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | create_zone | def create_zone(server, token, domain, identifier, dtype, master=None):
"""Create zone records.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
identifier: Template ID
dtype: MASTER|SLAVE|NATI... | python | def create_zone(server, token, domain, identifier, dtype, master=None):
"""Create zone records.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
identifier: Template ID
dtype: MASTER|SLAVE|NATI... | [
"def",
"create_zone",
"(",
"server",
",",
"token",
",",
"domain",
",",
"identifier",
",",
"dtype",
",",
"master",
"=",
"None",
")",
":",
"method",
"=",
"'PUT'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone'",
"obj",
"=",
"JSONConverter",
"(",
... | Create zone records.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
identifier: Template ID
dtype: MASTER|SLAVE|NATIVE (default: MASTER)
master: master server ip address when dtype is... | [
"Create",
"zone",
"records",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L29-L50 |
250,255 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | create_records | def create_records(server, token, domain, data):
"""Create records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
data: Create records
ContentType: application/json
x-authentication-tok... | python | def create_records(server, token, domain, data):
"""Create records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
data: Create records
ContentType: application/json
x-authentication-tok... | [
"def",
"create_records",
"(",
"server",
",",
"token",
",",
"domain",
",",
"data",
")",
":",
"method",
"=",
"'PUT'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone/'",
"+",
"domain",
"for",
"i",
"in",
"data",
":",
"connect",
".",
"tonicdns_client",... | Create records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
data: Create records
ContentType: application/json
x-authentication-token: token | [
"Create",
"records",
"of",
"specific",
"domain",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L53-L69 |
250,256 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | delete_records | def delete_records(server, token, data):
"""Delete records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
data: Delete records
ContentType: application/json
x-authentication-token: token
"""
method = 'DELETE'
... | python | def delete_records(server, token, data):
"""Delete records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
data: Delete records
ContentType: application/json
x-authentication-token: token
"""
method = 'DELETE'
... | [
"def",
"delete_records",
"(",
"server",
",",
"token",
",",
"data",
")",
":",
"method",
"=",
"'DELETE'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone'",
"for",
"i",
"in",
"data",
":",
"connect",
".",
"tonicdns_client",
"(",
"uri",
",",
"method",
... | Delete records of specific domain.
Arguments:
server: TonicDNS API server
token: TonicDNS API authentication token
data: Delete records
ContentType: application/json
x-authentication-token: token | [
"Delete",
"records",
"of",
"specific",
"domain",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L72-L87 |
250,257 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | get_zone | def get_zone(server, token, domain, keyword='', raw_flag=False):
"""Retrieve zone records.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
keyword: Search keyword
x-authentication-token: token
"""
metho... | python | def get_zone(server, token, domain, keyword='', raw_flag=False):
"""Retrieve zone records.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
keyword: Search keyword
x-authentication-token: token
"""
metho... | [
"def",
"get_zone",
"(",
"server",
",",
"token",
",",
"domain",
",",
"keyword",
"=",
"''",
",",
"raw_flag",
"=",
"False",
")",
":",
"method",
"=",
"'GET'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone/'",
"+",
"domain",
"data",
"=",
"connect",
... | Retrieve zone records.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
keyword: Search keyword
x-authentication-token: token | [
"Retrieve",
"zone",
"records",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L90-L106 |
250,258 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | delete_zone | def delete_zone(server, token, domain):
"""Delete specific zone.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
x-authentication-token: token
"""
method = 'DELETE'
uri = 'https://' + server + '/zone/' + domai... | python | def delete_zone(server, token, domain):
"""Delete specific zone.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
x-authentication-token: token
"""
method = 'DELETE'
uri = 'https://' + server + '/zone/' + domai... | [
"def",
"delete_zone",
"(",
"server",
",",
"token",
",",
"domain",
")",
":",
"method",
"=",
"'DELETE'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone/'",
"+",
"domain",
"connect",
".",
"tonicdns_client",
"(",
"uri",
",",
"method",
",",
"token",
",... | Delete specific zone.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
domain: Specify domain name
x-authentication-token: token | [
"Delete",
"specific",
"zone",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L124-L137 |
250,259 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | create_template | def create_template(server, token, identifier, template):
"""Create template.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
identifier: Template identifier
template: Create template datas
ContentType: application/json
x-authe... | python | def create_template(server, token, identifier, template):
"""Create template.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
identifier: Template identifier
template: Create template datas
ContentType: application/json
x-authe... | [
"def",
"create_template",
"(",
"server",
",",
"token",
",",
"identifier",
",",
"template",
")",
":",
"method",
"=",
"'PUT'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/template/'",
"+",
"identifier",
"connect",
".",
"tonicdns_client",
"(",
"uri",
",",
... | Create template.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
identifier: Template identifier
template: Create template datas
ContentType: application/json
x-authentication-token: token | [
"Create",
"template",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L140-L155 |
250,260 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | get_all_templates | def get_all_templates(server, token):
"""Retrieve all templates.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
x-authentication-token: token
"""
method = 'GET'
uri = 'https://' + server + '/template'
connect.tonicdns_client(uri, method... | python | def get_all_templates(server, token):
"""Retrieve all templates.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
x-authentication-token: token
"""
method = 'GET'
uri = 'https://' + server + '/template'
connect.tonicdns_client(uri, method... | [
"def",
"get_all_templates",
"(",
"server",
",",
"token",
")",
":",
"method",
"=",
"'GET'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/template'",
"connect",
".",
"tonicdns_client",
"(",
"uri",
",",
"method",
",",
"token",
",",
"data",
"=",
"False",
... | Retrieve all templates.
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
x-authentication-token: token | [
"Retrieve",
"all",
"templates",
"."
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L190-L202 |
250,261 | mkouhei/tonicdnscli | src/tonicdnscli/processing.py | update_soa_serial | def update_soa_serial(server, token, soa_content):
"""Update SOA serial
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
soa_content: SOA record data
x-authentication-token: token
Get SOA record
`cur_soa` is current SOA record.
... | python | def update_soa_serial(server, token, soa_content):
"""Update SOA serial
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
soa_content: SOA record data
x-authentication-token: token
Get SOA record
`cur_soa` is current SOA record.
... | [
"def",
"update_soa_serial",
"(",
"server",
",",
"token",
",",
"soa_content",
")",
":",
"method",
"=",
"'GET'",
"uri",
"=",
"'https://'",
"+",
"server",
"+",
"'/zone/'",
"+",
"soa_content",
".",
"get",
"(",
"'domain'",
")",
"cur_soa",
",",
"new_soa",
"=",
... | Update SOA serial
Argument:
server: TonicDNS API server
token: TonicDNS API authentication token
soa_content: SOA record data
x-authentication-token: token
Get SOA record
`cur_soa` is current SOA record.
`new_soa` is incremental serial SOA record. | [
"Update",
"SOA",
"serial"
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/processing.py#L205-L241 |
250,262 | shaypal5/utilitime | utilitime/time/time.py | decompose_seconds_in_day | def decompose_seconds_in_day(seconds):
"""Decomposes seconds in day into hour, minute and second components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
hour : int
The hour component of the given time of da... | python | def decompose_seconds_in_day(seconds):
"""Decomposes seconds in day into hour, minute and second components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
hour : int
The hour component of the given time of da... | [
"def",
"decompose_seconds_in_day",
"(",
"seconds",
")",
":",
"if",
"seconds",
">",
"SECONDS_IN_DAY",
":",
"seconds",
"=",
"seconds",
"-",
"SECONDS_IN_DAY",
"if",
"seconds",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"seconds param must be non-negative!\"",
")",
... | Decomposes seconds in day into hour, minute and second components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
hour : int
The hour component of the given time of day.
minut : int
The minute componen... | [
"Decomposes",
"seconds",
"in",
"day",
"into",
"hour",
"minute",
"and",
"second",
"components",
"."
] | 554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609 | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/time/time.py#L10-L35 |
250,263 | shaypal5/utilitime | utilitime/time/time.py | seconds_in_day_to_time | def seconds_in_day_to_time(seconds):
"""Decomposes atime of day into hour, minute and seconds components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
datetime.time
The corresponding time of day as a datetim... | python | def seconds_in_day_to_time(seconds):
"""Decomposes atime of day into hour, minute and seconds components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
datetime.time
The corresponding time of day as a datetim... | [
"def",
"seconds_in_day_to_time",
"(",
"seconds",
")",
":",
"try",
":",
"return",
"time",
"(",
"*",
"decompose_seconds_in_day",
"(",
"seconds",
")",
")",
"except",
"ValueError",
":",
"print",
"(",
"\"Seconds = {}\"",
".",
"format",
"(",
"seconds",
")",
")",
"... | Decomposes atime of day into hour, minute and seconds components.
Arguments
---------
seconds : int
A time of day by the number of seconds passed since midnight.
Returns
-------
datetime.time
The corresponding time of day as a datetime.time object.
Example
-------
... | [
"Decomposes",
"atime",
"of",
"day",
"into",
"hour",
"minute",
"and",
"seconds",
"components",
"."
] | 554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609 | https://github.com/shaypal5/utilitime/blob/554ca05fa83c2dbf5d6cf9c9cfa6b03ee6cdb609/utilitime/time/time.py#L38-L61 |
250,264 | tjomasc/snekbol | snekbol/identified.py | Identified._as_rdf_xml | def _as_rdf_xml(self, ns):
"""
Return identity details for the element as XML nodes
"""
self.rdf_identity = self._get_identity(ns)
elements = []
elements.append(ET.Element(NS('sbol', 'persistentIdentity'),
attrib={NS('rdf', 'resource'):
... | python | def _as_rdf_xml(self, ns):
"""
Return identity details for the element as XML nodes
"""
self.rdf_identity = self._get_identity(ns)
elements = []
elements.append(ET.Element(NS('sbol', 'persistentIdentity'),
attrib={NS('rdf', 'resource'):
... | [
"def",
"_as_rdf_xml",
"(",
"self",
",",
"ns",
")",
":",
"self",
".",
"rdf_identity",
"=",
"self",
".",
"_get_identity",
"(",
"ns",
")",
"elements",
"=",
"[",
"]",
"elements",
".",
"append",
"(",
"ET",
".",
"Element",
"(",
"NS",
"(",
"'sbol'",
",",
... | Return identity details for the element as XML nodes | [
"Return",
"identity",
"details",
"for",
"the",
"element",
"as",
"XML",
"nodes"
] | 0b491aa96e0b1bd09e6c80cfb43807dd8a876c83 | https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/identified.py#L68-L98 |
250,265 | steder/pundler | pundler/core.py | get_requirement_files | def get_requirement_files(args=None):
"""
Get the "best" requirements file we can find
"""
if args and args.input_filename:
return [args.input_filename]
paths = []
for regex in settings.REQUIREMENTS_SOURCE_GLOBS:
paths.extend(glob.glob(regex))
return paths | python | def get_requirement_files(args=None):
"""
Get the "best" requirements file we can find
"""
if args and args.input_filename:
return [args.input_filename]
paths = []
for regex in settings.REQUIREMENTS_SOURCE_GLOBS:
paths.extend(glob.glob(regex))
return paths | [
"def",
"get_requirement_files",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"and",
"args",
".",
"input_filename",
":",
"return",
"[",
"args",
".",
"input_filename",
"]",
"paths",
"=",
"[",
"]",
"for",
"regex",
"in",
"settings",
".",
"REQUIREMENTS_SOU... | Get the "best" requirements file we can find | [
"Get",
"the",
"best",
"requirements",
"file",
"we",
"can",
"find"
] | 68d730b08e46d5f7b8781017c9bba87c7378509d | https://github.com/steder/pundler/blob/68d730b08e46d5f7b8781017c9bba87c7378509d/pundler/core.py#L34-L44 |
250,266 | dariosky/wfcli | wfcli/wfapi.py | WebFactionAPI.list_domains | def list_domains(self):
""" Return all domains. Domain is a key, so group by them """
self.connect()
results = self.server.list_domains(self.session_id)
return {i['domain']: i['subdomains'] for i in results} | python | def list_domains(self):
""" Return all domains. Domain is a key, so group by them """
self.connect()
results = self.server.list_domains(self.session_id)
return {i['domain']: i['subdomains'] for i in results} | [
"def",
"list_domains",
"(",
"self",
")",
":",
"self",
".",
"connect",
"(",
")",
"results",
"=",
"self",
".",
"server",
".",
"list_domains",
"(",
"self",
".",
"session_id",
")",
"return",
"{",
"i",
"[",
"'domain'",
"]",
":",
"i",
"[",
"'subdomains'",
... | Return all domains. Domain is a key, so group by them | [
"Return",
"all",
"domains",
".",
"Domain",
"is",
"a",
"key",
"so",
"group",
"by",
"them"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/wfapi.py#L67-L71 |
250,267 | dariosky/wfcli | wfcli/wfapi.py | WebFactionAPI.list_websites | def list_websites(self):
""" Return all websites, name is not a key """
self.connect()
results = self.server.list_websites(self.session_id)
return results | python | def list_websites(self):
""" Return all websites, name is not a key """
self.connect()
results = self.server.list_websites(self.session_id)
return results | [
"def",
"list_websites",
"(",
"self",
")",
":",
"self",
".",
"connect",
"(",
")",
"results",
"=",
"self",
".",
"server",
".",
"list_websites",
"(",
"self",
".",
"session_id",
")",
"return",
"results"
] | Return all websites, name is not a key | [
"Return",
"all",
"websites",
"name",
"is",
"not",
"a",
"key"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/wfapi.py#L73-L78 |
250,268 | dariosky/wfcli | wfcli/wfapi.py | WebFactionAPI.website_exists | def website_exists(self, website, websites=None):
""" Look for websites matching the one passed """
if websites is None:
websites = self.list_websites()
if isinstance(website, str):
website = {"name": website}
ignored_fields = ('id',) # changes in these fields ar... | python | def website_exists(self, website, websites=None):
""" Look for websites matching the one passed """
if websites is None:
websites = self.list_websites()
if isinstance(website, str):
website = {"name": website}
ignored_fields = ('id',) # changes in these fields ar... | [
"def",
"website_exists",
"(",
"self",
",",
"website",
",",
"websites",
"=",
"None",
")",
":",
"if",
"websites",
"is",
"None",
":",
"websites",
"=",
"self",
".",
"list_websites",
"(",
")",
"if",
"isinstance",
"(",
"website",
",",
"str",
")",
":",
"websi... | Look for websites matching the one passed | [
"Look",
"for",
"websites",
"matching",
"the",
"one",
"passed"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/wfapi.py#L136-L155 |
250,269 | Adman/pynameday | pynameday/core.py | NamedayMixin.get_month_namedays | def get_month_namedays(self, month=None):
"""Return names as a tuple based on given month.
If no month given, use current one"""
if month is None:
month = datetime.now().month
return self.NAMEDAYS[month-1] | python | def get_month_namedays(self, month=None):
"""Return names as a tuple based on given month.
If no month given, use current one"""
if month is None:
month = datetime.now().month
return self.NAMEDAYS[month-1] | [
"def",
"get_month_namedays",
"(",
"self",
",",
"month",
"=",
"None",
")",
":",
"if",
"month",
"is",
"None",
":",
"month",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"month",
"return",
"self",
".",
"NAMEDAYS",
"[",
"month",
"-",
"1",
"]"
] | Return names as a tuple based on given month.
If no month given, use current one | [
"Return",
"names",
"as",
"a",
"tuple",
"based",
"on",
"given",
"month",
".",
"If",
"no",
"month",
"given",
"use",
"current",
"one"
] | a3153db3e26531dec54510705aac4ae077cf9316 | https://github.com/Adman/pynameday/blob/a3153db3e26531dec54510705aac4ae077cf9316/pynameday/core.py#L16-L21 |
250,270 | emencia/emencia-django-forum | forum/mixins.py | ModeratorCheckMixin.has_moderator_permissions | def has_moderator_permissions(self, request):
"""
Find if user have global or per object permission firstly on category instance,
if not then on thread instance
"""
return any(request.user.has_perm(perm) for perm in self.permission_required) | python | def has_moderator_permissions(self, request):
"""
Find if user have global or per object permission firstly on category instance,
if not then on thread instance
"""
return any(request.user.has_perm(perm) for perm in self.permission_required) | [
"def",
"has_moderator_permissions",
"(",
"self",
",",
"request",
")",
":",
"return",
"any",
"(",
"request",
".",
"user",
".",
"has_perm",
"(",
"perm",
")",
"for",
"perm",
"in",
"self",
".",
"permission_required",
")"
] | Find if user have global or per object permission firstly on category instance,
if not then on thread instance | [
"Find",
"if",
"user",
"have",
"global",
"or",
"per",
"object",
"permission",
"firstly",
"on",
"category",
"instance",
"if",
"not",
"then",
"on",
"thread",
"instance"
] | cda74ed7e5822675c340ee5ec71548d981bccd3b | https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/mixins.py#L35-L40 |
250,271 | rochacbruno/shiftpy | shiftpy/env.py | getvar | def getvar(key, default=None, template='OPENSHIFT_{key}'):
"""
Get OPENSHIFT envvar
"""
return os.environ.get(template.format(key=key), default) | python | def getvar(key, default=None, template='OPENSHIFT_{key}'):
"""
Get OPENSHIFT envvar
"""
return os.environ.get(template.format(key=key), default) | [
"def",
"getvar",
"(",
"key",
",",
"default",
"=",
"None",
",",
"template",
"=",
"'OPENSHIFT_{key}'",
")",
":",
"return",
"os",
".",
"environ",
".",
"get",
"(",
"template",
".",
"format",
"(",
"key",
"=",
"key",
")",
",",
"default",
")"
] | Get OPENSHIFT envvar | [
"Get",
"OPENSHIFT",
"envvar"
] | 6bffccf511f24b7e53dcfee9807e0e3388aa823a | https://github.com/rochacbruno/shiftpy/blob/6bffccf511f24b7e53dcfee9807e0e3388aa823a/shiftpy/env.py#L6-L10 |
250,272 | treycucco/bidon | bidon/json_patch.py | add | def add(parent, idx, value):
"""Add a value to a dict."""
if isinstance(parent, dict):
if idx in parent:
raise JSONPatchError("Item already exists")
parent[idx] = value
elif isinstance(parent, list):
if idx == "" or idx == "~":
parent.append(value)
else:
parent.insert(int(idx), v... | python | def add(parent, idx, value):
"""Add a value to a dict."""
if isinstance(parent, dict):
if idx in parent:
raise JSONPatchError("Item already exists")
parent[idx] = value
elif isinstance(parent, list):
if idx == "" or idx == "~":
parent.append(value)
else:
parent.insert(int(idx), v... | [
"def",
"add",
"(",
"parent",
",",
"idx",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"parent",
",",
"dict",
")",
":",
"if",
"idx",
"in",
"parent",
":",
"raise",
"JSONPatchError",
"(",
"\"Item already exists\"",
")",
"parent",
"[",
"idx",
"]",
"=",... | Add a value to a dict. | [
"Add",
"a",
"value",
"to",
"a",
"dict",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L62-L74 |
250,273 | treycucco/bidon | bidon/json_patch.py | remove | def remove(parent, idx):
"""Remove a value from a dict."""
if isinstance(parent, dict):
del parent[idx]
elif isinstance(parent, list):
del parent[int(idx)]
else:
raise JSONPathError("Invalid path for operation") | python | def remove(parent, idx):
"""Remove a value from a dict."""
if isinstance(parent, dict):
del parent[idx]
elif isinstance(parent, list):
del parent[int(idx)]
else:
raise JSONPathError("Invalid path for operation") | [
"def",
"remove",
"(",
"parent",
",",
"idx",
")",
":",
"if",
"isinstance",
"(",
"parent",
",",
"dict",
")",
":",
"del",
"parent",
"[",
"idx",
"]",
"elif",
"isinstance",
"(",
"parent",
",",
"list",
")",
":",
"del",
"parent",
"[",
"int",
"(",
"idx",
... | Remove a value from a dict. | [
"Remove",
"a",
"value",
"from",
"a",
"dict",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L77-L84 |
250,274 | treycucco/bidon | bidon/json_patch.py | replace | def replace(parent, idx, value, check_value=_NO_VAL):
"""Replace a value in a dict."""
if isinstance(parent, dict):
if idx not in parent:
raise JSONPatchError("Item does not exist")
elif isinstance(parent, list):
idx = int(idx)
if idx < 0 or idx >= len(parent):
raise JSONPatchError("List i... | python | def replace(parent, idx, value, check_value=_NO_VAL):
"""Replace a value in a dict."""
if isinstance(parent, dict):
if idx not in parent:
raise JSONPatchError("Item does not exist")
elif isinstance(parent, list):
idx = int(idx)
if idx < 0 or idx >= len(parent):
raise JSONPatchError("List i... | [
"def",
"replace",
"(",
"parent",
",",
"idx",
",",
"value",
",",
"check_value",
"=",
"_NO_VAL",
")",
":",
"if",
"isinstance",
"(",
"parent",
",",
"dict",
")",
":",
"if",
"idx",
"not",
"in",
"parent",
":",
"raise",
"JSONPatchError",
"(",
"\"Item does not e... | Replace a value in a dict. | [
"Replace",
"a",
"value",
"in",
"a",
"dict",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L87-L99 |
250,275 | treycucco/bidon | bidon/json_patch.py | merge | def merge(parent, idx, value):
"""Merge a value."""
target = get_child(parent, idx)
for key, val in value.items():
target[key] = val | python | def merge(parent, idx, value):
"""Merge a value."""
target = get_child(parent, idx)
for key, val in value.items():
target[key] = val | [
"def",
"merge",
"(",
"parent",
",",
"idx",
",",
"value",
")",
":",
"target",
"=",
"get_child",
"(",
"parent",
",",
"idx",
")",
"for",
"key",
",",
"val",
"in",
"value",
".",
"items",
"(",
")",
":",
"target",
"[",
"key",
"]",
"=",
"val"
] | Merge a value. | [
"Merge",
"a",
"value",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L102-L106 |
250,276 | treycucco/bidon | bidon/json_patch.py | copy | def copy(src_parent, src_idx, dest_parent, dest_idx):
"""Copy an item."""
if isinstance(dest_parent, list):
dest_idx = int(dest_idx)
dest_parent[dest_idx] = get_child(src_parent, src_idx) | python | def copy(src_parent, src_idx, dest_parent, dest_idx):
"""Copy an item."""
if isinstance(dest_parent, list):
dest_idx = int(dest_idx)
dest_parent[dest_idx] = get_child(src_parent, src_idx) | [
"def",
"copy",
"(",
"src_parent",
",",
"src_idx",
",",
"dest_parent",
",",
"dest_idx",
")",
":",
"if",
"isinstance",
"(",
"dest_parent",
",",
"list",
")",
":",
"dest_idx",
"=",
"int",
"(",
"dest_idx",
")",
"dest_parent",
"[",
"dest_idx",
"]",
"=",
"get_c... | Copy an item. | [
"Copy",
"an",
"item",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L109-L113 |
250,277 | treycucco/bidon | bidon/json_patch.py | move | def move(src_parent, src_idx, dest_parent, dest_idx):
"""Move an item."""
copy(src_parent, src_idx, dest_parent, dest_idx)
remove(src_parent, src_idx) | python | def move(src_parent, src_idx, dest_parent, dest_idx):
"""Move an item."""
copy(src_parent, src_idx, dest_parent, dest_idx)
remove(src_parent, src_idx) | [
"def",
"move",
"(",
"src_parent",
",",
"src_idx",
",",
"dest_parent",
",",
"dest_idx",
")",
":",
"copy",
"(",
"src_parent",
",",
"src_idx",
",",
"dest_parent",
",",
"dest_idx",
")",
"remove",
"(",
"src_parent",
",",
"src_idx",
")"
] | Move an item. | [
"Move",
"an",
"item",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L116-L119 |
250,278 | treycucco/bidon | bidon/json_patch.py | set_remove | def set_remove(parent, idx, value):
"""Remove an item from a list."""
lst = get_child(parent, idx)
if value in lst:
lst.remove(value) | python | def set_remove(parent, idx, value):
"""Remove an item from a list."""
lst = get_child(parent, idx)
if value in lst:
lst.remove(value) | [
"def",
"set_remove",
"(",
"parent",
",",
"idx",
",",
"value",
")",
":",
"lst",
"=",
"get_child",
"(",
"parent",
",",
"idx",
")",
"if",
"value",
"in",
"lst",
":",
"lst",
".",
"remove",
"(",
"value",
")"
] | Remove an item from a list. | [
"Remove",
"an",
"item",
"from",
"a",
"list",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L134-L138 |
250,279 | treycucco/bidon | bidon/json_patch.py | set_add | def set_add(parent, idx, value):
"""Add an item to a list if it doesn't exist."""
lst = get_child(parent, idx)
if value not in lst:
lst.append(value) | python | def set_add(parent, idx, value):
"""Add an item to a list if it doesn't exist."""
lst = get_child(parent, idx)
if value not in lst:
lst.append(value) | [
"def",
"set_add",
"(",
"parent",
",",
"idx",
",",
"value",
")",
":",
"lst",
"=",
"get_child",
"(",
"parent",
",",
"idx",
")",
"if",
"value",
"not",
"in",
"lst",
":",
"lst",
".",
"append",
"(",
"value",
")"
] | Add an item to a list if it doesn't exist. | [
"Add",
"an",
"item",
"to",
"a",
"list",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L141-L145 |
250,280 | treycucco/bidon | bidon/json_patch.py | parse_path | def parse_path(path):
"""Parse a rfc 6901 path."""
if not path:
raise ValueError("Invalid path")
if isinstance(path, str):
if path == "/":
raise ValueError("Invalid path")
if path[0] != "/":
raise ValueError("Invalid path")
return path.split(_PATH_SEP)[1:]
elif isinstance(path, (tup... | python | def parse_path(path):
"""Parse a rfc 6901 path."""
if not path:
raise ValueError("Invalid path")
if isinstance(path, str):
if path == "/":
raise ValueError("Invalid path")
if path[0] != "/":
raise ValueError("Invalid path")
return path.split(_PATH_SEP)[1:]
elif isinstance(path, (tup... | [
"def",
"parse_path",
"(",
"path",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"Invalid path\"",
")",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"if",
"path",
"==",
"\"/\"",
":",
"raise",
"ValueError",
"(",
"\"Invalid pat... | Parse a rfc 6901 path. | [
"Parse",
"a",
"rfc",
"6901",
"path",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L176-L190 |
250,281 | treycucco/bidon | bidon/json_patch.py | resolve_path | def resolve_path(root, path):
"""Resolve a rfc 6901 path, returning the parent and the last path part."""
path = parse_path(path)
parent = root
for part in path[:-1]:
parent = get_child(parent, rfc_6901_replace(part))
return (parent, rfc_6901_replace(path[-1])) | python | def resolve_path(root, path):
"""Resolve a rfc 6901 path, returning the parent and the last path part."""
path = parse_path(path)
parent = root
for part in path[:-1]:
parent = get_child(parent, rfc_6901_replace(part))
return (parent, rfc_6901_replace(path[-1])) | [
"def",
"resolve_path",
"(",
"root",
",",
"path",
")",
":",
"path",
"=",
"parse_path",
"(",
"path",
")",
"parent",
"=",
"root",
"for",
"part",
"in",
"path",
"[",
":",
"-",
"1",
"]",
":",
"parent",
"=",
"get_child",
"(",
"parent",
",",
"rfc_6901_replac... | Resolve a rfc 6901 path, returning the parent and the last path part. | [
"Resolve",
"a",
"rfc",
"6901",
"path",
"returning",
"the",
"parent",
"and",
"the",
"last",
"path",
"part",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L193-L202 |
250,282 | treycucco/bidon | bidon/json_patch.py | find_all | def find_all(root, path):
"""Get all children that satisfy the path."""
path = parse_path(path)
if len(path) == 1:
yield from get_children(root, path[0])
else:
for child in get_children(root, path[0]):
yield from find_all(child, path[1:]) | python | def find_all(root, path):
"""Get all children that satisfy the path."""
path = parse_path(path)
if len(path) == 1:
yield from get_children(root, path[0])
else:
for child in get_children(root, path[0]):
yield from find_all(child, path[1:]) | [
"def",
"find_all",
"(",
"root",
",",
"path",
")",
":",
"path",
"=",
"parse_path",
"(",
"path",
")",
"if",
"len",
"(",
"path",
")",
"==",
"1",
":",
"yield",
"from",
"get_children",
"(",
"root",
",",
"path",
"[",
"0",
"]",
")",
"else",
":",
"for",
... | Get all children that satisfy the path. | [
"Get",
"all",
"children",
"that",
"satisfy",
"the",
"path",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L210-L218 |
250,283 | treycucco/bidon | bidon/json_patch.py | apply_patch | def apply_patch(document, patch):
"""Apply a Patch object to a document."""
# pylint: disable=too-many-return-statements
op = patch.op
parent, idx = resolve_path(document, patch.path)
if op == "add":
return add(parent, idx, patch.value)
elif op == "remove":
return remove(parent, idx)
elif op == "r... | python | def apply_patch(document, patch):
"""Apply a Patch object to a document."""
# pylint: disable=too-many-return-statements
op = patch.op
parent, idx = resolve_path(document, patch.path)
if op == "add":
return add(parent, idx, patch.value)
elif op == "remove":
return remove(parent, idx)
elif op == "r... | [
"def",
"apply_patch",
"(",
"document",
",",
"patch",
")",
":",
"# pylint: disable=too-many-return-statements",
"op",
"=",
"patch",
".",
"op",
"parent",
",",
"idx",
"=",
"resolve_path",
"(",
"document",
",",
"patch",
".",
"path",
")",
"if",
"op",
"==",
"\"add... | Apply a Patch object to a document. | [
"Apply",
"a",
"Patch",
"object",
"to",
"a",
"document",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L226-L252 |
250,284 | treycucco/bidon | bidon/json_patch.py | apply_patches | def apply_patches(document, patches):
"""Serially apply all patches to a document."""
for i, patch in enumerate(patches):
try:
result = apply_patch(document, patch)
if patch.op == "test" and result is False:
raise JSONPatchError("Test patch {0} failed. Cancelling entire set.".format(i + 1))
... | python | def apply_patches(document, patches):
"""Serially apply all patches to a document."""
for i, patch in enumerate(patches):
try:
result = apply_patch(document, patch)
if patch.op == "test" and result is False:
raise JSONPatchError("Test patch {0} failed. Cancelling entire set.".format(i + 1))
... | [
"def",
"apply_patches",
"(",
"document",
",",
"patches",
")",
":",
"for",
"i",
",",
"patch",
"in",
"enumerate",
"(",
"patches",
")",
":",
"try",
":",
"result",
"=",
"apply_patch",
"(",
"document",
",",
"patch",
")",
"if",
"patch",
".",
"op",
"==",
"\... | Serially apply all patches to a document. | [
"Serially",
"apply",
"all",
"patches",
"to",
"a",
"document",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/json_patch.py#L255-L263 |
250,285 | xtrementl/focus | focus/plugin/modules/timer.py | Timer.execute | def execute(self, env, args):
""" Displays task time left in minutes.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
msg = u'Time Left: {0}m' if not args.short else '{0}'
mins = max(0, sel... | python | def execute(self, env, args):
""" Displays task time left in minutes.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
msg = u'Time Left: {0}m' if not args.short else '{0}'
mins = max(0, sel... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"msg",
"=",
"u'Time Left: {0}m'",
"if",
"not",
"args",
".",
"short",
"else",
"'{0}'",
"mins",
"=",
"max",
"(",
"0",
",",
"self",
".",
"total_duration",
"-",
"env",
".",
"task",
".",
... | Displays task time left in minutes.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Displays",
"task",
"time",
"left",
"in",
"minutes",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/timer.py#L42-L53 |
250,286 | xtrementl/focus | focus/plugin/modules/timer.py | Timer.parse_option | def parse_option(self, option, block_name, *values):
""" Parse duration option for timer.
"""
try:
if len(values) != 1:
raise TypeError
self.total_duration = int(values[0])
if self.total_duration <= 0:
raise ValueError
... | python | def parse_option(self, option, block_name, *values):
""" Parse duration option for timer.
"""
try:
if len(values) != 1:
raise TypeError
self.total_duration = int(values[0])
if self.total_duration <= 0:
raise ValueError
... | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"try",
":",
"if",
"len",
"(",
"values",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"self",
".",
"total_duration",
"=",
"int",
"(",
"values",
"[",
"0",... | Parse duration option for timer. | [
"Parse",
"duration",
"option",
"for",
"timer",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/timer.py#L55-L69 |
250,287 | samirelanduk/quickplots | quickplots/series.py | Series.add_data_point | def add_data_point(self, x, y):
"""Adds a data point to the series.
:param x: The numerical x value to be added.
:param y: The numerical y value to be added."""
if not is_numeric(x):
raise TypeError("x value must be numeric, not '%s'" % str(x))
if not is_numeric(y):... | python | def add_data_point(self, x, y):
"""Adds a data point to the series.
:param x: The numerical x value to be added.
:param y: The numerical y value to be added."""
if not is_numeric(x):
raise TypeError("x value must be numeric, not '%s'" % str(x))
if not is_numeric(y):... | [
"def",
"add_data_point",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"not",
"is_numeric",
"(",
"x",
")",
":",
"raise",
"TypeError",
"(",
"\"x value must be numeric, not '%s'\"",
"%",
"str",
"(",
"x",
")",
")",
"if",
"not",
"is_numeric",
"(",
"y",
... | Adds a data point to the series.
:param x: The numerical x value to be added.
:param y: The numerical y value to be added. | [
"Adds",
"a",
"data",
"point",
"to",
"the",
"series",
"."
] | 59f5e6ff367b2c1c24ba7cf1805d03552034c6d8 | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/series.py#L148-L161 |
250,288 | samirelanduk/quickplots | quickplots/series.py | Series.remove_data_point | def remove_data_point(self, x, y):
"""Removes the given data point from the series.
:param x: The numerical x value of the data point to be removed.
:param y: The numerical y value of the data point to be removed.
:raises ValueError: if you try to remove the last data point from\
... | python | def remove_data_point(self, x, y):
"""Removes the given data point from the series.
:param x: The numerical x value of the data point to be removed.
:param y: The numerical y value of the data point to be removed.
:raises ValueError: if you try to remove the last data point from\
... | [
"def",
"remove_data_point",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"len",
"(",
"self",
".",
"_data",
")",
"==",
"1",
":",
"raise",
"ValueError",
"(",
"\"You cannot remove a Series' last data point\"",
")",
"self",
".",
"_data",
".",
"remove",
"("... | Removes the given data point from the series.
:param x: The numerical x value of the data point to be removed.
:param y: The numerical y value of the data point to be removed.
:raises ValueError: if you try to remove the last data point from\
a series. | [
"Removes",
"the",
"given",
"data",
"point",
"from",
"the",
"series",
"."
] | 59f5e6ff367b2c1c24ba7cf1805d03552034c6d8 | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/series.py#L164-L174 |
250,289 | hmartiniano/faz | faz/main.py | faz | def faz(input_file, variables=None):
"""
FAZ entry point.
"""
logging.debug("input file:\n {0}\n".format(input_file))
tasks = parse_input_file(input_file, variables=variables)
print("Found {0} tasks.".format(len(tasks)))
graph = DependencyGraph(tasks)
graph.show_tasks()
graph.execute... | python | def faz(input_file, variables=None):
"""
FAZ entry point.
"""
logging.debug("input file:\n {0}\n".format(input_file))
tasks = parse_input_file(input_file, variables=variables)
print("Found {0} tasks.".format(len(tasks)))
graph = DependencyGraph(tasks)
graph.show_tasks()
graph.execute... | [
"def",
"faz",
"(",
"input_file",
",",
"variables",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\"input file:\\n {0}\\n\"",
".",
"format",
"(",
"input_file",
")",
")",
"tasks",
"=",
"parse_input_file",
"(",
"input_file",
",",
"variables",
"=",
"vari... | FAZ entry point. | [
"FAZ",
"entry",
"point",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/main.py#L34-L43 |
250,290 | blubberdiblub/eztemplate | setup.py | get_version | def get_version():
"""Build version number from git repository tag."""
try:
f = open('eztemplate/version.py', 'r')
except IOError as e:
if e.errno != errno.ENOENT:
raise
m = None
else:
m = re.match('^\s*__version__\s*=\s*(?P<version>.*)$', f.read(), re.M)
... | python | def get_version():
"""Build version number from git repository tag."""
try:
f = open('eztemplate/version.py', 'r')
except IOError as e:
if e.errno != errno.ENOENT:
raise
m = None
else:
m = re.match('^\s*__version__\s*=\s*(?P<version>.*)$', f.read(), re.M)
... | [
"def",
"get_version",
"(",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"'eztemplate/version.py'",
",",
"'r'",
")",
"except",
"IOError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errno",
".",
"ENOENT",
":",
"raise",
"m",
"=",
"None",
"else",
... | Build version number from git repository tag. | [
"Build",
"version",
"number",
"from",
"git",
"repository",
"tag",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/setup.py#L15-L68 |
250,291 | blubberdiblub/eztemplate | setup.py | get_long_description | def get_long_description():
"""Provide README.md converted to reStructuredText format."""
try:
with open('README.md', 'r') as f:
description = f.read()
except OSError as e:
if e.errno != errno.ENOENT:
raise
return None
try:
process = subprocess.Po... | python | def get_long_description():
"""Provide README.md converted to reStructuredText format."""
try:
with open('README.md', 'r') as f:
description = f.read()
except OSError as e:
if e.errno != errno.ENOENT:
raise
return None
try:
process = subprocess.Po... | [
"def",
"get_long_description",
"(",
")",
":",
"try",
":",
"with",
"open",
"(",
"'README.md'",
",",
"'r'",
")",
"as",
"f",
":",
"description",
"=",
"f",
".",
"read",
"(",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errn... | Provide README.md converted to reStructuredText format. | [
"Provide",
"README",
".",
"md",
"converted",
"to",
"reStructuredText",
"format",
"."
] | ab5b2b4987c045116d130fd83e216704b8edfb5d | https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/setup.py#L71-L103 |
250,292 | anti1869/sunhead | src/sunhead/workers/http/ext/runtime.py | RuntimeStatsView.get | async def get(self):
"""Printing runtime statistics in JSON"""
context_data = self.get_context_data()
context_data.update(getattr(self.request.app, "stats", {}))
response = self.json_response(context_data)
return response | python | async def get(self):
"""Printing runtime statistics in JSON"""
context_data = self.get_context_data()
context_data.update(getattr(self.request.app, "stats", {}))
response = self.json_response(context_data)
return response | [
"async",
"def",
"get",
"(",
"self",
")",
":",
"context_data",
"=",
"self",
".",
"get_context_data",
"(",
")",
"context_data",
".",
"update",
"(",
"getattr",
"(",
"self",
".",
"request",
".",
"app",
",",
"\"stats\"",
",",
"{",
"}",
")",
")",
"response",... | Printing runtime statistics in JSON | [
"Printing",
"runtime",
"statistics",
"in",
"JSON"
] | 5117ec797a38eb82d955241d20547d125efe80f3 | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/workers/http/ext/runtime.py#L56-L63 |
250,293 | sci-bots/mpm | mpm/bin/api.py | _dump_list | def _dump_list(list_data, jsonify, stream=sys.stdout):
'''
Dump list to output stream, optionally encoded as JSON.
Parameters
----------
list_data : list
jsonify : bool
stream : file-like
'''
if not jsonify and list_data:
print >> stream, '\n'.join(list_data)
else:
... | python | def _dump_list(list_data, jsonify, stream=sys.stdout):
'''
Dump list to output stream, optionally encoded as JSON.
Parameters
----------
list_data : list
jsonify : bool
stream : file-like
'''
if not jsonify and list_data:
print >> stream, '\n'.join(list_data)
else:
... | [
"def",
"_dump_list",
"(",
"list_data",
",",
"jsonify",
",",
"stream",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"not",
"jsonify",
"and",
"list_data",
":",
"print",
">>",
"stream",
",",
"'\\n'",
".",
"join",
"(",
"list_data",
")",
"else",
":",
"print",... | Dump list to output stream, optionally encoded as JSON.
Parameters
----------
list_data : list
jsonify : bool
stream : file-like | [
"Dump",
"list",
"to",
"output",
"stream",
"optionally",
"encoded",
"as",
"JSON",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/bin/api.py#L43-L56 |
250,294 | b3j0f/annotation | b3j0f/annotation/async.py | Asynchronous._threaded | def _threaded(self, *args, **kwargs):
"""Call the target and put the result in the Queue."""
for target in self.targets:
result = target(*args, **kwargs)
self.queue.put(result) | python | def _threaded(self, *args, **kwargs):
"""Call the target and put the result in the Queue."""
for target in self.targets:
result = target(*args, **kwargs)
self.queue.put(result) | [
"def",
"_threaded",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"target",
"in",
"self",
".",
"targets",
":",
"result",
"=",
"target",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"queue",
".",
"put",
... | Call the target and put the result in the Queue. | [
"Call",
"the",
"target",
"and",
"put",
"the",
"result",
"in",
"the",
"Queue",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/async.py#L97-L102 |
250,295 | b3j0f/annotation | b3j0f/annotation/async.py | Asynchronous.start | def start(self, *args, **kwargs):
"""Start execution of the function."""
self.queue = Queue()
thread = Thread(target=self._threaded, args=args, kwargs=kwargs)
thread.start()
return Asynchronous.Result(self.queue, thread) | python | def start(self, *args, **kwargs):
"""Start execution of the function."""
self.queue = Queue()
thread = Thread(target=self._threaded, args=args, kwargs=kwargs)
thread.start()
return Asynchronous.Result(self.queue, thread) | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"queue",
"=",
"Queue",
"(",
")",
"thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"_threaded",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
... | Start execution of the function. | [
"Start",
"execution",
"of",
"the",
"function",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/async.py#L111-L118 |
250,296 | Bekt/flask-pusher | flask_pusher.py | Pusher.init_app | def init_app(self, app, **options):
"""Configures the application."""
sd = options.setdefault
conf = app.config
sd('app_id', conf.get('PUSHER_APP_ID'))
sd('key', conf.get('PUSHER_KEY'))
sd('secret', conf.get('PUSHER_SECRET'))
sd('ssl', conf.get('PUSHER_SSL', True... | python | def init_app(self, app, **options):
"""Configures the application."""
sd = options.setdefault
conf = app.config
sd('app_id', conf.get('PUSHER_APP_ID'))
sd('key', conf.get('PUSHER_KEY'))
sd('secret', conf.get('PUSHER_SECRET'))
sd('ssl', conf.get('PUSHER_SSL', True... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"*",
"*",
"options",
")",
":",
"sd",
"=",
"options",
".",
"setdefault",
"conf",
"=",
"app",
".",
"config",
"sd",
"(",
"'app_id'",
",",
"conf",
".",
"get",
"(",
"'PUSHER_APP_ID'",
")",
")",
"sd",
"(",... | Configures the application. | [
"Configures",
"the",
"application",
"."
] | 7ee077687fb01011b19a5cae65ccb35512d4e0c5 | https://github.com/Bekt/flask-pusher/blob/7ee077687fb01011b19a5cae65ccb35512d4e0c5/flask_pusher.py#L11-L35 |
250,297 | minhhoit/yacms | yacms/blog/management/commands/import_tumblr.py | title_from_content | def title_from_content(content):
"""
Try and extract the first sentence from a block of test to use as a title.
"""
for end in (". ", "?", "!", "<br />", "\n", "</p>"):
if end in content:
content = content.split(end)[0] + end
break
return strip_tags(content) | python | def title_from_content(content):
"""
Try and extract the first sentence from a block of test to use as a title.
"""
for end in (". ", "?", "!", "<br />", "\n", "</p>"):
if end in content:
content = content.split(end)[0] + end
break
return strip_tags(content) | [
"def",
"title_from_content",
"(",
"content",
")",
":",
"for",
"end",
"in",
"(",
"\". \"",
",",
"\"?\"",
",",
"\"!\"",
",",
"\"<br />\"",
",",
"\"\\n\"",
",",
"\"</p>\"",
")",
":",
"if",
"end",
"in",
"content",
":",
"content",
"=",
"content",
".",
"spli... | Try and extract the first sentence from a block of test to use as a title. | [
"Try",
"and",
"extract",
"the",
"first",
"sentence",
"from",
"a",
"block",
"of",
"test",
"to",
"use",
"as",
"a",
"title",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/commands/import_tumblr.py#L25-L33 |
250,298 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/action_plugins/pause.py | ActionModule.run | def run(self, conn, tmp, module_name, module_args, inject):
''' run the pause actionmodule '''
hosts = ', '.join(self.runner.host_set)
args = parse_kv(template(self.runner.basedir, module_args, inject))
# Are 'minutes' or 'seconds' keys that exist in 'args'?
if 'minutes' in args... | python | def run(self, conn, tmp, module_name, module_args, inject):
''' run the pause actionmodule '''
hosts = ', '.join(self.runner.host_set)
args = parse_kv(template(self.runner.basedir, module_args, inject))
# Are 'minutes' or 'seconds' keys that exist in 'args'?
if 'minutes' in args... | [
"def",
"run",
"(",
"self",
",",
"conn",
",",
"tmp",
",",
"module_name",
",",
"module_args",
",",
"inject",
")",
":",
"hosts",
"=",
"', '",
".",
"join",
"(",
"self",
".",
"runner",
".",
"host_set",
")",
"args",
"=",
"parse_kv",
"(",
"template",
"(",
... | run the pause actionmodule | [
"run",
"the",
"pause",
"actionmodule"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/action_plugins/pause.py#L49-L109 |
250,299 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/action_plugins/pause.py | ActionModule._start | def _start(self):
''' mark the time of execution for duration calculations later '''
self.start = time.time()
self.result['start'] = str(datetime.datetime.now())
if not self.pause_type == 'prompt':
print "(^C-c = continue early, ^C-a = abort)" | python | def _start(self):
''' mark the time of execution for duration calculations later '''
self.start = time.time()
self.result['start'] = str(datetime.datetime.now())
if not self.pause_type == 'prompt':
print "(^C-c = continue early, ^C-a = abort)" | [
"def",
"_start",
"(",
"self",
")",
":",
"self",
".",
"start",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"result",
"[",
"'start'",
"]",
"=",
"str",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
")",
"if",
"not",
"self",
".",
"pa... | mark the time of execution for duration calculations later | [
"mark",
"the",
"time",
"of",
"execution",
"for",
"duration",
"calculations",
"later"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/action_plugins/pause.py#L111-L116 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.