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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
53,500 | ojii/django-multilingual-ng | multilingual/context_processors.py | multilingual | def multilingual(request):
"""
Returns context variables containing information about available languages.
"""
codes = sorted(get_language_code_list())
return {'LANGUAGE_CODES': codes,
'LANGUAGE_CODES_AND_NAMES': [(c, LANG_DICT.get(c, c)) for c in codes],
'DEFAULT_LANGUAGE_C... | python | def multilingual(request):
"""
Returns context variables containing information about available languages.
"""
codes = sorted(get_language_code_list())
return {'LANGUAGE_CODES': codes,
'LANGUAGE_CODES_AND_NAMES': [(c, LANG_DICT.get(c, c)) for c in codes],
'DEFAULT_LANGUAGE_C... | [
"def",
"multilingual",
"(",
"request",
")",
":",
"codes",
"=",
"sorted",
"(",
"get_language_code_list",
"(",
")",
")",
"return",
"{",
"'LANGUAGE_CODES'",
":",
"codes",
",",
"'LANGUAGE_CODES_AND_NAMES'",
":",
"[",
"(",
"c",
",",
"LANG_DICT",
".",
"get",
"(",
... | Returns context variables containing information about available languages. | [
"Returns",
"context",
"variables",
"containing",
"information",
"about",
"available",
"languages",
"."
] | 0d320a0732ec59949380d4b5f21e153174d3ecf7 | https://github.com/ojii/django-multilingual-ng/blob/0d320a0732ec59949380d4b5f21e153174d3ecf7/multilingual/context_processors.py#L6-L14 |
53,501 | gmr/tinman | tinman/handlers/mixins.py | StatsdMixin._statsd_address | def _statsd_address(self):
"""Return a tuple of host and port for the statsd server to send
stats to.
:return: tuple(host, port)
"""
return (self.application.settings.get('statsd',
{}).get('host',
... | python | def _statsd_address(self):
"""Return a tuple of host and port for the statsd server to send
stats to.
:return: tuple(host, port)
"""
return (self.application.settings.get('statsd',
{}).get('host',
... | [
"def",
"_statsd_address",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"application",
".",
"settings",
".",
"get",
"(",
"'statsd'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'host'",
",",
"self",
".",
"STATSD_HOST",
")",
",",
"self",
".",
"applicat... | Return a tuple of host and port for the statsd server to send
stats to.
:return: tuple(host, port) | [
"Return",
"a",
"tuple",
"of",
"host",
"and",
"port",
"for",
"the",
"statsd",
"server",
"to",
"send",
"stats",
"to",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L43-L55 |
53,502 | gmr/tinman | tinman/handlers/mixins.py | RedisMixin._new_redis_client | def _new_redis_client(self):
"""Create a new redis client and assign it the class _redis_client
attribute for reuse across requests.
:rtype: tornadoredis.Client()
"""
if 'tornadoredis' not in globals():
import tornadoredis
kwargs = self._redis_connection_set... | python | def _new_redis_client(self):
"""Create a new redis client and assign it the class _redis_client
attribute for reuse across requests.
:rtype: tornadoredis.Client()
"""
if 'tornadoredis' not in globals():
import tornadoredis
kwargs = self._redis_connection_set... | [
"def",
"_new_redis_client",
"(",
"self",
")",
":",
"if",
"'tornadoredis'",
"not",
"in",
"globals",
"(",
")",
":",
"import",
"tornadoredis",
"kwargs",
"=",
"self",
".",
"_redis_connection_settings",
"(",
")",
"LOGGER",
".",
"info",
"(",
"'Connecting to %(host)s:%... | Create a new redis client and assign it the class _redis_client
attribute for reuse across requests.
:rtype: tornadoredis.Client() | [
"Create",
"a",
"new",
"redis",
"client",
"and",
"assign",
"it",
"the",
"class",
"_redis_client",
"attribute",
"for",
"reuse",
"across",
"requests",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L152-L164 |
53,503 | gmr/tinman | tinman/handlers/mixins.py | RedisMixin._redis_connection_settings | def _redis_connection_settings(self):
"""Return a dictionary of redis connection settings.
"""
return {config.HOST: self.settings.get(config.HOST, self._REDIS_HOST),
config.PORT: self.settings.get(config.PORT, self._REDIS_PORT),
'selected_db': self.settings.get(c... | python | def _redis_connection_settings(self):
"""Return a dictionary of redis connection settings.
"""
return {config.HOST: self.settings.get(config.HOST, self._REDIS_HOST),
config.PORT: self.settings.get(config.PORT, self._REDIS_PORT),
'selected_db': self.settings.get(c... | [
"def",
"_redis_connection_settings",
"(",
"self",
")",
":",
"return",
"{",
"config",
".",
"HOST",
":",
"self",
".",
"settings",
".",
"get",
"(",
"config",
".",
"HOST",
",",
"self",
".",
"_REDIS_HOST",
")",
",",
"config",
".",
"PORT",
":",
"self",
".",
... | Return a dictionary of redis connection settings. | [
"Return",
"a",
"dictionary",
"of",
"redis",
"connection",
"settings",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L166-L172 |
53,504 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.delete | def delete(self, *args, **kwargs):
"""Handle delete of an item
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 404
... | python | def delete(self, *args, **kwargs):
"""Handle delete of an item
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 404
... | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Create the model and fetch its data",
"self",
".",
"model",
"=",
"self",
".",
"get_model",
"(",
"kwargs",
".",
"get",
"(",
"'id'",
")",
")",
"result",
"=",
"yield",
"... | Handle delete of an item
:param args:
:param kwargs: | [
"Handle",
"delete",
"of",
"an",
"item"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L200-L226 |
53,505 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.head | def head(self, *args, **kwargs):
"""Handle HEAD requests for the item
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 4... | python | def head(self, *args, **kwargs):
"""Handle HEAD requests for the item
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 4... | [
"def",
"head",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Create the model and fetch its data",
"self",
".",
"model",
"=",
"self",
".",
"get_model",
"(",
"kwargs",
".",
"get",
"(",
"'id'",
")",
")",
"result",
"=",
"yield",
"se... | Handle HEAD requests for the item
:param args:
:param kwargs: | [
"Handle",
"HEAD",
"requests",
"for",
"the",
"item"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L230-L254 |
53,506 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.get | def get(self, *args, **kwargs):
"""Handle reading of the model
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 404
... | python | def get(self, *args, **kwargs):
"""Handle reading of the model
:param args:
:param kwargs:
"""
# Create the model and fetch its data
self.model = self.get_model(kwargs.get('id'))
result = yield self.model.fetch()
# If model is not found, return 404
... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Create the model and fetch its data",
"self",
".",
"model",
"=",
"self",
".",
"get_model",
"(",
"kwargs",
".",
"get",
"(",
"'id'",
")",
")",
"result",
"=",
"yield",
"sel... | Handle reading of the model
:param args:
:param kwargs: | [
"Handle",
"reading",
"of",
"the",
"model"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L258-L283 |
53,507 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.post | def post(self, *args, **kwargs):
"""Handle creation of an item.
:param args:
:param kwargs:
"""
self.initialize_post()
# Don't allow the post if the poster does not have permission
if not self.has_create_permission():
LOGGER.debug('Does not have wri... | python | def post(self, *args, **kwargs):
"""Handle creation of an item.
:param args:
:param kwargs:
"""
self.initialize_post()
# Don't allow the post if the poster does not have permission
if not self.has_create_permission():
LOGGER.debug('Does not have wri... | [
"def",
"post",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"initialize_post",
"(",
")",
"# Don't allow the post if the poster does not have permission",
"if",
"not",
"self",
".",
"has_create_permission",
"(",
")",
":",
"LOGGER"... | Handle creation of an item.
:param args:
:param kwargs: | [
"Handle",
"creation",
"of",
"an",
"item",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L287-L310 |
53,508 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.put | def put(self, *args, **kwargs):
"""Handle updates of an item.
:param args:
:param kwargs:
"""
self.initialize_put(kwargs.get('id'))
if not self.has_update_permission():
self.set_status(403, self.status_message('Creation Forbidden'))
self.finish(... | python | def put(self, *args, **kwargs):
"""Handle updates of an item.
:param args:
:param kwargs:
"""
self.initialize_put(kwargs.get('id'))
if not self.has_update_permission():
self.set_status(403, self.status_message('Creation Forbidden'))
self.finish(... | [
"def",
"put",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"initialize_put",
"(",
"kwargs",
".",
"get",
"(",
"'id'",
")",
")",
"if",
"not",
"self",
".",
"has_update_permission",
"(",
")",
":",
"self",
".",
"set_sta... | Handle updates of an item.
:param args:
:param kwargs: | [
"Handle",
"updates",
"of",
"an",
"item",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L314-L343 |
53,509 | gmr/tinman | tinman/handlers/mixins.py | ModelAPIMixin.initialize_post | def initialize_post(self):
"""Invoked by the ModelAPIRequestHandler.post method prior to taking
any action.
"""
self.model = self.get_model()
for key in self.model.keys():
self.model.set(key, self.json_arguments.get(key)) | python | def initialize_post(self):
"""Invoked by the ModelAPIRequestHandler.post method prior to taking
any action.
"""
self.model = self.get_model()
for key in self.model.keys():
self.model.set(key, self.json_arguments.get(key)) | [
"def",
"initialize_post",
"(",
"self",
")",
":",
"self",
".",
"model",
"=",
"self",
".",
"get_model",
"(",
")",
"for",
"key",
"in",
"self",
".",
"model",
".",
"keys",
"(",
")",
":",
"self",
".",
"model",
".",
"set",
"(",
"key",
",",
"self",
".",
... | Invoked by the ModelAPIRequestHandler.post method prior to taking
any action. | [
"Invoked",
"by",
"the",
"ModelAPIRequestHandler",
".",
"post",
"method",
"prior",
"to",
"taking",
"any",
"action",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/mixins.py#L383-L390 |
53,510 | sigopt/sigopt-sklearn | sigopt_sklearn/search.py | SigOptSearchCV._convert_nonstring_categoricals | def _convert_nonstring_categoricals(self, param_dict):
"""Apply the self.categorical_mappings_ mappings where necessary."""
return {name: (self.categorical_mappings_[name][val] if name in self.categorical_mappings_ else val)
for (name, val) in param_dict.items()} | python | def _convert_nonstring_categoricals(self, param_dict):
"""Apply the self.categorical_mappings_ mappings where necessary."""
return {name: (self.categorical_mappings_[name][val] if name in self.categorical_mappings_ else val)
for (name, val) in param_dict.items()} | [
"def",
"_convert_nonstring_categoricals",
"(",
"self",
",",
"param_dict",
")",
":",
"return",
"{",
"name",
":",
"(",
"self",
".",
"categorical_mappings_",
"[",
"name",
"]",
"[",
"val",
"]",
"if",
"name",
"in",
"self",
".",
"categorical_mappings_",
"else",
"v... | Apply the self.categorical_mappings_ mappings where necessary. | [
"Apply",
"the",
"self",
".",
"categorical_mappings_",
"mappings",
"where",
"necessary",
"."
] | d27d9ca64b7a2c28dcf3434f88b9380b6b7281b2 | https://github.com/sigopt/sigopt-sklearn/blob/d27d9ca64b7a2c28dcf3434f88b9380b6b7281b2/sigopt_sklearn/search.py#L290-L293 |
53,511 | gmr/tinman | tinman/session.py | FileSession.delete | def delete(self):
"""Extend to the delete the session from storage
"""
self.clear()
if os.path.isfile(self._filename):
os.unlink(self._filename)
else:
LOGGER.debug('Session file did not exist: %s', self._filename) | python | def delete(self):
"""Extend to the delete the session from storage
"""
self.clear()
if os.path.isfile(self._filename):
os.unlink(self._filename)
else:
LOGGER.debug('Session file did not exist: %s', self._filename) | [
"def",
"delete",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"_filename",
")",
":",
"os",
".",
"unlink",
"(",
"self",
".",
"_filename",
")",
"else",
":",
"LOGGER",
".",
"debug",... | Extend to the delete the session from storage | [
"Extend",
"to",
"the",
"delete",
"the",
"session",
"from",
"storage"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L107-L115 |
53,512 | gmr/tinman | tinman/session.py | FileSession.save | def save(self):
"""Save the session for later retrieval
:raises: IOError
"""
try:
with open(self._filename, 'wb') as session_file:
session_file.write(self.dumps())
except IOError as error:
LOGGER.error('Session file error: %s', error)
... | python | def save(self):
"""Save the session for later retrieval
:raises: IOError
"""
try:
with open(self._filename, 'wb') as session_file:
session_file.write(self.dumps())
except IOError as error:
LOGGER.error('Session file error: %s', error)
... | [
"def",
"save",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_filename",
",",
"'wb'",
")",
"as",
"session_file",
":",
"session_file",
".",
"write",
"(",
"self",
".",
"dumps",
"(",
")",
")",
"except",
"IOError",
"as",
"error",
... | Save the session for later retrieval
:raises: IOError | [
"Save",
"the",
"session",
"for",
"later",
"retrieval"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L117-L128 |
53,513 | gmr/tinman | tinman/session.py | FileSession._cleanup | def _cleanup(self):
"""Remove any stale files from the session storage directory"""
for filename in os.listdir(self._storage_dir):
file_path = path.join(self._storage_dir, filename)
file_stat = os.stat(file_path)
evaluate = max(file_stat.st_ctime, file_stat.st_mtime)
... | python | def _cleanup(self):
"""Remove any stale files from the session storage directory"""
for filename in os.listdir(self._storage_dir):
file_path = path.join(self._storage_dir, filename)
file_stat = os.stat(file_path)
evaluate = max(file_stat.st_ctime, file_stat.st_mtime)
... | [
"def",
"_cleanup",
"(",
"self",
")",
":",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"_storage_dir",
")",
":",
"file_path",
"=",
"path",
".",
"join",
"(",
"self",
".",
"_storage_dir",
",",
"filename",
")",
"file_stat",
"=",
"os",
... | Remove any stale files from the session storage directory | [
"Remove",
"any",
"stale",
"files",
"from",
"the",
"session",
"storage",
"directory"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L130-L138 |
53,514 | gmr/tinman | tinman/session.py | FileSession._setup_storage_dir | def _setup_storage_dir(self):
"""Setup the storage directory path value and ensure the path exists.
:rtype: str
:raises: tinman.exceptions.ConfigurationException
"""
dir_path = self._settings.get(config.DIRECTORY)
if dir_path is None:
dir_path = self._defaul... | python | def _setup_storage_dir(self):
"""Setup the storage directory path value and ensure the path exists.
:rtype: str
:raises: tinman.exceptions.ConfigurationException
"""
dir_path = self._settings.get(config.DIRECTORY)
if dir_path is None:
dir_path = self._defaul... | [
"def",
"_setup_storage_dir",
"(",
"self",
")",
":",
"dir_path",
"=",
"self",
".",
"_settings",
".",
"get",
"(",
"config",
".",
"DIRECTORY",
")",
"if",
"dir_path",
"is",
"None",
":",
"dir_path",
"=",
"self",
".",
"_default_path",
"if",
"not",
"os",
".",
... | Setup the storage directory path value and ensure the path exists.
:rtype: str
:raises: tinman.exceptions.ConfigurationException | [
"Setup",
"the",
"storage",
"directory",
"path",
"value",
"and",
"ensure",
"the",
"path",
"exists",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L167-L184 |
53,515 | gmr/tinman | tinman/session.py | RedisSession._redis_connect | def _redis_connect(cls, settings):
"""Connect to redis and assign the client to the RedisSession class
so that it is globally available in this process.
:param dict settings: The redis session configuration
"""
if 'tornadoredis' not in globals():
import tornadoredis... | python | def _redis_connect(cls, settings):
"""Connect to redis and assign the client to the RedisSession class
so that it is globally available in this process.
:param dict settings: The redis session configuration
"""
if 'tornadoredis' not in globals():
import tornadoredis... | [
"def",
"_redis_connect",
"(",
"cls",
",",
"settings",
")",
":",
"if",
"'tornadoredis'",
"not",
"in",
"globals",
"(",
")",
":",
"import",
"tornadoredis",
"kwargs",
"=",
"{",
"'host'",
":",
"settings",
".",
"get",
"(",
"'host'",
",",
"cls",
".",
"REDIS_HOS... | Connect to redis and assign the client to the RedisSession class
so that it is globally available in this process.
:param dict settings: The redis session configuration | [
"Connect",
"to",
"redis",
"and",
"assign",
"the",
"client",
"to",
"the",
"RedisSession",
"class",
"so",
"that",
"it",
"is",
"globally",
"available",
"in",
"this",
"process",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L228-L243 |
53,516 | gmr/tinman | tinman/session.py | RedisSession.save | def save(self):
"""Store the session data in redis
:param method callback: The callback method to invoke when done
"""
result = yield gen.Task(RedisSession._redis_client.set,
self._key, self.dumps())
LOGGER.debug('Saved session %s (%r)', self.id,... | python | def save(self):
"""Store the session data in redis
:param method callback: The callback method to invoke when done
"""
result = yield gen.Task(RedisSession._redis_client.set,
self._key, self.dumps())
LOGGER.debug('Saved session %s (%r)', self.id,... | [
"def",
"save",
"(",
"self",
")",
":",
"result",
"=",
"yield",
"gen",
".",
"Task",
"(",
"RedisSession",
".",
"_redis_client",
".",
"set",
",",
"self",
".",
"_key",
",",
"self",
".",
"dumps",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"'Saved session ... | Store the session data in redis
:param method callback: The callback method to invoke when done | [
"Store",
"the",
"session",
"data",
"in",
"redis"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/session.py#L273-L282 |
53,517 | gmr/tinman | tinman/couchdb.py | CouchDBLoader._create_template | def _create_template(self, name):
"""Create an instance of a tornado.template.Template object for the
given template name.
:param str name: The name/path to the template
:rtype: tornado.template.Template
"""
url = '%s/%s' % (self._base_url, escape.url_escape(name))
... | python | def _create_template(self, name):
"""Create an instance of a tornado.template.Template object for the
given template name.
:param str name: The name/path to the template
:rtype: tornado.template.Template
"""
url = '%s/%s' % (self._base_url, escape.url_escape(name))
... | [
"def",
"_create_template",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"_base_url",
",",
"escape",
".",
"url_escape",
"(",
"name",
")",
")",
"LOGGER",
".",
"debug",
"(",
"'Making HTTP GET request to %s'",
",",
"url",
... | Create an instance of a tornado.template.Template object for the
given template name.
:param str name: The name/path to the template
:rtype: tornado.template.Template | [
"Create",
"an",
"instance",
"of",
"a",
"tornado",
".",
"template",
".",
"Template",
"object",
"for",
"the",
"given",
"template",
"name",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/couchdb.py#L48-L60 |
53,518 | cslarsen/crianza | crianza/native.py | xcompile | def xcompile(source_code, args=0, optimize=True):
"""Parses Crianza source code and returns a native Python function.
Args:
args: The resulting function's number of input parameters.
Returns:
A callable Python function.
"""
code = crianza.compile(crianza.parse(source_code), optimiz... | python | def xcompile(source_code, args=0, optimize=True):
"""Parses Crianza source code and returns a native Python function.
Args:
args: The resulting function's number of input parameters.
Returns:
A callable Python function.
"""
code = crianza.compile(crianza.parse(source_code), optimiz... | [
"def",
"xcompile",
"(",
"source_code",
",",
"args",
"=",
"0",
",",
"optimize",
"=",
"True",
")",
":",
"code",
"=",
"crianza",
".",
"compile",
"(",
"crianza",
".",
"parse",
"(",
"source_code",
")",
",",
"optimize",
"=",
"optimize",
")",
"return",
"crian... | Parses Crianza source code and returns a native Python function.
Args:
args: The resulting function's number of input parameters.
Returns:
A callable Python function. | [
"Parses",
"Crianza",
"source",
"code",
"and",
"returns",
"a",
"native",
"Python",
"function",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/native.py#L272-L282 |
53,519 | cslarsen/crianza | crianza/native.py | xeval | def xeval(source, optimize=True):
"""Compiles to native Python bytecode and runs program, returning the
topmost value on the stack.
Args:
optimize: Whether to optimize the code after parsing it.
Returns:
None: If the stack is empty
obj: If the stack contains a single value
... | python | def xeval(source, optimize=True):
"""Compiles to native Python bytecode and runs program, returning the
topmost value on the stack.
Args:
optimize: Whether to optimize the code after parsing it.
Returns:
None: If the stack is empty
obj: If the stack contains a single value
... | [
"def",
"xeval",
"(",
"source",
",",
"optimize",
"=",
"True",
")",
":",
"native",
"=",
"xcompile",
"(",
"source",
",",
"optimize",
"=",
"optimize",
")",
"return",
"native",
"(",
")"
] | Compiles to native Python bytecode and runs program, returning the
topmost value on the stack.
Args:
optimize: Whether to optimize the code after parsing it.
Returns:
None: If the stack is empty
obj: If the stack contains a single value
[obj, obj, ...]: If the stack contain... | [
"Compiles",
"to",
"native",
"Python",
"bytecode",
"and",
"runs",
"program",
"returning",
"the",
"topmost",
"value",
"on",
"the",
"stack",
"."
] | fa044f9d491f37cc06892bad14b2c80b8ac5a7cd | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/native.py#L284-L297 |
53,520 | matthiask/django-cte-forest | cte_forest/models.py | CTENode.clean | def clean(self):
""" Prevents cycles in the tree. """
super(CTENode, self).clean()
if self.parent and self.pk in getattr(self.parent, self._cte_node_path):
raise ValidationError(_("A node cannot be made a descendant of itself.")) | python | def clean(self):
""" Prevents cycles in the tree. """
super(CTENode, self).clean()
if self.parent and self.pk in getattr(self.parent, self._cte_node_path):
raise ValidationError(_("A node cannot be made a descendant of itself.")) | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
"CTENode",
",",
"self",
")",
".",
"clean",
"(",
")",
"if",
"self",
".",
"parent",
"and",
"self",
".",
"pk",
"in",
"getattr",
"(",
"self",
".",
"parent",
",",
"self",
".",
"_cte_node_path",
")",
... | Prevents cycles in the tree. | [
"Prevents",
"cycles",
"in",
"the",
"tree",
"."
] | 7bff29d69eddfcf214e9cf61647c91d28655619c | https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/models.py#L1085-L1089 |
53,521 | jshrake/ddg | ddg.py | main | def main():
"""Controls the flow of the ddg application"""
'Build the parser and parse the arguments'
parser = argparse.ArgumentParser(
description='www.duckduckgo.com zero-click api for your command-line'
)
parser.add_argument('query', nargs='*', help='the search query')
parser.add_arg... | python | def main():
"""Controls the flow of the ddg application"""
'Build the parser and parse the arguments'
parser = argparse.ArgumentParser(
description='www.duckduckgo.com zero-click api for your command-line'
)
parser.add_argument('query', nargs='*', help='the search query')
parser.add_arg... | [
"def",
"main",
"(",
")",
":",
"'Build the parser and parse the arguments'",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'www.duckduckgo.com zero-click api for your command-line'",
")",
"parser",
".",
"add_argument",
"(",
"'query'",
",",
"na... | Controls the flow of the ddg application | [
"Controls",
"the",
"flow",
"of",
"the",
"ddg",
"application"
] | 3bb0830629b6f987a46fad1d6652e2cfba909df8 | https://github.com/jshrake/ddg/blob/3bb0830629b6f987a46fad1d6652e2cfba909df8/ddg.py#L10-L84 |
53,522 | jshrake/ddg | ddg.py | get_results_priority | def get_results_priority(args):
"""Return a result priority list based on user input"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode:
results_priority = ['redirect', 'result', 'abstract']
else:
results_priority = ['answer', 'abstract', 'result']
insert_po... | python | def get_results_priority(args):
"""Return a result priority list based on user input"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode:
results_priority = ['redirect', 'result', 'abstract']
else:
results_priority = ['answer', 'abstract', 'result']
insert_po... | [
"def",
"get_results_priority",
"(",
"args",
")",
":",
"redirect_mode",
"=",
"args",
".",
"bang",
"or",
"args",
".",
"search",
"or",
"args",
".",
"lucky",
"if",
"redirect_mode",
":",
"results_priority",
"=",
"[",
"'redirect'",
",",
"'result'",
",",
"'abstract... | Return a result priority list based on user input | [
"Return",
"a",
"result",
"priority",
"list",
"based",
"on",
"user",
"input"
] | 3bb0830629b6f987a46fad1d6652e2cfba909df8 | https://github.com/jshrake/ddg/blob/3bb0830629b6f987a46fad1d6652e2cfba909df8/ddg.py#L87-L97 |
53,523 | jshrake/ddg | ddg.py | get_action | def get_action(args):
"""Return a function to launch the web browser or print a result"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode and not args.url:
return webbrowser.open_new_tab
else:
return print_result | python | def get_action(args):
"""Return a function to launch the web browser or print a result"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode and not args.url:
return webbrowser.open_new_tab
else:
return print_result | [
"def",
"get_action",
"(",
"args",
")",
":",
"redirect_mode",
"=",
"args",
".",
"bang",
"or",
"args",
".",
"search",
"or",
"args",
".",
"lucky",
"if",
"redirect_mode",
"and",
"not",
"args",
".",
"url",
":",
"return",
"webbrowser",
".",
"open_new_tab",
"el... | Return a function to launch the web browser or print a result | [
"Return",
"a",
"function",
"to",
"launch",
"the",
"web",
"browser",
"or",
"print",
"a",
"result"
] | 3bb0830629b6f987a46fad1d6652e2cfba909df8 | https://github.com/jshrake/ddg/blob/3bb0830629b6f987a46fad1d6652e2cfba909df8/ddg.py#L100-L106 |
53,524 | jshrake/ddg | ddg.py | get_text_or_url | def get_text_or_url(args):
"""Determine if we need text or url output"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode or args.url:
return 'url'
else:
return 'text' | python | def get_text_or_url(args):
"""Determine if we need text or url output"""
redirect_mode = args.bang or args.search or args.lucky
if redirect_mode or args.url:
return 'url'
else:
return 'text' | [
"def",
"get_text_or_url",
"(",
"args",
")",
":",
"redirect_mode",
"=",
"args",
".",
"bang",
"or",
"args",
".",
"search",
"or",
"args",
".",
"lucky",
"if",
"redirect_mode",
"or",
"args",
".",
"url",
":",
"return",
"'url'",
"else",
":",
"return",
"'text'"
... | Determine if we need text or url output | [
"Determine",
"if",
"we",
"need",
"text",
"or",
"url",
"output"
] | 3bb0830629b6f987a46fad1d6652e2cfba909df8 | https://github.com/jshrake/ddg/blob/3bb0830629b6f987a46fad1d6652e2cfba909df8/ddg.py#L109-L115 |
53,525 | jshrake/ddg | ddg.py | print_result | def print_result(result):
"""Print the result, ascii encode if necessary"""
try:
print result
except UnicodeEncodeError:
if sys.stdout.encoding:
print result.encode(sys.stdout.encoding, 'replace')
else:
print result.encode('utf8')
except:
print "Un... | python | def print_result(result):
"""Print the result, ascii encode if necessary"""
try:
print result
except UnicodeEncodeError:
if sys.stdout.encoding:
print result.encode(sys.stdout.encoding, 'replace')
else:
print result.encode('utf8')
except:
print "Un... | [
"def",
"print_result",
"(",
"result",
")",
":",
"try",
":",
"print",
"result",
"except",
"UnicodeEncodeError",
":",
"if",
"sys",
".",
"stdout",
".",
"encoding",
":",
"print",
"result",
".",
"encode",
"(",
"sys",
".",
"stdout",
".",
"encoding",
",",
"'rep... | Print the result, ascii encode if necessary | [
"Print",
"the",
"result",
"ascii",
"encode",
"if",
"necessary"
] | 3bb0830629b6f987a46fad1d6652e2cfba909df8 | https://github.com/jshrake/ddg/blob/3bb0830629b6f987a46fad1d6652e2cfba909df8/ddg.py#L118-L128 |
53,526 | synw/dataswim | dataswim/db/infos.py | Info.tables | def tables(self):
"""Print the existing tables in a database
:example: ``ds.tables()``
"""
if self._check_db() == False:
return
try:
pmodels = self._tables()
if pmodels is None:
return
num = len(pmodels)
... | python | def tables(self):
"""Print the existing tables in a database
:example: ``ds.tables()``
"""
if self._check_db() == False:
return
try:
pmodels = self._tables()
if pmodels is None:
return
num = len(pmodels)
... | [
"def",
"tables",
"(",
"self",
")",
":",
"if",
"self",
".",
"_check_db",
"(",
")",
"==",
"False",
":",
"return",
"try",
":",
"pmodels",
"=",
"self",
".",
"_tables",
"(",
")",
"if",
"pmodels",
"is",
"None",
":",
"return",
"num",
"=",
"len",
"(",
"p... | Print the existing tables in a database
:example: ``ds.tables()`` | [
"Print",
"the",
"existing",
"tables",
"in",
"a",
"database"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/infos.py#L10-L29 |
53,527 | synw/dataswim | dataswim/db/infos.py | Info.tables_ | def tables_(self) -> list:
"""Return a list of the existing tables in a database
:return: list of the table names
:rtype: list
:example: ``tables = ds.tables_()``
"""
if self._check_db() == False:
return
try:
return self._tables()
... | python | def tables_(self) -> list:
"""Return a list of the existing tables in a database
:return: list of the table names
:rtype: list
:example: ``tables = ds.tables_()``
"""
if self._check_db() == False:
return
try:
return self._tables()
... | [
"def",
"tables_",
"(",
"self",
")",
"->",
"list",
":",
"if",
"self",
".",
"_check_db",
"(",
")",
"==",
"False",
":",
"return",
"try",
":",
"return",
"self",
".",
"_tables",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
... | Return a list of the existing tables in a database
:return: list of the table names
:rtype: list
:example: ``tables = ds.tables_()`` | [
"Return",
"a",
"list",
"of",
"the",
"existing",
"tables",
"in",
"a",
"database"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/infos.py#L31-L44 |
53,528 | danpoland/pyramid-restful-framework | pyramid_restful/expandables.py | parse_requested_expands | def parse_requested_expands(query_key, request):
"""
Extracts the value of the expand query string parameter from a request.
Supports comma separated lists.
:param query_key: The name query string parameter.
:param request: Request instance.
:return: List of strings representing the values of t... | python | def parse_requested_expands(query_key, request):
"""
Extracts the value of the expand query string parameter from a request.
Supports comma separated lists.
:param query_key: The name query string parameter.
:param request: Request instance.
:return: List of strings representing the values of t... | [
"def",
"parse_requested_expands",
"(",
"query_key",
",",
"request",
")",
":",
"requested_expands",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"request",
".",
"params",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"query_key",
":",
"requested_expands... | Extracts the value of the expand query string parameter from a request.
Supports comma separated lists.
:param query_key: The name query string parameter.
:param request: Request instance.
:return: List of strings representing the values of the expand query string value. | [
"Extracts",
"the",
"value",
"of",
"the",
"expand",
"query",
"string",
"parameter",
"from",
"a",
"request",
".",
"Supports",
"comma",
"separated",
"lists",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/expandables.py#L8-L24 |
53,529 | Seeed-Studio/wio-cli | wio/commands/cmd_delete.py | cli | def cli(wio, sn):
'''
Delete a device.
\b
DOES:
Delete a device.
sn: device_sn
wio delete <device_sn>
\b
EXAMPLE:
wio delete 2885b2cab8abc5fb8e229e4a77bf5e4d
'''
user_token = wio.config.get("token", None)
api_prefix = wio.config.get("mserver", None)
... | python | def cli(wio, sn):
'''
Delete a device.
\b
DOES:
Delete a device.
sn: device_sn
wio delete <device_sn>
\b
EXAMPLE:
wio delete 2885b2cab8abc5fb8e229e4a77bf5e4d
'''
user_token = wio.config.get("token", None)
api_prefix = wio.config.get("mserver", None)
... | [
"def",
"cli",
"(",
"wio",
",",
"sn",
")",
":",
"user_token",
"=",
"wio",
".",
"config",
".",
"get",
"(",
"\"token\"",
",",
"None",
")",
"api_prefix",
"=",
"wio",
".",
"config",
".",
"get",
"(",
"\"mserver\"",
",",
"None",
")",
"if",
"not",
"api_pre... | Delete a device.
\b
DOES:
Delete a device.
sn: device_sn
wio delete <device_sn>
\b
EXAMPLE:
wio delete 2885b2cab8abc5fb8e229e4a77bf5e4d | [
"Delete",
"a",
"device",
"."
] | ce83f4c2d30be7f72d1a128acd123dfc5effa563 | https://github.com/Seeed-Studio/wio-cli/blob/ce83f4c2d30be7f72d1a128acd123dfc5effa563/wio/commands/cmd_delete.py#L12-L49 |
53,530 | danpoland/pyramid-restful-framework | pyramid_restful/routers.py | ViewSetRouter.register | def register(self, prefix, viewset, basename, factory=None, permission=None):
"""
Factory and permission are likely only going to exist until I have enough time
to write a permissions module for PRF.
:param prefix: the uri route prefix.
:param viewset: The ViewSet class to route... | python | def register(self, prefix, viewset, basename, factory=None, permission=None):
"""
Factory and permission are likely only going to exist until I have enough time
to write a permissions module for PRF.
:param prefix: the uri route prefix.
:param viewset: The ViewSet class to route... | [
"def",
"register",
"(",
"self",
",",
"prefix",
",",
"viewset",
",",
"basename",
",",
"factory",
"=",
"None",
",",
"permission",
"=",
"None",
")",
":",
"lookup",
"=",
"self",
".",
"get_lookup",
"(",
"viewset",
")",
"routes",
"=",
"self",
".",
"get_route... | Factory and permission are likely only going to exist until I have enough time
to write a permissions module for PRF.
:param prefix: the uri route prefix.
:param viewset: The ViewSet class to route.
:param basename: Used to name the route in pyramid.
:param factory: Optional, ro... | [
"Factory",
"and",
"permission",
"are",
"likely",
"only",
"going",
"to",
"exist",
"until",
"I",
"have",
"enough",
"time",
"to",
"write",
"a",
"permissions",
"module",
"for",
"PRF",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/routers.py#L87-L122 |
53,531 | danpoland/pyramid-restful-framework | pyramid_restful/routers.py | ViewSetRouter.get_routes | def get_routes(self, viewset):
"""
Augment `self.routes` with any dynamically generated routes.
Returns a list of the Route namedtuple.
"""
known_actions = list(flatten([route.mapping.values() for route in self.routes if isinstance(route, Route)]))
# Determine any `@det... | python | def get_routes(self, viewset):
"""
Augment `self.routes` with any dynamically generated routes.
Returns a list of the Route namedtuple.
"""
known_actions = list(flatten([route.mapping.values() for route in self.routes if isinstance(route, Route)]))
# Determine any `@det... | [
"def",
"get_routes",
"(",
"self",
",",
"viewset",
")",
":",
"known_actions",
"=",
"list",
"(",
"flatten",
"(",
"[",
"route",
".",
"mapping",
".",
"values",
"(",
")",
"for",
"route",
"in",
"self",
".",
"routes",
"if",
"isinstance",
"(",
"route",
",",
... | Augment `self.routes` with any dynamically generated routes.
Returns a list of the Route namedtuple. | [
"Augment",
"self",
".",
"routes",
"with",
"any",
"dynamically",
"generated",
"routes",
".",
"Returns",
"a",
"list",
"of",
"the",
"Route",
"namedtuple",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/routers.py#L124-L186 |
53,532 | danpoland/pyramid-restful-framework | pyramid_restful/routers.py | ViewSetRouter.get_method_map | def get_method_map(self, viewset, method_map):
"""
Given a viewset, and a mapping of http methods to actions, return a new mapping which only
includes any mappings that are actually implemented by the viewset.
"""
bound_methods = {}
for method, action in method_map.item... | python | def get_method_map(self, viewset, method_map):
"""
Given a viewset, and a mapping of http methods to actions, return a new mapping which only
includes any mappings that are actually implemented by the viewset.
"""
bound_methods = {}
for method, action in method_map.item... | [
"def",
"get_method_map",
"(",
"self",
",",
"viewset",
",",
"method_map",
")",
":",
"bound_methods",
"=",
"{",
"}",
"for",
"method",
",",
"action",
"in",
"method_map",
".",
"items",
"(",
")",
":",
"if",
"hasattr",
"(",
"viewset",
",",
"action",
")",
":"... | Given a viewset, and a mapping of http methods to actions, return a new mapping which only
includes any mappings that are actually implemented by the viewset. | [
"Given",
"a",
"viewset",
"and",
"a",
"mapping",
"of",
"http",
"methods",
"to",
"actions",
"return",
"a",
"new",
"mapping",
"which",
"only",
"includes",
"any",
"mappings",
"that",
"are",
"actually",
"implemented",
"by",
"the",
"viewset",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/routers.py#L205-L217 |
53,533 | gmr/tinman | tinman/handlers/base.py | RequestHandler.options | def options(self, *args, **kwargs):
"""Implement the HTTP OPTIONS method
:param list args: Positional arguments
:param dict kwargs: Keyword arguments
"""
self.set_header('Allow', ', '.join(self.ALLOW))
self.set_status(204)
self.finish() | python | def options(self, *args, **kwargs):
"""Implement the HTTP OPTIONS method
:param list args: Positional arguments
:param dict kwargs: Keyword arguments
"""
self.set_header('Allow', ', '.join(self.ALLOW))
self.set_status(204)
self.finish() | [
"def",
"options",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_header",
"(",
"'Allow'",
",",
"', '",
".",
"join",
"(",
"self",
".",
"ALLOW",
")",
")",
"self",
".",
"set_status",
"(",
"204",
")",
"self",
".",... | Implement the HTTP OPTIONS method
:param list args: Positional arguments
:param dict kwargs: Keyword arguments | [
"Implement",
"the",
"HTTP",
"OPTIONS",
"method"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L124-L133 |
53,534 | gmr/tinman | tinman/handlers/base.py | RequestHandler.prepare | def prepare(self):
"""Prepare the incoming request, checking to see the request is sending
JSON content in the request body. If so, the content is decoded and
assigned to the json_arguments attribute.
"""
super(RequestHandler, self).prepare()
if self.request.headers.get(... | python | def prepare(self):
"""Prepare the incoming request, checking to see the request is sending
JSON content in the request body. If so, the content is decoded and
assigned to the json_arguments attribute.
"""
super(RequestHandler, self).prepare()
if self.request.headers.get(... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"RequestHandler",
",",
"self",
")",
".",
"prepare",
"(",
")",
"if",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"'content-type'",
",",
"''",
")",
".",
"startswith",
"(",
"self",
".",... | Prepare the incoming request, checking to see the request is sending
JSON content in the request body. If so, the content is decoded and
assigned to the json_arguments attribute. | [
"Prepare",
"the",
"incoming",
"request",
"checking",
"to",
"see",
"the",
"request",
"is",
"sending",
"JSON",
"content",
"in",
"the",
"request",
"body",
".",
"If",
"so",
"the",
"content",
"is",
"decoded",
"and",
"assigned",
"to",
"the",
"json_arguments",
"att... | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L135-L143 |
53,535 | gmr/tinman | tinman/handlers/base.py | RequestHandler.write | def write(self, chunk):
"""Writes the given chunk to the output buffer. Checks for curl in the
user-agent and if set, provides indented output if returning JSON.
To write the output to the network, use the flush() method below.
If the given chunk is a dictionary, we write it as JSON an... | python | def write(self, chunk):
"""Writes the given chunk to the output buffer. Checks for curl in the
user-agent and if set, provides indented output if returning JSON.
To write the output to the network, use the flush() method below.
If the given chunk is a dictionary, we write it as JSON an... | [
"def",
"write",
"(",
"self",
",",
"chunk",
")",
":",
"if",
"self",
".",
"_finished",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot write() after finish(). May be caused \"",
"\"by using async operations without the \"",
"\"@asynchronous decorator.\"",
")",
"if",
"isinstance... | Writes the given chunk to the output buffer. Checks for curl in the
user-agent and if set, provides indented output if returning JSON.
To write the output to the network, use the flush() method below.
If the given chunk is a dictionary, we write it as JSON and set
the Content-Type of t... | [
"Writes",
"the",
"given",
"chunk",
"to",
"the",
"output",
"buffer",
".",
"Checks",
"for",
"curl",
"in",
"the",
"user",
"-",
"agent",
"and",
"if",
"set",
"provides",
"indented",
"output",
"if",
"returning",
"JSON",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L145-L170 |
53,536 | gmr/tinman | tinman/handlers/base.py | SessionRequestHandler.on_finish | def on_finish(self):
"""Called by Tornado when the request is done. Update the session data
and remove the session object.
"""
super(SessionRequestHandler, self).on_finish()
LOGGER.debug('Entering SessionRequestHandler.on_finish: %s',
self.session.id)
... | python | def on_finish(self):
"""Called by Tornado when the request is done. Update the session data
and remove the session object.
"""
super(SessionRequestHandler, self).on_finish()
LOGGER.debug('Entering SessionRequestHandler.on_finish: %s',
self.session.id)
... | [
"def",
"on_finish",
"(",
"self",
")",
":",
"super",
"(",
"SessionRequestHandler",
",",
"self",
")",
".",
"on_finish",
"(",
")",
"LOGGER",
".",
"debug",
"(",
"'Entering SessionRequestHandler.on_finish: %s'",
",",
"self",
".",
"session",
".",
"id",
")",
"self",
... | Called by Tornado when the request is done. Update the session data
and remove the session object. | [
"Called",
"by",
"Tornado",
"when",
"the",
"request",
"is",
"done",
".",
"Update",
"the",
"session",
"data",
"and",
"remove",
"the",
"session",
"object",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L183-L198 |
53,537 | gmr/tinman | tinman/handlers/base.py | SessionRequestHandler.prepare | def prepare(self):
"""Prepare the session, setting up the session object and loading in
the values, assigning the IP address to the session if it's an new one.
"""
super(SessionRequestHandler, self).prepare()
result = yield gen.Task(self.start_session)
LOGGER.debug('Exit... | python | def prepare(self):
"""Prepare the session, setting up the session object and loading in
the values, assigning the IP address to the session if it's an new one.
"""
super(SessionRequestHandler, self).prepare()
result = yield gen.Task(self.start_session)
LOGGER.debug('Exit... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"SessionRequestHandler",
",",
"self",
")",
".",
"prepare",
"(",
")",
"result",
"=",
"yield",
"gen",
".",
"Task",
"(",
"self",
".",
"start_session",
")",
"LOGGER",
".",
"debug",
"(",
"'Exiting Session... | Prepare the session, setting up the session object and loading in
the values, assigning the IP address to the session if it's an new one. | [
"Prepare",
"the",
"session",
"setting",
"up",
"the",
"session",
"object",
"and",
"loading",
"in",
"the",
"values",
"assigning",
"the",
"IP",
"address",
"to",
"the",
"session",
"if",
"it",
"s",
"an",
"new",
"one",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L222-L229 |
53,538 | gmr/tinman | tinman/handlers/base.py | SessionRequestHandler._cookie_expiration | def _cookie_expiration(self):
"""Return the expiration timestamp for the session cookie.
:rtype: datetime
"""
value = (datetime.datetime.utcnow() +
datetime.timedelta(seconds=self._session_duration))
LOGGER.debug('Cookie expires: %s', value.isoformat())
... | python | def _cookie_expiration(self):
"""Return the expiration timestamp for the session cookie.
:rtype: datetime
"""
value = (datetime.datetime.utcnow() +
datetime.timedelta(seconds=self._session_duration))
LOGGER.debug('Cookie expires: %s', value.isoformat())
... | [
"def",
"_cookie_expiration",
"(",
"self",
")",
":",
"value",
"=",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"_session_duration",
")",
")",
"LOGGER",
".",
"debug",
"(",
... | Return the expiration timestamp for the session cookie.
:rtype: datetime | [
"Return",
"the",
"expiration",
"timestamp",
"for",
"the",
"session",
"cookie",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L232-L241 |
53,539 | gmr/tinman | tinman/handlers/base.py | SessionRequestHandler._session_start | def _session_start(self):
"""Return an instance of the proper session object.
:rtype: Session
"""
return self._session_class(self._session_id,
self._session_duration,
self._session_settings) | python | def _session_start(self):
"""Return an instance of the proper session object.
:rtype: Session
"""
return self._session_class(self._session_id,
self._session_duration,
self._session_settings) | [
"def",
"_session_start",
"(",
"self",
")",
":",
"return",
"self",
".",
"_session_class",
"(",
"self",
".",
"_session_id",
",",
"self",
".",
"_session_duration",
",",
"self",
".",
"_session_settings",
")"
] | Return an instance of the proper session object.
:rtype: Session | [
"Return",
"an",
"instance",
"of",
"the",
"proper",
"session",
"object",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L296-L304 |
53,540 | gmr/tinman | tinman/handlers/base.py | SessionRequestHandler._set_session_cookie | def _set_session_cookie(self):
"""Set the session data cookie."""
LOGGER.debug('Setting session cookie for %s', self.session.id)
self.set_secure_cookie(name=self._session_cookie_name,
value=self.session.id,
expires=self._cookie_expira... | python | def _set_session_cookie(self):
"""Set the session data cookie."""
LOGGER.debug('Setting session cookie for %s', self.session.id)
self.set_secure_cookie(name=self._session_cookie_name,
value=self.session.id,
expires=self._cookie_expira... | [
"def",
"_set_session_cookie",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Setting session cookie for %s'",
",",
"self",
".",
"session",
".",
"id",
")",
"self",
".",
"set_secure_cookie",
"(",
"name",
"=",
"self",
".",
"_session_cookie_name",
",",
"val... | Set the session data cookie. | [
"Set",
"the",
"session",
"data",
"cookie",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L305-L310 |
53,541 | synw/dataswim | dataswim/data/transform/columns.py | Columns.rename | def rename(self, source_col: str, dest_col: str):
"""
Renames a column in the main dataframe
:param source_col: name of the column to rename
:type source_col: str
:param dest_col: new name of the column
:type dest_col: str
:example: ``ds.rename("Col 1", "New col... | python | def rename(self, source_col: str, dest_col: str):
"""
Renames a column in the main dataframe
:param source_col: name of the column to rename
:type source_col: str
:param dest_col: new name of the column
:type dest_col: str
:example: ``ds.rename("Col 1", "New col... | [
"def",
"rename",
"(",
"self",
",",
"source_col",
":",
"str",
",",
"dest_col",
":",
"str",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
".",
"rename",
"(",
"columns",
"=",
"{",
"source_col",
":",
"dest_col",
"}",
")",
"except",
... | Renames a column in the main dataframe
:param source_col: name of the column to rename
:type source_col: str
:param dest_col: new name of the column
:type dest_col: str
:example: ``ds.rename("Col 1", "New col")`` | [
"Renames",
"a",
"column",
"in",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L10-L26 |
53,542 | synw/dataswim | dataswim/data/transform/columns.py | Columns.add | def add(self, col: str, value):
"""
Add a column with default values
:param col: column name
:type col: str
:param value: column value
:type value: any
:example: ``ds.add("Col 4", 0)``
"""
try:
self.df[col] = value
except Exce... | python | def add(self, col: str, value):
"""
Add a column with default values
:param col: column name
:type col: str
:param value: column value
:type value: any
:example: ``ds.add("Col 4", 0)``
"""
try:
self.df[col] = value
except Exce... | [
"def",
"add",
"(",
"self",
",",
"col",
":",
"str",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"df",
"[",
"col",
"]",
"=",
"value",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",
"self",
".",
"add",
",",
"\"Can... | Add a column with default values
:param col: column name
:type col: str
:param value: column value
:type value: any
:example: ``ds.add("Col 4", 0)`` | [
"Add",
"a",
"column",
"with",
"default",
"values"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L28-L42 |
53,543 | synw/dataswim | dataswim/data/transform/columns.py | Columns.keep_ | def keep_(self, *cols) -> "Ds":
"""
Returns a dataswim instance with a dataframe limited
to some columns
:param cols: names of the columns
:type cols: str
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.keep_("Col 1", "Col 2")``
"""
... | python | def keep_(self, *cols) -> "Ds":
"""
Returns a dataswim instance with a dataframe limited
to some columns
:param cols: names of the columns
:type cols: str
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.keep_("Col 1", "Col 2")``
"""
... | [
"def",
"keep_",
"(",
"self",
",",
"*",
"cols",
")",
"->",
"\"Ds\"",
":",
"try",
":",
"ds2",
"=",
"self",
".",
"_duplicate_",
"(",
"self",
".",
"df",
"[",
"list",
"(",
"cols",
")",
"]",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"e... | Returns a dataswim instance with a dataframe limited
to some columns
:param cols: names of the columns
:type cols: str
:return: a dataswim instance
:rtype: Ds
:example: ``ds2 = ds.keep_("Col 1", "Col 2")`` | [
"Returns",
"a",
"dataswim",
"instance",
"with",
"a",
"dataframe",
"limited",
"to",
"some",
"columns"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L44-L62 |
53,544 | synw/dataswim | dataswim/data/transform/columns.py | Columns.keep | def keep(self, *cols):
"""
Limit the dataframe to some columns
:param cols: names of the columns
:type cols: str
:example: ``ds.keep("Col 1", "Col 2")``
"""
try:
self.df = self.df[list(cols)]
except Exception as e:
self.err(e, "Ca... | python | def keep(self, *cols):
"""
Limit the dataframe to some columns
:param cols: names of the columns
:type cols: str
:example: ``ds.keep("Col 1", "Col 2")``
"""
try:
self.df = self.df[list(cols)]
except Exception as e:
self.err(e, "Ca... | [
"def",
"keep",
"(",
"self",
",",
"*",
"cols",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
"[",
"list",
"(",
"cols",
")",
"]",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
",",
"\"Can not remove colums\... | Limit the dataframe to some columns
:param cols: names of the columns
:type cols: str
:example: ``ds.keep("Col 1", "Col 2")`` | [
"Limit",
"the",
"dataframe",
"to",
"some",
"columns"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L64-L78 |
53,545 | synw/dataswim | dataswim/data/transform/columns.py | Columns.drop | def drop(self, *cols):
"""
Drops columns from the main dataframe
:param cols: names of the columns
:type cols: str
:example: ``ds.drop("Col 1", "Col 2")``
"""
try:
index = self.df.columns.values
for col in cols:
if col not... | python | def drop(self, *cols):
"""
Drops columns from the main dataframe
:param cols: names of the columns
:type cols: str
:example: ``ds.drop("Col 1", "Col 2")``
"""
try:
index = self.df.columns.values
for col in cols:
if col not... | [
"def",
"drop",
"(",
"self",
",",
"*",
"cols",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"df",
".",
"columns",
".",
"values",
"for",
"col",
"in",
"cols",
":",
"if",
"col",
"not",
"in",
"index",
":",
"self",
".",
"warning",
"(",
"\"Column\""... | Drops columns from the main dataframe
:param cols: names of the columns
:type cols: str
:example: ``ds.drop("Col 1", "Col 2")`` | [
"Drops",
"columns",
"from",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L80-L97 |
53,546 | synw/dataswim | dataswim/data/transform/columns.py | Columns.exclude | def exclude(self, col: str, val):
"""
Delete rows based on value
:param col: column name
:type col: str
:param val: value to delete
:type val: any
:example: ``ds.exclude("Col 1", "value")``
"""
try:
self.df = self.df[self.df[col] != v... | python | def exclude(self, col: str, val):
"""
Delete rows based on value
:param col: column name
:type col: str
:param val: value to delete
:type val: any
:example: ``ds.exclude("Col 1", "value")``
"""
try:
self.df = self.df[self.df[col] != v... | [
"def",
"exclude",
"(",
"self",
",",
"col",
":",
"str",
",",
"val",
")",
":",
"try",
":",
"self",
".",
"df",
"=",
"self",
".",
"df",
"[",
"self",
".",
"df",
"[",
"col",
"]",
"!=",
"val",
"]",
"except",
"Exception",
"as",
"e",
":",
"self",
".",... | Delete rows based on value
:param col: column name
:type col: str
:param val: value to delete
:type val: any
:example: ``ds.exclude("Col 1", "value")`` | [
"Delete",
"rows",
"based",
"on",
"value"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L99-L113 |
53,547 | synw/dataswim | dataswim/data/transform/columns.py | Columns.copycol | def copycol(self, origin_col: str, dest_col: str):
"""
Copy a columns values in another column
:param origin_col: name of the column to copy
:type origin_col: str
:param dest_col: name of the new column
:type dest_col: str
:example: ``ds.copy("col 1", "New col")... | python | def copycol(self, origin_col: str, dest_col: str):
"""
Copy a columns values in another column
:param origin_col: name of the column to copy
:type origin_col: str
:param dest_col: name of the new column
:type dest_col: str
:example: ``ds.copy("col 1", "New col")... | [
"def",
"copycol",
"(",
"self",
",",
"origin_col",
":",
"str",
",",
"dest_col",
":",
"str",
")",
":",
"try",
":",
"self",
".",
"df",
"[",
"dest_col",
"]",
"=",
"self",
".",
"df",
"[",
"[",
"origin_col",
"]",
"]",
"except",
"Exception",
"as",
"e",
... | Copy a columns values in another column
:param origin_col: name of the column to copy
:type origin_col: str
:param dest_col: name of the new column
:type dest_col: str
:example: ``ds.copy("col 1", "New col")`` | [
"Copy",
"a",
"columns",
"values",
"in",
"another",
"column"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L115-L129 |
53,548 | synw/dataswim | dataswim/data/transform/columns.py | Columns.indexcol | def indexcol(self, col: str):
"""
Add a column from the index
:param col: name of the new column
:type col: str
:example: ``ds.index_col("New col")``
"""
try:
self.df[col] = self.df.index.values
except Exception as e:
self.err(e)
... | python | def indexcol(self, col: str):
"""
Add a column from the index
:param col: name of the new column
:type col: str
:example: ``ds.index_col("New col")``
"""
try:
self.df[col] = self.df.index.values
except Exception as e:
self.err(e)
... | [
"def",
"indexcol",
"(",
"self",
",",
"col",
":",
"str",
")",
":",
"try",
":",
"self",
".",
"df",
"[",
"col",
"]",
"=",
"self",
".",
"df",
".",
"index",
".",
"values",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"err",
"(",
"e",
")",
"... | Add a column from the index
:param col: name of the new column
:type col: str
:example: ``ds.index_col("New col")`` | [
"Add",
"a",
"column",
"from",
"the",
"index"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/columns.py#L131-L145 |
53,549 | misli/django-cms-articles | cms_articles/search_indexes.py | TitleIndex.get_article_placeholders | def get_article_placeholders(self, article):
"""
In the project settings set up the variable
CMS_ARTICLES_PLACEHOLDERS_SEARCH_LIST = {
'include': [ 'slot1', 'slot2', etc. ],
'exclude': [ 'slot3', 'slot4', etc. ],
}
or leave it empty
CMS_ARTICLES... | python | def get_article_placeholders(self, article):
"""
In the project settings set up the variable
CMS_ARTICLES_PLACEHOLDERS_SEARCH_LIST = {
'include': [ 'slot1', 'slot2', etc. ],
'exclude': [ 'slot3', 'slot4', etc. ],
}
or leave it empty
CMS_ARTICLES... | [
"def",
"get_article_placeholders",
"(",
"self",
",",
"article",
")",
":",
"placeholders_search_list",
"=",
"getattr",
"(",
"settings",
",",
"'CMS_ARTICLES_PLACEHOLDERS_SEARCH_LIST'",
",",
"{",
"}",
")",
"included",
"=",
"placeholders_search_list",
".",
"get",
"(",
"... | In the project settings set up the variable
CMS_ARTICLES_PLACEHOLDERS_SEARCH_LIST = {
'include': [ 'slot1', 'slot2', etc. ],
'exclude': [ 'slot3', 'slot4', etc. ],
}
or leave it empty
CMS_ARTICLES_PLACEHOLDERS_SEARCH_LIST = {} | [
"In",
"the",
"project",
"settings",
"set",
"up",
"the",
"variable"
] | d96ac77e049022deb4c70d268e4eab74d175145c | https://github.com/misli/django-cms-articles/blob/d96ac77e049022deb4c70d268e4eab74d175145c/cms_articles/search_indexes.py#L46-L69 |
53,550 | synw/dataswim | dataswim/__init__.py | Ds.new_ | def new_(self, df=pd.DataFrame(), db=None, quiet=False,
nbload_libs=True):
"""
Returns a new DataSwim instance from a dataframe
"""
ds2 = Ds(df, db, nbload_libs)
if quiet is False:
self.ok("A new instance was created")
return ds2 | python | def new_(self, df=pd.DataFrame(), db=None, quiet=False,
nbload_libs=True):
"""
Returns a new DataSwim instance from a dataframe
"""
ds2 = Ds(df, db, nbload_libs)
if quiet is False:
self.ok("A new instance was created")
return ds2 | [
"def",
"new_",
"(",
"self",
",",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
")",
",",
"db",
"=",
"None",
",",
"quiet",
"=",
"False",
",",
"nbload_libs",
"=",
"True",
")",
":",
"ds2",
"=",
"Ds",
"(",
"df",
",",
"db",
",",
"nbload_libs",
")",
"if",
... | Returns a new DataSwim instance from a dataframe | [
"Returns",
"a",
"new",
"DataSwim",
"instance",
"from",
"a",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/__init__.py#L68-L76 |
53,551 | synw/dataswim | dataswim/db/insert.py | Insert.insert | def insert(self, table, records, create_cols=False, dtypes=None):
"""
Insert one or many records in the database from a dictionary or a list of dictionaries
"""
if self._check_db() is False:
return
try:
table = self.db[table]
except Exception as e:... | python | def insert(self, table, records, create_cols=False, dtypes=None):
"""
Insert one or many records in the database from a dictionary or a list of dictionaries
"""
if self._check_db() is False:
return
try:
table = self.db[table]
except Exception as e:... | [
"def",
"insert",
"(",
"self",
",",
"table",
",",
"records",
",",
"create_cols",
"=",
"False",
",",
"dtypes",
"=",
"None",
")",
":",
"if",
"self",
".",
"_check_db",
"(",
")",
"is",
"False",
":",
"return",
"try",
":",
"table",
"=",
"self",
".",
"db",... | Insert one or many records in the database from a dictionary or a list of dictionaries | [
"Insert",
"one",
"or",
"many",
"records",
"in",
"the",
"database",
"from",
"a",
"dictionary",
"or",
"a",
"list",
"of",
"dictionaries"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/insert.py#L15-L46 |
53,552 | synw/dataswim | dataswim/db/insert.py | Insert.upsert | def upsert(self, table: str, record: dict, create_cols: bool=False,
dtypes: list=None, pks=["id"], namefields=["id"]):
"""
Upsert a record in a table
"""
try:
self.db[table].upsert(record, pks, create_cols, dtypes)
except Exception as e:
sel... | python | def upsert(self, table: str, record: dict, create_cols: bool=False,
dtypes: list=None, pks=["id"], namefields=["id"]):
"""
Upsert a record in a table
"""
try:
self.db[table].upsert(record, pks, create_cols, dtypes)
except Exception as e:
sel... | [
"def",
"upsert",
"(",
"self",
",",
"table",
":",
"str",
",",
"record",
":",
"dict",
",",
"create_cols",
":",
"bool",
"=",
"False",
",",
"dtypes",
":",
"list",
"=",
"None",
",",
"pks",
"=",
"[",
"\"id\"",
"]",
",",
"namefields",
"=",
"[",
"\"id\"",
... | Upsert a record in a table | [
"Upsert",
"a",
"record",
"in",
"a",
"table"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/insert.py#L48-L61 |
53,553 | synw/dataswim | dataswim/db/insert.py | Insert.update_table | def update_table(self, table, pks=['id']):
"""
Update records in a database table from the main dataframe
"""
if self._check_db() is False:
return
try:
table = self.db[table]
except Exception as e:
self.err(e, "Can not find table " + ta... | python | def update_table(self, table, pks=['id']):
"""
Update records in a database table from the main dataframe
"""
if self._check_db() is False:
return
try:
table = self.db[table]
except Exception as e:
self.err(e, "Can not find table " + ta... | [
"def",
"update_table",
"(",
"self",
",",
"table",
",",
"pks",
"=",
"[",
"'id'",
"]",
")",
":",
"if",
"self",
".",
"_check_db",
"(",
")",
"is",
"False",
":",
"return",
"try",
":",
"table",
"=",
"self",
".",
"db",
"[",
"table",
"]",
"except",
"Exce... | Update records in a database table from the main dataframe | [
"Update",
"records",
"in",
"a",
"database",
"table",
"from",
"the",
"main",
"dataframe"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/insert.py#L63-L80 |
53,554 | synw/dataswim | dataswim/db/insert.py | Insert.to_db | def to_db(self, table, dtypes=None):
"""
Save the main dataframe to the database
"""
if self._check_db() is False:
return
if table not in self.db.tables:
self.db.create_table(table)
self.info("Created table ", table)
self.start("Saving ... | python | def to_db(self, table, dtypes=None):
"""
Save the main dataframe to the database
"""
if self._check_db() is False:
return
if table not in self.db.tables:
self.db.create_table(table)
self.info("Created table ", table)
self.start("Saving ... | [
"def",
"to_db",
"(",
"self",
",",
"table",
",",
"dtypes",
"=",
"None",
")",
":",
"if",
"self",
".",
"_check_db",
"(",
")",
"is",
"False",
":",
"return",
"if",
"table",
"not",
"in",
"self",
".",
"db",
".",
"tables",
":",
"self",
".",
"db",
".",
... | Save the main dataframe to the database | [
"Save",
"the",
"main",
"dataframe",
"to",
"the",
"database"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/db/insert.py#L82-L94 |
53,555 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn.residual_ | def residual_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn models residuals chart
"""
color, _ = self._get_color_size(style)
try:
fig = sns.residplot(self.df[self.x], self.df[self.y],
lowess=True, color=color)
... | python | def residual_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn models residuals chart
"""
color, _ = self._get_color_size(style)
try:
fig = sns.residplot(self.df[self.x], self.df[self.y],
lowess=True, color=color)
... | [
"def",
"residual_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"color",
",",
"_",
"=",
"self",
".",
"_get_color_size",
"(",
"style",
")",
"try",
":",
"fig",
"=",
"sns",
".",
"residplot",
... | Returns a Seaborn models residuals chart | [
"Returns",
"a",
"Seaborn",
"models",
"residuals",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L14-L26 |
53,556 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._density_seaborn_ | def _density_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn density chart
"""
try:
fig = sns.kdeplot(self.df[self.x], self.df[self.y])
fig = self._set_with_height(fig, opts)
return fig
except Exception as e:
... | python | def _density_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn density chart
"""
try:
fig = sns.kdeplot(self.df[self.x], self.df[self.y])
fig = self._set_with_height(fig, opts)
return fig
except Exception as e:
... | [
"def",
"_density_seaborn_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"try",
":",
"fig",
"=",
"sns",
".",
"kdeplot",
"(",
"self",
".",
"df",
"[",
"self",
".",
"x",
"]",
",",
"self",
"... | Returns a Seaborn density chart | [
"Returns",
"a",
"Seaborn",
"density",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L28-L38 |
53,557 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._distrib_seaborn_ | def _distrib_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn distribution chart
"""
try:
kde = False
rug = True
if "kde" in opts:
kde = opts["kde"]
rug = opts["rug"]
fig = sns.distplo... | python | def _distrib_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn distribution chart
"""
try:
kde = False
rug = True
if "kde" in opts:
kde = opts["kde"]
rug = opts["rug"]
fig = sns.distplo... | [
"def",
"_distrib_seaborn_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"try",
":",
"kde",
"=",
"False",
"rug",
"=",
"True",
"if",
"\"kde\"",
"in",
"opts",
":",
"kde",
"=",
"opts",
"[",
"... | Returns a Seaborn distribution chart | [
"Returns",
"a",
"Seaborn",
"distribution",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L40-L55 |
53,558 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._linear_seaborn_ | def _linear_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn linear regression plot
"""
xticks, yticks = self._get_ticks(opts)
try:
fig = sns.lmplot(self.x, self.y, data=self.df)
fig = self._set_with_height(fig, opts)
re... | python | def _linear_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn linear regression plot
"""
xticks, yticks = self._get_ticks(opts)
try:
fig = sns.lmplot(self.x, self.y, data=self.df)
fig = self._set_with_height(fig, opts)
re... | [
"def",
"_linear_seaborn_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"xticks",
",",
"yticks",
"=",
"self",
".",
"_get_ticks",
"(",
"opts",
")",
"try",
":",
"fig",
"=",
"sns",
".",
"lmplot... | Returns a Seaborn linear regression plot | [
"Returns",
"a",
"Seaborn",
"linear",
"regression",
"plot"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L57-L68 |
53,559 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._dlinear_seaborn_ | def _dlinear_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn linear regression plot with marginal distribution
"""
color, size = self._get_color_size(style)
try:
fig = sns.jointplot(self.x, self.y, color=color,
... | python | def _dlinear_seaborn_(self, label=None, style=None, opts=None):
"""
Returns a Seaborn linear regression plot with marginal distribution
"""
color, size = self._get_color_size(style)
try:
fig = sns.jointplot(self.x, self.y, color=color,
... | [
"def",
"_dlinear_seaborn_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"color",
",",
"size",
"=",
"self",
".",
"_get_color_size",
"(",
"style",
")",
"try",
":",
"fig",
"=",
"sns",
".",
"jo... | Returns a Seaborn linear regression plot with marginal distribution | [
"Returns",
"a",
"Seaborn",
"linear",
"regression",
"plot",
"with",
"marginal",
"distribution"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L70-L82 |
53,560 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn.seaborn_bar_ | def seaborn_bar_(self, label=None, style=None, opts=None):
"""
Get a Seaborn bar chart
"""
try:
fig = sns.barplot(self.x, self.y, palette="BuGn_d")
return fig
except Exception as e:
self.err(e, self.seaborn_bar_,
"Can not g... | python | def seaborn_bar_(self, label=None, style=None, opts=None):
"""
Get a Seaborn bar chart
"""
try:
fig = sns.barplot(self.x, self.y, palette="BuGn_d")
return fig
except Exception as e:
self.err(e, self.seaborn_bar_,
"Can not g... | [
"def",
"seaborn_bar_",
"(",
"self",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
",",
"opts",
"=",
"None",
")",
":",
"try",
":",
"fig",
"=",
"sns",
".",
"barplot",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"palette",
"=",
"\"B... | Get a Seaborn bar chart | [
"Get",
"a",
"Seaborn",
"bar",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L84-L93 |
53,561 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._get_opts_seaborn | def _get_opts_seaborn(self, opts, style):
"""
Initialialize for chart rendering
"""
if opts is None:
if self.chart_opts is None:
opts = {}
else:
opts = self.chart_opts
if style is None:
if self.chart_style is Non... | python | def _get_opts_seaborn(self, opts, style):
"""
Initialialize for chart rendering
"""
if opts is None:
if self.chart_opts is None:
opts = {}
else:
opts = self.chart_opts
if style is None:
if self.chart_style is Non... | [
"def",
"_get_opts_seaborn",
"(",
"self",
",",
"opts",
",",
"style",
")",
":",
"if",
"opts",
"is",
"None",
":",
"if",
"self",
".",
"chart_opts",
"is",
"None",
":",
"opts",
"=",
"{",
"}",
"else",
":",
"opts",
"=",
"self",
".",
"chart_opts",
"if",
"st... | Initialialize for chart rendering | [
"Initialialize",
"for",
"chart",
"rendering"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L95-L109 |
53,562 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._get_seaborn_chart | def _get_seaborn_chart(self, xfield, yfield, chart_type, label,
_opts=None, _style=None, **kwargs):
"""
Get an Seaborn chart object
"""
plt.figure()
try:
opts, style = self._get_opts_seaborn(_opts, _style)
except Exception as e:
... | python | def _get_seaborn_chart(self, xfield, yfield, chart_type, label,
_opts=None, _style=None, **kwargs):
"""
Get an Seaborn chart object
"""
plt.figure()
try:
opts, style = self._get_opts_seaborn(_opts, _style)
except Exception as e:
... | [
"def",
"_get_seaborn_chart",
"(",
"self",
",",
"xfield",
",",
"yfield",
",",
"chart_type",
",",
"label",
",",
"_opts",
"=",
"None",
",",
"_style",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"plt",
".",
"figure",
"(",
")",
"try",
":",
"opts",
"... | Get an Seaborn chart object | [
"Get",
"an",
"Seaborn",
"chart",
"object"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L111-L151 |
53,563 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._get_ticks | def _get_ticks(self, opts):
"""
Check if xticks and yticks are set
"""
opts, _ = self._get_opts(opts, None)
if "xticks" not in opts:
if "xticks" not in self.chart_opts:
self.err(self.dlinear_,
"Please set the xticks option for ... | python | def _get_ticks(self, opts):
"""
Check if xticks and yticks are set
"""
opts, _ = self._get_opts(opts, None)
if "xticks" not in opts:
if "xticks" not in self.chart_opts:
self.err(self.dlinear_,
"Please set the xticks option for ... | [
"def",
"_get_ticks",
"(",
"self",
",",
"opts",
")",
":",
"opts",
",",
"_",
"=",
"self",
".",
"_get_opts",
"(",
"opts",
",",
"None",
")",
"if",
"\"xticks\"",
"not",
"in",
"opts",
":",
"if",
"\"xticks\"",
"not",
"in",
"self",
".",
"chart_opts",
":",
... | Check if xticks and yticks are set | [
"Check",
"if",
"xticks",
"and",
"yticks",
"are",
"set"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L153-L176 |
53,564 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._get_color_size | def _get_color_size(self, style):
"""
Get color and size from a style dict
"""
color = "b"
if "color" in style:
color = style["color"]
size = 7
if "size" in style:
size = style["size"]
return color, size | python | def _get_color_size(self, style):
"""
Get color and size from a style dict
"""
color = "b"
if "color" in style:
color = style["color"]
size = 7
if "size" in style:
size = style["size"]
return color, size | [
"def",
"_get_color_size",
"(",
"self",
",",
"style",
")",
":",
"color",
"=",
"\"b\"",
"if",
"\"color\"",
"in",
"style",
":",
"color",
"=",
"style",
"[",
"\"color\"",
"]",
"size",
"=",
"7",
"if",
"\"size\"",
"in",
"style",
":",
"size",
"=",
"style",
"... | Get color and size from a style dict | [
"Get",
"color",
"and",
"size",
"from",
"a",
"style",
"dict"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L178-L188 |
53,565 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._set_with_height | def _set_with_height(self, fig, opts):
"""
Set the width and height of a Matplotlib figure
"""
h = 5
if "height" in opts:
h = opts["height"]
w = 12
if "width" in opts:
w = opts["width"]
try:
fig.figure.set_size_inches((w... | python | def _set_with_height(self, fig, opts):
"""
Set the width and height of a Matplotlib figure
"""
h = 5
if "height" in opts:
h = opts["height"]
w = 12
if "width" in opts:
w = opts["width"]
try:
fig.figure.set_size_inches((w... | [
"def",
"_set_with_height",
"(",
"self",
",",
"fig",
",",
"opts",
")",
":",
"h",
"=",
"5",
"if",
"\"height\"",
"in",
"opts",
":",
"h",
"=",
"opts",
"[",
"\"height\"",
"]",
"w",
"=",
"12",
"if",
"\"width\"",
"in",
"opts",
":",
"w",
"=",
"opts",
"["... | Set the width and height of a Matplotlib figure | [
"Set",
"the",
"width",
"and",
"height",
"of",
"a",
"Matplotlib",
"figure"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L190-L209 |
53,566 | synw/dataswim | dataswim/charts/seaborn.py | Seaborn._save_seaborn_chart | def _save_seaborn_chart(self, report, folderpath):
"""
Saves a png image of the seaborn chart
"""
if folderpath is None:
if self.imgs_path is None:
self.err(self._save_seaborn_chart,
"Please set a path where to save images: ds.imgs_pat... | python | def _save_seaborn_chart(self, report, folderpath):
"""
Saves a png image of the seaborn chart
"""
if folderpath is None:
if self.imgs_path is None:
self.err(self._save_seaborn_chart,
"Please set a path where to save images: ds.imgs_pat... | [
"def",
"_save_seaborn_chart",
"(",
"self",
",",
"report",
",",
"folderpath",
")",
":",
"if",
"folderpath",
"is",
"None",
":",
"if",
"self",
".",
"imgs_path",
"is",
"None",
":",
"self",
".",
"err",
"(",
"self",
".",
"_save_seaborn_chart",
",",
"\"Please set... | Saves a png image of the seaborn chart | [
"Saves",
"a",
"png",
"image",
"of",
"the",
"seaborn",
"chart"
] | 4a4a53f80daa7cd8e8409d76a19ce07296269da2 | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L211-L242 |
53,567 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.register_dimension | def register_dimension(self, name, dim_data, **kwargs):
"""
Registers a dimension on this cube.
.. code-block:: python
cube.register_dimension('ntime', 10000,
decription="Number of Timesteps",
lower_extent=100, upper_extent=200)
... | python | def register_dimension(self, name, dim_data, **kwargs):
"""
Registers a dimension on this cube.
.. code-block:: python
cube.register_dimension('ntime', 10000,
decription="Number of Timesteps",
lower_extent=100, upper_extent=200)
... | [
"def",
"register_dimension",
"(",
"self",
",",
"name",
",",
"dim_data",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"in",
"self",
".",
"_dims",
":",
"raise",
"AttributeError",
"(",
"(",
"\"Attempted to register dimension '{n}'' \"",
"\"as an attribute of the ... | Registers a dimension on this cube.
.. code-block:: python
cube.register_dimension('ntime', 10000,
decription="Number of Timesteps",
lower_extent=100, upper_extent=200)
Parameters
----------
dim_data : int or :class:`~hypercu... | [
"Registers",
"a",
"dimension",
"on",
"this",
"cube",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L101-L150 |
53,568 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.register_dimensions | def register_dimensions(self, dims):
"""
Register multiple dimensions on the cube.
.. code-block:: python
cube.register_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'glo... | python | def register_dimensions(self, dims):
"""
Register multiple dimensions on the cube.
.. code-block:: python
cube.register_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'glo... | [
"def",
"register_dimensions",
"(",
"self",
",",
"dims",
")",
":",
"if",
"isinstance",
"(",
"dims",
",",
"collections",
".",
"Mapping",
")",
":",
"dims",
"=",
"dims",
".",
"itervalues",
"(",
")",
"for",
"dim",
"in",
"dims",
":",
"self",
".",
"register_d... | Register multiple dimensions on the cube.
.. code-block:: python
cube.register_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'global_size' : 3,
'lower_extent' : 2, 'upper... | [
"Register",
"multiple",
"dimensions",
"on",
"the",
"cube",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L152-L177 |
53,569 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.update_dimensions | def update_dimensions(self, dims):
"""
Update multiple dimension on the cube.
.. code-block:: python
cube.update_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'global_siz... | python | def update_dimensions(self, dims):
"""
Update multiple dimension on the cube.
.. code-block:: python
cube.update_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'global_siz... | [
"def",
"update_dimensions",
"(",
"self",
",",
"dims",
")",
":",
"if",
"isinstance",
"(",
"dims",
",",
"collections",
".",
"Mapping",
")",
":",
"dims",
"=",
"dims",
".",
"itervalues",
"(",
")",
"for",
"dim",
"in",
"dims",
":",
"# Defer to update dimension f... | Update multiple dimension on the cube.
.. code-block:: python
cube.update_dimensions([
{'name' : 'ntime', 'global_size' : 10,
'lower_extent' : 2, 'upper_extent' : 7 },
{'name' : 'na', 'global_size' : 3,
'lower_extent' : 2, 'upper_exte... | [
"Update",
"multiple",
"dimension",
"on",
"the",
"cube",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L179-L210 |
53,570 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.update_dimension | def update_dimension(self, name, **update_dict):
"""
Update the dimension size and extents.
Parameters
----------
**update_dict : : dict: dict
A dictionary containing keywords passed through to
:meth:`~hypercube.dims.Dimension.update`
name : str
... | python | def update_dimension(self, name, **update_dict):
"""
Update the dimension size and extents.
Parameters
----------
**update_dict : : dict: dict
A dictionary containing keywords passed through to
:meth:`~hypercube.dims.Dimension.update`
name : str
... | [
"def",
"update_dimension",
"(",
"self",
",",
"name",
",",
"*",
"*",
"update_dict",
")",
":",
"if",
"not",
"name",
":",
"raise",
"AttributeError",
"(",
"\"A dimension name is required to update \"",
"\"a dimension. Update dictionary {u}.\"",
".",
"format",
"(",
"u",
... | Update the dimension size and extents.
Parameters
----------
**update_dict : : dict: dict
A dictionary containing keywords passed through to
:meth:`~hypercube.dims.Dimension.update`
name : str
Name of the dimension to update | [
"Update",
"the",
"dimension",
"size",
"and",
"extents",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L212-L237 |
53,571 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube._dim_attribute | def _dim_attribute(self, attr, *args, **kwargs):
"""
Returns a list of dimension attribute attr, for the
dimensions specified as strings in args.
.. code-block:: python
ntime, nbl, nchan = cube._dim_attribute('global_size', 'ntime', 'nbl', 'nchan')
or
.. c... | python | def _dim_attribute(self, attr, *args, **kwargs):
"""
Returns a list of dimension attribute attr, for the
dimensions specified as strings in args.
.. code-block:: python
ntime, nbl, nchan = cube._dim_attribute('global_size', 'ntime', 'nbl', 'nchan')
or
.. c... | [
"def",
"_dim_attribute",
"(",
"self",
",",
"attr",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"re",
"# If we got a single string argument, try splitting it by separators",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
... | Returns a list of dimension attribute attr, for the
dimensions specified as strings in args.
.. code-block:: python
ntime, nbl, nchan = cube._dim_attribute('global_size', 'ntime', 'nbl', 'nchan')
or
.. code-block:: python
ntime, nbl, nchan, nsrc = cube._dim_a... | [
"Returns",
"a",
"list",
"of",
"dimension",
"attribute",
"attr",
"for",
"the",
"dimensions",
"specified",
"as",
"strings",
"in",
"args",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L239-L268 |
53,572 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_global_size_dict | def dim_global_size_dict(self):
""" Returns a mapping of dimension name to global size """
return { d.name: d.global_size for d in self._dims.itervalues()} | python | def dim_global_size_dict(self):
""" Returns a mapping of dimension name to global size """
return { d.name: d.global_size for d in self._dims.itervalues()} | [
"def",
"dim_global_size_dict",
"(",
"self",
")",
":",
"return",
"{",
"d",
".",
"name",
":",
"d",
".",
"global_size",
"for",
"d",
"in",
"self",
".",
"_dims",
".",
"itervalues",
"(",
")",
"}"
] | Returns a mapping of dimension name to global size | [
"Returns",
"a",
"mapping",
"of",
"dimension",
"name",
"to",
"global",
"size"
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L270-L272 |
53,573 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_lower_extent_dict | def dim_lower_extent_dict(self):
""" Returns a mapping of dimension name to lower_extent """
return { d.name: d.lower_extent for d in self._dims.itervalues()} | python | def dim_lower_extent_dict(self):
""" Returns a mapping of dimension name to lower_extent """
return { d.name: d.lower_extent for d in self._dims.itervalues()} | [
"def",
"dim_lower_extent_dict",
"(",
"self",
")",
":",
"return",
"{",
"d",
".",
"name",
":",
"d",
".",
"lower_extent",
"for",
"d",
"in",
"self",
".",
"_dims",
".",
"itervalues",
"(",
")",
"}"
] | Returns a mapping of dimension name to lower_extent | [
"Returns",
"a",
"mapping",
"of",
"dimension",
"name",
"to",
"lower_extent"
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L274-L276 |
53,574 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_upper_extent_dict | def dim_upper_extent_dict(self):
""" Returns a mapping of dimension name to upper_extent """
return { d.name: d.upper_extent for d in self._dims.itervalues()} | python | def dim_upper_extent_dict(self):
""" Returns a mapping of dimension name to upper_extent """
return { d.name: d.upper_extent for d in self._dims.itervalues()} | [
"def",
"dim_upper_extent_dict",
"(",
"self",
")",
":",
"return",
"{",
"d",
".",
"name",
":",
"d",
".",
"upper_extent",
"for",
"d",
"in",
"self",
".",
"_dims",
".",
"itervalues",
"(",
")",
"}"
] | Returns a mapping of dimension name to upper_extent | [
"Returns",
"a",
"mapping",
"of",
"dimension",
"name",
"to",
"upper_extent"
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L278-L280 |
53,575 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_lower_extent | def dim_lower_extent(self, *args, **kwargs):
"""
Returns the lower extent of the dimensions in args.
.. code-block:: python
t_ex, bl_ex, ch_ex = cube.dim_lower_extent('ntime', 'nbl', 'nchan')
or
.. code-block:: python
t_ex, bl_ex, ch_ex, src_ex = cube... | python | def dim_lower_extent(self, *args, **kwargs):
"""
Returns the lower extent of the dimensions in args.
.. code-block:: python
t_ex, bl_ex, ch_ex = cube.dim_lower_extent('ntime', 'nbl', 'nchan')
or
.. code-block:: python
t_ex, bl_ex, ch_ex, src_ex = cube... | [
"def",
"dim_lower_extent",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# The lower extent of any integral dimension is 0 by default",
"args",
"=",
"tuple",
"(",
"0",
"if",
"isinstance",
"(",
"a",
",",
"(",
"int",
",",
"np",
".",
"integ... | Returns the lower extent of the dimensions in args.
.. code-block:: python
t_ex, bl_ex, ch_ex = cube.dim_lower_extent('ntime', 'nbl', 'nchan')
or
.. code-block:: python
t_ex, bl_ex, ch_ex, src_ex = cube.dim_lower_extent('ntime,nbl:nchan nsrc') | [
"Returns",
"the",
"lower",
"extent",
"of",
"the",
"dimensions",
"in",
"args",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L300-L318 |
53,576 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_extents | def dim_extents(self, *args, **kwargs):
"""
Returns extent tuples of the dimensions in args.
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_extents('ntime', 'nbl')
or
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_upper_extent('ntime,nbl')... | python | def dim_extents(self, *args, **kwargs):
"""
Returns extent tuples of the dimensions in args.
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_extents('ntime', 'nbl')
or
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_upper_extent('ntime,nbl')... | [
"def",
"dim_extents",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"l",
"=",
"self",
".",
"dim_lower_extent",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"u",
"=",
"self",
".",
"dim_upper_extent",
"(",
"*",
"args",
",",
"... | Returns extent tuples of the dimensions in args.
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_extents('ntime', 'nbl')
or
.. code-block:: python
(tl, tu), (bl, bu) = cube.dim_upper_extent('ntime,nbl') | [
"Returns",
"extent",
"tuples",
"of",
"the",
"dimensions",
"in",
"args",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L337-L360 |
53,577 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.dim_extent_size | def dim_extent_size(self, *args, **kwargs):
"""
Returns extent sizes of the dimensions in args.
.. code-block:: python
ts, bs, cs = cube.dim_extent_size('ntime', 'nbl', 'nchan')
or
.. code-block:: python
ts, bs, cs, ss = cube.dim_extent_size('ntime,nb... | python | def dim_extent_size(self, *args, **kwargs):
"""
Returns extent sizes of the dimensions in args.
.. code-block:: python
ts, bs, cs = cube.dim_extent_size('ntime', 'nbl', 'nchan')
or
.. code-block:: python
ts, bs, cs, ss = cube.dim_extent_size('ntime,nb... | [
"def",
"dim_extent_size",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"extents",
"=",
"self",
".",
"dim_extents",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# Handle tuples and sequences differently",
"if",
"isinstance",
"(",
"e... | Returns extent sizes of the dimensions in args.
.. code-block:: python
ts, bs, cs = cube.dim_extent_size('ntime', 'nbl', 'nchan')
or
.. code-block:: python
ts, bs, cs, ss = cube.dim_extent_size('ntime,nbl:nchan nsrc') | [
"Returns",
"extent",
"sizes",
"of",
"the",
"dimensions",
"in",
"args",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L362-L384 |
53,578 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.register_array | def register_array(self, name, shape, dtype, **kwargs):
"""
Register an array with this cube.
.. code-block:: python
cube.register_array("model_vis", ("ntime", "nbl", "nchan", 4), np.complex128)
Parameters
----------
name : str
Array name
... | python | def register_array(self, name, shape, dtype, **kwargs):
"""
Register an array with this cube.
.. code-block:: python
cube.register_array("model_vis", ("ntime", "nbl", "nchan", 4), np.complex128)
Parameters
----------
name : str
Array name
... | [
"def",
"register_array",
"(",
"self",
",",
"name",
",",
"shape",
",",
"dtype",
",",
"*",
"*",
"kwargs",
")",
":",
"# Complain if array exists",
"if",
"name",
"in",
"self",
".",
"_arrays",
":",
"raise",
"ValueError",
"(",
"(",
"'Array %s is already registered '... | Register an array with this cube.
.. code-block:: python
cube.register_array("model_vis", ("ntime", "nbl", "nchan", 4), np.complex128)
Parameters
----------
name : str
Array name
shape : A tuple containing either Dimension names or ints
Arra... | [
"Register",
"an",
"array",
"with",
"this",
"cube",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L386-L414 |
53,579 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.register_arrays | def register_arrays(self, arrays):
"""
Register arrays using a list of dictionaries defining the arrays.
The list should itself contain dictionaries. i.e.
.. code-block:: python
D = [{ 'name':'uvw', 'shape':(3,'ntime','nbl'),'dtype':np.float32 },
{ 'name':'... | python | def register_arrays(self, arrays):
"""
Register arrays using a list of dictionaries defining the arrays.
The list should itself contain dictionaries. i.e.
.. code-block:: python
D = [{ 'name':'uvw', 'shape':(3,'ntime','nbl'),'dtype':np.float32 },
{ 'name':'... | [
"def",
"register_arrays",
"(",
"self",
",",
"arrays",
")",
":",
"if",
"isinstance",
"(",
"arrays",
",",
"collections",
".",
"Mapping",
")",
":",
"arrays",
"=",
"arrays",
".",
"itervalues",
"(",
")",
"for",
"ary",
"in",
"arrays",
":",
"self",
".",
"regi... | Register arrays using a list of dictionaries defining the arrays.
The list should itself contain dictionaries. i.e.
.. code-block:: python
D = [{ 'name':'uvw', 'shape':(3,'ntime','nbl'),'dtype':np.float32 },
{ 'name':'lm', 'shape':(2,'nsrc'),'dtype':np.float32 }]
... | [
"Register",
"arrays",
"using",
"a",
"list",
"of",
"dictionaries",
"defining",
"the",
"arrays",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L416-L437 |
53,580 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.register_properties | def register_properties(self, properties):
"""
Register properties using a list defining the properties.
The dictionary should itself contain dictionaries. i.e.
.. code-block:: python
D = [
{ 'name':'ref_wave','dtype':np.float32,
'defaul... | python | def register_properties(self, properties):
"""
Register properties using a list defining the properties.
The dictionary should itself contain dictionaries. i.e.
.. code-block:: python
D = [
{ 'name':'ref_wave','dtype':np.float32,
'defaul... | [
"def",
"register_properties",
"(",
"self",
",",
"properties",
")",
":",
"if",
"isinstance",
"(",
"properties",
",",
"collections",
".",
"Mapping",
")",
":",
"properties",
"=",
"properties",
".",
"itervalues",
"(",
")",
"for",
"prop",
"in",
"properties",
":",... | Register properties using a list defining the properties.
The dictionary should itself contain dictionaries. i.e.
.. code-block:: python
D = [
{ 'name':'ref_wave','dtype':np.float32,
'default':1.41e6 },
]
Parameters
--------... | [
"Register",
"properties",
"using",
"a",
"list",
"defining",
"the",
"properties",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L499-L523 |
53,581 | ska-sa/hypercube | hypercube/base_cube.py | HyperCube.array_extents | def array_extents(self, array_name, **kwargs):
"""
Return a list of lower and upper extents for
the given array_name.
.. code-block:: python
cube.register("uvw", ("ntime", "na", 3), np.float64)
(lt, ut), (la, ua), (_, _) = cube.array_extents("uvw")
Par... | python | def array_extents(self, array_name, **kwargs):
"""
Return a list of lower and upper extents for
the given array_name.
.. code-block:: python
cube.register("uvw", ("ntime", "na", 3), np.float64)
(lt, ut), (la, ua), (_, _) = cube.array_extents("uvw")
Par... | [
"def",
"array_extents",
"(",
"self",
",",
"array_name",
",",
"*",
"*",
"kwargs",
")",
":",
"A",
"=",
"self",
".",
"array",
"(",
"array_name",
",",
"reify",
"=",
"False",
")",
"return",
"self",
".",
"dim_extents",
"(",
"*",
"A",
".",
"shape",
",",
"... | Return a list of lower and upper extents for
the given array_name.
.. code-block:: python
cube.register("uvw", ("ntime", "na", 3), np.float64)
(lt, ut), (la, ua), (_, _) = cube.array_extents("uvw")
Parameters
----------
array_name : string
... | [
"Return",
"a",
"list",
"of",
"lower",
"and",
"upper",
"extents",
"for",
"the",
"given",
"array_name",
"."
] | 6564a9e65ccd9ed7e7a71bd643f183e1ec645b29 | https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L906-L933 |
53,582 | wummel/dosage | scripts/scriptutil.py | contains_case_insensitive | def contains_case_insensitive(adict, akey):
"""Check if key is in adict. The search is case insensitive."""
for key in adict:
if key.lower() == akey.lower():
return True
return False | python | def contains_case_insensitive(adict, akey):
"""Check if key is in adict. The search is case insensitive."""
for key in adict:
if key.lower() == akey.lower():
return True
return False | [
"def",
"contains_case_insensitive",
"(",
"adict",
",",
"akey",
")",
":",
"for",
"key",
"in",
"adict",
":",
"if",
"key",
".",
"lower",
"(",
")",
"==",
"akey",
".",
"lower",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | Check if key is in adict. The search is case insensitive. | [
"Check",
"if",
"key",
"is",
"in",
"adict",
".",
"The",
"search",
"is",
"case",
"insensitive",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/scriptutil.py#L6-L11 |
53,583 | wummel/dosage | scripts/scriptutil.py | save_result | def save_result(res, json_file):
"""Save result to file."""
with open(json_file, 'wb') as f:
json.dump(res, f, sort_keys=True) | python | def save_result(res, json_file):
"""Save result to file."""
with open(json_file, 'wb') as f:
json.dump(res, f, sort_keys=True) | [
"def",
"save_result",
"(",
"res",
",",
"json_file",
")",
":",
"with",
"open",
"(",
"json_file",
",",
"'wb'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"res",
",",
"f",
",",
"sort_keys",
"=",
"True",
")"
] | Save result to file. | [
"Save",
"result",
"to",
"file",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/scriptutil.py#L35-L38 |
53,584 | wummel/dosage | scripts/scriptutil.py | format_name | def format_name(text):
"""Format a comic name."""
name = unescape(text)
name = asciify(name.replace(u'&', u'And').replace(u'@', u'At'))
name = capfirst(name)
return name | python | def format_name(text):
"""Format a comic name."""
name = unescape(text)
name = asciify(name.replace(u'&', u'And').replace(u'@', u'At'))
name = capfirst(name)
return name | [
"def",
"format_name",
"(",
"text",
")",
":",
"name",
"=",
"unescape",
"(",
"text",
")",
"name",
"=",
"asciify",
"(",
"name",
".",
"replace",
"(",
"u'&'",
",",
"u'And'",
")",
".",
"replace",
"(",
"u'@'",
",",
"u'At'",
")",
")",
"name",
"=",
"capfirs... | Format a comic name. | [
"Format",
"a",
"comic",
"name",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/scriptutil.py#L52-L57 |
53,585 | misli/django-cms-articles | cms_articles/utils/article.py | get_article_from_slug | def get_article_from_slug(tree, slug, preview=False, draft=False):
"""
Resolves a slug to a single article object.
Returns None if article does not exist
"""
from ..models import Title
titles = Title.objects.select_related('article').filter(article__tree=tree)
published_only = (not draft an... | python | def get_article_from_slug(tree, slug, preview=False, draft=False):
"""
Resolves a slug to a single article object.
Returns None if article does not exist
"""
from ..models import Title
titles = Title.objects.select_related('article').filter(article__tree=tree)
published_only = (not draft an... | [
"def",
"get_article_from_slug",
"(",
"tree",
",",
"slug",
",",
"preview",
"=",
"False",
",",
"draft",
"=",
"False",
")",
":",
"from",
".",
".",
"models",
"import",
"Title",
"titles",
"=",
"Title",
".",
"objects",
".",
"select_related",
"(",
"'article'",
... | Resolves a slug to a single article object.
Returns None if article does not exist | [
"Resolves",
"a",
"slug",
"to",
"a",
"single",
"article",
"object",
".",
"Returns",
"None",
"if",
"article",
"does",
"not",
"exist"
] | d96ac77e049022deb4c70d268e4eab74d175145c | https://github.com/misli/django-cms-articles/blob/d96ac77e049022deb4c70d268e4eab74d175145c/cms_articles/utils/article.py#L7-L31 |
53,586 | danpoland/pyramid-restful-framework | pyramid_restful/viewsets.py | ViewSetMixin.as_view | def as_view(cls, action_map=None, **initkwargs):
"""
Allows custom request to method routing based on given ``action_map`` kwarg.
"""
# Needs to re-implement the method but contains all the things the parent does.
if not action_map: # actions must not be empty
raise... | python | def as_view(cls, action_map=None, **initkwargs):
"""
Allows custom request to method routing based on given ``action_map`` kwarg.
"""
# Needs to re-implement the method but contains all the things the parent does.
if not action_map: # actions must not be empty
raise... | [
"def",
"as_view",
"(",
"cls",
",",
"action_map",
"=",
"None",
",",
"*",
"*",
"initkwargs",
")",
":",
"# Needs to re-implement the method but contains all the things the parent does.",
"if",
"not",
"action_map",
":",
"# actions must not be empty",
"raise",
"TypeError",
"("... | Allows custom request to method routing based on given ``action_map`` kwarg. | [
"Allows",
"custom",
"request",
"to",
"method",
"routing",
"based",
"on",
"given",
"action_map",
"kwarg",
"."
] | 4d8c9db44b1869c3d1fdd59ca304c3166473fcbb | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/viewsets.py#L18-L40 |
53,587 | gmr/tinman | tinman/example.py | Handler.get | def get(self, *args, **kwargs):
"""Example HTTP Get response method.
:param args: positional args
:param kwargs: keyword args
"""
self.session.username = 'gmr'
session = self.session.as_dict()
if session['last_request_at']:
session['last_request_at'... | python | def get(self, *args, **kwargs):
"""Example HTTP Get response method.
:param args: positional args
:param kwargs: keyword args
"""
self.session.username = 'gmr'
session = self.session.as_dict()
if session['last_request_at']:
session['last_request_at'... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"session",
".",
"username",
"=",
"'gmr'",
"session",
"=",
"self",
".",
"session",
".",
"as_dict",
"(",
")",
"if",
"session",
"[",
"'last_request_at'",
"]",
... | Example HTTP Get response method.
:param args: positional args
:param kwargs: keyword args | [
"Example",
"HTTP",
"Get",
"response",
"method",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/example.py#L44-L68 |
53,588 | gmr/tinman | tinman/serializers.py | Serializer._deserialize_datetime | def _deserialize_datetime(self, data):
"""Take any values coming in as a datetime and deserialize them
"""
for key in data:
if isinstance(data[key], dict):
if data[key].get('type') == 'datetime':
data[key] = \
datetime.date... | python | def _deserialize_datetime(self, data):
"""Take any values coming in as a datetime and deserialize them
"""
for key in data:
if isinstance(data[key], dict):
if data[key].get('type') == 'datetime':
data[key] = \
datetime.date... | [
"def",
"_deserialize_datetime",
"(",
"self",
",",
"data",
")",
":",
"for",
"key",
"in",
"data",
":",
"if",
"isinstance",
"(",
"data",
"[",
"key",
"]",
",",
"dict",
")",
":",
"if",
"data",
"[",
"key",
"]",
".",
"get",
"(",
"'type'",
")",
"==",
"'d... | Take any values coming in as a datetime and deserialize them | [
"Take",
"any",
"values",
"coming",
"in",
"as",
"a",
"datetime",
"and",
"deserialize",
"them"
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/serializers.py#L39-L48 |
53,589 | gmr/tinman | tinman/serializers.py | Pickle.deserialize | def deserialize(self, data):
"""Return the deserialized data.
:param str data: The data to deserialize
:rtype: dict
"""
if not data:
return dict()
return self._deserialize_datetime(pickle.loads(data)) | python | def deserialize(self, data):
"""Return the deserialized data.
:param str data: The data to deserialize
:rtype: dict
"""
if not data:
return dict()
return self._deserialize_datetime(pickle.loads(data)) | [
"def",
"deserialize",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"dict",
"(",
")",
"return",
"self",
".",
"_deserialize_datetime",
"(",
"pickle",
".",
"loads",
"(",
"data",
")",
")"
] | Return the deserialized data.
:param str data: The data to deserialize
:rtype: dict | [
"Return",
"the",
"deserialized",
"data",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/serializers.py#L60-L69 |
53,590 | gmr/tinman | tinman/serializers.py | JSON.serialize | def serialize(self, data):
"""Return the data as serialized string.
:param dict data: The data to serialize
:rtype: str
"""
return json.dumps(self._serialize_datetime(data), ensure_ascii=False) | python | def serialize(self, data):
"""Return the data as serialized string.
:param dict data: The data to serialize
:rtype: str
"""
return json.dumps(self._serialize_datetime(data), ensure_ascii=False) | [
"def",
"serialize",
"(",
"self",
",",
"data",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"_serialize_datetime",
"(",
"data",
")",
",",
"ensure_ascii",
"=",
"False",
")"
] | Return the data as serialized string.
:param dict data: The data to serialize
:rtype: str | [
"Return",
"the",
"data",
"as",
"serialized",
"string",
"."
] | 98f0acd15a228d752caa1864cdf02aaa3d492a9f | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/serializers.py#L92-L99 |
53,591 | wummel/dosage | dosagelib/director.py | get_host_lock | def get_host_lock(url):
"""Get lock object for given URL host."""
hostname = get_hostname(url)
return host_locks.setdefault(hostname, threading.Lock()) | python | def get_host_lock(url):
"""Get lock object for given URL host."""
hostname = get_hostname(url)
return host_locks.setdefault(hostname, threading.Lock()) | [
"def",
"get_host_lock",
"(",
"url",
")",
":",
"hostname",
"=",
"get_hostname",
"(",
"url",
")",
"return",
"host_locks",
".",
"setdefault",
"(",
"hostname",
",",
"threading",
".",
"Lock",
"(",
")",
")"
] | Get lock object for given URL host. | [
"Get",
"lock",
"object",
"for",
"given",
"URL",
"host",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L58-L61 |
53,592 | wummel/dosage | dosagelib/director.py | getComics | def getComics(options):
"""Retrieve comics."""
if options.handler:
for name in set(options.handler):
events.addHandler(name, options.basepath, options.baseurl, options.allowdownscale)
events.getHandler().start()
errors = 0
try:
for scraperobj in getScrapers(options.comic,... | python | def getComics(options):
"""Retrieve comics."""
if options.handler:
for name in set(options.handler):
events.addHandler(name, options.basepath, options.baseurl, options.allowdownscale)
events.getHandler().start()
errors = 0
try:
for scraperobj in getScrapers(options.comic,... | [
"def",
"getComics",
"(",
"options",
")",
":",
"if",
"options",
".",
"handler",
":",
"for",
"name",
"in",
"set",
"(",
"options",
".",
"handler",
")",
":",
"events",
".",
"addHandler",
"(",
"name",
",",
"options",
".",
"basepath",
",",
"options",
".",
... | Retrieve comics. | [
"Retrieve",
"comics",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L153-L180 |
53,593 | wummel/dosage | dosagelib/director.py | finish | def finish():
"""Print warning about interrupt and empty the job queue."""
out.warn("Interrupted!")
for t in threads:
t.stop()
jobs.clear()
out.warn("Waiting for download threads to finish.") | python | def finish():
"""Print warning about interrupt and empty the job queue."""
out.warn("Interrupted!")
for t in threads:
t.stop()
jobs.clear()
out.warn("Waiting for download threads to finish.") | [
"def",
"finish",
"(",
")",
":",
"out",
".",
"warn",
"(",
"\"Interrupted!\"",
")",
"for",
"t",
"in",
"threads",
":",
"t",
".",
"stop",
"(",
")",
"jobs",
".",
"clear",
"(",
")",
"out",
".",
"warn",
"(",
"\"Waiting for download threads to finish.\"",
")"
] | Print warning about interrupt and empty the job queue. | [
"Print",
"warning",
"about",
"interrupt",
"and",
"empty",
"the",
"job",
"queue",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L183-L189 |
53,594 | wummel/dosage | dosagelib/director.py | getScrapers | def getScrapers(comics, basepath=None, adult=True, multiple_allowed=False, listing=False):
"""Get scraper objects for the given comics."""
if '@' in comics:
# only scrapers whose directory already exists
if len(comics) > 1:
out.warn(u"using '@' as comic name ignores all other specifi... | python | def getScrapers(comics, basepath=None, adult=True, multiple_allowed=False, listing=False):
"""Get scraper objects for the given comics."""
if '@' in comics:
# only scrapers whose directory already exists
if len(comics) > 1:
out.warn(u"using '@' as comic name ignores all other specifi... | [
"def",
"getScrapers",
"(",
"comics",
",",
"basepath",
"=",
"None",
",",
"adult",
"=",
"True",
",",
"multiple_allowed",
"=",
"False",
",",
"listing",
"=",
"False",
")",
":",
"if",
"'@'",
"in",
"comics",
":",
"# only scrapers whose directory already exists",
"if... | Get scraper objects for the given comics. | [
"Get",
"scraper",
"objects",
"for",
"the",
"given",
"comics",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L197-L236 |
53,595 | wummel/dosage | dosagelib/director.py | warn_disabled | def warn_disabled(scraperclass, reasons):
"""Print warning about disabled comic modules."""
out.warn(u"Skipping comic %s: %s" % (scraperclass.getName(), ' '.join(reasons.values()))) | python | def warn_disabled(scraperclass, reasons):
"""Print warning about disabled comic modules."""
out.warn(u"Skipping comic %s: %s" % (scraperclass.getName(), ' '.join(reasons.values()))) | [
"def",
"warn_disabled",
"(",
"scraperclass",
",",
"reasons",
")",
":",
"out",
".",
"warn",
"(",
"u\"Skipping comic %s: %s\"",
"%",
"(",
"scraperclass",
".",
"getName",
"(",
")",
",",
"' '",
".",
"join",
"(",
"reasons",
".",
"values",
"(",
")",
")",
")",
... | Print warning about disabled comic modules. | [
"Print",
"warning",
"about",
"disabled",
"comic",
"modules",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L256-L258 |
53,596 | wummel/dosage | dosagelib/director.py | ComicQueue.clear | def clear(self):
"""Remove all queue entries."""
self.mutex.acquire()
self.queue.clear()
self.mutex.release() | python | def clear(self):
"""Remove all queue entries."""
self.mutex.acquire()
self.queue.clear()
self.mutex.release() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"mutex",
".",
"acquire",
"(",
")",
"self",
".",
"queue",
".",
"clear",
"(",
")",
"self",
".",
"mutex",
".",
"release",
"(",
")"
] | Remove all queue entries. | [
"Remove",
"all",
"queue",
"entries",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L41-L45 |
53,597 | wummel/dosage | dosagelib/director.py | ComicGetter.run | def run(self):
"""Process from queue until it is empty."""
try:
while not self.stopped:
scraperobj = jobs.get(False)
self.setName(scraperobj.getName())
try:
self.getStrips(scraperobj)
finally:
... | python | def run(self):
"""Process from queue until it is empty."""
try:
while not self.stopped:
scraperobj = jobs.get(False)
self.setName(scraperobj.getName())
try:
self.getStrips(scraperobj)
finally:
... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"while",
"not",
"self",
".",
"stopped",
":",
"scraperobj",
"=",
"jobs",
".",
"get",
"(",
"False",
")",
"self",
".",
"setName",
"(",
"scraperobj",
".",
"getName",
"(",
")",
")",
"try",
":",
"self",
... | Process from queue until it is empty. | [
"Process",
"from",
"queue",
"until",
"it",
"is",
"empty",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L75-L89 |
53,598 | wummel/dosage | dosagelib/director.py | ComicGetter.getStrips | def getStrips(self, scraperobj):
"""Download comic strips."""
with lock:
host_lock = get_host_lock(scraperobj.url)
with host_lock:
self._getStrips(scraperobj) | python | def getStrips(self, scraperobj):
"""Download comic strips."""
with lock:
host_lock = get_host_lock(scraperobj.url)
with host_lock:
self._getStrips(scraperobj) | [
"def",
"getStrips",
"(",
"self",
",",
"scraperobj",
")",
":",
"with",
"lock",
":",
"host_lock",
"=",
"get_host_lock",
"(",
"scraperobj",
".",
"url",
")",
"with",
"host_lock",
":",
"self",
".",
"_getStrips",
"(",
"scraperobj",
")"
] | Download comic strips. | [
"Download",
"comic",
"strips",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L91-L96 |
53,599 | wummel/dosage | dosagelib/director.py | ComicGetter._getStrips | def _getStrips(self, scraperobj):
"""Get all strips from a scraper."""
if self.options.all or self.options.cont:
numstrips = None
elif self.options.numstrips:
numstrips = self.options.numstrips
else:
# get current strip
numstrips = 1
... | python | def _getStrips(self, scraperobj):
"""Get all strips from a scraper."""
if self.options.all or self.options.cont:
numstrips = None
elif self.options.numstrips:
numstrips = self.options.numstrips
else:
# get current strip
numstrips = 1
... | [
"def",
"_getStrips",
"(",
"self",
",",
"scraperobj",
")",
":",
"if",
"self",
".",
"options",
".",
"all",
"or",
"self",
".",
"options",
".",
"cont",
":",
"numstrips",
"=",
"None",
"elif",
"self",
".",
"options",
".",
"numstrips",
":",
"numstrips",
"=",
... | Get all strips from a scraper. | [
"Get",
"all",
"strips",
"from",
"a",
"scraper",
"."
] | a0109c3a46219f280e6e5e77183674e40da0f304 | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/director.py#L98-L124 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.