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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
239,900 | JukeboxPipeline/jukebox-core | src/jukeboxcore/main.py | init_environment | def init_environment():
"""Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None
"""
os.environ['DJANGO_SETTINGS_MODULE'] = 'jukeboxcore.djsettings'
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN_PATH', ''), constants.BUILTIN_... | python | def init_environment():
"""Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None
"""
os.environ['DJANGO_SETTINGS_MODULE'] = 'jukeboxcore.djsettings'
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN_PATH', ''), constants.BUILTIN_... | [
"def",
"init_environment",
"(",
")",
":",
"os",
".",
"environ",
"[",
"'DJANGO_SETTINGS_MODULE'",
"]",
"=",
"'jukeboxcore.djsettings'",
"pluginpath",
"=",
"os",
".",
"pathsep",
".",
"join",
"(",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'JUKEBOX_PLUGIN_PATH'... | Set environment variables that are important for the pipeline.
:returns: None
:rtype: None
:raises: None | [
"Set",
"environment",
"variables",
"that",
"are",
"important",
"for",
"the",
"pipeline",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/main.py#L13-L22 |
239,901 | JukeboxPipeline/jukebox-core | src/jukeboxcore/main.py | unload_modules | def unload_modules():
""" Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because... | python | def unload_modules():
""" Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because... | [
"def",
"unload_modules",
"(",
")",
":",
"mods",
"=",
"set",
"(",
"[",
"]",
")",
"for",
"m",
"in",
"sys",
".",
"modules",
":",
"if",
"m",
".",
"startswith",
"(",
"'jukebox'",
")",
":",
"mods",
".",
"add",
"(",
"m",
")",
"pm",
"=",
"PluginManager",... | Unload all modules of the jukebox package and all plugin modules
Python provides the ``reload`` command for reloading modules. The major drawback is, that if this module is loaded in any other module
the source code will not be resourced!
If you want to reload the code because you changed the source file, ... | [
"Unload",
"all",
"modules",
"of",
"the",
"jukebox",
"package",
"and",
"all",
"plugin",
"modules"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/main.py#L36-L55 |
239,902 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | _get_LDAP_connection | def _get_LDAP_connection():
"""
Return a LDAP connection
"""
server = ldap3.Server('ldap://' + get_optional_env('EPFL_LDAP_SERVER_FOR_SEARCH'))
connection = ldap3.Connection(server)
connection.open()
return connection, get_optional_env('EPFL_LDAP_BASE_DN_FOR_SEARCH') | python | def _get_LDAP_connection():
"""
Return a LDAP connection
"""
server = ldap3.Server('ldap://' + get_optional_env('EPFL_LDAP_SERVER_FOR_SEARCH'))
connection = ldap3.Connection(server)
connection.open()
return connection, get_optional_env('EPFL_LDAP_BASE_DN_FOR_SEARCH') | [
"def",
"_get_LDAP_connection",
"(",
")",
":",
"server",
"=",
"ldap3",
".",
"Server",
"(",
"'ldap://'",
"+",
"get_optional_env",
"(",
"'EPFL_LDAP_SERVER_FOR_SEARCH'",
")",
")",
"connection",
"=",
"ldap3",
".",
"Connection",
"(",
"server",
")",
"connection",
".",
... | Return a LDAP connection | [
"Return",
"a",
"LDAP",
"connection"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L7-L15 |
239,903 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | LDAP_search | def LDAP_search(pattern_search, attribute):
"""
Do a LDAP search
"""
connection, ldap_base = _get_LDAP_connection()
connection.search(
search_base=ldap_base,
search_filter=pattern_search,
attributes=[attribute]
)
return connection.response | python | def LDAP_search(pattern_search, attribute):
"""
Do a LDAP search
"""
connection, ldap_base = _get_LDAP_connection()
connection.search(
search_base=ldap_base,
search_filter=pattern_search,
attributes=[attribute]
)
return connection.response | [
"def",
"LDAP_search",
"(",
"pattern_search",
",",
"attribute",
")",
":",
"connection",
",",
"ldap_base",
"=",
"_get_LDAP_connection",
"(",
")",
"connection",
".",
"search",
"(",
"search_base",
"=",
"ldap_base",
",",
"search_filter",
"=",
"pattern_search",
",",
"... | Do a LDAP search | [
"Do",
"a",
"LDAP",
"search"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L18-L29 |
239,904 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | is_unit_exist | def is_unit_exist(unit_id):
"""
Return True if the unit 'unid_id' exists.
Otherwise return False
"""
attribute = 'objectClass'
response = LDAP_search(
pattern_search="(uniqueidentifier={})".format(unit_id),
attribute=attribute
)
try:
unit_exist = 'EPFLorganization... | python | def is_unit_exist(unit_id):
"""
Return True if the unit 'unid_id' exists.
Otherwise return False
"""
attribute = 'objectClass'
response = LDAP_search(
pattern_search="(uniqueidentifier={})".format(unit_id),
attribute=attribute
)
try:
unit_exist = 'EPFLorganization... | [
"def",
"is_unit_exist",
"(",
"unit_id",
")",
":",
"attribute",
"=",
"'objectClass'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"\"(uniqueidentifier={})\"",
".",
"format",
"(",
"unit_id",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",... | Return True if the unit 'unid_id' exists.
Otherwise return False | [
"Return",
"True",
"if",
"the",
"unit",
"unid_id",
"exists",
".",
"Otherwise",
"return",
"False"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L36-L51 |
239,905 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_unit_name | def get_unit_name(unit_id):
"""
Return the unit name to the unit 'unit_id'
"""
attribute = 'cn'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(unit_id),
attribute=attribute
)
try:
unit_name = get_attribute(response, attribute)
except Excepti... | python | def get_unit_name(unit_id):
"""
Return the unit name to the unit 'unit_id'
"""
attribute = 'cn'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(unit_id),
attribute=attribute
)
try:
unit_name = get_attribute(response, attribute)
except Excepti... | [
"def",
"get_unit_name",
"(",
"unit_id",
")",
":",
"attribute",
"=",
"'cn'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"unit_id",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"unit_na... | Return the unit name to the unit 'unit_id' | [
"Return",
"the",
"unit",
"name",
"to",
"the",
"unit",
"unit_id"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L54-L68 |
239,906 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_unit_id | def get_unit_id(unit_name):
"""
Return the unit id to the unit 'unit_name'
"""
unit_name = unit_name.lower()
attribute = 'uniqueIdentifier'
response = LDAP_search(
pattern_search='(cn={})'.format(unit_name),
attribute=attribute
)
unit_id = ""
try:
for element... | python | def get_unit_id(unit_name):
"""
Return the unit id to the unit 'unit_name'
"""
unit_name = unit_name.lower()
attribute = 'uniqueIdentifier'
response = LDAP_search(
pattern_search='(cn={})'.format(unit_name),
attribute=attribute
)
unit_id = ""
try:
for element... | [
"def",
"get_unit_id",
"(",
"unit_name",
")",
":",
"unit_name",
"=",
"unit_name",
".",
"lower",
"(",
")",
"attribute",
"=",
"'uniqueIdentifier'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(cn={})'",
".",
"format",
"(",
"unit_name",
")",
",",... | Return the unit id to the unit 'unit_name' | [
"Return",
"the",
"unit",
"id",
"to",
"the",
"unit",
"unit_name"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L71-L93 |
239,907 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_units | def get_units(username):
"""
Return all units of user 'username'
"""
connection, ldap_base = _get_LDAP_connection()
# Search the user dn
connection.search(
search_base=ldap_base,
search_filter='(uid={}@*)'.format(username),
)
# For each user dn give me the unit
dn_l... | python | def get_units(username):
"""
Return all units of user 'username'
"""
connection, ldap_base = _get_LDAP_connection()
# Search the user dn
connection.search(
search_base=ldap_base,
search_filter='(uid={}@*)'.format(username),
)
# For each user dn give me the unit
dn_l... | [
"def",
"get_units",
"(",
"username",
")",
":",
"connection",
",",
"ldap_base",
"=",
"_get_LDAP_connection",
"(",
")",
"# Search the user dn",
"connection",
".",
"search",
"(",
"search_base",
"=",
"ldap_base",
",",
"search_filter",
"=",
"'(uid={}@*)'",
".",
"format... | Return all units of user 'username' | [
"Return",
"all",
"units",
"of",
"user",
"username"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L96-L118 |
239,908 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_username | def get_username(sciper):
"""
Return username of user
"""
attribute = 'uid'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
username = get_attribute(response, attribute)
except Exception:
raise Epfl... | python | def get_username(sciper):
"""
Return username of user
"""
attribute = 'uid'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
username = get_attribute(response, attribute)
except Exception:
raise Epfl... | [
"def",
"get_username",
"(",
"sciper",
")",
":",
"attribute",
"=",
"'uid'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"sciper",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"username"... | Return username of user | [
"Return",
"username",
"of",
"user"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L137-L150 |
239,909 | epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | get_email | def get_email(sciper):
"""
Return email of user
"""
attribute = 'mail'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
email = get_attribute(response, attribute)
except Exception:
raise EpflLdapExce... | python | def get_email(sciper):
"""
Return email of user
"""
attribute = 'mail'
response = LDAP_search(
pattern_search='(uniqueIdentifier={})'.format(sciper),
attribute=attribute
)
try:
email = get_attribute(response, attribute)
except Exception:
raise EpflLdapExce... | [
"def",
"get_email",
"(",
"sciper",
")",
":",
"attribute",
"=",
"'mail'",
"response",
"=",
"LDAP_search",
"(",
"pattern_search",
"=",
"'(uniqueIdentifier={})'",
".",
"format",
"(",
"sciper",
")",
",",
"attribute",
"=",
"attribute",
")",
"try",
":",
"email",
"... | Return email of user | [
"Return",
"email",
"of",
"user"
] | bebb94da3609d358bd83f31672eeaddcda872c5d | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L153-L166 |
239,910 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.with_code | def with_code(self, code):
"""
Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object
"""
self.code = code if code != None ... | python | def with_code(self, code):
"""
Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object
"""
self.code = code if code != None ... | [
"def",
"with_code",
"(",
"self",
",",
"code",
")",
":",
"self",
".",
"code",
"=",
"code",
"if",
"code",
"!=",
"None",
"else",
"'UNKNOWN'",
"self",
".",
"name",
"=",
"code",
"return",
"self"
] | Sets a unique error code.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param code: a unique error code
:return: this exception object | [
"Sets",
"a",
"unique",
"error",
"code",
".",
"This",
"method",
"returns",
"reference",
"to",
"this",
"exception",
"to",
"implement",
"Builder",
"pattern",
"to",
"chain",
"additional",
"calls",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L131-L142 |
239,911 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.with_details | def with_details(self, key, value):
"""
Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a... | python | def with_details(self, key, value):
"""
Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a... | [
"def",
"with_details",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"details",
"=",
"self",
".",
"details",
"if",
"self",
".",
"details",
"!=",
"None",
"else",
"{",
"}",
"self",
".",
"details",
"[",
"key",
"]",
"=",
"value",
"retur... | Sets a parameter for additional error details.
This details can be used to restore error description in other languages.
This method returns reference to this exception to implement Builder pattern to chain additional calls.
:param key: a details parameter name
:param value: a details... | [
"Sets",
"a",
"parameter",
"for",
"additional",
"error",
"details",
".",
"This",
"details",
"can",
"be",
"used",
"to",
"restore",
"error",
"description",
"in",
"other",
"languages",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L156-L171 |
239,912 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.wrap | def wrap(self, cause):
"""
Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: a... | python | def wrap(self, cause):
"""
Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: a... | [
"def",
"wrap",
"(",
"self",
",",
"cause",
")",
":",
"if",
"isinstance",
"(",
"cause",
",",
"ApplicationException",
")",
":",
"return",
"cause",
"self",
".",
"with_cause",
"(",
"cause",
")",
"return",
"self"
] | Wraps another exception into an application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise a new ApplicationException is created and original error is set as its cause.
:param cause: an original error object
:return: a... | [
"Wraps",
"another",
"exception",
"into",
"an",
"application",
"exception",
"object",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L199-L214 |
239,913 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/errors/ApplicationException.py | ApplicationException.wrap_exception | def wrap_exception(exception, cause):
"""
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
... | python | def wrap_exception(exception, cause):
"""
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
... | [
"def",
"wrap_exception",
"(",
"exception",
",",
"cause",
")",
":",
"if",
"isinstance",
"(",
"cause",
",",
"ApplicationException",
")",
":",
"return",
"cause",
"exception",
".",
"with_cause",
"(",
"cause",
")",
"return",
"exception"
] | Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without changes.
Otherwise the original error is set as a cause to specified ApplicationException object.
:param exception: an ApplicationException object t... | [
"Wraps",
"another",
"exception",
"into",
"specified",
"application",
"exception",
"object",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/errors/ApplicationException.py#L217-L234 |
239,914 | FujiMakoto/AgentML | agentml/parser/tags/var.py | Var.value | def value(self):
"""
Return the current value of a variable
"""
# Does the variable name have tags to parse?
if len(self._element):
var = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger)))
else:
var = self._element.text... | python | def value(self):
"""
Return the current value of a variable
"""
# Does the variable name have tags to parse?
if len(self._element):
var = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger)))
else:
var = self._element.text... | [
"def",
"value",
"(",
"self",
")",
":",
"# Does the variable name have tags to parse?",
"if",
"len",
"(",
"self",
".",
"_element",
")",
":",
"var",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"str",
",",
"self",
".",
"trigger",
".",
"agentml",
".",
"parse_ta... | Return the current value of a variable | [
"Return",
"the",
"current",
"value",
"of",
"a",
"variable"
] | c8cb64b460d876666bf29ea2c682189874c7c403 | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/tags/var.py#L28-L55 |
239,915 | rbarrois/django-batchform | batchform/parsers/csv.py | BaseCsvParser.reopen | def reopen(self, file_obj):
"""Reopen the file-like object in a safe manner."""
file_obj.open('U')
if sys.version_info[0] <= 2:
return file_obj
else:
return codecs.getreader('utf-8')(file_obj) | python | def reopen(self, file_obj):
"""Reopen the file-like object in a safe manner."""
file_obj.open('U')
if sys.version_info[0] <= 2:
return file_obj
else:
return codecs.getreader('utf-8')(file_obj) | [
"def",
"reopen",
"(",
"self",
",",
"file_obj",
")",
":",
"file_obj",
".",
"open",
"(",
"'U'",
")",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"<=",
"2",
":",
"return",
"file_obj",
"else",
":",
"return",
"codecs",
".",
"getreader",
"(",
"'utf-8'... | Reopen the file-like object in a safe manner. | [
"Reopen",
"the",
"file",
"-",
"like",
"object",
"in",
"a",
"safe",
"manner",
"."
] | f6b659a6790750285af248ccd1d4d178ecbad129 | https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/parsers/csv.py#L36-L42 |
239,916 | caseyjlaw/sdmreader | sdmreader/sdmreader.py | BDFData.parse | def parse(self):
"""wrapper for original parse function. will read pkl with bdf info, if available."""
if os.path.exists(self.pklname): # check for pkl with binary info
logger.info('Found bdf pkl file %s. Loading...' % (self.pklname))
try:
with open(... | python | def parse(self):
"""wrapper for original parse function. will read pkl with bdf info, if available."""
if os.path.exists(self.pklname): # check for pkl with binary info
logger.info('Found bdf pkl file %s. Loading...' % (self.pklname))
try:
with open(... | [
"def",
"parse",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"pklname",
")",
":",
"# check for pkl with binary info\r",
"logger",
".",
"info",
"(",
"'Found bdf pkl file %s. Loading...'",
"%",
"(",
"self",
".",
"pklname",
"... | wrapper for original parse function. will read pkl with bdf info, if available. | [
"wrapper",
"for",
"original",
"parse",
"function",
".",
"will",
"read",
"pkl",
"with",
"bdf",
"info",
"if",
"available",
"."
] | b6c3498f1915138727819715ee00d2c46353382d | https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L331-L349 |
239,917 | Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.toString | def toString(self):
"""
Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on.
"""
output = ""
if self.childs or se... | python | def toString(self):
"""
Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on.
"""
output = ""
if self.childs or se... | [
"def",
"toString",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"childs",
"or",
"self",
".",
"isOpeningTag",
"(",
")",
":",
"output",
"+=",
"self",
".",
"tagToString",
"(",
")",
"for",
"c",
"in",
"self",
".",
"childs",
":",
"out... | Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on. | [
"Returns",
"almost",
"original",
"string",
"."
] | 4756f93dd048500b038ece2323fe26e46b6bfdea | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L20-L44 |
239,918 | Bystroushaak/pyDHTMLParser | src/dhtmlparser/htmlelement/html_element.py | HTMLElement.replaceWith | def replaceWith(self, el):
"""
Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance.
"""
self.childs = el.childs
self.params = el.params
... | python | def replaceWith(self, el):
"""
Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance.
"""
self.childs = el.childs
self.params = el.params
... | [
"def",
"replaceWith",
"(",
"self",
",",
"el",
")",
":",
"self",
".",
"childs",
"=",
"el",
".",
"childs",
"self",
".",
"params",
"=",
"el",
".",
"params",
"self",
".",
"endtag",
"=",
"el",
".",
"endtag",
"self",
".",
"openertag",
"=",
"el",
".",
"... | Replace value in this element with values from `el`.
This useful when you don't want change all references to object.
Args:
el (obj): :class:`HTMLElement` instance. | [
"Replace",
"value",
"in",
"this",
"element",
"with",
"values",
"from",
"el",
"."
] | 4756f93dd048500b038ece2323fe26e46b6bfdea | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/htmlelement/html_element.py#L133-L153 |
239,919 | renzon/gaepagseguro | gaepagseguro/save_commands.py | SaveItemCmd.handle_previous | def handle_previous(self, command):
"""
Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte
"""
self.result = command.items
self._to_commit = self.result | python | def handle_previous(self, command):
"""
Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte
"""
self.result = command.items
self._to_commit = self.result | [
"def",
"handle_previous",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"result",
"=",
"command",
".",
"items",
"self",
".",
"_to_commit",
"=",
"self",
".",
"result"
] | Method to generate item from a ItemForm. The form must be exposed on form attribute
@param command: a command tha expose data through form attributte | [
"Method",
"to",
"generate",
"item",
"from",
"a",
"ItemForm",
".",
"The",
"form",
"must",
"be",
"exposed",
"on",
"form",
"attribute"
] | c88f00580c380ff5b35d873311d6c786fa1f29d2 | https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/save_commands.py#L11-L17 |
239,920 | ErikBjare/pyzenobase | examples/upload_lifelogger_spreadsheet/main.py | Lifelogger_to_Zenobase.get_dates | def get_dates(raw_table) -> "list of dates":
"""
Goes through the first column of input table and
returns the first sequence of dates it finds.
"""
dates = []
found_first = False
for i, dstr in enumerate([raw_table[i][0] for i in range(0, len(raw_table))])... | python | def get_dates(raw_table) -> "list of dates":
"""
Goes through the first column of input table and
returns the first sequence of dates it finds.
"""
dates = []
found_first = False
for i, dstr in enumerate([raw_table[i][0] for i in range(0, len(raw_table))])... | [
"def",
"get_dates",
"(",
"raw_table",
")",
"->",
"\"list of dates\"",
":",
"dates",
"=",
"[",
"]",
"found_first",
"=",
"False",
"for",
"i",
",",
"dstr",
"in",
"enumerate",
"(",
"[",
"raw_table",
"[",
"i",
"]",
"[",
"0",
"]",
"for",
"i",
"in",
"range"... | Goes through the first column of input table and
returns the first sequence of dates it finds. | [
"Goes",
"through",
"the",
"first",
"column",
"of",
"input",
"table",
"and",
"returns",
"the",
"first",
"sequence",
"of",
"dates",
"it",
"finds",
"."
] | eb0572c7441a350bf5578bc5287f3be53d32ea19 | https://github.com/ErikBjare/pyzenobase/blob/eb0572c7441a350bf5578bc5287f3be53d32ea19/examples/upload_lifelogger_spreadsheet/main.py#L63-L87 |
239,921 | ErikBjare/pyzenobase | examples/upload_lifelogger_spreadsheet/main.py | Lifelogger_to_Zenobase.get_main | def get_main(self) -> 'table[category: str][label: str][date: date]':
"""
Returns a table with the above typesignature
"""
raw_table = self.get_raw_table("M")
categories = raw_table[0]
labels = raw_table[1]
dates = self.get_dates(raw_table)
def next_... | python | def get_main(self) -> 'table[category: str][label: str][date: date]':
"""
Returns a table with the above typesignature
"""
raw_table = self.get_raw_table("M")
categories = raw_table[0]
labels = raw_table[1]
dates = self.get_dates(raw_table)
def next_... | [
"def",
"get_main",
"(",
"self",
")",
"->",
"'table[category: str][label: str][date: date]'",
":",
"raw_table",
"=",
"self",
".",
"get_raw_table",
"(",
"\"M\"",
")",
"categories",
"=",
"raw_table",
"[",
"0",
"]",
"labels",
"=",
"raw_table",
"[",
"1",
"]",
"date... | Returns a table with the above typesignature | [
"Returns",
"a",
"table",
"with",
"the",
"above",
"typesignature"
] | eb0572c7441a350bf5578bc5287f3be53d32ea19 | https://github.com/ErikBjare/pyzenobase/blob/eb0572c7441a350bf5578bc5287f3be53d32ea19/examples/upload_lifelogger_spreadsheet/main.py#L89-L130 |
239,922 | funkybob/antfarm | antfarm/response.py | Response.build_headers | def build_headers(self):
'''
Return the list of headers as two-tuples
'''
if not 'Content-Type' in self.headers:
content_type = self.content_type
if self.encoding != DEFAULT_ENCODING:
content_type += '; charset=%s' % self.encoding
self.... | python | def build_headers(self):
'''
Return the list of headers as two-tuples
'''
if not 'Content-Type' in self.headers:
content_type = self.content_type
if self.encoding != DEFAULT_ENCODING:
content_type += '; charset=%s' % self.encoding
self.... | [
"def",
"build_headers",
"(",
"self",
")",
":",
"if",
"not",
"'Content-Type'",
"in",
"self",
".",
"headers",
":",
"content_type",
"=",
"self",
".",
"content_type",
"if",
"self",
".",
"encoding",
"!=",
"DEFAULT_ENCODING",
":",
"content_type",
"+=",
"'; charset=%... | Return the list of headers as two-tuples | [
"Return",
"the",
"list",
"of",
"headers",
"as",
"two",
"-",
"tuples"
] | 40a7cc450eba09a280b7bc8f7c68a807b0177c62 | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L90-L106 |
239,923 | funkybob/antfarm | antfarm/response.py | Response.add_cookie | def add_cookie(self, key, value, **attrs):
'''
Finer control over cookies. Allow specifying an Morsel arguments.
'''
if attrs:
c = Morsel()
c.set(key, value, **attrs)
self.cookies[key] = c
else:
self.cookies[key] = value | python | def add_cookie(self, key, value, **attrs):
'''
Finer control over cookies. Allow specifying an Morsel arguments.
'''
if attrs:
c = Morsel()
c.set(key, value, **attrs)
self.cookies[key] = c
else:
self.cookies[key] = value | [
"def",
"add_cookie",
"(",
"self",
",",
"key",
",",
"value",
",",
"*",
"*",
"attrs",
")",
":",
"if",
"attrs",
":",
"c",
"=",
"Morsel",
"(",
")",
"c",
".",
"set",
"(",
"key",
",",
"value",
",",
"*",
"*",
"attrs",
")",
"self",
".",
"cookies",
"[... | Finer control over cookies. Allow specifying an Morsel arguments. | [
"Finer",
"control",
"over",
"cookies",
".",
"Allow",
"specifying",
"an",
"Morsel",
"arguments",
"."
] | 40a7cc450eba09a280b7bc8f7c68a807b0177c62 | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L108-L117 |
239,924 | funkybob/antfarm | antfarm/response.py | Response.status | def status(self):
'''Allow custom status messages'''
message = self.status_message
if message is None:
message = STATUS[self.status_code]
return '%s %s' % (self.status_code, message) | python | def status(self):
'''Allow custom status messages'''
message = self.status_message
if message is None:
message = STATUS[self.status_code]
return '%s %s' % (self.status_code, message) | [
"def",
"status",
"(",
"self",
")",
":",
"message",
"=",
"self",
".",
"status_message",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"STATUS",
"[",
"self",
".",
"status_code",
"]",
"return",
"'%s %s'",
"%",
"(",
"self",
".",
"status_code",
",",
"... | Allow custom status messages | [
"Allow",
"custom",
"status",
"messages"
] | 40a7cc450eba09a280b7bc8f7c68a807b0177c62 | https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/response.py#L120-L125 |
239,925 | jambonrose/django-decorator-plus | decorator_plus/version.py | get_git_changeset | def get_git_changeset():
"""Get git identifier; taken from Django project."""
git_log = Popen(
'git log --pretty=format:%ct --quiet -1 HEAD',
stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
timestamp = git_log.communicate()[0]
try:
timestamp = datetime.utcfromtimes... | python | def get_git_changeset():
"""Get git identifier; taken from Django project."""
git_log = Popen(
'git log --pretty=format:%ct --quiet -1 HEAD',
stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
timestamp = git_log.communicate()[0]
try:
timestamp = datetime.utcfromtimes... | [
"def",
"get_git_changeset",
"(",
")",
":",
"git_log",
"=",
"Popen",
"(",
"'git log --pretty=format:%ct --quiet -1 HEAD'",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
",",
"shell",
"=",
"True",
",",
"universal_newlines",
"=",
"True",
")",
"timestamp",... | Get git identifier; taken from Django project. | [
"Get",
"git",
"identifier",
";",
"taken",
"from",
"Django",
"project",
"."
] | 2039ef7a4b5f8abb29e455e8218c207fcae24e2c | https://github.com/jambonrose/django-decorator-plus/blob/2039ef7a4b5f8abb29e455e8218c207fcae24e2c/decorator_plus/version.py#L25-L35 |
239,926 | jambonrose/django-decorator-plus | decorator_plus/version.py | get_version | def get_version(version_tuple):
"""Convert 4-tuple into a PEP 440 compliant string."""
if version_tuple[3] == FINAL and version_tuple[4] != 0:
raise Exception(
'Project version number misconfigured:\n'
' version may not be final and have segment number.')
if version_tuple[... | python | def get_version(version_tuple):
"""Convert 4-tuple into a PEP 440 compliant string."""
if version_tuple[3] == FINAL and version_tuple[4] != 0:
raise Exception(
'Project version number misconfigured:\n'
' version may not be final and have segment number.')
if version_tuple[... | [
"def",
"get_version",
"(",
"version_tuple",
")",
":",
"if",
"version_tuple",
"[",
"3",
"]",
"==",
"FINAL",
"and",
"version_tuple",
"[",
"4",
"]",
"!=",
"0",
":",
"raise",
"Exception",
"(",
"'Project version number misconfigured:\\n'",
"' version may not be final a... | Convert 4-tuple into a PEP 440 compliant string. | [
"Convert",
"4",
"-",
"tuple",
"into",
"a",
"PEP",
"440",
"compliant",
"string",
"."
] | 2039ef7a4b5f8abb29e455e8218c207fcae24e2c | https://github.com/jambonrose/django-decorator-plus/blob/2039ef7a4b5f8abb29e455e8218c207fcae24e2c/decorator_plus/version.py#L38-L72 |
239,927 | Meseira/subordinate | subordinate/idmap.py | IdMap.append | def append(self, name):
"""If name is not in the map, append it with an empty id range set."""
if not isinstance(name, str):
raise TypeError(
"argument 'name' must be a string, not {}".format(
name.__class__.__name__
)
... | python | def append(self, name):
"""If name is not in the map, append it with an empty id range set."""
if not isinstance(name, str):
raise TypeError(
"argument 'name' must be a string, not {}".format(
name.__class__.__name__
)
... | [
"def",
"append",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"argument 'name' must be a string, not {}\"",
".",
"format",
"(",
"name",
".",
"__class__",
".",
"__name__",
")",
... | If name is not in the map, append it with an empty id range set. | [
"If",
"name",
"is",
"not",
"in",
"the",
"map",
"append",
"it",
"with",
"an",
"empty",
"id",
"range",
"set",
"."
] | 3438df304af3dccc5bd1515231402afa708f1cc3 | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L74-L88 |
239,928 | Meseira/subordinate | subordinate/idmap.py | IdMap.who_has | def who_has(self, subid):
"""Return a list of names who own subid in their id range set."""
answer = []
for name in self.__map:
if subid in self.__map[name] and not name in answer:
answer.append(name)
return answer | python | def who_has(self, subid):
"""Return a list of names who own subid in their id range set."""
answer = []
for name in self.__map:
if subid in self.__map[name] and not name in answer:
answer.append(name)
return answer | [
"def",
"who_has",
"(",
"self",
",",
"subid",
")",
":",
"answer",
"=",
"[",
"]",
"for",
"name",
"in",
"self",
".",
"__map",
":",
"if",
"subid",
"in",
"self",
".",
"__map",
"[",
"name",
"]",
"and",
"not",
"name",
"in",
"answer",
":",
"answer",
".",... | Return a list of names who own subid in their id range set. | [
"Return",
"a",
"list",
"of",
"names",
"who",
"own",
"subid",
"in",
"their",
"id",
"range",
"set",
"."
] | 3438df304af3dccc5bd1515231402afa708f1cc3 | https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L177-L185 |
239,929 | fdb/aufmachen | aufmachen/crawler.py | cache_path_for_url | def cache_path_for_url(url):
"""Return the path where the URL might be cached."""
m = hashlib.md5()
m.update(url)
digest = m.hexdigest()
return os.path.join(CACHE_DIRECTORY, '%s.html' % digest) | python | def cache_path_for_url(url):
"""Return the path where the URL might be cached."""
m = hashlib.md5()
m.update(url)
digest = m.hexdigest()
return os.path.join(CACHE_DIRECTORY, '%s.html' % digest) | [
"def",
"cache_path_for_url",
"(",
"url",
")",
":",
"m",
"=",
"hashlib",
".",
"md5",
"(",
")",
"m",
".",
"update",
"(",
"url",
")",
"digest",
"=",
"m",
".",
"hexdigest",
"(",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"CACHE_DIRECTORY",
","... | Return the path where the URL might be cached. | [
"Return",
"the",
"path",
"where",
"the",
"URL",
"might",
"be",
"cached",
"."
] | f2986a0cf087ac53969f82b84d872e3f1c6986f4 | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L71-L76 |
239,930 | fdb/aufmachen | aufmachen/crawler.py | get_url | def get_url(url, data=None, cached=True, cache_key=None, crawler='urllib'):
"""Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the ... | python | def get_url(url, data=None, cached=True, cache_key=None, crawler='urllib'):
"""Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the ... | [
"def",
"get_url",
"(",
"url",
",",
"data",
"=",
"None",
",",
"cached",
"=",
"True",
",",
"cache_key",
"=",
"None",
",",
"crawler",
"=",
"'urllib'",
")",
":",
"if",
"cache_key",
"is",
"None",
":",
"cache_key",
"=",
"url",
"cache_path",
"=",
"cache_path_... | Retrieves the HTML code for a given URL.
If a cached version is not available, uses phantom_retrieve to fetch the page.
data - Additional data that gets passed onto the crawler.
cached - If True, retrieves the URL from the cache if it is available. If False, will still store the page in cache.
cache_k... | [
"Retrieves",
"the",
"HTML",
"code",
"for",
"a",
"given",
"URL",
".",
"If",
"a",
"cached",
"version",
"is",
"not",
"available",
"uses",
"phantom_retrieve",
"to",
"fetch",
"the",
"page",
"."
] | f2986a0cf087ac53969f82b84d872e3f1c6986f4 | https://github.com/fdb/aufmachen/blob/f2986a0cf087ac53969f82b84d872e3f1c6986f4/aufmachen/crawler.py#L89-L117 |
239,931 | ArabellaTech/aa-intercom | aa_intercom/models.py | IntercomEvent.get_intercom_data | def get_intercom_data(self):
"""Specify the data sent to Intercom API according to event type"""
data = {
"event_name": self.get_type_display(), # event type
"created_at": calendar.timegm(self.created.utctimetuple()), # date
"metadata": self.metadata
}
... | python | def get_intercom_data(self):
"""Specify the data sent to Intercom API according to event type"""
data = {
"event_name": self.get_type_display(), # event type
"created_at": calendar.timegm(self.created.utctimetuple()), # date
"metadata": self.metadata
}
... | [
"def",
"get_intercom_data",
"(",
"self",
")",
":",
"data",
"=",
"{",
"\"event_name\"",
":",
"self",
".",
"get_type_display",
"(",
")",
",",
"# event type",
"\"created_at\"",
":",
"calendar",
".",
"timegm",
"(",
"self",
".",
"created",
".",
"utctimetuple",
"(... | Specify the data sent to Intercom API according to event type | [
"Specify",
"the",
"data",
"sent",
"to",
"Intercom",
"API",
"according",
"to",
"event",
"type"
] | f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2 | https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/models.py#L33-L42 |
239,932 | openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_lab_text | def get_lab_text(lab_slug, language):
"""Gets text description in English or Italian from a single lab from makeinitaly.foundation."""
if language == "English" or language == "english" or language == "EN" or language == "En":
language = "en"
elif language == "Italian" or language == "italian" or lan... | python | def get_lab_text(lab_slug, language):
"""Gets text description in English or Italian from a single lab from makeinitaly.foundation."""
if language == "English" or language == "english" or language == "EN" or language == "En":
language = "en"
elif language == "Italian" or language == "italian" or lan... | [
"def",
"get_lab_text",
"(",
"lab_slug",
",",
"language",
")",
":",
"if",
"language",
"==",
"\"English\"",
"or",
"language",
"==",
"\"english\"",
"or",
"language",
"==",
"\"EN\"",
"or",
"language",
"==",
"\"En\"",
":",
"language",
"=",
"\"en\"",
"elif",
"lang... | Gets text description in English or Italian from a single lab from makeinitaly.foundation. | [
"Gets",
"text",
"description",
"in",
"English",
"or",
"Italian",
"from",
"a",
"single",
"lab",
"from",
"makeinitaly",
".",
"foundation",
"."
] | b5838440174f10d370abb671358db9a99d7739fd | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L34-L61 |
239,933 | openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_single_lab | def get_single_lab(lab_slug):
"""Gets data from a single lab from makeinitaly.foundation."""
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'titles': lab_slug,
'prop': 'revisions',
'rvprop': 'content'})
# If we don't k... | python | def get_single_lab(lab_slug):
"""Gets data from a single lab from makeinitaly.foundation."""
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'titles': lab_slug,
'prop': 'revisions',
'rvprop': 'content'})
# If we don't k... | [
"def",
"get_single_lab",
"(",
"lab_slug",
")",
":",
"wiki",
"=",
"MediaWiki",
"(",
"makeinitaly__foundation_api_url",
")",
"wiki_response",
"=",
"wiki",
".",
"call",
"(",
"{",
"'action'",
":",
"'query'",
",",
"'titles'",
":",
"lab_slug",
",",
"'prop'",
":",
... | Gets data from a single lab from makeinitaly.foundation. | [
"Gets",
"data",
"from",
"a",
"single",
"lab",
"from",
"makeinitaly",
".",
"foundation",
"."
] | b5838440174f10d370abb671358db9a99d7739fd | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L64-L137 |
239,934 | openp2pdesign/makerlabs | makerlabs/makeinitaly_foundation.py | get_labs | def get_labs(format):
"""Gets data from all labs from makeinitaly.foundation."""
labs = []
# Get the first page of data
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'list': 'categorymembers',
'cmtitle': 'Category:Italian... | python | def get_labs(format):
"""Gets data from all labs from makeinitaly.foundation."""
labs = []
# Get the first page of data
wiki = MediaWiki(makeinitaly__foundation_api_url)
wiki_response = wiki.call(
{'action': 'query',
'list': 'categorymembers',
'cmtitle': 'Category:Italian... | [
"def",
"get_labs",
"(",
"format",
")",
":",
"labs",
"=",
"[",
"]",
"# Get the first page of data",
"wiki",
"=",
"MediaWiki",
"(",
"makeinitaly__foundation_api_url",
")",
"wiki_response",
"=",
"wiki",
".",
"call",
"(",
"{",
"'action'",
":",
"'query'",
",",
"'li... | Gets data from all labs from makeinitaly.foundation. | [
"Gets",
"data",
"from",
"all",
"labs",
"from",
"makeinitaly",
".",
"foundation",
"."
] | b5838440174f10d370abb671358db9a99d7739fd | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/makeinitaly_foundation.py#L140-L225 |
239,935 | twneale/uni | uni/checker.py | SpecChecker.path_eval | def path_eval(self, obj, keypath):
'''Given an object and a mongo-style dotted key path, return the
object value referenced by that key path.
'''
segs = keypath.split('.')
this = obj
for seg in segs:
if isinstance(this, dict):
try:
... | python | def path_eval(self, obj, keypath):
'''Given an object and a mongo-style dotted key path, return the
object value referenced by that key path.
'''
segs = keypath.split('.')
this = obj
for seg in segs:
if isinstance(this, dict):
try:
... | [
"def",
"path_eval",
"(",
"self",
",",
"obj",
",",
"keypath",
")",
":",
"segs",
"=",
"keypath",
".",
"split",
"(",
"'.'",
")",
"this",
"=",
"obj",
"for",
"seg",
"in",
"segs",
":",
"if",
"isinstance",
"(",
"this",
",",
"dict",
")",
":",
"try",
":",... | Given an object and a mongo-style dotted key path, return the
object value referenced by that key path. | [
"Given",
"an",
"object",
"and",
"a",
"mongo",
"-",
"style",
"dotted",
"key",
"path",
"return",
"the",
"object",
"value",
"referenced",
"by",
"that",
"key",
"path",
"."
] | 1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5 | https://github.com/twneale/uni/blob/1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5/uni/checker.py#L43-L63 |
239,936 | twneale/uni | uni/checker.py | SpecChecker.check | def check(self, spec, data):
'''Given a mongo-style spec and some data or python object,
check whether the object complies with the spec. Fails eagerly.
'''
path_eval = self.path_eval
for keypath, specvalue in spec.items():
if keypath.startswith('$'):
... | python | def check(self, spec, data):
'''Given a mongo-style spec and some data or python object,
check whether the object complies with the spec. Fails eagerly.
'''
path_eval = self.path_eval
for keypath, specvalue in spec.items():
if keypath.startswith('$'):
... | [
"def",
"check",
"(",
"self",
",",
"spec",
",",
"data",
")",
":",
"path_eval",
"=",
"self",
".",
"path_eval",
"for",
"keypath",
",",
"specvalue",
"in",
"spec",
".",
"items",
"(",
")",
":",
"if",
"keypath",
".",
"startswith",
"(",
"'$'",
")",
":",
"o... | Given a mongo-style spec and some data or python object,
check whether the object complies with the spec. Fails eagerly. | [
"Given",
"a",
"mongo",
"-",
"style",
"spec",
"and",
"some",
"data",
"or",
"python",
"object",
"check",
"whether",
"the",
"object",
"complies",
"with",
"the",
"spec",
".",
"Fails",
"eagerly",
"."
] | 1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5 | https://github.com/twneale/uni/blob/1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5/uni/checker.py#L65-L87 |
239,937 | twneale/uni | uni/checker.py | SpecChecker.handle_literal | def handle_literal(self, val, checkable):
'''This one's tricky...check for equality,
then for contains.
'''
# I.e., spec: {'x': 1}, data: {'x': 1}
if val == checkable:
yield True
return
# I.e., spec: {'x': 1}, data: {'x': [1, 2, 3]}
else:
... | python | def handle_literal(self, val, checkable):
'''This one's tricky...check for equality,
then for contains.
'''
# I.e., spec: {'x': 1}, data: {'x': 1}
if val == checkable:
yield True
return
# I.e., spec: {'x': 1}, data: {'x': [1, 2, 3]}
else:
... | [
"def",
"handle_literal",
"(",
"self",
",",
"val",
",",
"checkable",
")",
":",
"# I.e., spec: {'x': 1}, data: {'x': 1}",
"if",
"val",
"==",
"checkable",
":",
"yield",
"True",
"return",
"# I.e., spec: {'x': 1}, data: {'x': [1, 2, 3]}",
"else",
":",
"try",
":",
"yield",
... | This one's tricky...check for equality,
then for contains. | [
"This",
"one",
"s",
"tricky",
"...",
"check",
"for",
"equality",
"then",
"for",
"contains",
"."
] | 1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5 | https://github.com/twneale/uni/blob/1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5/uni/checker.py#L95-L110 |
239,938 | anjos/rrbob | rr/preprocessor.py | normalize | def normalize(X, norm):
'''Applies the given norm to the input data set
Parameters:
X (numpy.ndarray): A 3D numpy ndarray in which the rows represent examples
while the columns, features of the data set you want to normalize. Every
depth corresponds to data for a particular class
norm (tuple... | python | def normalize(X, norm):
'''Applies the given norm to the input data set
Parameters:
X (numpy.ndarray): A 3D numpy ndarray in which the rows represent examples
while the columns, features of the data set you want to normalize. Every
depth corresponds to data for a particular class
norm (tuple... | [
"def",
"normalize",
"(",
"X",
",",
"norm",
")",
":",
"return",
"numpy",
".",
"array",
"(",
"[",
"(",
"k",
"-",
"norm",
"[",
"0",
"]",
")",
"/",
"norm",
"[",
"1",
"]",
"for",
"k",
"in",
"X",
"]",
")"
] | Applies the given norm to the input data set
Parameters:
X (numpy.ndarray): A 3D numpy ndarray in which the rows represent examples
while the columns, features of the data set you want to normalize. Every
depth corresponds to data for a particular class
norm (tuple): A tuple containing two 1D ... | [
"Applies",
"the",
"given",
"norm",
"to",
"the",
"input",
"data",
"set"
] | d32d35bab2aa2698d3caa923fd02afb6d67f3235 | https://github.com/anjos/rrbob/blob/d32d35bab2aa2698d3caa923fd02afb6d67f3235/rr/preprocessor.py#L37-L58 |
239,939 | krukas/Trionyx | trionyx/trionyx/search.py | auto_register_search_models | def auto_register_search_models():
"""Auto register all search models"""
for config in models_config.get_all_configs():
if config.disable_search_index:
continue
search.register(
config.model.objects.get_queryset(),
ModelSearchAdapter,
fields=confi... | python | def auto_register_search_models():
"""Auto register all search models"""
for config in models_config.get_all_configs():
if config.disable_search_index:
continue
search.register(
config.model.objects.get_queryset(),
ModelSearchAdapter,
fields=confi... | [
"def",
"auto_register_search_models",
"(",
")",
":",
"for",
"config",
"in",
"models_config",
".",
"get_all_configs",
"(",
")",
":",
"if",
"config",
".",
"disable_search_index",
":",
"continue",
"search",
".",
"register",
"(",
"config",
".",
"model",
".",
"obje... | Auto register all search models | [
"Auto",
"register",
"all",
"search",
"models"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/search.py#L42-L53 |
239,940 | krukas/Trionyx | trionyx/trionyx/search.py | ModelSearchAdapter.get_title | def get_title(self, obj):
"""Set search entry title for object"""
search_title = self.get_model_config_value(obj, 'search_title')
if not search_title:
return super().get_title(obj)
return search_title.format(**obj.__dict__) | python | def get_title(self, obj):
"""Set search entry title for object"""
search_title = self.get_model_config_value(obj, 'search_title')
if not search_title:
return super().get_title(obj)
return search_title.format(**obj.__dict__) | [
"def",
"get_title",
"(",
"self",
",",
"obj",
")",
":",
"search_title",
"=",
"self",
".",
"get_model_config_value",
"(",
"obj",
",",
"'search_title'",
")",
"if",
"not",
"search_title",
":",
"return",
"super",
"(",
")",
".",
"get_title",
"(",
"obj",
")",
"... | Set search entry title for object | [
"Set",
"search",
"entry",
"title",
"for",
"object"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/search.py#L18-L25 |
239,941 | krukas/Trionyx | trionyx/trionyx/search.py | ModelSearchAdapter.get_description | def get_description(self, obj):
"""Set search entry description for object"""
search_description = self.get_model_config_value(obj, 'search_description')
if not search_description:
return super().get_description(obj)
return search_description.format(**obj.__dict__) | python | def get_description(self, obj):
"""Set search entry description for object"""
search_description = self.get_model_config_value(obj, 'search_description')
if not search_description:
return super().get_description(obj)
return search_description.format(**obj.__dict__) | [
"def",
"get_description",
"(",
"self",
",",
"obj",
")",
":",
"search_description",
"=",
"self",
".",
"get_model_config_value",
"(",
"obj",
",",
"'search_description'",
")",
"if",
"not",
"search_description",
":",
"return",
"super",
"(",
")",
".",
"get_descriptio... | Set search entry description for object | [
"Set",
"search",
"entry",
"description",
"for",
"object"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/search.py#L27-L34 |
239,942 | krukas/Trionyx | trionyx/trionyx/search.py | ModelSearchAdapter.get_model_config_value | def get_model_config_value(self, obj, name):
"""Get config value for given model"""
config = models_config.get_config(obj)
return getattr(config, name) | python | def get_model_config_value(self, obj, name):
"""Get config value for given model"""
config = models_config.get_config(obj)
return getattr(config, name) | [
"def",
"get_model_config_value",
"(",
"self",
",",
"obj",
",",
"name",
")",
":",
"config",
"=",
"models_config",
".",
"get_config",
"(",
"obj",
")",
"return",
"getattr",
"(",
"config",
",",
"name",
")"
] | Get config value for given model | [
"Get",
"config",
"value",
"for",
"given",
"model"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/search.py#L36-L39 |
239,943 | ereOn/pyslot | pyslot/signal.py | Signal.disconnect | def disconnect(self, callback):
"""
Disconnects a callback from this signal.
:param callback: The callback to disconnect.
:param weak: A flag that must have the same value than the one
specified during the call to `connect`.
.. warning::
If the callback ... | python | def disconnect(self, callback):
"""
Disconnects a callback from this signal.
:param callback: The callback to disconnect.
:param weak: A flag that must have the same value than the one
specified during the call to `connect`.
.. warning::
If the callback ... | [
"def",
"disconnect",
"(",
"self",
",",
"callback",
")",
":",
"try",
":",
"self",
".",
"_callbacks",
".",
"remove",
"(",
"callback",
")",
"except",
"ValueError",
":",
"self",
".",
"_callbacks",
".",
"remove",
"(",
"ref",
"(",
"callback",
")",
")"
] | Disconnects a callback from this signal.
:param callback: The callback to disconnect.
:param weak: A flag that must have the same value than the one
specified during the call to `connect`.
.. warning::
If the callback is not connected at the time of call, a
... | [
"Disconnects",
"a",
"callback",
"from",
"this",
"signal",
"."
] | 9201ce84449ca811afb65fde6cd46a3cb7029182 | https://github.com/ereOn/pyslot/blob/9201ce84449ca811afb65fde6cd46a3cb7029182/pyslot/signal.py#L57-L75 |
239,944 | Kopachris/seshet | seshet/bot.py | _add_channel_names | def _add_channel_names(client, e):
"""Add a new channel to self.channels and initialize its user list.
Called as event handler for RPL_NAMES events. Do not call directly.
"""
chan = IRCstr(e.channel)
names = set([IRCstr(n) for n in e.name_list])
client.channels[chan] = ... | python | def _add_channel_names(client, e):
"""Add a new channel to self.channels and initialize its user list.
Called as event handler for RPL_NAMES events. Do not call directly.
"""
chan = IRCstr(e.channel)
names = set([IRCstr(n) for n in e.name_list])
client.channels[chan] = ... | [
"def",
"_add_channel_names",
"(",
"client",
",",
"e",
")",
":",
"chan",
"=",
"IRCstr",
"(",
"e",
".",
"channel",
")",
"names",
"=",
"set",
"(",
"[",
"IRCstr",
"(",
"n",
")",
"for",
"n",
"in",
"e",
".",
"name_list",
"]",
")",
"client",
".",
"chann... | Add a new channel to self.channels and initialize its user list.
Called as event handler for RPL_NAMES events. Do not call directly. | [
"Add",
"a",
"new",
"channel",
"to",
"self",
".",
"channels",
"and",
"initialize",
"its",
"user",
"list",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L517-L525 |
239,945 | Kopachris/seshet | seshet/bot.py | SeshetUser.join | def join(self, channel):
"""Add this user to the channel's user list and add the channel to this
user's list of joined channels.
"""
if channel not in self.channels:
channel.users.add(self.nick)
self.channels.append(channel) | python | def join(self, channel):
"""Add this user to the channel's user list and add the channel to this
user's list of joined channels.
"""
if channel not in self.channels:
channel.users.add(self.nick)
self.channels.append(channel) | [
"def",
"join",
"(",
"self",
",",
"channel",
")",
":",
"if",
"channel",
"not",
"in",
"self",
".",
"channels",
":",
"channel",
".",
"users",
".",
"add",
"(",
"self",
".",
"nick",
")",
"self",
".",
"channels",
".",
"append",
"(",
"channel",
")"
] | Add this user to the channel's user list and add the channel to this
user's list of joined channels. | [
"Add",
"this",
"user",
"to",
"the",
"channel",
"s",
"user",
"list",
"and",
"add",
"the",
"channel",
"to",
"this",
"user",
"s",
"list",
"of",
"joined",
"channels",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L23-L30 |
239,946 | Kopachris/seshet | seshet/bot.py | SeshetUser.part | def part(self, channel):
"""Remove this user from the channel's user list and remove the channel
from this user's list of joined channels.
"""
if channel in self.channels:
channel.users.remove(self.nick)
self.channels.remove(channel) | python | def part(self, channel):
"""Remove this user from the channel's user list and remove the channel
from this user's list of joined channels.
"""
if channel in self.channels:
channel.users.remove(self.nick)
self.channels.remove(channel) | [
"def",
"part",
"(",
"self",
",",
"channel",
")",
":",
"if",
"channel",
"in",
"self",
".",
"channels",
":",
"channel",
".",
"users",
".",
"remove",
"(",
"self",
".",
"nick",
")",
"self",
".",
"channels",
".",
"remove",
"(",
"channel",
")"
] | Remove this user from the channel's user list and remove the channel
from this user's list of joined channels. | [
"Remove",
"this",
"user",
"from",
"the",
"channel",
"s",
"user",
"list",
"and",
"remove",
"the",
"channel",
"from",
"this",
"user",
"s",
"list",
"of",
"joined",
"channels",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L32-L39 |
239,947 | Kopachris/seshet | seshet/bot.py | SeshetUser.quit | def quit(self):
"""Remove this user from all channels and reinitialize the user's list
of joined channels.
"""
for c in self.channels:
c.users.remove(self.nick)
self.channels = [] | python | def quit(self):
"""Remove this user from all channels and reinitialize the user's list
of joined channels.
"""
for c in self.channels:
c.users.remove(self.nick)
self.channels = [] | [
"def",
"quit",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"channels",
":",
"c",
".",
"users",
".",
"remove",
"(",
"self",
".",
"nick",
")",
"self",
".",
"channels",
"=",
"[",
"]"
] | Remove this user from all channels and reinitialize the user's list
of joined channels. | [
"Remove",
"this",
"user",
"from",
"all",
"channels",
"and",
"reinitialize",
"the",
"user",
"s",
"list",
"of",
"joined",
"channels",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L41-L48 |
239,948 | Kopachris/seshet | seshet/bot.py | SeshetUser.change_nick | def change_nick(self, nick):
"""Update this user's nick in all joined channels."""
old_nick = self.nick
self.nick = IRCstr(nick)
for c in self.channels:
c.users.remove(old_nick)
c.users.add(self.nick) | python | def change_nick(self, nick):
"""Update this user's nick in all joined channels."""
old_nick = self.nick
self.nick = IRCstr(nick)
for c in self.channels:
c.users.remove(old_nick)
c.users.add(self.nick) | [
"def",
"change_nick",
"(",
"self",
",",
"nick",
")",
":",
"old_nick",
"=",
"self",
".",
"nick",
"self",
".",
"nick",
"=",
"IRCstr",
"(",
"nick",
")",
"for",
"c",
"in",
"self",
".",
"channels",
":",
"c",
".",
"users",
".",
"remove",
"(",
"old_nick",... | Update this user's nick in all joined channels. | [
"Update",
"this",
"user",
"s",
"nick",
"in",
"all",
"joined",
"channels",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L50-L58 |
239,949 | Kopachris/seshet | seshet/bot.py | SeshetChannel.log_message | def log_message(self, user, message):
"""Log a channel message.
This log acts as a sort of cache so that recent activity can be searched
by the bot and command modules without querying the database.
"""
if isinstance(user, SeshetUser):
user = user.ni... | python | def log_message(self, user, message):
"""Log a channel message.
This log acts as a sort of cache so that recent activity can be searched
by the bot and command modules without querying the database.
"""
if isinstance(user, SeshetUser):
user = user.ni... | [
"def",
"log_message",
"(",
"self",
",",
"user",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"user",
",",
"SeshetUser",
")",
":",
"user",
"=",
"user",
".",
"nick",
"elif",
"not",
"isinstance",
"(",
"user",
",",
"IRCstr",
")",
":",
"user",
"=",
... | Log a channel message.
This log acts as a sort of cache so that recent activity can be searched
by the bot and command modules without querying the database. | [
"Log",
"a",
"channel",
"message",
".",
"This",
"log",
"acts",
"as",
"a",
"sort",
"of",
"cache",
"so",
"that",
"recent",
"activity",
"can",
"be",
"searched",
"by",
"the",
"bot",
"and",
"command",
"modules",
"without",
"querying",
"the",
"database",
"."
] | d55bae01cff56762c5467138474145a2c17d1932 | https://github.com/Kopachris/seshet/blob/d55bae01cff56762c5467138474145a2c17d1932/seshet/bot.py#L77-L94 |
239,950 | Archived-Object/ligament | ligament/buildcontext.py | Context.register_dependency | def register_dependency(self, data_src, data_sink):
""" registers a dependency of data_src -> data_sink
by placing appropriate entries in provides_for and depends_on
"""
pdebug("registering dependency %s -> %s" % (data_src, data_sink))
if (data_src not in self._gettask(data... | python | def register_dependency(self, data_src, data_sink):
""" registers a dependency of data_src -> data_sink
by placing appropriate entries in provides_for and depends_on
"""
pdebug("registering dependency %s -> %s" % (data_src, data_sink))
if (data_src not in self._gettask(data... | [
"def",
"register_dependency",
"(",
"self",
",",
"data_src",
",",
"data_sink",
")",
":",
"pdebug",
"(",
"\"registering dependency %s -> %s\"",
"%",
"(",
"data_src",
",",
"data_sink",
")",
")",
"if",
"(",
"data_src",
"not",
"in",
"self",
".",
"_gettask",
"(",
... | registers a dependency of data_src -> data_sink
by placing appropriate entries in provides_for and depends_on | [
"registers",
"a",
"dependency",
"of",
"data_src",
"-",
">",
"data_sink",
"by",
"placing",
"appropriate",
"entries",
"in",
"provides_for",
"and",
"depends_on"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L55-L66 |
239,951 | Archived-Object/ligament | ligament/buildcontext.py | Context.build_task | def build_task(self, name):
""" Builds a task by name, resolving any dependencies on the way """
try:
self._gettask(name).value = (
self._gettask(name).task.resolve_and_build())
except TaskExecutionException as e:
perror(e.header, indent="+0")
... | python | def build_task(self, name):
""" Builds a task by name, resolving any dependencies on the way """
try:
self._gettask(name).value = (
self._gettask(name).task.resolve_and_build())
except TaskExecutionException as e:
perror(e.header, indent="+0")
... | [
"def",
"build_task",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"self",
".",
"_gettask",
"(",
"name",
")",
".",
"value",
"=",
"(",
"self",
".",
"_gettask",
"(",
"name",
")",
".",
"task",
".",
"resolve_and_build",
"(",
")",
")",
"except",
"Task... | Builds a task by name, resolving any dependencies on the way | [
"Builds",
"a",
"task",
"by",
"name",
"resolving",
"any",
"dependencies",
"on",
"the",
"way"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L68-L84 |
239,952 | Archived-Object/ligament | ligament/buildcontext.py | Context.is_build_needed | def is_build_needed(self, data_sink, data_src):
""" returns true if data_src needs to be rebuilt, given that data_sink
has had a rebuild requested.
"""
return (self._gettask(data_src).last_build_time == 0 or
self._gettask(data_src).last_build_time <
se... | python | def is_build_needed(self, data_sink, data_src):
""" returns true if data_src needs to be rebuilt, given that data_sink
has had a rebuild requested.
"""
return (self._gettask(data_src).last_build_time == 0 or
self._gettask(data_src).last_build_time <
se... | [
"def",
"is_build_needed",
"(",
"self",
",",
"data_sink",
",",
"data_src",
")",
":",
"return",
"(",
"self",
".",
"_gettask",
"(",
"data_src",
")",
".",
"last_build_time",
"==",
"0",
"or",
"self",
".",
"_gettask",
"(",
"data_src",
")",
".",
"last_build_time"... | returns true if data_src needs to be rebuilt, given that data_sink
has had a rebuild requested. | [
"returns",
"true",
"if",
"data_src",
"needs",
"to",
"be",
"rebuilt",
"given",
"that",
"data_sink",
"has",
"had",
"a",
"rebuild",
"requested",
"."
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L86-L92 |
239,953 | Archived-Object/ligament | ligament/buildcontext.py | Context.deep_dependendants | def deep_dependendants(self, target):
""" Recursively finds the dependents of a given build target.
Assumes the dependency graph is noncyclic
"""
direct_dependents = self._gettask(target).provides_for
return (direct_dependents +
reduce(
la... | python | def deep_dependendants(self, target):
""" Recursively finds the dependents of a given build target.
Assumes the dependency graph is noncyclic
"""
direct_dependents = self._gettask(target).provides_for
return (direct_dependents +
reduce(
la... | [
"def",
"deep_dependendants",
"(",
"self",
",",
"target",
")",
":",
"direct_dependents",
"=",
"self",
".",
"_gettask",
"(",
"target",
")",
".",
"provides_for",
"return",
"(",
"direct_dependents",
"+",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"+",
... | Recursively finds the dependents of a given build target.
Assumes the dependency graph is noncyclic | [
"Recursively",
"finds",
"the",
"dependents",
"of",
"a",
"given",
"build",
"target",
".",
"Assumes",
"the",
"dependency",
"graph",
"is",
"noncyclic"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L114-L124 |
239,954 | Archived-Object/ligament | ligament/buildcontext.py | Context.resolve_dependency_graph | def resolve_dependency_graph(self, target):
""" resolves the build order for interdependent build targets
Assumes no cyclic dependencies
"""
targets = self.deep_dependendants(target)
# print "deep dependants:", targets
return sorted(targets,
cmp... | python | def resolve_dependency_graph(self, target):
""" resolves the build order for interdependent build targets
Assumes no cyclic dependencies
"""
targets = self.deep_dependendants(target)
# print "deep dependants:", targets
return sorted(targets,
cmp... | [
"def",
"resolve_dependency_graph",
"(",
"self",
",",
"target",
")",
":",
"targets",
"=",
"self",
".",
"deep_dependendants",
"(",
"target",
")",
"# print \"deep dependants:\", targets",
"return",
"sorted",
"(",
"targets",
",",
"cmp",
"=",
"lambda",
"a",
",",
"b",... | resolves the build order for interdependent build targets
Assumes no cyclic dependencies | [
"resolves",
"the",
"build",
"order",
"for",
"interdependent",
"build",
"targets"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L126-L137 |
239,955 | Archived-Object/ligament | ligament/buildcontext.py | DeferredDependency.resolve | def resolve(self):
"""Builds all targets of this dependency and returns the result
of self.function on the resulting values
"""
values = {}
for target_name in self.target_names:
if self.context.is_build_needed(self.parent, target_name):
self.context... | python | def resolve(self):
"""Builds all targets of this dependency and returns the result
of self.function on the resulting values
"""
values = {}
for target_name in self.target_names:
if self.context.is_build_needed(self.parent, target_name):
self.context... | [
"def",
"resolve",
"(",
"self",
")",
":",
"values",
"=",
"{",
"}",
"for",
"target_name",
"in",
"self",
".",
"target_names",
":",
"if",
"self",
".",
"context",
".",
"is_build_needed",
"(",
"self",
".",
"parent",
",",
"target_name",
")",
":",
"self",
".",... | Builds all targets of this dependency and returns the result
of self.function on the resulting values | [
"Builds",
"all",
"targets",
"of",
"this",
"dependency",
"and",
"returns",
"the",
"result",
"of",
"self",
".",
"function",
"on",
"the",
"resulting",
"values"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament/buildcontext.py#L188-L204 |
239,956 | shreyaspotnis/rampage | rampage/widgets/KeyFrameWidgets.py | QKeyFrameList.updateAllKeys | def updateAllKeys(self):
"""Update times for all keys in the layout."""
for kf, key in zip(self.kf_list, self.sorted_key_list()):
kf.update(key, self.dct[key]) | python | def updateAllKeys(self):
"""Update times for all keys in the layout."""
for kf, key in zip(self.kf_list, self.sorted_key_list()):
kf.update(key, self.dct[key]) | [
"def",
"updateAllKeys",
"(",
"self",
")",
":",
"for",
"kf",
",",
"key",
"in",
"zip",
"(",
"self",
".",
"kf_list",
",",
"self",
".",
"sorted_key_list",
"(",
")",
")",
":",
"kf",
".",
"update",
"(",
"key",
",",
"self",
".",
"dct",
"[",
"key",
"]",
... | Update times for all keys in the layout. | [
"Update",
"times",
"for",
"all",
"keys",
"in",
"the",
"layout",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/widgets/KeyFrameWidgets.py#L472-L475 |
239,957 | unfoldingWord-dev/tx-shared-tools | general_tools/print_utils.py | print_with_header | def print_with_header(header, message, color, indent=0):
"""
Use one of the functions below for printing, not this one.
"""
print()
padding = ' ' * indent
print(padding + color + BOLD + header + ENDC + color + message + ENDC) | python | def print_with_header(header, message, color, indent=0):
"""
Use one of the functions below for printing, not this one.
"""
print()
padding = ' ' * indent
print(padding + color + BOLD + header + ENDC + color + message + ENDC) | [
"def",
"print_with_header",
"(",
"header",
",",
"message",
",",
"color",
",",
"indent",
"=",
"0",
")",
":",
"print",
"(",
")",
"padding",
"=",
"' '",
"*",
"indent",
"print",
"(",
"padding",
"+",
"color",
"+",
"BOLD",
"+",
"header",
"+",
"ENDC",
"+",
... | Use one of the functions below for printing, not this one. | [
"Use",
"one",
"of",
"the",
"functions",
"below",
"for",
"printing",
"not",
"this",
"one",
"."
] | 6ff5cd024e1ab54c53dd1bc788bbc78e2358772e | https://github.com/unfoldingWord-dev/tx-shared-tools/blob/6ff5cd024e1ab54c53dd1bc788bbc78e2358772e/general_tools/print_utils.py#L22-L28 |
239,958 | macbre/phantomas-python | phantomas/client.py | Phantomas.run | def run(self):
""" Perform phantomas run """
self._logger.info("running for <{url}>".format(url=self._url))
args = format_args(self._options)
self._logger.debug("command: `{cmd}` / args: {args}".
format(cmd=self._cmd, args=args))
# run the process
... | python | def run(self):
""" Perform phantomas run """
self._logger.info("running for <{url}>".format(url=self._url))
args = format_args(self._options)
self._logger.debug("command: `{cmd}` / args: {args}".
format(cmd=self._cmd, args=args))
# run the process
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"running for <{url}>\"",
".",
"format",
"(",
"url",
"=",
"self",
".",
"_url",
")",
")",
"args",
"=",
"format_args",
"(",
"self",
".",
"_options",
")",
"self",
".",
"_log... | Perform phantomas run | [
"Perform",
"phantomas",
"run"
] | 63b1b1bd3fc97feb460beb6ae509bfb5cccf04f5 | https://github.com/macbre/phantomas-python/blob/63b1b1bd3fc97feb460beb6ae509bfb5cccf04f5/phantomas/client.py#L44-L96 |
239,959 | EnTeQuAk/django-babel-underscore | src/django_babel_underscore/__init__.py | extract | def extract(fileobj, keywords, comment_tags, options):
"""Extracts translation messages from underscore template files.
This method does also extract django templates. If a template does not
contain any django translation tags we always fallback to underscore extraction.
This is a plugin to Babel, wri... | python | def extract(fileobj, keywords, comment_tags, options):
"""Extracts translation messages from underscore template files.
This method does also extract django templates. If a template does not
contain any django translation tags we always fallback to underscore extraction.
This is a plugin to Babel, wri... | [
"def",
"extract",
"(",
"fileobj",
",",
"keywords",
",",
"comment_tags",
",",
"options",
")",
":",
"encoding",
"=",
"options",
".",
"get",
"(",
"'encoding'",
",",
"'utf-8'",
")",
"original_position",
"=",
"fileobj",
".",
"tell",
"(",
")",
"text",
"=",
"fi... | Extracts translation messages from underscore template files.
This method does also extract django templates. If a template does not
contain any django translation tags we always fallback to underscore extraction.
This is a plugin to Babel, written according to
http://babel.pocoo.org/docs/messages/#wr... | [
"Extracts",
"translation",
"messages",
"from",
"underscore",
"template",
"files",
"."
] | cba715691850c956a1ab97c9f2457c6a4016d877 | https://github.com/EnTeQuAk/django-babel-underscore/blob/cba715691850c956a1ab97c9f2457c6a4016d877/src/django_babel_underscore/__init__.py#L16-L90 |
239,960 | boatd/python-boatd | boatdclient/point.py | Point.from_radians | def from_radians(cls, lat_radians, long_radians):
'''
Return a new instance of Point from a pair of coordinates in radians.
'''
return cls(math.degrees(lat_radians), math.degrees(long_radians)) | python | def from_radians(cls, lat_radians, long_radians):
'''
Return a new instance of Point from a pair of coordinates in radians.
'''
return cls(math.degrees(lat_radians), math.degrees(long_radians)) | [
"def",
"from_radians",
"(",
"cls",
",",
"lat_radians",
",",
"long_radians",
")",
":",
"return",
"cls",
"(",
"math",
".",
"degrees",
"(",
"lat_radians",
")",
",",
"math",
".",
"degrees",
"(",
"long_radians",
")",
")"
] | Return a new instance of Point from a pair of coordinates in radians. | [
"Return",
"a",
"new",
"instance",
"of",
"Point",
"from",
"a",
"pair",
"of",
"coordinates",
"in",
"radians",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/point.py#L17-L21 |
239,961 | boatd/python-boatd | boatdclient/point.py | Point.distance_to | def distance_to(self, point):
'''
Return the distance between this point and another point in meters.
:param point: Point to measure distance to
:type point: Point
:returns: The distance to the other point
:rtype: float
'''
angle = math.acos(
... | python | def distance_to(self, point):
'''
Return the distance between this point and another point in meters.
:param point: Point to measure distance to
:type point: Point
:returns: The distance to the other point
:rtype: float
'''
angle = math.acos(
... | [
"def",
"distance_to",
"(",
"self",
",",
"point",
")",
":",
"angle",
"=",
"math",
".",
"acos",
"(",
"sin",
"(",
"self",
".",
"lat_radians",
")",
"*",
"sin",
"(",
"point",
".",
"lat_radians",
")",
"+",
"cos",
"(",
"self",
".",
"lat_radians",
")",
"*"... | Return the distance between this point and another point in meters.
:param point: Point to measure distance to
:type point: Point
:returns: The distance to the other point
:rtype: float | [
"Return",
"the",
"distance",
"between",
"this",
"point",
"and",
"another",
"point",
"in",
"meters",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/point.py#L63-L78 |
239,962 | boatd/python-boatd | boatdclient/point.py | Point.bearing_to | def bearing_to(self, point):
'''
Return the bearing to another point.
:param point: Point to measure bearing to
:type point: Point
:returns: The bearing to the other point
:rtype: Bearing
'''
delta_long = point.long_radians - self.long_radians
y ... | python | def bearing_to(self, point):
'''
Return the bearing to another point.
:param point: Point to measure bearing to
:type point: Point
:returns: The bearing to the other point
:rtype: Bearing
'''
delta_long = point.long_radians - self.long_radians
y ... | [
"def",
"bearing_to",
"(",
"self",
",",
"point",
")",
":",
"delta_long",
"=",
"point",
".",
"long_radians",
"-",
"self",
".",
"long_radians",
"y",
"=",
"sin",
"(",
"delta_long",
")",
"*",
"cos",
"(",
"point",
".",
"lat_radians",
")",
"x",
"=",
"(",
"c... | Return the bearing to another point.
:param point: Point to measure bearing to
:type point: Point
:returns: The bearing to the other point
:rtype: Bearing | [
"Return",
"the",
"bearing",
"to",
"another",
"point",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/point.py#L80-L97 |
239,963 | boatd/python-boatd | boatdclient/point.py | Point.relative_point | def relative_point(self, bearing_to_point, distance):
'''
Return a waypoint at a location described relative to the current point
:param bearing_to_point: Relative bearing from the current waypoint
:type bearing_to_point: Bearing
:param distance: Distance from the current waypoi... | python | def relative_point(self, bearing_to_point, distance):
'''
Return a waypoint at a location described relative to the current point
:param bearing_to_point: Relative bearing from the current waypoint
:type bearing_to_point: Bearing
:param distance: Distance from the current waypoi... | [
"def",
"relative_point",
"(",
"self",
",",
"bearing_to_point",
",",
"distance",
")",
":",
"bearing",
"=",
"math",
".",
"radians",
"(",
"360",
"-",
"bearing_to_point",
")",
"rad_distance",
"=",
"(",
"distance",
"/",
"EARTH_RADIUS",
")",
"lat1",
"=",
"(",
"s... | Return a waypoint at a location described relative to the current point
:param bearing_to_point: Relative bearing from the current waypoint
:type bearing_to_point: Bearing
:param distance: Distance from the current waypoint
:type distance: float
:return: The point described by t... | [
"Return",
"a",
"waypoint",
"at",
"a",
"location",
"described",
"relative",
"to",
"the",
"current",
"point"
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/point.py#L132-L150 |
239,964 | rehandalal/buchner | buchner/project-template/PROJECTMODULE/main.py | create_app | def create_app(settings):
"""Create a new Flask application"""
app = Flask(__name__)
# Import settings from file
for name in dir(settings):
value = getattr(settings, name)
if not (name.startswith('_') or isinstance(value, ModuleType)
or isinstance(value, FunctionType)):
... | python | def create_app(settings):
"""Create a new Flask application"""
app = Flask(__name__)
# Import settings from file
for name in dir(settings):
value = getattr(settings, name)
if not (name.startswith('_') or isinstance(value, ModuleType)
or isinstance(value, FunctionType)):
... | [
"def",
"create_app",
"(",
"settings",
")",
":",
"app",
"=",
"Flask",
"(",
"__name__",
")",
"# Import settings from file",
"for",
"name",
"in",
"dir",
"(",
"settings",
")",
":",
"value",
"=",
"getattr",
"(",
"settings",
",",
"name",
")",
"if",
"not",
"(",... | Create a new Flask application | [
"Create",
"a",
"new",
"Flask",
"application"
] | dc22a61c493b9d4a74d76e8b42a319aa13e385f3 | https://github.com/rehandalal/buchner/blob/dc22a61c493b9d4a74d76e8b42a319aa13e385f3/buchner/project-template/PROJECTMODULE/main.py#L10-L49 |
239,965 | vinu76jsr/pipsort | lib/pipsort/cli.py | main | def main(argv=None):
""" Execute the application CLI.
Arguments are taken from sys.argv by default.
"""
args = _cmdline(argv)
config.load(args.config)
results = get_package_list(args.search_term)
results = sorted(results, key=lambda a: sort_function(a[1]), reverse=True)
results_normali... | python | def main(argv=None):
""" Execute the application CLI.
Arguments are taken from sys.argv by default.
"""
args = _cmdline(argv)
config.load(args.config)
results = get_package_list(args.search_term)
results = sorted(results, key=lambda a: sort_function(a[1]), reverse=True)
results_normali... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"args",
"=",
"_cmdline",
"(",
"argv",
")",
"config",
".",
"load",
"(",
"args",
".",
"config",
")",
"results",
"=",
"get_package_list",
"(",
"args",
".",
"search_term",
")",
"results",
"=",
"sorted",
... | Execute the application CLI.
Arguments are taken from sys.argv by default. | [
"Execute",
"the",
"application",
"CLI",
"."
] | 71ead1269de85ee0255741390bf1da85d81b7d16 | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/lib/pipsort/cli.py#L60-L78 |
239,966 | Perfectial/django-view-acl | view_acl/utils.py | generate_permissions | def generate_permissions(urlpatterns, permissions={}):
"""Generate names for permissions."""
for pattern in urlpatterns:
if isinstance(pattern, urlresolvers.RegexURLPattern):
perm = generate_perm_name(pattern.callback)
if is_allowed_view(perm) and perm not in permissions:
... | python | def generate_permissions(urlpatterns, permissions={}):
"""Generate names for permissions."""
for pattern in urlpatterns:
if isinstance(pattern, urlresolvers.RegexURLPattern):
perm = generate_perm_name(pattern.callback)
if is_allowed_view(perm) and perm not in permissions:
... | [
"def",
"generate_permissions",
"(",
"urlpatterns",
",",
"permissions",
"=",
"{",
"}",
")",
":",
"for",
"pattern",
"in",
"urlpatterns",
":",
"if",
"isinstance",
"(",
"pattern",
",",
"urlresolvers",
".",
"RegexURLPattern",
")",
":",
"perm",
"=",
"generate_perm_n... | Generate names for permissions. | [
"Generate",
"names",
"for",
"permissions",
"."
] | 71f514f65761895bc64d5ca735997c5455c254fa | https://github.com/Perfectial/django-view-acl/blob/71f514f65761895bc64d5ca735997c5455c254fa/view_acl/utils.py#L16-L25 |
239,967 | Perfectial/django-view-acl | view_acl/utils.py | is_allowed_view | def is_allowed_view(perm):
"""Check if permission is in acl list."""
# Check if permission is in excluded list
for view in ACL_EXCLUDED_VIEWS:
module, separator, view_name = view.partition('*')
if view and perm.startswith(module):
return False
# Check if permission is in ac... | python | def is_allowed_view(perm):
"""Check if permission is in acl list."""
# Check if permission is in excluded list
for view in ACL_EXCLUDED_VIEWS:
module, separator, view_name = view.partition('*')
if view and perm.startswith(module):
return False
# Check if permission is in ac... | [
"def",
"is_allowed_view",
"(",
"perm",
")",
":",
"# Check if permission is in excluded list",
"for",
"view",
"in",
"ACL_EXCLUDED_VIEWS",
":",
"module",
",",
"separator",
",",
"view_name",
"=",
"view",
".",
"partition",
"(",
"'*'",
")",
"if",
"view",
"and",
"perm... | Check if permission is in acl list. | [
"Check",
"if",
"permission",
"is",
"in",
"acl",
"list",
"."
] | 71f514f65761895bc64d5ca735997c5455c254fa | https://github.com/Perfectial/django-view-acl/blob/71f514f65761895bc64d5ca735997c5455c254fa/view_acl/utils.py#L34-L54 |
239,968 | openp2pdesign/makerlabs | makerlabs/utils.py | get_location | def get_location(query, format, api_key):
"""Get geographic data of a lab in a coherent way for all labs."""
# Play nice with the API...
sleep(1)
geolocator = OpenCage(api_key=api_key, timeout=10)
# Variables for storing the data
data = {"city": None,
"address_1": None,
... | python | def get_location(query, format, api_key):
"""Get geographic data of a lab in a coherent way for all labs."""
# Play nice with the API...
sleep(1)
geolocator = OpenCage(api_key=api_key, timeout=10)
# Variables for storing the data
data = {"city": None,
"address_1": None,
... | [
"def",
"get_location",
"(",
"query",
",",
"format",
",",
"api_key",
")",
":",
"# Play nice with the API...",
"sleep",
"(",
"1",
")",
"geolocator",
"=",
"OpenCage",
"(",
"api_key",
"=",
"api_key",
",",
"timeout",
"=",
"10",
")",
"# Variables for storing the data"... | Get geographic data of a lab in a coherent way for all labs. | [
"Get",
"geographic",
"data",
"of",
"a",
"lab",
"in",
"a",
"coherent",
"way",
"for",
"all",
"labs",
"."
] | b5838440174f10d370abb671358db9a99d7739fd | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/utils.py#L18-L110 |
239,969 | vilmibm/done | sql_interp/sql_interp.py | SQLInterp.interp | def interp(self, *args):
"""
This method takes a list of SQL snippets and returns a SQL statement and
a list of bind variables to be passed to the DB API's execute method.
"""
sql = ""
bind = ()
def _append_sql(sql, part):
"Handle whitespace when appe... | python | def interp(self, *args):
"""
This method takes a list of SQL snippets and returns a SQL statement and
a list of bind variables to be passed to the DB API's execute method.
"""
sql = ""
bind = ()
def _append_sql(sql, part):
"Handle whitespace when appe... | [
"def",
"interp",
"(",
"self",
",",
"*",
"args",
")",
":",
"sql",
"=",
"\"\"",
"bind",
"=",
"(",
")",
"def",
"_append_sql",
"(",
"sql",
",",
"part",
")",
":",
"\"Handle whitespace when appending properly.\"",
"if",
"len",
"(",
"sql",
")",
"==",
"0",
":"... | This method takes a list of SQL snippets and returns a SQL statement and
a list of bind variables to be passed to the DB API's execute method. | [
"This",
"method",
"takes",
"a",
"list",
"of",
"SQL",
"snippets",
"and",
"returns",
"a",
"SQL",
"statement",
"and",
"a",
"list",
"of",
"bind",
"variables",
"to",
"be",
"passed",
"to",
"the",
"DB",
"API",
"s",
"execute",
"method",
"."
] | 7e5b60d2900ceddefa49de352a19b794199b51a8 | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/sql_interp/sql_interp.py#L16-L50 |
239,970 | vilmibm/done | sql_interp/sql_interp.py | SQLInterp.esc | def esc(self, val):
"""
Returns the given object in the appropriate wrapper class from esc_types.py.
In most cases, you will not need to call this directly. However, if you are
passing a string to the interp method that should be used as an SQL bind value
and not raw SQL, you m... | python | def esc(self, val):
"""
Returns the given object in the appropriate wrapper class from esc_types.py.
In most cases, you will not need to call this directly. However, if you are
passing a string to the interp method that should be used as an SQL bind value
and not raw SQL, you m... | [
"def",
"esc",
"(",
"self",
",",
"val",
")",
":",
"if",
"type",
"(",
"val",
")",
"in",
"self",
".",
"type_map",
":",
"return",
"self",
".",
"type_map",
"[",
"type",
"(",
"val",
")",
"]",
"(",
"val",
")",
"else",
":",
"return",
"Esc",
"(",
"val",... | Returns the given object in the appropriate wrapper class from esc_types.py.
In most cases, you will not need to call this directly. However, if you are
passing a string to the interp method that should be used as an SQL bind value
and not raw SQL, you must pass it to this method to avoid a SQ... | [
"Returns",
"the",
"given",
"object",
"in",
"the",
"appropriate",
"wrapper",
"class",
"from",
"esc_types",
".",
"py",
"."
] | 7e5b60d2900ceddefa49de352a19b794199b51a8 | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/sql_interp/sql_interp.py#L52-L77 |
239,971 | arcus-io/puppetdb-python | puppetdb/utils.py | api_request | def api_request(api_base_url='http://localhost:8080/', path='', method='get',
data=None, params={}, verify=True, cert=list()):
"""
Wrapper function for requests
:param api_base_url: Base URL for requests
:param path: Path to request
:param method: HTTP method
:param data: Data for post (ign... | python | def api_request(api_base_url='http://localhost:8080/', path='', method='get',
data=None, params={}, verify=True, cert=list()):
"""
Wrapper function for requests
:param api_base_url: Base URL for requests
:param path: Path to request
:param method: HTTP method
:param data: Data for post (ign... | [
"def",
"api_request",
"(",
"api_base_url",
"=",
"'http://localhost:8080/'",
",",
"path",
"=",
"''",
",",
"method",
"=",
"'get'",
",",
"data",
"=",
"None",
",",
"params",
"=",
"{",
"}",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"list",
"(",
")",
"... | Wrapper function for requests
:param api_base_url: Base URL for requests
:param path: Path to request
:param method: HTTP method
:param data: Data for post (ignored for GETs)
:param params: Dict of key, value query params
:param verify: True/False/CA_File_Name to perform SSL Verification of CA ... | [
"Wrapper",
"function",
"for",
"requests"
] | d772eb80a1dfb1154a1f421c7ecdc1ac951b5ea2 | https://github.com/arcus-io/puppetdb-python/blob/d772eb80a1dfb1154a1f421c7ecdc1ac951b5ea2/puppetdb/utils.py#L29-L59 |
239,972 | fr33jc/bang | bang/cmd_bang.py | set_ssh_creds | def set_ssh_creds(config, args):
"""
Set ssh credentials into config.
Note that these values might also be set in ~/.bangrc. If they are
specified both in ~/.bangrc and as command-line arguments to ``bang``, then
the command-line arguments win.
"""
creds = config.get(A.DEPLOYER_CREDS, {})... | python | def set_ssh_creds(config, args):
"""
Set ssh credentials into config.
Note that these values might also be set in ~/.bangrc. If they are
specified both in ~/.bangrc and as command-line arguments to ``bang``, then
the command-line arguments win.
"""
creds = config.get(A.DEPLOYER_CREDS, {})... | [
"def",
"set_ssh_creds",
"(",
"config",
",",
"args",
")",
":",
"creds",
"=",
"config",
".",
"get",
"(",
"A",
".",
"DEPLOYER_CREDS",
",",
"{",
"}",
")",
"creds",
"[",
"A",
".",
"creds",
".",
"SSH_USER",
"]",
"=",
"args",
".",
"user",
"if",
"args",
... | Set ssh credentials into config.
Note that these values might also be set in ~/.bangrc. If they are
specified both in ~/.bangrc and as command-line arguments to ``bang``, then
the command-line arguments win. | [
"Set",
"ssh",
"credentials",
"into",
"config",
"."
] | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/cmd_bang.py#L39-L55 |
239,973 | fr33jc/bang | bang/cmd_bang.py | run_bang | def run_bang(alt_args=None):
"""
Runs bang with optional list of strings as command line options.
If ``alt_args`` is not specified, defaults to parsing ``sys.argv`` for
command line options.
"""
parser = get_parser()
args = parser.parse_args(alt_args)
source = args.config_specs or get_... | python | def run_bang(alt_args=None):
"""
Runs bang with optional list of strings as command line options.
If ``alt_args`` is not specified, defaults to parsing ``sys.argv`` for
command line options.
"""
parser = get_parser()
args = parser.parse_args(alt_args)
source = args.config_specs or get_... | [
"def",
"run_bang",
"(",
"alt_args",
"=",
"None",
")",
":",
"parser",
"=",
"get_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"alt_args",
")",
"source",
"=",
"args",
".",
"config_specs",
"or",
"get_env_configs",
"(",
")",
"if",
"not",
... | Runs bang with optional list of strings as command line options.
If ``alt_args`` is not specified, defaults to parsing ``sys.argv`` for
command line options. | [
"Runs",
"bang",
"with",
"optional",
"list",
"of",
"strings",
"as",
"command",
"line",
"options",
"."
] | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/cmd_bang.py#L209-L258 |
239,974 | listen-lavender/webcrawl | webcrawl/daemon.py | Daemon.monitor | def monitor(self, timeout):
"""
Monitor the process, check whether it runs out of time.
"""
def check(self, timeout):
time.sleep(timeout)
self.stop()
wather = threading.Thread(target=check)
wather.setDaemon(True)
wather.start() | python | def monitor(self, timeout):
"""
Monitor the process, check whether it runs out of time.
"""
def check(self, timeout):
time.sleep(timeout)
self.stop()
wather = threading.Thread(target=check)
wather.setDaemon(True)
wather.start() | [
"def",
"monitor",
"(",
"self",
",",
"timeout",
")",
":",
"def",
"check",
"(",
"self",
",",
"timeout",
")",
":",
"time",
".",
"sleep",
"(",
"timeout",
")",
"self",
".",
"stop",
"(",
")",
"wather",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",... | Monitor the process, check whether it runs out of time. | [
"Monitor",
"the",
"process",
"check",
"whether",
"it",
"runs",
"out",
"of",
"time",
"."
] | 905dcfa6e6934aac764045660c0efcef28eae1e6 | https://github.com/listen-lavender/webcrawl/blob/905dcfa6e6934aac764045660c0efcef28eae1e6/webcrawl/daemon.py#L164-L174 |
239,975 | DecBayComp/RWA-python | rwa/hdf5.py | hdf5_storable | def hdf5_storable(type_or_storable, *args, **kwargs):
'''Registers a `Storable` instance in the global service.'''
if not isinstance(type_or_storable, Storable):
type_or_storable = default_storable(type_or_storable)
hdf5_service.registerStorable(type_or_storable, *args, **kwargs) | python | def hdf5_storable(type_or_storable, *args, **kwargs):
'''Registers a `Storable` instance in the global service.'''
if not isinstance(type_or_storable, Storable):
type_or_storable = default_storable(type_or_storable)
hdf5_service.registerStorable(type_or_storable, *args, **kwargs) | [
"def",
"hdf5_storable",
"(",
"type_or_storable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"type_or_storable",
",",
"Storable",
")",
":",
"type_or_storable",
"=",
"default_storable",
"(",
"type_or_storable",
")",
"hdf... | Registers a `Storable` instance in the global service. | [
"Registers",
"a",
"Storable",
"instance",
"in",
"the",
"global",
"service",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/hdf5.py#L266-L270 |
239,976 | DecBayComp/RWA-python | rwa/hdf5.py | hdf5_not_storable | def hdf5_not_storable(_type, *args, **kwargs):
'''Tags a type as not serializable.'''
hdf5_service.registerStorable(not_storable(_type), *args, **kwargs) | python | def hdf5_not_storable(_type, *args, **kwargs):
'''Tags a type as not serializable.'''
hdf5_service.registerStorable(not_storable(_type), *args, **kwargs) | [
"def",
"hdf5_not_storable",
"(",
"_type",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"hdf5_service",
".",
"registerStorable",
"(",
"not_storable",
"(",
"_type",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Tags a type as not serializable. | [
"Tags",
"a",
"type",
"as",
"not",
"serializable",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/hdf5.py#L272-L274 |
239,977 | Archived-Object/ligament | ligament_precompiler_template/__init__.py | Precompiler.compile_and_process | def compile_and_process(self, in_path):
"""compile a file, save it to the ouput file if the inline flag true"""
out_path = self.path_mapping[in_path]
if not self.embed:
pdebug("[%s::%s] %s -> %s" % (
self.compiler_name,
self.name,
os.p... | python | def compile_and_process(self, in_path):
"""compile a file, save it to the ouput file if the inline flag true"""
out_path = self.path_mapping[in_path]
if not self.embed:
pdebug("[%s::%s] %s -> %s" % (
self.compiler_name,
self.name,
os.p... | [
"def",
"compile_and_process",
"(",
"self",
",",
"in_path",
")",
":",
"out_path",
"=",
"self",
".",
"path_mapping",
"[",
"in_path",
"]",
"if",
"not",
"self",
".",
"embed",
":",
"pdebug",
"(",
"\"[%s::%s] %s -> %s\"",
"%",
"(",
"self",
".",
"compiler_name",
... | compile a file, save it to the ouput file if the inline flag true | [
"compile",
"a",
"file",
"save",
"it",
"to",
"the",
"ouput",
"file",
"if",
"the",
"inline",
"flag",
"true"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament_precompiler_template/__init__.py#L87-L114 |
239,978 | Archived-Object/ligament | ligament_precompiler_template/__init__.py | Precompiler.collect_output | def collect_output(self):
""" helper function to gather the results of `compile_and_process` on
all target files
"""
if self.embed:
if self.concat:
concat_scripts = [self.compiled_scripts[path]
for path in self.build_order... | python | def collect_output(self):
""" helper function to gather the results of `compile_and_process` on
all target files
"""
if self.embed:
if self.concat:
concat_scripts = [self.compiled_scripts[path]
for path in self.build_order... | [
"def",
"collect_output",
"(",
"self",
")",
":",
"if",
"self",
".",
"embed",
":",
"if",
"self",
".",
"concat",
":",
"concat_scripts",
"=",
"[",
"self",
".",
"compiled_scripts",
"[",
"path",
"]",
"for",
"path",
"in",
"self",
".",
"build_order",
"]",
"ret... | helper function to gather the results of `compile_and_process` on
all target files | [
"helper",
"function",
"to",
"gather",
"the",
"results",
"of",
"compile_and_process",
"on",
"all",
"target",
"files"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament_precompiler_template/__init__.py#L116-L139 |
239,979 | Archived-Object/ligament | ligament_precompiler_template/__init__.py | Precompiler.build | def build(self):
"""build the scripts and return a string"""
if not self.embed:
mkdir_recursive(self.output_directory)
# get list of script files in build order
self.build_order = remove_dups(
reduce(lambda a, b: a + glob.glob(b),
self.build_t... | python | def build(self):
"""build the scripts and return a string"""
if not self.embed:
mkdir_recursive(self.output_directory)
# get list of script files in build order
self.build_order = remove_dups(
reduce(lambda a, b: a + glob.glob(b),
self.build_t... | [
"def",
"build",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"embed",
":",
"mkdir_recursive",
"(",
"self",
".",
"output_directory",
")",
"# get list of script files in build order",
"self",
".",
"build_order",
"=",
"remove_dups",
"(",
"reduce",
"(",
"lambda"... | build the scripts and return a string | [
"build",
"the",
"scripts",
"and",
"return",
"a",
"string"
] | ff3d78130522676a20dc64086dc8a27b197cc20f | https://github.com/Archived-Object/ligament/blob/ff3d78130522676a20dc64086dc8a27b197cc20f/ligament_precompiler_template/__init__.py#L141-L181 |
239,980 | bernoulli-metrics/bernoulli-python | bernoulli/client_api.py | get_experiments | def get_experiments(experiment_ids=None, user_id=None, client_id=None, bucket_if_necessary=True, user_data=None):
"""
Retrieve the experiments the user is a part of
@param experiment_ids : Either a single or list of experiment ids to retreive
@param user_id : An identifier for the user
@param client... | python | def get_experiments(experiment_ids=None, user_id=None, client_id=None, bucket_if_necessary=True, user_data=None):
"""
Retrieve the experiments the user is a part of
@param experiment_ids : Either a single or list of experiment ids to retreive
@param user_id : An identifier for the user
@param client... | [
"def",
"get_experiments",
"(",
"experiment_ids",
"=",
"None",
",",
"user_id",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"bucket_if_necessary",
"=",
"True",
",",
"user_data",
"=",
"None",
")",
":",
"if",
"not",
"client_id",
":",
"client_id",
"=",
"os... | Retrieve the experiments the user is a part of
@param experiment_ids : Either a single or list of experiment ids to retreive
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID - will default to BERNOULLI_CLIENT_ID ENV variable
@param bucket_if_necessary : Choose a variant... | [
"Retrieve",
"the",
"experiments",
"the",
"user",
"is",
"a",
"part",
"of"
] | 572bd165ac354eb4b95ac3abdfe74b67f4fd703b | https://github.com/bernoulli-metrics/bernoulli-python/blob/572bd165ac354eb4b95ac3abdfe74b67f4fd703b/bernoulli/client_api.py#L6-L44 |
239,981 | bernoulli-metrics/bernoulli-python | bernoulli/client_api.py | record_goal_attained | def record_goal_attained(experiment_id, user_id, client_id = None):
"""
Record that a variant was successful for a user
@param experiment_id : A single experiment id
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID
"""
if not client_id:
client_id = ... | python | def record_goal_attained(experiment_id, user_id, client_id = None):
"""
Record that a variant was successful for a user
@param experiment_id : A single experiment id
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID
"""
if not client_id:
client_id = ... | [
"def",
"record_goal_attained",
"(",
"experiment_id",
",",
"user_id",
",",
"client_id",
"=",
"None",
")",
":",
"if",
"not",
"client_id",
":",
"client_id",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'BERNOULLI_CLIENT_ID'",
")",
"if",
"not",
"client_id",
":",... | Record that a variant was successful for a user
@param experiment_id : A single experiment id
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID | [
"Record",
"that",
"a",
"variant",
"was",
"successful",
"for",
"a",
"user"
] | 572bd165ac354eb4b95ac3abdfe74b67f4fd703b | https://github.com/bernoulli-metrics/bernoulli-python/blob/572bd165ac354eb4b95ac3abdfe74b67f4fd703b/bernoulli/client_api.py#L46-L73 |
239,982 | Fuyukai/ConfigMaster | configmaster/YAMLConfigFile.py | yaml_dump_hook | def yaml_dump_hook(cfg, text: bool=False):
"""
Dumps all the data into a YAML file.
"""
data = cfg.config.dump()
if not text:
yaml.dump(data, cfg.fd, Dumper=cfg.dumper, default_flow_style=False)
else:
return yaml.dump(data, Dumper=cfg.dumper, default_flow_style=False) | python | def yaml_dump_hook(cfg, text: bool=False):
"""
Dumps all the data into a YAML file.
"""
data = cfg.config.dump()
if not text:
yaml.dump(data, cfg.fd, Dumper=cfg.dumper, default_flow_style=False)
else:
return yaml.dump(data, Dumper=cfg.dumper, default_flow_style=False) | [
"def",
"yaml_dump_hook",
"(",
"cfg",
",",
"text",
":",
"bool",
"=",
"False",
")",
":",
"data",
"=",
"cfg",
".",
"config",
".",
"dump",
"(",
")",
"if",
"not",
"text",
":",
"yaml",
".",
"dump",
"(",
"data",
",",
"cfg",
".",
"fd",
",",
"Dumper",
"... | Dumps all the data into a YAML file. | [
"Dumps",
"all",
"the",
"data",
"into",
"a",
"YAML",
"file",
"."
] | 8018aa415da55c84edaa8a49664f674758a14edd | https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/YAMLConfigFile.py#L94-L103 |
239,983 | bretth/djset | djset/commands.py | _create_djset | def _create_djset(args, cls):
""" Return a DjSecret object """
name = args.get('--name')
settings = args.get('--settings')
if name:
return cls(name=name)
elif settings:
return cls(name=settings)
else:
return cls() | python | def _create_djset(args, cls):
""" Return a DjSecret object """
name = args.get('--name')
settings = args.get('--settings')
if name:
return cls(name=name)
elif settings:
return cls(name=settings)
else:
return cls() | [
"def",
"_create_djset",
"(",
"args",
",",
"cls",
")",
":",
"name",
"=",
"args",
".",
"get",
"(",
"'--name'",
")",
"settings",
"=",
"args",
".",
"get",
"(",
"'--settings'",
")",
"if",
"name",
":",
"return",
"cls",
"(",
"name",
"=",
"name",
")",
"eli... | Return a DjSecret object | [
"Return",
"a",
"DjSecret",
"object"
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/commands.py#L16-L25 |
239,984 | bretth/djset | djset/commands.py | _parse_args | def _parse_args(args, cls):
""" Parse a docopt dictionary of arguments """
d = _create_djset(args, cls)
key_value_pair = args.get('<key>=<value>')
key = args.get('<key>')
func = None
if args.get('add') and key_value_pair:
fargs = tuple(args.get('<key>=<value>').split('='))
... | python | def _parse_args(args, cls):
""" Parse a docopt dictionary of arguments """
d = _create_djset(args, cls)
key_value_pair = args.get('<key>=<value>')
key = args.get('<key>')
func = None
if args.get('add') and key_value_pair:
fargs = tuple(args.get('<key>=<value>').split('='))
... | [
"def",
"_parse_args",
"(",
"args",
",",
"cls",
")",
":",
"d",
"=",
"_create_djset",
"(",
"args",
",",
"cls",
")",
"key_value_pair",
"=",
"args",
".",
"get",
"(",
"'<key>=<value>'",
")",
"key",
"=",
"args",
".",
"get",
"(",
"'<key>'",
")",
"func",
"="... | Parse a docopt dictionary of arguments | [
"Parse",
"a",
"docopt",
"dictionary",
"of",
"arguments"
] | e04cbcadc311f6edec50a718415d0004aa304034 | https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/commands.py#L28-L47 |
239,985 | ddorn/pyconfiglib | configlib/core.py | prompt_update_all | def prompt_update_all(config: 'Config'):
"""Prompt each field of the configuration to the user."""
click.echo()
click.echo('Welcome !')
click.echo('Press enter to keep the defaults or enter a new value to update the configuration.')
click.echo('Press Ctrl+C at any time to quit and save')
click.... | python | def prompt_update_all(config: 'Config'):
"""Prompt each field of the configuration to the user."""
click.echo()
click.echo('Welcome !')
click.echo('Press enter to keep the defaults or enter a new value to update the configuration.')
click.echo('Press Ctrl+C at any time to quit and save')
click.... | [
"def",
"prompt_update_all",
"(",
"config",
":",
"'Config'",
")",
":",
"click",
".",
"echo",
"(",
")",
"click",
".",
"echo",
"(",
"'Welcome !'",
")",
"click",
".",
"echo",
"(",
"'Press enter to keep the defaults or enter a new value to update the configuration.'",
")",... | Prompt each field of the configuration to the user. | [
"Prompt",
"each",
"field",
"of",
"the",
"configuration",
"to",
"the",
"user",
"."
] | 3ad01d0bb9344e18719d82a5928b4d8e5fe726ac | https://github.com/ddorn/pyconfiglib/blob/3ad01d0bb9344e18719d82a5928b4d8e5fe726ac/configlib/core.py#L85-L128 |
239,986 | ddorn/pyconfiglib | configlib/core.py | update_config | def update_config(configclass: type(Config)):
"""Command line function to update and the a config."""
# we build the real click command inside the function, because it needs to be done
# dynamically, depending on the config.
# we ignore the type errors, keeping the the defaults if needed
# everyth... | python | def update_config(configclass: type(Config)):
"""Command line function to update and the a config."""
# we build the real click command inside the function, because it needs to be done
# dynamically, depending on the config.
# we ignore the type errors, keeping the the defaults if needed
# everyth... | [
"def",
"update_config",
"(",
"configclass",
":",
"type",
"(",
"Config",
")",
")",
":",
"# we build the real click command inside the function, because it needs to be done",
"# dynamically, depending on the config.",
"# we ignore the type errors, keeping the the defaults if needed",
"# ev... | Command line function to update and the a config. | [
"Command",
"line",
"function",
"to",
"update",
"and",
"the",
"a",
"config",
"."
] | 3ad01d0bb9344e18719d82a5928b4d8e5fe726ac | https://github.com/ddorn/pyconfiglib/blob/3ad01d0bb9344e18719d82a5928b4d8e5fe726ac/configlib/core.py#L495-L603 |
239,987 | Deisss/python-sockjsroom | examples/chat/server.py | configureLogger | def configureLogger(logFolder, logFile):
''' Start the logger instance and configure it '''
# Set debug level
logLevel = 'DEBUG'
logger = logging.getLogger()
logger.setLevel(logLevel)
# Format
formatter = logging.Formatter('%(asctime)s - %(levelname)s | %(name)s -> %(message)s', '%Y-%m-%d %... | python | def configureLogger(logFolder, logFile):
''' Start the logger instance and configure it '''
# Set debug level
logLevel = 'DEBUG'
logger = logging.getLogger()
logger.setLevel(logLevel)
# Format
formatter = logging.Formatter('%(asctime)s - %(levelname)s | %(name)s -> %(message)s', '%Y-%m-%d %... | [
"def",
"configureLogger",
"(",
"logFolder",
",",
"logFile",
")",
":",
"# Set debug level",
"logLevel",
"=",
"'DEBUG'",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"logger",
".",
"setLevel",
"(",
"logLevel",
")",
"# Format",
"formatter",
"=",
"logging... | Start the logger instance and configure it | [
"Start",
"the",
"logger",
"instance",
"and",
"configure",
"it"
] | 7c20187571d39e7fede848dc98f954235ca77241 | https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/examples/chat/server.py#L111-L153 |
239,988 | Deisss/python-sockjsroom | examples/chat/server.py | printWelcomeMessage | def printWelcomeMessage(msg, place=10):
''' Print any welcome message '''
logging.debug('*' * 30)
welcome = ' ' * place
welcome+= msg
logging.debug(welcome)
logging.debug('*' * 30 + '\n') | python | def printWelcomeMessage(msg, place=10):
''' Print any welcome message '''
logging.debug('*' * 30)
welcome = ' ' * place
welcome+= msg
logging.debug(welcome)
logging.debug('*' * 30 + '\n') | [
"def",
"printWelcomeMessage",
"(",
"msg",
",",
"place",
"=",
"10",
")",
":",
"logging",
".",
"debug",
"(",
"'*'",
"*",
"30",
")",
"welcome",
"=",
"' '",
"*",
"place",
"welcome",
"+=",
"msg",
"logging",
".",
"debug",
"(",
"welcome",
")",
"logging",
".... | Print any welcome message | [
"Print",
"any",
"welcome",
"message"
] | 7c20187571d39e7fede848dc98f954235ca77241 | https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/examples/chat/server.py#L155-L162 |
239,989 | Deisss/python-sockjsroom | examples/chat/server.py | ChatSocketHandler.on_chat | def on_chat(self, data):
''' Transfert a message to everybody '''
# XXX: we cannot use on_message as it's 'official' one already used
# by sockjsroom to create multiple on_* elements (like on_chat),
# so we use on_chat instead of on_message
# data => message
if self.room... | python | def on_chat(self, data):
''' Transfert a message to everybody '''
# XXX: we cannot use on_message as it's 'official' one already used
# by sockjsroom to create multiple on_* elements (like on_chat),
# so we use on_chat instead of on_message
# data => message
if self.room... | [
"def",
"on_chat",
"(",
"self",
",",
"data",
")",
":",
"# XXX: we cannot use on_message as it's 'official' one already used",
"# by sockjsroom to create multiple on_* elements (like on_chat),",
"# so we use on_chat instead of on_message",
"# data => message",
"if",
"self",
".",
"roomId"... | Transfert a message to everybody | [
"Transfert",
"a",
"message",
"to",
"everybody"
] | 7c20187571d39e7fede848dc98f954235ca77241 | https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/examples/chat/server.py#L61-L73 |
239,990 | Deisss/python-sockjsroom | examples/chat/server.py | ChatSocketHandler.on_leave | def on_leave(self):
''' Quit chat room '''
# Only if user has time to call self.initialize
# (sometimes it's not the case)
if self.roomId != '-1':
# Debug
logging.debug('chat: leave room (roomId: %s)' % self.roomId)
# Say to other users the current us... | python | def on_leave(self):
''' Quit chat room '''
# Only if user has time to call self.initialize
# (sometimes it's not the case)
if self.roomId != '-1':
# Debug
logging.debug('chat: leave room (roomId: %s)' % self.roomId)
# Say to other users the current us... | [
"def",
"on_leave",
"(",
"self",
")",
":",
"# Only if user has time to call self.initialize",
"# (sometimes it's not the case)",
"if",
"self",
".",
"roomId",
"!=",
"'-1'",
":",
"# Debug",
"logging",
".",
"debug",
"(",
"'chat: leave room (roomId: %s)'",
"%",
"self",
".",
... | Quit chat room | [
"Quit",
"chat",
"room"
] | 7c20187571d39e7fede848dc98f954235ca77241 | https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/examples/chat/server.py#L76-L93 |
239,991 | klmitch/tendril | tendril/udp.py | UDPTendrilManager.connect | def connect(self, target, acceptor):
"""
Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a UDPTendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:param accepto... | python | def connect(self, target, acceptor):
"""
Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a UDPTendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:param accepto... | [
"def",
"connect",
"(",
"self",
",",
"target",
",",
"acceptor",
")",
":",
"# Call some common sanity-checks",
"super",
"(",
"UDPTendrilManager",
",",
"self",
")",
".",
"connect",
"(",
"target",
",",
"acceptor",
",",
"None",
")",
"# Construct the Tendril",
"tend",... | Initiate a connection from the tendril manager's endpoint.
Once the connection is completed, a UDPTendril object will be
created and passed to the given acceptor.
:param target: The target of the connection attempt.
:param acceptor: A callable which will initialize the state of
... | [
"Initiate",
"a",
"connection",
"from",
"the",
"tendril",
"manager",
"s",
"endpoint",
".",
"Once",
"the",
"connection",
"is",
"completed",
"a",
"UDPTendril",
"object",
"will",
"be",
"created",
"and",
"passed",
"to",
"the",
"given",
"acceptor",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/udp.py#L157-L185 |
239,992 | klmitch/tendril | tendril/udp.py | UDPTendrilManager.listener | def listener(self, acceptor, wrapper):
"""
Listens for new connections to the manager's endpoint. Once a
new connection is received, a UDPTendril object is generated
for it and it is passed to the acceptor, which must initialize
the state of the connection. If no acceptor is gi... | python | def listener(self, acceptor, wrapper):
"""
Listens for new connections to the manager's endpoint. Once a
new connection is received, a UDPTendril object is generated
for it and it is passed to the acceptor, which must initialize
the state of the connection. If no acceptor is gi... | [
"def",
"listener",
"(",
"self",
",",
"acceptor",
",",
"wrapper",
")",
":",
"# OK, set up the socket",
"sock",
"=",
"socket",
".",
"socket",
"(",
"self",
".",
"addr_family",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"with",
"utils",
".",
"SocketCloser",
"(",
"... | Listens for new connections to the manager's endpoint. Once a
new connection is received, a UDPTendril object is generated
for it and it is passed to the acceptor, which must initialize
the state of the connection. If no acceptor is given, no new
connections can be initialized.
... | [
"Listens",
"for",
"new",
"connections",
"to",
"the",
"manager",
"s",
"endpoint",
".",
"Once",
"a",
"new",
"connection",
"is",
"received",
"a",
"UDPTendril",
"object",
"is",
"generated",
"for",
"it",
"and",
"it",
"is",
"passed",
"to",
"the",
"acceptor",
"wh... | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/udp.py#L187-L260 |
239,993 | fr33jc/bang | bang/providers/hpcloud/load_balancer.py | HPLoadBalancer.add_lb_nodes | def add_lb_nodes(self, lb_id, nodes):
"""
Adds nodes to an existing LBaaS instance
:param string lb_id: Balancer id
:param list nodes: Nodes to add. {address, port, [condition]}
:rtype :class:`list`
"""
log.info("Adding load balancer nodes %s" % nodes)
... | python | def add_lb_nodes(self, lb_id, nodes):
"""
Adds nodes to an existing LBaaS instance
:param string lb_id: Balancer id
:param list nodes: Nodes to add. {address, port, [condition]}
:rtype :class:`list`
"""
log.info("Adding load balancer nodes %s" % nodes)
... | [
"def",
"add_lb_nodes",
"(",
"self",
",",
"lb_id",
",",
"nodes",
")",
":",
"log",
".",
"info",
"(",
"\"Adding load balancer nodes %s\"",
"%",
"nodes",
")",
"resp",
",",
"body",
"=",
"self",
".",
"_request",
"(",
"'post'",
",",
"'/loadbalancers/%s/nodes'",
"%"... | Adds nodes to an existing LBaaS instance
:param string lb_id: Balancer id
:param list nodes: Nodes to add. {address, port, [condition]}
:rtype :class:`list` | [
"Adds",
"nodes",
"to",
"an",
"existing",
"LBaaS",
"instance"
] | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/load_balancer.py#L126-L141 |
239,994 | fr33jc/bang | bang/providers/hpcloud/load_balancer.py | HPLoadBalancer.match_lb_nodes | def match_lb_nodes(self, lb_id, existing_nodes, host_addresses, host_port):
"""
Add and remove nodes to match the host addresses
and port given, based on existing_nodes. HPCS doesn't
allow a load balancer with no backends, so we'll add
first, delete after.
:param string ... | python | def match_lb_nodes(self, lb_id, existing_nodes, host_addresses, host_port):
"""
Add and remove nodes to match the host addresses
and port given, based on existing_nodes. HPCS doesn't
allow a load balancer with no backends, so we'll add
first, delete after.
:param string ... | [
"def",
"match_lb_nodes",
"(",
"self",
",",
"lb_id",
",",
"existing_nodes",
",",
"host_addresses",
",",
"host_port",
")",
":",
"delete_filter",
"=",
"lambda",
"n",
":",
"n",
"[",
"'address'",
"]",
"not",
"in",
"host_addresses",
"or",
"str",
"(",
"n",
"[",
... | Add and remove nodes to match the host addresses
and port given, based on existing_nodes. HPCS doesn't
allow a load balancer with no backends, so we'll add
first, delete after.
:param string lb_id: Load balancer id
:param :class:`list` of :class:`dict` existing_nodes: Existing ... | [
"Add",
"and",
"remove",
"nodes",
"to",
"match",
"the",
"host",
"addresses",
"and",
"port",
"given",
"based",
"on",
"existing_nodes",
".",
"HPCS",
"doesn",
"t",
"allow",
"a",
"load",
"balancer",
"with",
"no",
"backends",
"so",
"we",
"ll",
"add",
"first",
... | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/load_balancer.py#L143-L183 |
239,995 | fr33jc/bang | bang/providers/hpcloud/load_balancer.py | HPLoadBalancer.remove_lb_nodes | def remove_lb_nodes(self, lb_id, node_ids):
"""
Remove one or more nodes
:param string lb_id: Balancer id
:param list node_ids: List of node ids
"""
log.info("Removing load balancer nodes %s" % node_ids)
for node_id in node_ids:
self._request('dele... | python | def remove_lb_nodes(self, lb_id, node_ids):
"""
Remove one or more nodes
:param string lb_id: Balancer id
:param list node_ids: List of node ids
"""
log.info("Removing load balancer nodes %s" % node_ids)
for node_id in node_ids:
self._request('dele... | [
"def",
"remove_lb_nodes",
"(",
"self",
",",
"lb_id",
",",
"node_ids",
")",
":",
"log",
".",
"info",
"(",
"\"Removing load balancer nodes %s\"",
"%",
"node_ids",
")",
"for",
"node_id",
"in",
"node_ids",
":",
"self",
".",
"_request",
"(",
"'delete'",
",",
"'/l... | Remove one or more nodes
:param string lb_id: Balancer id
:param list node_ids: List of node ids | [
"Remove",
"one",
"or",
"more",
"nodes"
] | 8f000713f88d2a9a8c1193b63ca10a6578560c16 | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/load_balancer.py#L185-L195 |
239,996 | estilen/simplebrowser | simplebrowser/browser.py | SimpleBrowser.soup | def soup(self, *args, **kwargs):
"""Parse the currently loaded website.
Optionally, SoupStrainer can be used to only parse relevant
parts of the page. This can be particularly useful if the website is
complex or perfomance is a factor.
<https://www.crummy.com/software/BeautifulS... | python | def soup(self, *args, **kwargs):
"""Parse the currently loaded website.
Optionally, SoupStrainer can be used to only parse relevant
parts of the page. This can be particularly useful if the website is
complex or perfomance is a factor.
<https://www.crummy.com/software/BeautifulS... | [
"def",
"soup",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_url",
"is",
"None",
":",
"raise",
"NoWebsiteLoadedError",
"(",
"'website parsing requires a loaded website'",
")",
"content_type",
"=",
"self",
".",
"_respo... | Parse the currently loaded website.
Optionally, SoupStrainer can be used to only parse relevant
parts of the page. This can be particularly useful if the website is
complex or perfomance is a factor.
<https://www.crummy.com/software/BeautifulSoup/bs4/doc/#soupstrainer>
Args:
... | [
"Parse",
"the",
"currently",
"loaded",
"website",
"."
] | 76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b | https://github.com/estilen/simplebrowser/blob/76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b/simplebrowser/browser.py#L49-L76 |
239,997 | estilen/simplebrowser | simplebrowser/browser.py | SimpleBrowser.get | def get(self, url, **kwargs):
"""Send a GET request to the specified URL.
Method directly wraps around `Session.get` and updates browser
attributes.
<http://docs.python-requests.org/en/master/api/#requests.get>
Args:
url: URL for the new `Request` object.
... | python | def get(self, url, **kwargs):
"""Send a GET request to the specified URL.
Method directly wraps around `Session.get` and updates browser
attributes.
<http://docs.python-requests.org/en/master/api/#requests.get>
Args:
url: URL for the new `Request` object.
... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_url",
"=",
"response",
".",
"url",
"self",
".",
"_response",
... | Send a GET request to the specified URL.
Method directly wraps around `Session.get` and updates browser
attributes.
<http://docs.python-requests.org/en/master/api/#requests.get>
Args:
url: URL for the new `Request` object.
**kwargs: Optional arguments that `Requ... | [
"Send",
"a",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"."
] | 76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b | https://github.com/estilen/simplebrowser/blob/76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b/simplebrowser/browser.py#L78-L95 |
239,998 | estilen/simplebrowser | simplebrowser/browser.py | SimpleBrowser.post | def post(self, **kwargs):
"""Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
... | python | def post(self, **kwargs):
"""Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
... | [
"def",
"post",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_url",
"is",
"None",
":",
"raise",
"NoWebsiteLoadedError",
"(",
"'request submission requires a loaded website'",
")",
"data",
"=",
"kwargs",
".",
"get",
"(",
"'data'",
",",
... | Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
`Response` object of a success... | [
"Send",
"a",
"POST",
"request",
"to",
"the",
"currently",
"loaded",
"website",
"s",
"URL",
"."
] | 76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b | https://github.com/estilen/simplebrowser/blob/76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b/simplebrowser/browser.py#L97-L122 |
239,999 | tBaxter/tango-shared-core | build/lib/tango_shared/views.py | build_howto | def build_howto(request=None):
"""
Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them.
"""
how_tos = {}
for app in settings.INSTALLED_APPS:
mod = import_module(app)
app_dir = os.path.dirname(mod.__file__)
... | python | def build_howto(request=None):
"""
Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them.
"""
how_tos = {}
for app in settings.INSTALLED_APPS:
mod = import_module(app)
app_dir = os.path.dirname(mod.__file__)
... | [
"def",
"build_howto",
"(",
"request",
"=",
"None",
")",
":",
"how_tos",
"=",
"{",
"}",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"mod",
"=",
"import_module",
"(",
"app",
")",
"app_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"... | Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them. | [
"Searches",
"for",
"how_to",
".",
"md",
"files",
"in",
"app",
"directories",
".",
"Creates",
"user",
"-",
"friendly",
"admin",
"how",
"-",
"to",
"section",
"from",
"apps",
"that",
"have",
"them",
"."
] | 35fc10aef1ceedcdb4d6d866d44a22efff718812 | https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/views.py#L41-L57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.