repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
basvandenbroek/gcloud_taskqueue
gcloud_taskqueue/task.py
Task.delete
def delete(self, client=None): """Deletes a task from Task Queue. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use. If not passed, falls back to the ``client`` stored on the task's taskqueue. :rtype...
python
def delete(self, client=None): """Deletes a task from Task Queue. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use. If not passed, falls back to the ``client`` stored on the task's taskqueue. :rtype...
[ "def", "delete", "(", "self", ",", "client", "=", "None", ")", ":", "return", "self", ".", "taskqueue", ".", "delete_task", "(", "self", ".", "id", ",", "client", "=", "client", ")" ]
Deletes a task from Task Queue. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use. If not passed, falls back to the ``client`` stored on the task's taskqueue. :rtype: :class:`Task` :returns: The task...
[ "Deletes", "a", "task", "from", "Task", "Queue", "." ]
train
https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L93-L106
basvandenbroek/gcloud_taskqueue
gcloud_taskqueue/task.py
Task.update
def update(self, new_lease_time, client=None): """Update the duration of a task lease :type new_lease_time: int :param new_lease_time: the new lease time in seconds. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use...
python
def update(self, new_lease_time, client=None): """Update the duration of a task lease :type new_lease_time: int :param new_lease_time: the new lease time in seconds. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use...
[ "def", "update", "(", "self", ",", "new_lease_time", ",", "client", "=", "None", ")", ":", "return", "self", ".", "taskqueue", ".", "update_task", "(", "self", ".", "id", ",", "new_lease_time", "=", "new_lease_time", ",", "client", "=", "client", ")" ]
Update the duration of a task lease :type new_lease_time: int :param new_lease_time: the new lease time in seconds. :type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType`` :param client: Optional. The client to use. If not passed, falls back to the...
[ "Update", "the", "duration", "of", "a", "task", "lease" ]
train
https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L108-L124
basvandenbroek/gcloud_taskqueue
gcloud_taskqueue/task.py
Task.description
def description(self): """The description for this task. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: string :returns: The description for this task. """ if self._description is None: if 'payloadBase64' not in self._proper...
python
def description(self): """The description for this task. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: string :returns: The description for this task. """ if self._description is None: if 'payloadBase64' not in self._proper...
[ "def", "description", "(", "self", ")", ":", "if", "self", ".", "_description", "is", "None", ":", "if", "'payloadBase64'", "not", "in", "self", ".", "_properties", ":", "self", ".", "_properties", "=", "self", ".", "taskqueue", ".", "get_task", "(", "id...
The description for this task. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: string :returns: The description for this task.
[ "The", "description", "for", "this", "task", "." ]
train
https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L162-L174
basvandenbroek/gcloud_taskqueue
gcloud_taskqueue/task.py
Task.time_enqueued
def time_enqueued(self): """Retrieve the timestamp at which the task was enqueued. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: :class:`datetime.datetime` or ``NoneType`` :returns: Datetime object parsed from microsecond timestamp, or ...
python
def time_enqueued(self): """Retrieve the timestamp at which the task was enqueued. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: :class:`datetime.datetime` or ``NoneType`` :returns: Datetime object parsed from microsecond timestamp, or ...
[ "def", "time_enqueued", "(", "self", ")", ":", "value", "=", "self", ".", "_properties", ".", "get", "(", "'enqueueTimestamp'", ")", "if", "value", "is", "not", "None", ":", "return", "_datetime_from_microseconds", "(", "int", "(", "value", ")", ")" ]
Retrieve the timestamp at which the task was enqueued. See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks :rtype: :class:`datetime.datetime` or ``NoneType`` :returns: Datetime object parsed from microsecond timestamp, or ``None`` if the property is not s...
[ "Retrieve", "the", "timestamp", "at", "which", "the", "task", "was", "enqueued", "." ]
train
https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L177-L188
basvandenbroek/gcloud_taskqueue
gcloud_taskqueue/task.py
Task.leaseTimestamp
def leaseTimestamp(self): """Retrieve the timestamp at which the task lease will expire. If this task has never been leased, it will be None. If this this task has been previously leased and the lease has expired, this value will be < Now(). See: https://cloud.google.com/appengine/docs/...
python
def leaseTimestamp(self): """Retrieve the timestamp at which the task lease will expire. If this task has never been leased, it will be None. If this this task has been previously leased and the lease has expired, this value will be < Now(). See: https://cloud.google.com/appengine/docs/...
[ "def", "leaseTimestamp", "(", "self", ")", ":", "value", "=", "self", ".", "_properties", ".", "get", "(", "'leaseTimestamp'", ")", "if", "value", "is", "not", "None", ":", "return", "_datetime_from_microseconds", "(", "int", "(", "value", ")", ")" ]
Retrieve the timestamp at which the task lease will expire. If this task has never been leased, it will be None. If this this task has been previously leased and the lease has expired, this value will be < Now(). See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks ...
[ "Retrieve", "the", "timestamp", "at", "which", "the", "task", "lease", "will", "expire", ".", "If", "this", "task", "has", "never", "been", "leased", "it", "will", "be", "None", ".", "If", "this", "this", "task", "has", "been", "previously", "leased", "a...
train
https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L191-L205
stormy-ua/DeepLearningToy
src/pydeeptoy/computational_graph.py
ComputationalGraph.conv2d
def conv2d(self, x_in: Connection, w_in: Connection, receptive_field_size, filters_number, stride=1, padding=1, name=""): """ Computes a 2-D convolution given 4-D input and filter tensors. """ x_cols = self.tensor_3d_to_cols(x_in, receptive_field_size, stride=stride, paddi...
python
def conv2d(self, x_in: Connection, w_in: Connection, receptive_field_size, filters_number, stride=1, padding=1, name=""): """ Computes a 2-D convolution given 4-D input and filter tensors. """ x_cols = self.tensor_3d_to_cols(x_in, receptive_field_size, stride=stride, paddi...
[ "def", "conv2d", "(", "self", ",", "x_in", ":", "Connection", ",", "w_in", ":", "Connection", ",", "receptive_field_size", ",", "filters_number", ",", "stride", "=", "1", ",", "padding", "=", "1", ",", "name", "=", "\"\"", ")", ":", "x_cols", "=", "sel...
Computes a 2-D convolution given 4-D input and filter tensors.
[ "Computes", "a", "2", "-", "D", "convolution", "given", "4", "-", "D", "input", "and", "filter", "tensors", "." ]
train
https://github.com/stormy-ua/DeepLearningToy/blob/7ab0814ec0491a575ebee8eb1ccd61ce4bf9554b/src/pydeeptoy/computational_graph.py#L141-L156
beatmax/redmodel
redmodel/models/writer.py
SortedSetFieldWriter.append
def append(self, hcont, value, score = None): """ If sort_field is specified, score must be None. If sort_field is not specified, score is mandatory. """ assert (score is None) != (self.field.sort_field is None) if score is None: score = getattr(value, self.field.sort_fie...
python
def append(self, hcont, value, score = None): """ If sort_field is specified, score must be None. If sort_field is not specified, score is mandatory. """ assert (score is None) != (self.field.sort_field is None) if score is None: score = getattr(value, self.field.sort_fie...
[ "def", "append", "(", "self", ",", "hcont", ",", "value", ",", "score", "=", "None", ")", ":", "assert", "(", "score", "is", "None", ")", "!=", "(", "self", ".", "field", ".", "sort_field", "is", "None", ")", "if", "score", "is", "None", ":", "sc...
If sort_field is specified, score must be None. If sort_field is not specified, score is mandatory.
[ "If", "sort_field", "is", "specified", "score", "must", "be", "None", ".", "If", "sort_field", "is", "not", "specified", "score", "is", "mandatory", "." ]
train
https://github.com/beatmax/redmodel/blob/1df545ecd8e36e8addeaac124db32d9d0e22938c/redmodel/models/writer.py#L203-L209
fogcitymarathoner/s3_mysql_backup
s3_mysql_backup/copy_file.py
copy_file
def copy_file(aws_access_key_id, aws_secret_access_key, bucket_name, file, s3_folder): """ copies file to bucket s3_folder """ # Connect to the bucket bucket = s3_bucket(aws_access_key_id, aws_secret_access_key, bucket_name) key = boto.s3.key.Key(bucket) if s3_folder: target_name...
python
def copy_file(aws_access_key_id, aws_secret_access_key, bucket_name, file, s3_folder): """ copies file to bucket s3_folder """ # Connect to the bucket bucket = s3_bucket(aws_access_key_id, aws_secret_access_key, bucket_name) key = boto.s3.key.Key(bucket) if s3_folder: target_name...
[ "def", "copy_file", "(", "aws_access_key_id", ",", "aws_secret_access_key", ",", "bucket_name", ",", "file", ",", "s3_folder", ")", ":", "# Connect to the bucket", "bucket", "=", "s3_bucket", "(", "aws_access_key_id", ",", "aws_secret_access_key", ",", "bucket_name", ...
copies file to bucket s3_folder
[ "copies", "file", "to", "bucket", "s3_folder" ]
train
https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/copy_file.py#L8-L26
minorg/pastpy
py/src/pastpy/gen/database/impl/online/online_database_objects_list_item.py
OnlineDatabaseObjectsListItem.read
def read(cls, iprot): ''' Read a new object from the given input protocol and return the object. :type iprot: thryft.protocol._input_protocol._InputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem ''' init_...
python
def read(cls, iprot): ''' Read a new object from the given input protocol and return the object. :type iprot: thryft.protocol._input_protocol._InputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem ''' init_...
[ "def", "read", "(", "cls", ",", "iprot", ")", ":", "init_kwds", "=", "{", "}", "iprot", ".", "read_struct_begin", "(", ")", "while", "True", ":", "ifield_name", ",", "ifield_type", ",", "_ifield_id", "=", "iprot", ".", "read_field_begin", "(", ")", "if",...
Read a new object from the given input protocol and return the object. :type iprot: thryft.protocol._input_protocol._InputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem
[ "Read", "a", "new", "object", "from", "the", "given", "input", "protocol", "and", "return", "the", "object", "." ]
train
https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/online/online_database_objects_list_item.py#L255-L284
minorg/pastpy
py/src/pastpy/gen/database/impl/online/online_database_objects_list_item.py
OnlineDatabaseObjectsListItem.write
def write(self, oprot): ''' Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem ''' oprot.wr...
python
def write(self, oprot): ''' Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem ''' oprot.wr...
[ "def", "write", "(", "self", ",", "oprot", ")", ":", "oprot", ".", "write_struct_begin", "(", "'OnlineDatabaseObjectsListItem'", ")", "oprot", ".", "write_field_begin", "(", "name", "=", "'detail_href'", ",", "type", "=", "11", ",", "id", "=", "None", ")", ...
Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.online.online_database_objects_list_item.OnlineDatabaseObjectsListItem
[ "Write", "this", "object", "to", "the", "given", "output", "protocol", "and", "return", "self", "." ]
train
https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/online/online_database_objects_list_item.py#L309-L340
sliem/barrett
example/plot.py
main
def main(): """ We here demostrate the basic functionality of barrett. We use a global scan of scalar dark matter as an example. The details aren't really important. """ dataset = 'RD' observables = ['log(<\sigma v>)', '\Omega_{\chi}h^2', 'log(\sigma_p^{SI})'] var = ['log(m_{\chi})'] var +...
python
def main(): """ We here demostrate the basic functionality of barrett. We use a global scan of scalar dark matter as an example. The details aren't really important. """ dataset = 'RD' observables = ['log(<\sigma v>)', '\Omega_{\chi}h^2', 'log(\sigma_p^{SI})'] var = ['log(m_{\chi})'] var +...
[ "def", "main", "(", ")", ":", "dataset", "=", "'RD'", "observables", "=", "[", "'log(<\\sigma v>)'", ",", "'\\Omega_{\\chi}h^2'", ",", "'log(\\sigma_p^{SI})'", "]", "var", "=", "[", "'log(m_{\\chi})'", "]", "var", "+=", "[", "'log(C_1)'", ",", "'log(C_2)'", ",...
We here demostrate the basic functionality of barrett. We use a global scan of scalar dark matter as an example. The details aren't really important.
[ "We", "here", "demostrate", "the", "basic", "functionality", "of", "barrett", ".", "We", "use", "a", "global", "scan", "of", "scalar", "dark", "matter", "as", "an", "example", ".", "The", "details", "aren", "t", "really", "important", "." ]
train
https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L10-L23
sliem/barrett
example/plot.py
pairplot
def pairplot(dataset, vars, filename, bins=60): """ Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs. """ n = len(vars) fig, axes = plt.subplots(nrows=n, ncols=n) plt.subplots_adjust(wspace=0.1, hspace=0.1) for i, x in enumerate(vars): for j, y in enumerate(var...
python
def pairplot(dataset, vars, filename, bins=60): """ Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs. """ n = len(vars) fig, axes = plt.subplots(nrows=n, ncols=n) plt.subplots_adjust(wspace=0.1, hspace=0.1) for i, x in enumerate(vars): for j, y in enumerate(var...
[ "def", "pairplot", "(", "dataset", ",", "vars", ",", "filename", ",", "bins", "=", "60", ")", ":", "n", "=", "len", "(", "vars", ")", "fig", ",", "axes", "=", "plt", ".", "subplots", "(", "nrows", "=", "n", ",", "ncols", "=", "n", ")", "plt", ...
Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs.
[ "Plot", "a", "matrix", "of", "the", "specified", "variables", "with", "all", "the", "2D", "pdfs", "and", "1D", "pdfs", "." ]
train
https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L26-L73
sliem/barrett
example/plot.py
plot_vs_mass
def plot_vs_mass(dataset, vars, filename, bins=60): """ Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass. We plot the one sigma, and two sigma filled contours. More contours can be plotted which produces something more akin to a heatmap. If one require more complicated plotting, it...
python
def plot_vs_mass(dataset, vars, filename, bins=60): """ Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass. We plot the one sigma, and two sigma filled contours. More contours can be plotted which produces something more akin to a heatmap. If one require more complicated plotting, it...
[ "def", "plot_vs_mass", "(", "dataset", ",", "vars", ",", "filename", ",", "bins", "=", "60", ")", ":", "n", "=", "len", "(", "vars", ")", "fig", ",", "axes", "=", "plt", ".", "subplots", "(", "nrows", "=", "n", ",", "ncols", "=", "1", ",", "sha...
Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass. We plot the one sigma, and two sigma filled contours. More contours can be plotted which produces something more akin to a heatmap. If one require more complicated plotting, it is recommended to write a custom plotting function by e...
[ "Plot", "2D", "marginalised", "posteriors", "of", "the", "vars", "vs", "the", "dark", "matter", "mass", ".", "We", "plot", "the", "one", "sigma", "and", "two", "sigma", "filled", "contours", ".", "More", "contours", "can", "be", "plotted", "which", "produc...
train
https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L76-L110
sliem/barrett
example/plot.py
plot_oneD
def plot_oneD(dataset, vars, filename, bins=60): """ Plot 1D marginalised posteriors for the 'vars' of interest.""" n = len(vars) fig, axes = plt.subplots(nrows=n, ncols=1, sharex=False, sharey=False) for i, x in en...
python
def plot_oneD(dataset, vars, filename, bins=60): """ Plot 1D marginalised posteriors for the 'vars' of interest.""" n = len(vars) fig, axes = plt.subplots(nrows=n, ncols=1, sharex=False, sharey=False) for i, x in en...
[ "def", "plot_oneD", "(", "dataset", ",", "vars", ",", "filename", ",", "bins", "=", "60", ")", ":", "n", "=", "len", "(", "vars", ")", "fig", ",", "axes", "=", "plt", ".", "subplots", "(", "nrows", "=", "n", ",", "ncols", "=", "1", ",", "sharex...
Plot 1D marginalised posteriors for the 'vars' of interest.
[ "Plot", "1D", "marginalised", "posteriors", "for", "the", "vars", "of", "interest", "." ]
train
https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L113-L131
Vesuvium/frustum
frustum/Frustum.py
Frustum.start_logger
def start_logger(self): """ Enables the root logger and configures extra loggers. """ level = self.real_level(self.level) logging.basicConfig(level=level) self.set_logger(self.name, self.level) config.dictConfig(self.config) self.logger = logging.getLogger...
python
def start_logger(self): """ Enables the root logger and configures extra loggers. """ level = self.real_level(self.level) logging.basicConfig(level=level) self.set_logger(self.name, self.level) config.dictConfig(self.config) self.logger = logging.getLogger...
[ "def", "start_logger", "(", "self", ")", ":", "level", "=", "self", ".", "real_level", "(", "self", ".", "level", ")", "logging", ".", "basicConfig", "(", "level", "=", "level", ")", "self", ".", "set_logger", "(", "self", ".", "name", ",", "self", "...
Enables the root logger and configures extra loggers.
[ "Enables", "the", "root", "logger", "and", "configures", "extra", "loggers", "." ]
train
https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L22-L30
Vesuvium/frustum
frustum/Frustum.py
Frustum.set_logger
def set_logger(self, logger_name, level, handler=None): """ Sets the level of a logger """ if 'loggers' not in self.config: self.config['loggers'] = {} real_level = self.real_level(level) self.config['loggers'][logger_name] = {'level': real_level} if h...
python
def set_logger(self, logger_name, level, handler=None): """ Sets the level of a logger """ if 'loggers' not in self.config: self.config['loggers'] = {} real_level = self.real_level(level) self.config['loggers'][logger_name] = {'level': real_level} if h...
[ "def", "set_logger", "(", "self", ",", "logger_name", ",", "level", ",", "handler", "=", "None", ")", ":", "if", "'loggers'", "not", "in", "self", ".", "config", ":", "self", ".", "config", "[", "'loggers'", "]", "=", "{", "}", "real_level", "=", "se...
Sets the level of a logger
[ "Sets", "the", "level", "of", "a", "logger" ]
train
https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L37-L46
Vesuvium/frustum
frustum/Frustum.py
Frustum.register_event
def register_event(self, event_name, event_level, message): """ Registers an event so that it can be logged later. """ self.events[event_name] = (event_level, message)
python
def register_event(self, event_name, event_level, message): """ Registers an event so that it can be logged later. """ self.events[event_name] = (event_level, message)
[ "def", "register_event", "(", "self", ",", "event_name", ",", "event_level", ",", "message", ")", ":", "self", ".", "events", "[", "event_name", "]", "=", "(", "event_level", ",", "message", ")" ]
Registers an event so that it can be logged later.
[ "Registers", "an", "event", "so", "that", "it", "can", "be", "logged", "later", "." ]
train
https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L55-L59
rameshg87/pyremotevbox
pyremotevbox/ZSI/twisted/WSresource.py
DefaultCallbackHandler.processRequest
def processRequest(cls, ps, **kw): """invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request """ resource = kw['resour...
python
def processRequest(cls, ps, **kw): """invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request """ resource = kw['resour...
[ "def", "processRequest", "(", "cls", ",", "ps", ",", "*", "*", "kw", ")", ":", "resource", "=", "kw", "[", "'resource'", "]", "request", "=", "kw", "[", "'request'", "]", "method", "=", "getattr", "(", "resource", ",", "'soap_%s'", "%", "_get_element_n...
invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request
[ "invokes", "callback", "that", "should", "return", "a", "(", "request", "response", ")", "tuple", ".", "representing", "the", "SOAP", "request", "and", "response", "respectively", ".", "ps", "--", "ParsedSoap", "instance", "representing", "HTTP", "Body", ".", ...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/twisted/WSresource.py#L73-L96
rameshg87/pyremotevbox
pyremotevbox/ZSI/twisted/WSresource.py
WSResource._writeResponse
def _writeResponse(self, response, request, status=200): """ request -- request message response --- response message status -- HTTP Status """ request.setResponseCode(status) if self.encoding is not None: mimeType = 'text/xml; charset="%s"' % self.enc...
python
def _writeResponse(self, response, request, status=200): """ request -- request message response --- response message status -- HTTP Status """ request.setResponseCode(status) if self.encoding is not None: mimeType = 'text/xml; charset="%s"' % self.enc...
[ "def", "_writeResponse", "(", "self", ",", "response", ",", "request", ",", "status", "=", "200", ")", ":", "request", ".", "setResponseCode", "(", "status", ")", "if", "self", ".", "encoding", "is", "not", "None", ":", "mimeType", "=", "'text/xml; charset...
request -- request message response --- response message status -- HTTP Status
[ "request", "--", "request", "message", "response", "---", "response", "message", "status", "--", "HTTP", "Status" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/twisted/WSresource.py#L280-L295
rameshg87/pyremotevbox
pyremotevbox/ZSI/twisted/WSresource.py
WSResource._writeFault
def _writeFault(self, fail, request): """ fail -- failure request -- request message ex -- Exception """ response = fault.FaultFromException(fail.value, False, fail.tb).AsSOAP() self._writeResponse(response, request, status=500)
python
def _writeFault(self, fail, request): """ fail -- failure request -- request message ex -- Exception """ response = fault.FaultFromException(fail.value, False, fail.tb).AsSOAP() self._writeResponse(response, request, status=500)
[ "def", "_writeFault", "(", "self", ",", "fail", ",", "request", ")", ":", "response", "=", "fault", ".", "FaultFromException", "(", "fail", ".", "value", ",", "False", ",", "fail", ".", "tb", ")", ".", "AsSOAP", "(", ")", "self", ".", "_writeResponse",...
fail -- failure request -- request message ex -- Exception
[ "fail", "--", "failure", "request", "--", "request", "message", "ex", "--", "Exception" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/twisted/WSresource.py#L297-L304
rameshg87/pyremotevbox
pyremotevbox/ZSI/twisted/WSresource.py
WSResource.render_POST
def render_POST(self, request): """Dispatch Method called by twisted render, creates a request/response handler chain. request -- twisted.web.server.Request """ from twisted.internet.defer import maybeDeferred chain = self.factory.newInstance() data = re...
python
def render_POST(self, request): """Dispatch Method called by twisted render, creates a request/response handler chain. request -- twisted.web.server.Request """ from twisted.internet.defer import maybeDeferred chain = self.factory.newInstance() data = re...
[ "def", "render_POST", "(", "self", ",", "request", ")", ":", "from", "twisted", ".", "internet", ".", "defer", "import", "maybeDeferred", "chain", "=", "self", ".", "factory", ".", "newInstance", "(", ")", "data", "=", "request", ".", "content", ".", "re...
Dispatch Method called by twisted render, creates a request/response handler chain. request -- twisted.web.server.Request
[ "Dispatch", "Method", "called", "by", "twisted", "render", "creates", "a", "request", "/", "response", "handler", "chain", ".", "request", "--", "twisted", ".", "web", ".", "server", ".", "Request" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/twisted/WSresource.py#L306-L321
ikalnytskyi/dooku
dooku/datetime.py
to_iso8601
def to_iso8601(dt, tz=None): """ Returns an ISO-8601 representation of a given datetime instance. >>> to_iso8601(datetime.datetime.now()) '2014-10-01T23:21:33.718508Z' :param dt: a :class:`~datetime.datetime` instance :param tz: a :class:`~datetime.tzinfo` to use; if None - use a defau...
python
def to_iso8601(dt, tz=None): """ Returns an ISO-8601 representation of a given datetime instance. >>> to_iso8601(datetime.datetime.now()) '2014-10-01T23:21:33.718508Z' :param dt: a :class:`~datetime.datetime` instance :param tz: a :class:`~datetime.tzinfo` to use; if None - use a defau...
[ "def", "to_iso8601", "(", "dt", ",", "tz", "=", "None", ")", ":", "if", "tz", "is", "not", "None", ":", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "tz", ")", "iso8601", "=", "dt", ".", "isoformat", "(", ")", "# Naive datetime objects usuall...
Returns an ISO-8601 representation of a given datetime instance. >>> to_iso8601(datetime.datetime.now()) '2014-10-01T23:21:33.718508Z' :param dt: a :class:`~datetime.datetime` instance :param tz: a :class:`~datetime.tzinfo` to use; if None - use a default one
[ "Returns", "an", "ISO", "-", "8601", "representation", "of", "a", "given", "datetime", "instance", "." ]
train
https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L20-L39
ikalnytskyi/dooku
dooku/datetime.py
Local._is_dst
def _is_dst(dt): """ Returns True if a given datetime object represents a time with DST shift. """ # we can't use `dt.timestamp()` here since it requires a `utcoffset` # and we don't want to get into a recursive loop localtime = time.localtime(time.mktime(( ...
python
def _is_dst(dt): """ Returns True if a given datetime object represents a time with DST shift. """ # we can't use `dt.timestamp()` here since it requires a `utcoffset` # and we don't want to get into a recursive loop localtime = time.localtime(time.mktime(( ...
[ "def", "_is_dst", "(", "dt", ")", ":", "# we can't use `dt.timestamp()` here since it requires a `utcoffset`", "# and we don't want to get into a recursive loop", "localtime", "=", "time", ".", "localtime", "(", "time", ".", "mktime", "(", "(", "dt", ".", "year", ",", "...
Returns True if a given datetime object represents a time with DST shift.
[ "Returns", "True", "if", "a", "given", "datetime", "object", "represents", "a", "time", "with", "DST", "shift", "." ]
train
https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L93-L111
ikalnytskyi/dooku
dooku/datetime.py
Local.dst
def dst(self, dt): """ Returns a difference in seconds between standard offset and dst offset. """ if not self._is_dst(dt): return datetime.timedelta(0) offset = time.timezone - time.altzone return datetime.timedelta(seconds=-offset)
python
def dst(self, dt): """ Returns a difference in seconds between standard offset and dst offset. """ if not self._is_dst(dt): return datetime.timedelta(0) offset = time.timezone - time.altzone return datetime.timedelta(seconds=-offset)
[ "def", "dst", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "_is_dst", "(", "dt", ")", ":", "return", "datetime", ".", "timedelta", "(", "0", ")", "offset", "=", "time", ".", "timezone", "-", "time", ".", "altzone", "return", "datetim...
Returns a difference in seconds between standard offset and dst offset.
[ "Returns", "a", "difference", "in", "seconds", "between", "standard", "offset", "and", "dst", "offset", "." ]
train
https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L118-L127
collectiveacuity/labPack
labpack/parsing/conversion.py
_to_camelcase
def _to_camelcase(input_string): ''' a helper method to convert python to camelcase''' camel_string = '' for i in range(len(input_string)): if input_string[i] == '_': pass elif not camel_string: camel_string += input_string[i].upper() elif input_string[i-1] ==...
python
def _to_camelcase(input_string): ''' a helper method to convert python to camelcase''' camel_string = '' for i in range(len(input_string)): if input_string[i] == '_': pass elif not camel_string: camel_string += input_string[i].upper() elif input_string[i-1] ==...
[ "def", "_to_camelcase", "(", "input_string", ")", ":", "camel_string", "=", "''", "for", "i", "in", "range", "(", "len", "(", "input_string", ")", ")", ":", "if", "input_string", "[", "i", "]", "==", "'_'", ":", "pass", "elif", "not", "camel_string", "...
a helper method to convert python to camelcase
[ "a", "helper", "method", "to", "convert", "python", "to", "camelcase" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L6-L18
collectiveacuity/labPack
labpack/parsing/conversion.py
_to_python
def _to_python(input_string): ''' a helper method to convert camelcase to python''' python_string = '' for i in range(len(input_string)): if not python_string: python_string += input_string[i].lower() elif input_string[i].isupper(): python_string += '_%s' % input_stri...
python
def _to_python(input_string): ''' a helper method to convert camelcase to python''' python_string = '' for i in range(len(input_string)): if not python_string: python_string += input_string[i].lower() elif input_string[i].isupper(): python_string += '_%s' % input_stri...
[ "def", "_to_python", "(", "input_string", ")", ":", "python_string", "=", "''", "for", "i", "in", "range", "(", "len", "(", "input_string", ")", ")", ":", "if", "not", "python_string", ":", "python_string", "+=", "input_string", "[", "i", "]", ".", "lowe...
a helper method to convert camelcase to python
[ "a", "helper", "method", "to", "convert", "camelcase", "to", "python" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L20-L30
collectiveacuity/labPack
labpack/parsing/conversion.py
camelcase_to_lowercase
def camelcase_to_lowercase(camelcase_input, python_input=None): ''' a function to recursively convert data with camelcase key names into lowercase keys :param camelcase_input: list or dictionary with camelcase keys :param python_input: [optional] list or dictionary with default lower...
python
def camelcase_to_lowercase(camelcase_input, python_input=None): ''' a function to recursively convert data with camelcase key names into lowercase keys :param camelcase_input: list or dictionary with camelcase keys :param python_input: [optional] list or dictionary with default lower...
[ "def", "camelcase_to_lowercase", "(", "camelcase_input", ",", "python_input", "=", "None", ")", ":", "if", "python_input", ":", "if", "camelcase_input", ".", "__class__", "!=", "python_input", ".", "__class__", ":", "raise", "ValueError", "(", "'python_input type %s...
a function to recursively convert data with camelcase key names into lowercase keys :param camelcase_input: list or dictionary with camelcase keys :param python_input: [optional] list or dictionary with default lowercase keys in output :return: dictionary with lowercase key names
[ "a", "function", "to", "recursively", "convert", "data", "with", "camelcase", "key", "names", "into", "lowercase", "keys", ":", "param", "camelcase_input", ":", "list", "or", "dictionary", "with", "camelcase", "keys", ":", "param", "python_input", ":", "[", "o...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L105-L123
collectiveacuity/labPack
labpack/parsing/conversion.py
lowercase_to_camelcase
def lowercase_to_camelcase(python_input, camelcase_input=None): ''' a function to recursively convert data with lowercase key names into camelcase keys :param camelcase_input: list or dictionary with lowercase keys :param python_input: [optional] list or dictionary with default camel...
python
def lowercase_to_camelcase(python_input, camelcase_input=None): ''' a function to recursively convert data with lowercase key names into camelcase keys :param camelcase_input: list or dictionary with lowercase keys :param python_input: [optional] list or dictionary with default camel...
[ "def", "lowercase_to_camelcase", "(", "python_input", ",", "camelcase_input", "=", "None", ")", ":", "if", "camelcase_input", ":", "if", "python_input", ".", "__class__", "!=", "camelcase_input", ".", "__class__", ":", "raise", "ValueError", "(", "'camelcase_input t...
a function to recursively convert data with lowercase key names into camelcase keys :param camelcase_input: list or dictionary with lowercase keys :param python_input: [optional] list or dictionary with default camelcase keys in output :return: dictionary with camelcase key names
[ "a", "function", "to", "recursively", "convert", "data", "with", "lowercase", "key", "names", "into", "camelcase", "keys", ":", "param", "camelcase_input", ":", "list", "or", "dictionary", "with", "lowercase", "keys", ":", "param", "python_input", ":", "[", "o...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L125-L143
GemHQ/round-py
round/subscriptions.py
Subscriptions.create
def create(self, callback_url): """Register a new Subscription on this collection's parent object. Args: callback_url (str): URI of an active endpoint which can receive notifications. Returns: A round.Subscription object if successful. """ resourc...
python
def create(self, callback_url): """Register a new Subscription on this collection's parent object. Args: callback_url (str): URI of an active endpoint which can receive notifications. Returns: A round.Subscription object if successful. """ resourc...
[ "def", "create", "(", "self", ",", "callback_url", ")", ":", "resource", "=", "self", ".", "resource", ".", "create", "(", "{", "'subscribed_to'", ":", "'address'", ",", "'callback_url'", ":", "callback_url", "}", ")", "subscription", "=", "self", ".", "wr...
Register a new Subscription on this collection's parent object. Args: callback_url (str): URI of an active endpoint which can receive notifications. Returns: A round.Subscription object if successful.
[ "Register", "a", "new", "Subscription", "on", "this", "collection", "s", "parent", "object", "." ]
train
https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/subscriptions.py#L15-L29
mbodenhamer/syn
syn/schema/b/sequence.py
Sequence.enumerate
def enumerate(self, **kwargs): '''Iterate through all possible sequences (lists). By default, will stop after 50 items have been yielded. This value can be change by supplying a different value via the max_enumerate kwarg. ''' for item in self.set.enumerate(**kwargs): ...
python
def enumerate(self, **kwargs): '''Iterate through all possible sequences (lists). By default, will stop after 50 items have been yielded. This value can be change by supplying a different value via the max_enumerate kwarg. ''' for item in self.set.enumerate(**kwargs): ...
[ "def", "enumerate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "item", "in", "self", ".", "set", ".", "enumerate", "(", "*", "*", "kwargs", ")", ":", "yield", "flattened", "(", "item", ")" ]
Iterate through all possible sequences (lists). By default, will stop after 50 items have been yielded. This value can be change by supplying a different value via the max_enumerate kwarg.
[ "Iterate", "through", "all", "possible", "sequences", "(", "lists", ")", ".", "By", "default", "will", "stop", "after", "50", "items", "have", "been", "yielded", ".", "This", "value", "can", "be", "change", "by", "supplying", "a", "different", "value", "vi...
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/schema/b/sequence.py#L245-L251
mbodenhamer/syn
syn/schema/b/sequence.py
Sequence.match
def match(self, seq, **kwargs): '''If the schema matches seq, returns a list of the matched objects. Otherwise, returns MatchFailure instance. ''' strict = kwargs.get('strict', False) top_level = kwargs.get('top_level', True) match = kwargs.get('match', list()) i...
python
def match(self, seq, **kwargs): '''If the schema matches seq, returns a list of the matched objects. Otherwise, returns MatchFailure instance. ''' strict = kwargs.get('strict', False) top_level = kwargs.get('top_level', True) match = kwargs.get('match', list()) i...
[ "def", "match", "(", "self", ",", "seq", ",", "*", "*", "kwargs", ")", ":", "strict", "=", "kwargs", ".", "get", "(", "'strict'", ",", "False", ")", "top_level", "=", "kwargs", ".", "get", "(", "'top_level'", ",", "True", ")", "match", "=", "kwargs...
If the schema matches seq, returns a list of the matched objects. Otherwise, returns MatchFailure instance.
[ "If", "the", "schema", "matches", "seq", "returns", "a", "list", "of", "the", "matched", "objects", ".", "Otherwise", "returns", "MatchFailure", "instance", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/schema/b/sequence.py#L259-L285
scieloorg/accessstatsapi
accessstats/queries.py
downloads_per_year
def downloads_per_year(collection, code, raw=False): """ This method retrieve the total of downloads per year. arguments collection: SciELO 3 letters Acronym code: (Journal ISSN, Issue PID, Article PID) return [ ("2017", "20101"), ("2016", "11201"), ("2015", "12311"...
python
def downloads_per_year(collection, code, raw=False): """ This method retrieve the total of downloads per year. arguments collection: SciELO 3 letters Acronym code: (Journal ISSN, Issue PID, Article PID) return [ ("2017", "20101"), ("2016", "11201"), ("2015", "12311"...
[ "def", "downloads_per_year", "(", "collection", ",", "code", ",", "raw", "=", "False", ")", ":", "tc", "=", "ThriftClient", "(", ")", "body", "=", "{", "\"query\"", ":", "{", "\"filtered\"", ":", "{", "}", "}", "}", "fltr", "=", "{", "}", "query", ...
This method retrieve the total of downloads per year. arguments collection: SciELO 3 letters Acronym code: (Journal ISSN, Issue PID, Article PID) return [ ("2017", "20101"), ("2016", "11201"), ("2015", "12311"), ... ]
[ "This", "method", "retrieve", "the", "total", "of", "downloads", "per", "year", "." ]
train
https://github.com/scieloorg/accessstatsapi/blob/8092d76bedab9e82efce4005f9bcd21fb94e8e98/accessstats/queries.py#L38-L115
zorg/zorg-emic
zorg_emic/emic2.py
Emic2.word_wrap
def word_wrap(self, text, width=1023): """ A simple word wrapping greedy algorithm that puts as many words into a single string as possible. """ substrings = [] string = text while len(string) > width: index = width - 1 while not string[in...
python
def word_wrap(self, text, width=1023): """ A simple word wrapping greedy algorithm that puts as many words into a single string as possible. """ substrings = [] string = text while len(string) > width: index = width - 1 while not string[in...
[ "def", "word_wrap", "(", "self", ",", "text", ",", "width", "=", "1023", ")", ":", "substrings", "=", "[", "]", "string", "=", "text", "while", "len", "(", "string", ")", ">", "width", ":", "index", "=", "width", "-", "1", "while", "not", "string",...
A simple word wrapping greedy algorithm that puts as many words into a single string as possible.
[ "A", "simple", "word", "wrapping", "greedy", "algorithm", "that", "puts", "as", "many", "words", "into", "a", "single", "string", "as", "possible", "." ]
train
https://github.com/zorg/zorg-emic/blob/34d49897131cf7773b2b0f46e1e0a796911144e3/zorg_emic/emic2.py#L66-L86
zorg/zorg-emic
zorg_emic/emic2.py
Emic2.speak
def speak(self, text): """ The main function to convert text into speech. """ if not self.is_valid_string(text): raise Exception("%s is not ISO-8859-1 compatible." % (text)) # Maximum allowable 1023 characters per message if len(text) > 1023: line...
python
def speak(self, text): """ The main function to convert text into speech. """ if not self.is_valid_string(text): raise Exception("%s is not ISO-8859-1 compatible." % (text)) # Maximum allowable 1023 characters per message if len(text) > 1023: line...
[ "def", "speak", "(", "self", ",", "text", ")", ":", "if", "not", "self", ".", "is_valid_string", "(", "text", ")", ":", "raise", "Exception", "(", "\"%s is not ISO-8859-1 compatible.\"", "%", "(", "text", ")", ")", "# Maximum allowable 1023 characters per message"...
The main function to convert text into speech.
[ "The", "main", "function", "to", "convert", "text", "into", "speech", "." ]
train
https://github.com/zorg/zorg-emic/blob/34d49897131cf7773b2b0f46e1e0a796911144e3/zorg_emic/emic2.py#L88-L101
zorg/zorg-emic
zorg_emic/emic2.py
Emic2.set_language
def set_language(self, language, dialect=None): """ Set the language used for TTS. en: English es: Spanish | [ lan: latino or ca: castilian ] """ self.currentAction = 'setting language' l = 0 if language == 'en': l = 0 elif language == ...
python
def set_language(self, language, dialect=None): """ Set the language used for TTS. en: English es: Spanish | [ lan: latino or ca: castilian ] """ self.currentAction = 'setting language' l = 0 if language == 'en': l = 0 elif language == ...
[ "def", "set_language", "(", "self", ",", "language", ",", "dialect", "=", "None", ")", ":", "self", ".", "currentAction", "=", "'setting language'", "l", "=", "0", "if", "language", "==", "'en'", ":", "l", "=", "0", "elif", "language", "==", "'es'", ":...
Set the language used for TTS. en: English es: Spanish | [ lan: latino or ca: castilian ]
[ "Set", "the", "language", "used", "for", "TTS", ".", "en", ":", "English", "es", ":", "Spanish", "|", "[", "lan", ":", "latino", "or", "ca", ":", "castilian", "]" ]
train
https://github.com/zorg/zorg-emic/blob/34d49897131cf7773b2b0f46e1e0a796911144e3/zorg_emic/emic2.py#L119-L135
xtream1101/web-wrapper
web_wrapper/selenium_utils.py
SeleniumUtils._get_site
def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs): """ Try and return page content in the requested format using selenium """ try: # **TODO**: Find what exception this will throw and catch it and call # self.driver.execute_script("w...
python
def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs): """ Try and return page content in the requested format using selenium """ try: # **TODO**: Find what exception this will throw and catch it and call # self.driver.execute_script("w...
[ "def", "_get_site", "(", "self", ",", "url", ",", "headers", ",", "cookies", ",", "timeout", ",", "driver_args", ",", "driver_kwargs", ")", ":", "try", ":", "# **TODO**: Find what exception this will throw and catch it and call", "# self.driver.execute_script(\"window.sto...
Try and return page content in the requested format using selenium
[ "Try", "and", "return", "page", "content", "in", "the", "requested", "format", "using", "selenium" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L63-L101
xtream1101/web-wrapper
web_wrapper/selenium_utils.py
SeleniumUtils.hover
def hover(self, element): """ In selenium, move cursor over an element :element: Object found using driver.find_...("element_class/id/etc") """ javascript = """var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseover\", true, false...
python
def hover(self, element): """ In selenium, move cursor over an element :element: Object found using driver.find_...("element_class/id/etc") """ javascript = """var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseover\", true, false...
[ "def", "hover", "(", "self", ",", "element", ")", ":", "javascript", "=", "\"\"\"var evObj = document.createEvent('MouseEvents');\n evObj.initMouseEvent(\\\"mouseover\\\", true, false, window, 0, 0, 0, 0, 0, \\\n false, false, false, false, 0, null);...
In selenium, move cursor over an element :element: Object found using driver.find_...("element_class/id/etc")
[ "In", "selenium", "move", "cursor", "over", "an", "element", ":", "element", ":", "Object", "found", "using", "driver", ".", "find_", "...", "(", "element_class", "/", "id", "/", "etc", ")" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L103-L114
xtream1101/web-wrapper
web_wrapper/selenium_utils.py
SeleniumUtils.scroll_to_bottom
def scroll_to_bottom(self): """ Scoll to the very bottom of the page TODO: add increment & delay options to scoll slowly down the whole page to let each section load in """ if self.driver.selenium is not None: try: self.driver.selenium.execute_script("...
python
def scroll_to_bottom(self): """ Scoll to the very bottom of the page TODO: add increment & delay options to scoll slowly down the whole page to let each section load in """ if self.driver.selenium is not None: try: self.driver.selenium.execute_script("...
[ "def", "scroll_to_bottom", "(", "self", ")", ":", "if", "self", ".", "driver", ".", "selenium", "is", "not", "None", ":", "try", ":", "self", ".", "driver", ".", "selenium", ".", "execute_script", "(", "\"window.scrollTo(0, document.body.scrollHeight);\"", ")", ...
Scoll to the very bottom of the page TODO: add increment & delay options to scoll slowly down the whole page to let each section load in
[ "Scoll", "to", "the", "very", "bottom", "of", "the", "page", "TODO", ":", "add", "increment", "&", "delay", "options", "to", "scoll", "slowly", "down", "the", "whole", "page", "to", "let", "each", "section", "load", "in" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L126-L137
xtream1101/web-wrapper
web_wrapper/selenium_utils.py
SeleniumUtils.chrome_fullpage_screenshot
def chrome_fullpage_screenshot(self, file, delay=0): """ Fullscreen workaround for chrome Source: http://seleniumpythonqa.blogspot.com/2015/08/generate-full-page-screenshot-in-chrome.html """ total_width = self.driver.execute_script("return document.body.offsetWidth") tot...
python
def chrome_fullpage_screenshot(self, file, delay=0): """ Fullscreen workaround for chrome Source: http://seleniumpythonqa.blogspot.com/2015/08/generate-full-page-screenshot-in-chrome.html """ total_width = self.driver.execute_script("return document.body.offsetWidth") tot...
[ "def", "chrome_fullpage_screenshot", "(", "self", ",", "file", ",", "delay", "=", "0", ")", ":", "total_width", "=", "self", ".", "driver", ".", "execute_script", "(", "\"return document.body.offsetWidth\"", ")", "total_height", "=", "self", ".", "driver", ".", ...
Fullscreen workaround for chrome Source: http://seleniumpythonqa.blogspot.com/2015/08/generate-full-page-screenshot-in-chrome.html
[ "Fullscreen", "workaround", "for", "chrome", "Source", ":", "http", ":", "//", "seleniumpythonqa", ".", "blogspot", ".", "com", "/", "2015", "/", "08", "/", "generate", "-", "full", "-", "page", "-", "screenshot", "-", "in", "-", "chrome", ".", "html" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L139-L204
20c/twentyc.database
twentyc/database/couchbase/client.py
CouchbaseClient.unset
def unset(self, key): """ Delete object indexed by <key> """ try: try: self.bucket.delete(key) except couchbase.exception.MemcachedError, inst: if str(inst) == "Memcached error #1: Not found": # for some reason the py cb client raises an error when # a ...
python
def unset(self, key): """ Delete object indexed by <key> """ try: try: self.bucket.delete(key) except couchbase.exception.MemcachedError, inst: if str(inst) == "Memcached error #1: Not found": # for some reason the py cb client raises an error when # a ...
[ "def", "unset", "(", "self", ",", "key", ")", ":", "try", ":", "try", ":", "self", ".", "bucket", ".", "delete", "(", "key", ")", "except", "couchbase", ".", "exception", ".", "MemcachedError", ",", "inst", ":", "if", "str", "(", "inst", ")", "==",...
Delete object indexed by <key>
[ "Delete", "object", "indexed", "by", "<key", ">" ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/couchbase/client.py#L78-L96
20c/twentyc.database
twentyc/database/couchbase/client.py
CouchbaseClient.get
def get(self, key): """ Retrieve object indexed by <key> """ try: try: obj = self.bucket.get(key) except couchbase.exception.MemcachedError, inst: if str(inst) == "Memcached error #1: Not found": # for some reason the py cb client raises an error when ...
python
def get(self, key): """ Retrieve object indexed by <key> """ try: try: obj = self.bucket.get(key) except couchbase.exception.MemcachedError, inst: if str(inst) == "Memcached error #1: Not found": # for some reason the py cb client raises an error when ...
[ "def", "get", "(", "self", ",", "key", ")", ":", "try", ":", "try", ":", "obj", "=", "self", ".", "bucket", ".", "get", "(", "key", ")", "except", "couchbase", ".", "exception", ".", "MemcachedError", ",", "inst", ":", "if", "str", "(", "inst", "...
Retrieve object indexed by <key>
[ "Retrieve", "object", "indexed", "by", "<key", ">" ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/couchbase/client.py#L101-L126
20c/twentyc.database
twentyc/database/couchbase/client.py
CouchbaseClient.set
def set(self, key, data, retry=0): """ Store data <data> index by key <key> Args key <string> couchbase document id data <dict> data to store """ try: if type(data) != dict: raise Exception("data needs to be of type <dict>") self.bucket.set(key, 0, 0, json.d...
python
def set(self, key, data, retry=0): """ Store data <data> index by key <key> Args key <string> couchbase document id data <dict> data to store """ try: if type(data) != dict: raise Exception("data needs to be of type <dict>") self.bucket.set(key, 0, 0, json.d...
[ "def", "set", "(", "self", ",", "key", ",", "data", ",", "retry", "=", "0", ")", ":", "try", ":", "if", "type", "(", "data", ")", "!=", "dict", ":", "raise", "Exception", "(", "\"data needs to be of type <dict>\"", ")", "self", ".", "bucket", ".", "s...
Store data <data> index by key <key> Args key <string> couchbase document id data <dict> data to store
[ "Store", "data", "<data", ">", "index", "by", "key", "<key", ">" ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/couchbase/client.py#L130-L149
20c/twentyc.database
twentyc/database/couchbase/client.py
CouchbaseClient.dump
def dump(self, key): """ Retrieve object indexed by <key> and return it serialized """ try: obj = self.get(key) if obj: return json.dumps(obj) else: return None except: raise
python
def dump(self, key): """ Retrieve object indexed by <key> and return it serialized """ try: obj = self.get(key) if obj: return json.dumps(obj) else: return None except: raise
[ "def", "dump", "(", "self", ",", "key", ")", ":", "try", ":", "obj", "=", "self", ".", "get", "(", "key", ")", "if", "obj", ":", "return", "json", ".", "dumps", "(", "obj", ")", "else", ":", "return", "None", "except", ":", "raise" ]
Retrieve object indexed by <key> and return it serialized
[ "Retrieve", "object", "indexed", "by", "<key", ">", "and", "return", "it", "serialized" ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/couchbase/client.py#L164-L179
delfick/aws_syncr
aws_syncr/option_spec/encryption_keys.py
EncryptionKeys.sync_one
def sync_one(self, aws_syncr, amazon, key): """Make sure this key is as defined""" key_info = amazon.kms.key_info(key.name, key.location) if not key_info: amazon.kms.create_key(key.name, key.description, key.location, key.grant, key.policy.document) else: amazon.k...
python
def sync_one(self, aws_syncr, amazon, key): """Make sure this key is as defined""" key_info = amazon.kms.key_info(key.name, key.location) if not key_info: amazon.kms.create_key(key.name, key.description, key.location, key.grant, key.policy.document) else: amazon.k...
[ "def", "sync_one", "(", "self", ",", "aws_syncr", ",", "amazon", ",", "key", ")", ":", "key_info", "=", "amazon", ".", "kms", ".", "key_info", "(", "key", ".", "name", ",", "key", ".", "location", ")", "if", "not", "key_info", ":", "amazon", ".", "...
Make sure this key is as defined
[ "Make", "sure", "this", "key", "is", "as", "defined" ]
train
https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/encryption_keys.py#L50-L56
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient._import
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs): ''' a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record ...
python
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs): ''' a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record ...
[ "def", "_import", "(", "self", ",", "record_key", ",", "record_data", ",", "overwrite", "=", "True", ",", "last_modified", "=", "0.0", ",", "*", "*", "kwargs", ")", ":", "title", "=", "'%s._import'", "%", "self", ".", "__class__", ".", "__name__", "# che...
a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record :param overwrite: [optional] boolean to overwrite existing records :param last_modified: [optional] float to r...
[ "a", "helper", "method", "for", "other", "storage", "clients", "to", "import", "into", "appdata", ":", "param", "record_key", ":", "string", "with", "key", "for", "record", ":", "param", "record_data", ":", "byte", "data", "for", "body", "of", "record", ":...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L220-L275
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient._walk
def _walk(self, root_path=''): ''' an iterator method which walks the file structure of the dropbox collection ''' title = '%s._walk' % self.__class__.__name__ if root_path: root_path = '/%s' % root_path try: response = self.dropbox.files_list_folder(path=ro...
python
def _walk(self, root_path=''): ''' an iterator method which walks the file structure of the dropbox collection ''' title = '%s._walk' % self.__class__.__name__ if root_path: root_path = '/%s' % root_path try: response = self.dropbox.files_list_folder(path=ro...
[ "def", "_walk", "(", "self", ",", "root_path", "=", "''", ")", ":", "title", "=", "'%s._walk'", "%", "self", ".", "__class__", ".", "__name__", "if", "root_path", ":", "root_path", "=", "'/%s'", "%", "root_path", "try", ":", "response", "=", "self", "....
an iterator method which walks the file structure of the dropbox collection
[ "an", "iterator", "method", "which", "walks", "the", "file", "structure", "of", "the", "dropbox", "collection" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L277-L296
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.exists
def exists(self, record_key): ''' a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean reporting status ''' title = '%s.exists' % self.__class__.__name__ # validate...
python
def exists(self, record_key): ''' a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean reporting status ''' title = '%s.exists' % self.__class__.__name__ # validate...
[ "def", "exists", "(", "self", ",", "record_key", ")", ":", "title", "=", "'%s.exists'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", "{", "'record_key'", ":", "record_key", "}", "for", "key", ",", "value", "in",...
a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean reporting status
[ "a", "method", "to", "determine", "if", "a", "record", "exists", "in", "collection", ":", "param", "record_key", ":", "string", "with", "key", "of", "record", ":", "return", ":", "boolean", "reporting", "status" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L298-L327
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.save
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite:...
python
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite:...
[ "def", "save", "(", "self", ",", "record_key", ",", "record_data", ",", "overwrite", "=", "True", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.save'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", ...
a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite: [optional] boolean to overwrite records with same name :param secret_key: [optional] string...
[ "a", "method", "to", "create", "a", "record", "in", "the", "collection", "folder", ":", "param", "record_key", ":", "string", "with", "name", "to", "assign", "to", "record", "(", "see", "NOTES", "below", ")", ":", "param", "record_data", ":", "byte", "da...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L329-L420
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.load
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' title =...
python
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' title =...
[ "def", "load", "(", "self", ",", "record_key", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.load'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", "{", "'record_key'", ":", "record_key", ",", "'secre...
a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body
[ "a", "method", "to", "retrieve", "byte", "data", "of", "appdata", "record", ":", "param", "record_key", ":", "string", "with", "name", "of", "record", ":", "param", "secret_key", ":", "[", "optional", "]", "string", "used", "to", "decrypt", "data", ":", ...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L422-L462
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.delete
def delete(self, record_key): ''' a method to delete a file :param record_key: string with name of file :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'record_key': rec...
python
def delete(self, record_key): ''' a method to delete a file :param record_key: string with name of file :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'record_key': rec...
[ "def", "delete", "(", "self", ",", "record_key", ")", ":", "title", "=", "'%s.delete'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", "{", "'record_key'", ":", "record_key", "}", "for", "key", ",", "value", "in",...
a method to delete a file :param record_key: string with name of file :return: string reporting outcome
[ "a", "method", "to", "delete", "a", "file", ":", "param", "record_key", ":", "string", "with", "name", "of", "file", ":", "return", ":", "string", "reporting", "outcome" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L603-L648
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.remove
def remove(self): ''' a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove the app folder ...
python
def remove(self): ''' a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove the app folder ...
[ "def", "remove", "(", "self", ")", ":", "title", "=", "'%s.remove'", "%", "self", ".", "__class__", ".", "__name__", "# get contents in root\r", "try", ":", "response", "=", "self", ".", "dropbox", ".", "files_list_folder", "(", "path", "=", "''", ")", "ex...
a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove the app folder :return: string with confirm...
[ "a", "method", "to", "remove", "all", "records", "in", "the", "collection", "NOTE", ":", "this", "method", "removes", "all", "the", "files", "in", "the", "collection", "but", "the", "collection", "folder", "itself", "created", "by", "oauth2", "cannot", "be",...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L650-L696
collectiveacuity/labPack
labpack/storage/dropbox.py
dropboxClient.export
def export(self, storage_client, overwrite=True): ''' a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message ''' tit...
python
def export(self, storage_client, overwrite=True): ''' a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message ''' tit...
[ "def", "export", "(", "self", ",", "storage_client", ",", "overwrite", "=", "True", ")", ":", "title", "=", "'%s.export'", "%", "self", ".", "__class__", ".", "__name__", "# validate storage client\r", "method_list", "=", "[", "'save'", ",", "'load'", ",", "...
a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message
[ "a", "method", "to", "export", "all", "the", "records", "in", "collection", "to", "another", "platform", ":", "param", "storage_client", ":", "class", "object", "with", "storage", "client", "methods", ":", "return", ":", "string", "with", "exit", "message" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L698-L758
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/monitor.py
_read_stdin
def _read_stdin(): """ Generator for reading from standard input in nonblocking mode. Other ways of reading from ``stdin`` in python waits, until the buffer is big enough, or until EOF character is sent. This functions yields immediately after each line. """ line = sys.stdin.readline() ...
python
def _read_stdin(): """ Generator for reading from standard input in nonblocking mode. Other ways of reading from ``stdin`` in python waits, until the buffer is big enough, or until EOF character is sent. This functions yields immediately after each line. """ line = sys.stdin.readline() ...
[ "def", "_read_stdin", "(", ")", ":", "line", "=", "sys", ".", "stdin", ".", "readline", "(", ")", "while", "line", ":", "yield", "line", "line", "=", "sys", ".", "stdin", ".", "readline", "(", ")" ]
Generator for reading from standard input in nonblocking mode. Other ways of reading from ``stdin`` in python waits, until the buffer is big enough, or until EOF character is sent. This functions yields immediately after each line.
[ "Generator", "for", "reading", "from", "standard", "input", "in", "nonblocking", "mode", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L36-L48
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/monitor.py
_parse_line
def _parse_line(line): """ Convert one line from the extended log to dict. Args: line (str): Line which will be converted. Returns: dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \ keys. Note: Typical line looks like this:: ...
python
def _parse_line(line): """ Convert one line from the extended log to dict. Args: line (str): Line which will be converted. Returns: dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \ keys. Note: Typical line looks like this:: ...
[ "def", "_parse_line", "(", "line", ")", ":", "line", ",", "timestamp", "=", "line", ".", "rsplit", "(", "\",\"", ",", "1", ")", "line", ",", "command", "=", "line", ".", "rsplit", "(", "\",\"", ",", "1", ")", "path", ",", "username", "=", "line", ...
Convert one line from the extended log to dict. Args: line (str): Line which will be converted. Returns: dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \ keys. Note: Typical line looks like this:: /home/ftp/xex/asd bsd.dat, xex, ST...
[ "Convert", "one", "line", "from", "the", "extended", "log", "to", "dict", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L51-L79
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/monitor.py
process_log
def process_log(file_iterator): """ Process the extended ProFTPD log. Args: file_iterator (file): any file-like iterator for reading the log or stdin (see :func:`_read_stdin`). Yields: ImportRequest: with each import. """ for line in file_iterator:...
python
def process_log(file_iterator): """ Process the extended ProFTPD log. Args: file_iterator (file): any file-like iterator for reading the log or stdin (see :func:`_read_stdin`). Yields: ImportRequest: with each import. """ for line in file_iterator:...
[ "def", "process_log", "(", "file_iterator", ")", ":", "for", "line", "in", "file_iterator", ":", "if", "\",\"", "not", "in", "line", ":", "continue", "parsed", "=", "_parse_line", "(", "line", ")", "if", "not", "parsed", "[", "\"command\"", "]", ".", "up...
Process the extended ProFTPD log. Args: file_iterator (file): any file-like iterator for reading the log or stdin (see :func:`_read_stdin`). Yields: ImportRequest: with each import.
[ "Process", "the", "extended", "ProFTPD", "log", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L82-L130
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/monitor.py
main
def main(filename): """ Open `filename` and start processing it line by line. If `filename` is none, process lines from `stdin`. """ if filename: if not os.path.exists(filename): logger.error("'%s' doesn't exists!" % filename) sys.stderr.write("'%s' doesn't exists!\n"...
python
def main(filename): """ Open `filename` and start processing it line by line. If `filename` is none, process lines from `stdin`. """ if filename: if not os.path.exists(filename): logger.error("'%s' doesn't exists!" % filename) sys.stderr.write("'%s' doesn't exists!\n"...
[ "def", "main", "(", "filename", ")", ":", "if", "filename", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "logger", ".", "error", "(", "\"'%s' doesn't exists!\"", "%", "filename", ")", "sys", ".", "stderr", ".", "write"...
Open `filename` and start processing it line by line. If `filename` is none, process lines from `stdin`.
[ "Open", "filename", "and", "start", "processing", "it", "line", "by", "line", ".", "If", "filename", "is", "none", "process", "lines", "from", "stdin", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L133-L150
sassoo/goldman
goldman/serializers/base.py
Serializer.serialize
def serialize(self, data): """ Invoke the serializer These are common things for all serializers. Mostly, stuff to do with managing headers. The data passed in may not be reliable for much of anything. Conditionally, set the Content-Type header unless it has already bee...
python
def serialize(self, data): """ Invoke the serializer These are common things for all serializers. Mostly, stuff to do with managing headers. The data passed in may not be reliable for much of anything. Conditionally, set the Content-Type header unless it has already bee...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "if", "not", "self", ".", "resp", ".", "content_type", ":", "self", ".", "resp", ".", "set_header", "(", "'Content-Type'", ",", "getattr", "(", "self", ",", "'MIMETYPE'", ")", ")" ]
Invoke the serializer These are common things for all serializers. Mostly, stuff to do with managing headers. The data passed in may not be reliable for much of anything. Conditionally, set the Content-Type header unless it has already been set.
[ "Invoke", "the", "serializer" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/base.py#L21-L33
ronaldguillen/wave
wave/relations.py
RelatedField.many_init
def many_init(cls, *args, **kwargs): """ This method handles creating a parent `ManyRelatedField` instance when the `many=True` keyword argument is passed. Typically you won't need to override this method. Note that we're over-cautious in passing most arguments to both parent ...
python
def many_init(cls, *args, **kwargs): """ This method handles creating a parent `ManyRelatedField` instance when the `many=True` keyword argument is passed. Typically you won't need to override this method. Note that we're over-cautious in passing most arguments to both parent ...
[ "def", "many_init", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "list_kwargs", "=", "{", "'child_relation'", ":", "cls", "(", "*", "args", ",", "*", "*", "kwargs", ")", "}", "for", "key", "in", "kwargs", ".", "keys", "(", ")"...
This method handles creating a parent `ManyRelatedField` instance when the `many=True` keyword argument is passed. Typically you won't need to override this method. Note that we're over-cautious in passing most arguments to both parent and child classes in order to try to cover the gen...
[ "This", "method", "handles", "creating", "a", "parent", "ManyRelatedField", "instance", "when", "the", "many", "=", "True", "keyword", "argument", "is", "passed", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/relations.py#L88-L108
ronaldguillen/wave
wave/relations.py
HyperlinkedRelatedField.get_object
def get_object(self, view_name, view_args, view_kwargs): """ Return the object corresponding to a matched URL. Takes the matched URL conf arguments, and should return an object instance, or raise an `ObjectDoesNotExist` exception. """ lookup_value = view_kwargs[self.look...
python
def get_object(self, view_name, view_args, view_kwargs): """ Return the object corresponding to a matched URL. Takes the matched URL conf arguments, and should return an object instance, or raise an `ObjectDoesNotExist` exception. """ lookup_value = view_kwargs[self.look...
[ "def", "get_object", "(", "self", ",", "view_name", ",", "view_args", ",", "view_kwargs", ")", ":", "lookup_value", "=", "view_kwargs", "[", "self", ".", "lookup_url_kwarg", "]", "lookup_kwargs", "=", "{", "self", ".", "lookup_field", ":", "lookup_value", "}",...
Return the object corresponding to a matched URL. Takes the matched URL conf arguments, and should return an object instance, or raise an `ObjectDoesNotExist` exception.
[ "Return", "the", "object", "corresponding", "to", "a", "matched", "URL", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/relations.py#L253-L262
ronaldguillen/wave
wave/relations.py
HyperlinkedRelatedField.get_url
def get_url(self, obj, view_name, request, format): """ Given an object, return the URL that hyperlinks to the object. May raise a `NoReverseMatch` if the `view_name` and `lookup_field` attributes are not configured to correctly match the URL conf. """ # Unsaved objects ...
python
def get_url(self, obj, view_name, request, format): """ Given an object, return the URL that hyperlinks to the object. May raise a `NoReverseMatch` if the `view_name` and `lookup_field` attributes are not configured to correctly match the URL conf. """ # Unsaved objects ...
[ "def", "get_url", "(", "self", ",", "obj", ",", "view_name", ",", "request", ",", "format", ")", ":", "# Unsaved objects will not yet have a valid URL.", "if", "hasattr", "(", "obj", ",", "'pk'", ")", "and", "obj", ".", "pk", "is", "None", ":", "return", "...
Given an object, return the URL that hyperlinks to the object. May raise a `NoReverseMatch` if the `view_name` and `lookup_field` attributes are not configured to correctly match the URL conf.
[ "Given", "an", "object", "return", "the", "URL", "that", "hyperlinks", "to", "the", "object", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/relations.py#L264-L277
TC01/calcpkg
calcrepo/info.py
FileInfo.printData
def printData(self, output = sys.stdout): """Output all the file data to be written to any writable output""" self.printDatum("Name : ", self.fileName, output) self.printDatum("Author : ", self.author, output) self.printDatum("Repository : ", self.repository, output) self.printDatum("Catego...
python
def printData(self, output = sys.stdout): """Output all the file data to be written to any writable output""" self.printDatum("Name : ", self.fileName, output) self.printDatum("Author : ", self.author, output) self.printDatum("Repository : ", self.repository, output) self.printDatum("Catego...
[ "def", "printData", "(", "self", ",", "output", "=", "sys", ".", "stdout", ")", ":", "self", ".", "printDatum", "(", "\"Name : \"", ",", "self", ".", "fileName", ",", "output", ")", "self", ".", "printDatum", "(", "\"Author : \"", ",", "sel...
Output all the file data to be written to any writable output
[ "Output", "all", "the", "file", "data", "to", "be", "written", "to", "any", "writable", "output" ]
train
https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/info.py#L58-L71
ronaldguillen/wave
wave/serializers.py
raise_errors_on_nested_writes
def raise_errors_on_nested_writes(method_name, serializer, validated_data): """ Give explicit errors when users attempt to pass writable nested data. If we don't do this explicitly they'd get a less helpful error when calling `.save()` on the serializer. We don't *automatically* support these sort...
python
def raise_errors_on_nested_writes(method_name, serializer, validated_data): """ Give explicit errors when users attempt to pass writable nested data. If we don't do this explicitly they'd get a less helpful error when calling `.save()` on the serializer. We don't *automatically* support these sort...
[ "def", "raise_errors_on_nested_writes", "(", "method_name", ",", "serializer", ",", "validated_data", ")", ":", "# Ensure we don't have a writable nested field. For example:", "#", "# class UserSerializer(ModelSerializer):", "# ...", "# profile = ProfileSerializer()", "assert",...
Give explicit errors when users attempt to pass writable nested data. If we don't do this explicitly they'd get a less helpful error when calling `.save()` on the serializer. We don't *automatically* support these sorts of nested writes because there are too many ambiguities to define a default behavi...
[ "Give", "explicit", "errors", "when", "users", "attempt", "to", "pass", "writable", "nested", "data", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L688-L747
ronaldguillen/wave
wave/serializers.py
BaseSerializer.many_init
def many_init(cls, *args, **kwargs): """ This method implements the creation of a `ListSerializer` parent class when `many=True` is used. You can customize it if you need to control which keyword arguments are passed to the parent, and which are passed to the child. Note...
python
def many_init(cls, *args, **kwargs): """ This method implements the creation of a `ListSerializer` parent class when `many=True` is used. You can customize it if you need to control which keyword arguments are passed to the parent, and which are passed to the child. Note...
[ "def", "many_init", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "allow_empty", "=", "kwargs", ".", "pop", "(", "'allow_empty'", ",", "None", ")", "child_serializer", "=", "cls", "(", "*", "args", ",", "*", "*", "kwargs", ")", "...
This method implements the creation of a `ListSerializer` parent class when `many=True` is used. You can customize it if you need to control which keyword arguments are passed to the parent, and which are passed to the child. Note that we're over-cautious in passing most arguments to bo...
[ "This", "method", "implements", "the", "creation", "of", "a", "ListSerializer", "parent", "class", "when", "many", "=", "True", "is", "used", ".", "You", "can", "customize", "it", "if", "you", "need", "to", "control", "which", "keyword", "arguments", "are", ...
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L105-L134
ronaldguillen/wave
wave/serializers.py
ListSerializer.get_value
def get_value(self, dictionary): """ Given the input dictionary, return the field value. """ # We override the default field access in order to support # lists in HTML forms. if html.is_html_input(dictionary): return html.parse_html_list(dictionary, prefix=sel...
python
def get_value(self, dictionary): """ Given the input dictionary, return the field value. """ # We override the default field access in order to support # lists in HTML forms. if html.is_html_input(dictionary): return html.parse_html_list(dictionary, prefix=sel...
[ "def", "get_value", "(", "self", ",", "dictionary", ")", ":", "# We override the default field access in order to support", "# lists in HTML forms.", "if", "html", ".", "is_html_input", "(", "dictionary", ")", ":", "return", "html", ".", "parse_html_list", "(", "diction...
Given the input dictionary, return the field value.
[ "Given", "the", "input", "dictionary", "return", "the", "field", "value", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L537-L545
ronaldguillen/wave
wave/serializers.py
ListSerializer.run_validation
def run_validation(self, data=empty): """ We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key. """ (is_empty_value, data) = self.vali...
python
def run_validation(self, data=empty): """ We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key. """ (is_empty_value, data) = self.vali...
[ "def", "run_validation", "(", "self", ",", "data", "=", "empty", ")", ":", "(", "is_empty_value", ",", "data", ")", "=", "self", ".", "validate_empty_values", "(", "data", ")", "if", "is_empty_value", ":", "return", "data", "value", "=", "self", ".", "to...
We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key.
[ "We", "override", "the", "default", "run_validation", "because", "the", "validation", "performed", "by", "validators", "and", "the", ".", "validate", "()", "method", "should", "be", "coerced", "into", "an", "error", "dictionary", "with", "a", "non_fields_error", ...
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L547-L565
ronaldguillen/wave
wave/serializers.py
ListSerializer.to_internal_value
def to_internal_value(self, data): """ List of dicts of native values <- List of dicts of primitive datatypes. """ if html.is_html_input(data): data = html.parse_html_list(data) if not isinstance(data, list): message = self.error_messages['not_a_list'].fo...
python
def to_internal_value(self, data): """ List of dicts of native values <- List of dicts of primitive datatypes. """ if html.is_html_input(data): data = html.parse_html_list(data) if not isinstance(data, list): message = self.error_messages['not_a_list'].fo...
[ "def", "to_internal_value", "(", "self", ",", "data", ")", ":", "if", "html", ".", "is_html_input", "(", "data", ")", ":", "data", "=", "html", ".", "parse_html_list", "(", "data", ")", "if", "not", "isinstance", "(", "data", ",", "list", ")", ":", "...
List of dicts of native values <- List of dicts of primitive datatypes.
[ "List", "of", "dicts", "of", "native", "values", "<", "-", "List", "of", "dicts", "of", "primitive", "datatypes", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L567-L603
ronaldguillen/wave
wave/serializers.py
ListSerializer.save
def save(self, **kwargs): """ Save and return a list of object instances. """ # Guard against incorrect use of `serializer.save(commit=False)` assert 'commit' not in kwargs, ( "'commit' is not a valid keyword argument to the 'save()' method. " "If you need...
python
def save(self, **kwargs): """ Save and return a list of object instances. """ # Guard against incorrect use of `serializer.save(commit=False)` assert 'commit' not in kwargs, ( "'commit' is not a valid keyword argument to the 'save()' method. " "If you need...
[ "def", "save", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Guard against incorrect use of `serializer.save(commit=False)`", "assert", "'commit'", "not", "in", "kwargs", ",", "(", "\"'commit' is not a valid keyword argument to the 'save()' method. \"", "\"If you need to a...
Save and return a list of object instances.
[ "Save", "and", "return", "a", "list", "of", "object", "instances", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L634-L664
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_field_names
def get_field_names(self, declared_fields, info): """ Returns the list of all field names that should be created when instantiating this serializer class. This is based on the default set of fields, but also takes into account the `Meta.fields` or `Meta.exclude` options if they h...
python
def get_field_names(self, declared_fields, info): """ Returns the list of all field names that should be created when instantiating this serializer class. This is based on the default set of fields, but also takes into account the `Meta.fields` or `Meta.exclude` options if they h...
[ "def", "get_field_names", "(", "self", ",", "declared_fields", ",", "info", ")", ":", "fields", "=", "getattr", "(", "self", ".", "Meta", ",", "'fields'", ",", "None", ")", "exclude", "=", "getattr", "(", "self", ".", "Meta", ",", "'exclude'", ",", "No...
Returns the list of all field names that should be created when instantiating this serializer class. This is based on the default set of fields, but also takes into account the `Meta.fields` or `Meta.exclude` options if they have been specified.
[ "Returns", "the", "list", "of", "all", "field", "names", "that", "should", "be", "created", "when", "instantiating", "this", "serializer", "class", ".", "This", "is", "based", "on", "the", "default", "set", "of", "fields", "but", "also", "takes", "into", "...
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L958-L1039
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_default_field_names
def get_default_field_names(self, declared_fields, model_info): """ Return the default list of field names that will be used if the `Meta.fields` option is not specified. """ return ( [model_info.pk.name] + list(declared_fields.keys()) + list(m...
python
def get_default_field_names(self, declared_fields, model_info): """ Return the default list of field names that will be used if the `Meta.fields` option is not specified. """ return ( [model_info.pk.name] + list(declared_fields.keys()) + list(m...
[ "def", "get_default_field_names", "(", "self", ",", "declared_fields", ",", "model_info", ")", ":", "return", "(", "[", "model_info", ".", "pk", ".", "name", "]", "+", "list", "(", "declared_fields", ".", "keys", "(", ")", ")", "+", "list", "(", "model_i...
Return the default list of field names that will be used if the `Meta.fields` option is not specified.
[ "Return", "the", "default", "list", "of", "field", "names", "that", "will", "be", "used", "if", "the", "Meta", ".", "fields", "option", "is", "not", "specified", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1041-L1051
ronaldguillen/wave
wave/serializers.py
ModelSerializer.build_field
def build_field(self, field_name, info, model_class, nested_depth): """ Return a two tuple of (cls, kwargs) to build a serializer field with. """ if field_name in info.fields_and_pk: model_field = info.fields_and_pk[field_name] return self.build_standard_field(fie...
python
def build_field(self, field_name, info, model_class, nested_depth): """ Return a two tuple of (cls, kwargs) to build a serializer field with. """ if field_name in info.fields_and_pk: model_field = info.fields_and_pk[field_name] return self.build_standard_field(fie...
[ "def", "build_field", "(", "self", ",", "field_name", ",", "info", ",", "model_class", ",", "nested_depth", ")", ":", "if", "field_name", "in", "info", ".", "fields_and_pk", ":", "model_field", "=", "info", ".", "fields_and_pk", "[", "field_name", "]", "retu...
Return a two tuple of (cls, kwargs) to build a serializer field with.
[ "Return", "a", "two", "tuple", "of", "(", "cls", "kwargs", ")", "to", "build", "a", "serializer", "field", "with", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1055-L1076
ronaldguillen/wave
wave/serializers.py
ModelSerializer.build_standard_field
def build_standard_field(self, field_name, model_field): """ Create regular model fields. """ field_mapping = ClassLookupDict(self.serializer_field_mapping) field_class = field_mapping[model_field] field_kwargs = get_field_kwargs(field_name, model_field) if 'cho...
python
def build_standard_field(self, field_name, model_field): """ Create regular model fields. """ field_mapping = ClassLookupDict(self.serializer_field_mapping) field_class = field_mapping[model_field] field_kwargs = get_field_kwargs(field_name, model_field) if 'cho...
[ "def", "build_standard_field", "(", "self", ",", "field_name", ",", "model_field", ")", ":", "field_mapping", "=", "ClassLookupDict", "(", "self", ".", "serializer_field_mapping", ")", "field_class", "=", "field_mapping", "[", "model_field", "]", "field_kwargs", "="...
Create regular model fields.
[ "Create", "regular", "model", "fields", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1078-L1124
ronaldguillen/wave
wave/serializers.py
ModelSerializer.build_relational_field
def build_relational_field(self, field_name, relation_info): """ Create fields for forward and reverse relationships. """ field_class = self.serializer_related_field field_kwargs = get_relation_kwargs(field_name, relation_info) to_field = field_kwargs.pop('to_field', Non...
python
def build_relational_field(self, field_name, relation_info): """ Create fields for forward and reverse relationships. """ field_class = self.serializer_related_field field_kwargs = get_relation_kwargs(field_name, relation_info) to_field = field_kwargs.pop('to_field', Non...
[ "def", "build_relational_field", "(", "self", ",", "field_name", ",", "relation_info", ")", ":", "field_class", "=", "self", ".", "serializer_related_field", "field_kwargs", "=", "get_relation_kwargs", "(", "field_name", ",", "relation_info", ")", "to_field", "=", "...
Create fields for forward and reverse relationships.
[ "Create", "fields", "for", "forward", "and", "reverse", "relationships", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1126-L1142
ronaldguillen/wave
wave/serializers.py
ModelSerializer.build_url_field
def build_url_field(self, field_name, model_class): """ Create a field representing the object's own URL. """ field_class = self.serializer_url_field field_kwargs = get_url_kwargs(model_class) return field_class, field_kwargs
python
def build_url_field(self, field_name, model_class): """ Create a field representing the object's own URL. """ field_class = self.serializer_url_field field_kwargs = get_url_kwargs(model_class) return field_class, field_kwargs
[ "def", "build_url_field", "(", "self", ",", "field_name", ",", "model_class", ")", ":", "field_class", "=", "self", ".", "serializer_url_field", "field_kwargs", "=", "get_url_kwargs", "(", "model_class", ")", "return", "field_class", ",", "field_kwargs" ]
Create a field representing the object's own URL.
[ "Create", "a", "field", "representing", "the", "object", "s", "own", "URL", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1167-L1174
ronaldguillen/wave
wave/serializers.py
ModelSerializer.include_extra_kwargs
def include_extra_kwargs(self, kwargs, extra_kwargs): """ Include any 'extra_kwargs' that have been included for this field, possibly removing any incompatible existing keyword arguments. """ if extra_kwargs.get('read_only', False): for attr in [ 'requ...
python
def include_extra_kwargs(self, kwargs, extra_kwargs): """ Include any 'extra_kwargs' that have been included for this field, possibly removing any incompatible existing keyword arguments. """ if extra_kwargs.get('read_only', False): for attr in [ 'requ...
[ "def", "include_extra_kwargs", "(", "self", ",", "kwargs", ",", "extra_kwargs", ")", ":", "if", "extra_kwargs", ".", "get", "(", "'read_only'", ",", "False", ")", ":", "for", "attr", "in", "[", "'required'", ",", "'default'", ",", "'allow_blank'", ",", "'a...
Include any 'extra_kwargs' that have been included for this field, possibly removing any incompatible existing keyword arguments.
[ "Include", "any", "extra_kwargs", "that", "have", "been", "included", "for", "this", "field", "possibly", "removing", "any", "incompatible", "existing", "keyword", "arguments", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1185-L1206
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_extra_kwargs
def get_extra_kwargs(self): """ Return a dictionary mapping field names to a dictionary of additional keyword arguments. """ extra_kwargs = getattr(self.Meta, 'extra_kwargs', {}) read_only_fields = getattr(self.Meta, 'read_only_fields', None) if read_only_fields ...
python
def get_extra_kwargs(self): """ Return a dictionary mapping field names to a dictionary of additional keyword arguments. """ extra_kwargs = getattr(self.Meta, 'extra_kwargs', {}) read_only_fields = getattr(self.Meta, 'read_only_fields', None) if read_only_fields ...
[ "def", "get_extra_kwargs", "(", "self", ")", ":", "extra_kwargs", "=", "getattr", "(", "self", ".", "Meta", ",", "'extra_kwargs'", ",", "{", "}", ")", "read_only_fields", "=", "getattr", "(", "self", ".", "Meta", ",", "'read_only_fields'", ",", "None", ")"...
Return a dictionary mapping field names to a dictionary of additional keyword arguments.
[ "Return", "a", "dictionary", "mapping", "field", "names", "to", "a", "dictionary", "of", "additional", "keyword", "arguments", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1210-L1224
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_uniqueness_extra_kwargs
def get_uniqueness_extra_kwargs(self, field_names, declared_fields, extra_kwargs): """ Return any additional field options that need to be included as a result of uniqueness constraints on the model. This is returned as a two-tuple of: ('dict of updated extra kwargs', 'mapping o...
python
def get_uniqueness_extra_kwargs(self, field_names, declared_fields, extra_kwargs): """ Return any additional field options that need to be included as a result of uniqueness constraints on the model. This is returned as a two-tuple of: ('dict of updated extra kwargs', 'mapping o...
[ "def", "get_uniqueness_extra_kwargs", "(", "self", ",", "field_names", ",", "declared_fields", ",", "extra_kwargs", ")", ":", "model", "=", "getattr", "(", "self", ".", "Meta", ",", "'model'", ")", "model_fields", "=", "self", ".", "_get_model_fields", "(", "f...
Return any additional field options that need to be included as a result of uniqueness constraints on the model. This is returned as a two-tuple of: ('dict of updated extra kwargs', 'mapping of hidden fields')
[ "Return", "any", "additional", "field", "options", "that", "need", "to", "be", "included", "as", "a", "result", "of", "uniqueness", "constraints", "on", "the", "model", ".", "This", "is", "returned", "as", "a", "two", "-", "tuple", "of", ":" ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1226-L1296
ronaldguillen/wave
wave/serializers.py
ModelSerializer._get_model_fields
def _get_model_fields(self, field_names, declared_fields, extra_kwargs): """ Returns all the model fields that are being mapped to by fields on the serializer class. Returned as a dict of 'model field name' -> 'model field'. Used internally by `get_uniqueness_field_options`. ...
python
def _get_model_fields(self, field_names, declared_fields, extra_kwargs): """ Returns all the model fields that are being mapped to by fields on the serializer class. Returned as a dict of 'model field name' -> 'model field'. Used internally by `get_uniqueness_field_options`. ...
[ "def", "_get_model_fields", "(", "self", ",", "field_names", ",", "declared_fields", ",", "extra_kwargs", ")", ":", "model", "=", "getattr", "(", "self", ".", "Meta", ",", "'model'", ")", "model_fields", "=", "{", "}", "for", "field_name", "in", "field_names...
Returns all the model fields that are being mapped to by fields on the serializer class. Returned as a dict of 'model field name' -> 'model field'. Used internally by `get_uniqueness_field_options`.
[ "Returns", "all", "the", "model", "fields", "that", "are", "being", "mapped", "to", "by", "fields", "on", "the", "serializer", "class", ".", "Returned", "as", "a", "dict", "of", "model", "field", "name", "-", ">", "model", "field", ".", "Used", "internal...
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1298-L1331
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_validators
def get_validators(self): """ Determine the set of validators to use when instantiating serializer. """ # If the validators have been declared explicitly then use that. validators = getattr(getattr(self, 'Meta', None), 'validators', None) if validators is not None: ...
python
def get_validators(self): """ Determine the set of validators to use when instantiating serializer. """ # If the validators have been declared explicitly then use that. validators = getattr(getattr(self, 'Meta', None), 'validators', None) if validators is not None: ...
[ "def", "get_validators", "(", "self", ")", ":", "# If the validators have been declared explicitly then use that.", "validators", "=", "getattr", "(", "getattr", "(", "self", ",", "'Meta'", ",", "None", ")", ",", "'validators'", ",", "None", ")", "if", "validators",...
Determine the set of validators to use when instantiating serializer.
[ "Determine", "the", "set", "of", "validators", "to", "use", "when", "instantiating", "serializer", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1335-L1348
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_unique_together_validators
def get_unique_together_validators(self): """ Determine a default set of validators for any unique_together contraints. """ model_class_inheritance_tree = ( [self.Meta.model] + list(self.Meta.model._meta.parents.keys()) ) # The field names we're p...
python
def get_unique_together_validators(self): """ Determine a default set of validators for any unique_together contraints. """ model_class_inheritance_tree = ( [self.Meta.model] + list(self.Meta.model._meta.parents.keys()) ) # The field names we're p...
[ "def", "get_unique_together_validators", "(", "self", ")", ":", "model_class_inheritance_tree", "=", "(", "[", "self", ".", "Meta", ".", "model", "]", "+", "list", "(", "self", ".", "Meta", ".", "model", ".", "_meta", ".", "parents", ".", "keys", "(", ")...
Determine a default set of validators for any unique_together contraints.
[ "Determine", "a", "default", "set", "of", "validators", "for", "any", "unique_together", "contraints", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1350-L1379
ronaldguillen/wave
wave/serializers.py
ModelSerializer.get_unique_for_date_validators
def get_unique_for_date_validators(self): """ Determine a default set of validators for the following contraints: * unique_for_date * unique_for_month * unique_for_year """ info = model_meta.get_field_info(self.Meta.model) default_manager = self.Meta.mode...
python
def get_unique_for_date_validators(self): """ Determine a default set of validators for the following contraints: * unique_for_date * unique_for_month * unique_for_year """ info = model_meta.get_field_info(self.Meta.model) default_manager = self.Meta.mode...
[ "def", "get_unique_for_date_validators", "(", "self", ")", ":", "info", "=", "model_meta", ".", "get_field_info", "(", "self", ".", "Meta", ".", "model", ")", "default_manager", "=", "self", ".", "Meta", ".", "model", ".", "_default_manager", "field_names", "=...
Determine a default set of validators for the following contraints: * unique_for_date * unique_for_month * unique_for_year
[ "Determine", "a", "default", "set", "of", "validators", "for", "the", "following", "contraints", ":" ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1381-L1420
ronaldguillen/wave
wave/serializers.py
HyperlinkedModelSerializer.get_default_field_names
def get_default_field_names(self, declared_fields, model_info): """ Return the default list of field names that will be used if the `Meta.fields` option is not specified. """ return ( [self.url_field_name] + list(declared_fields.keys()) + list(...
python
def get_default_field_names(self, declared_fields, model_info): """ Return the default list of field names that will be used if the `Meta.fields` option is not specified. """ return ( [self.url_field_name] + list(declared_fields.keys()) + list(...
[ "def", "get_default_field_names", "(", "self", ",", "declared_fields", ",", "model_info", ")", ":", "return", "(", "[", "self", ".", "url_field_name", "]", "+", "list", "(", "declared_fields", ".", "keys", "(", ")", ")", "+", "list", "(", "model_info", "."...
Return the default list of field names that will be used if the `Meta.fields` option is not specified.
[ "Return", "the", "default", "list", "of", "field", "names", "that", "will", "be", "used", "if", "the", "Meta", ".", "fields", "option", "is", "not", "specified", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1448-L1458
ronaldguillen/wave
wave/serializers.py
HyperlinkedModelSerializer.build_nested_field
def build_nested_field(self, field_name, relation_info, nested_depth): """ Create nested fields for forward and reverse relationships. """ class NestedSerializer(HyperlinkedModelSerializer): class Meta: model = relation_info.related_model depth...
python
def build_nested_field(self, field_name, relation_info, nested_depth): """ Create nested fields for forward and reverse relationships. """ class NestedSerializer(HyperlinkedModelSerializer): class Meta: model = relation_info.related_model depth...
[ "def", "build_nested_field", "(", "self", ",", "field_name", ",", "relation_info", ",", "nested_depth", ")", ":", "class", "NestedSerializer", "(", "HyperlinkedModelSerializer", ")", ":", "class", "Meta", ":", "model", "=", "relation_info", ".", "related_model", "...
Create nested fields for forward and reverse relationships.
[ "Create", "nested", "fields", "for", "forward", "and", "reverse", "relationships", "." ]
train
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1460-L1472
bfontaine/p7magma
magma/session.py
Session.get_url
def get_url(self, url): """ Get an absolute URL from a given one. """ if url.startswith('/'): url = '%s%s' % (self.base_url, url) return url
python
def get_url(self, url): """ Get an absolute URL from a given one. """ if url.startswith('/'): url = '%s%s' % (self.base_url, url) return url
[ "def", "get_url", "(", "self", ",", "url", ")", ":", "if", "url", ".", "startswith", "(", "'/'", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "base_url", ",", "url", ")", "return", "url" ]
Get an absolute URL from a given one.
[ "Get", "an", "absolute", "URL", "from", "a", "given", "one", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L57-L63
bfontaine/p7magma
magma/session.py
Session.get_soup
def get_soup(self, *args, **kwargs): """ Shortcut for ``get`` which returns a ``BeautifulSoup`` element """ return BeautifulSoup(self.get(*args, **kwargs).text)
python
def get_soup(self, *args, **kwargs): """ Shortcut for ``get`` which returns a ``BeautifulSoup`` element """ return BeautifulSoup(self.get(*args, **kwargs).text)
[ "def", "get_soup", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "BeautifulSoup", "(", "self", ".", "get", "(", "*", "args", ",", "*", "*", "kwargs", ")", ".", "text", ")" ]
Shortcut for ``get`` which returns a ``BeautifulSoup`` element
[ "Shortcut", "for", "get", "which", "returns", "a", "BeautifulSoup", "element" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L73-L77
bfontaine/p7magma
magma/session.py
Session.post_soup
def post_soup(self, *args, **kwargs): """ Shortcut for ``post`` which returns a ``BeautifulSoup`` element """ return BeautifulSoup(self.post(*args, **kwargs).text)
python
def post_soup(self, *args, **kwargs): """ Shortcut for ``post`` which returns a ``BeautifulSoup`` element """ return BeautifulSoup(self.post(*args, **kwargs).text)
[ "def", "post_soup", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "BeautifulSoup", "(", "self", ".", "post", "(", "*", "args", ",", "*", "*", "kwargs", ")", ".", "text", ")" ]
Shortcut for ``post`` which returns a ``BeautifulSoup`` element
[ "Shortcut", "for", "post", "which", "returns", "a", "BeautifulSoup", "element" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L79-L83
bfontaine/p7magma
magma/session.py
Session.get_results_soup
def get_results_soup(self, year=None): """ ``get_soup`` on the results page. The page URL depends on the year. """ if year is None: year = self.year year = YEARS.get(year, year) return self.get_soup(URLS['results'][year])
python
def get_results_soup(self, year=None): """ ``get_soup`` on the results page. The page URL depends on the year. """ if year is None: year = self.year year = YEARS.get(year, year) return self.get_soup(URLS['results'][year])
[ "def", "get_results_soup", "(", "self", ",", "year", "=", "None", ")", ":", "if", "year", "is", "None", ":", "year", "=", "self", ".", "year", "year", "=", "YEARS", ".", "get", "(", "year", ",", "year", ")", "return", "self", ".", "get_soup", "(", ...
``get_soup`` on the results page. The page URL depends on the year.
[ "get_soup", "on", "the", "results", "page", ".", "The", "page", "URL", "depends", "on", "the", "year", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L85-L93
bfontaine/p7magma
magma/session.py
Session.login
def login(self, year, firstname, lastname, passwd, with_year=True): """ Authenticate an user """ firstname = firstname.upper() lastname = lastname.upper() if with_year and not self.set_year(year): return False url = URLS['login'] params = { ...
python
def login(self, year, firstname, lastname, passwd, with_year=True): """ Authenticate an user """ firstname = firstname.upper() lastname = lastname.upper() if with_year and not self.set_year(year): return False url = URLS['login'] params = { ...
[ "def", "login", "(", "self", ",", "year", ",", "firstname", ",", "lastname", ",", "passwd", ",", "with_year", "=", "True", ")", ":", "firstname", "=", "firstname", ".", "upper", "(", ")", "lastname", "=", "lastname", ".", "upper", "(", ")", "if", "wi...
Authenticate an user
[ "Authenticate", "an", "user" ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L95-L114
bfontaine/p7magma
magma/session.py
Session.set_year
def set_year(self, year): """ Set an user's year. This is required on magma just before the login. It's called by default by ``login``. """ self.year = YEARS.get(year, year) data = {'idCursus': self.year} soup = self.post_soup('/~etudiant/login.php', data=data) ...
python
def set_year(self, year): """ Set an user's year. This is required on magma just before the login. It's called by default by ``login``. """ self.year = YEARS.get(year, year) data = {'idCursus': self.year} soup = self.post_soup('/~etudiant/login.php', data=data) ...
[ "def", "set_year", "(", "self", ",", "year", ")", ":", "self", ".", "year", "=", "YEARS", ".", "get", "(", "year", ",", "year", ")", "data", "=", "{", "'idCursus'", ":", "self", ".", "year", "}", "soup", "=", "self", ".", "post_soup", "(", "'/~et...
Set an user's year. This is required on magma just before the login. It's called by default by ``login``.
[ "Set", "an", "user", "s", "year", ".", "This", "is", "required", "on", "magma", "just", "before", "the", "login", ".", "It", "s", "called", "by", "default", "by", "login", "." ]
train
https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L122-L130
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/upgrades/invenio_upgrader_2015_11_12_innodb_removal.py
InnoDBRemoval.do_upgrade
def do_upgrade(self): """Implement your upgrades here.""" sql = text('delete from upgrade where upgrade = :upgrade') db.engine.execute( sct(ql, upgrade='invenio_upgrader_2015_11_12_innodb_removal'))
python
def do_upgrade(self): """Implement your upgrades here.""" sql = text('delete from upgrade where upgrade = :upgrade') db.engine.execute( sct(ql, upgrade='invenio_upgrader_2015_11_12_innodb_removal'))
[ "def", "do_upgrade", "(", "self", ")", ":", "sql", "=", "text", "(", "'delete from upgrade where upgrade = :upgrade'", ")", "db", ".", "engine", ".", "execute", "(", "sct", "(", "ql", ",", "upgrade", "=", "'invenio_upgrader_2015_11_12_innodb_removal'", ")", ")" ]
Implement your upgrades here.
[ "Implement", "your", "upgrades", "here", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/upgrades/invenio_upgrader_2015_11_12_innodb_removal.py#L35-L39
inveniosoftware-attic/invenio-upgrader
invenio_upgrader/upgrades/invenio_upgrader_2015_11_12_innodb_removal.py
InnoDBRemoval.pre_upgrade
def pre_upgrade(self): """Run pre-upgrade checks (optional).""" sql = text('select 1 from upgrade where upgrade = :upgrade') if not db.engine.execute( sql, upgrade='invenio_upgrader_2015_11_12_innodb_removal' ).fetchall(): warnings.warn("Upgrade '{}' was not ap...
python
def pre_upgrade(self): """Run pre-upgrade checks (optional).""" sql = text('select 1 from upgrade where upgrade = :upgrade') if not db.engine.execute( sql, upgrade='invenio_upgrader_2015_11_12_innodb_removal' ).fetchall(): warnings.warn("Upgrade '{}' was not ap...
[ "def", "pre_upgrade", "(", "self", ")", ":", "sql", "=", "text", "(", "'select 1 from upgrade where upgrade = :upgrade'", ")", "if", "not", "db", ".", "engine", ".", "execute", "(", "sql", ",", "upgrade", "=", "'invenio_upgrader_2015_11_12_innodb_removal'", ")", "...
Run pre-upgrade checks (optional).
[ "Run", "pre", "-", "upgrade", "checks", "(", "optional", ")", "." ]
train
https://github.com/inveniosoftware-attic/invenio-upgrader/blob/cee4bcb118515463ecf6de1421642007f79a9fcd/invenio_upgrader/upgrades/invenio_upgrader_2015_11_12_innodb_removal.py#L41-L48
xaptum/xtt-python
xtt/exceptions.py
_build_return_code_enum
def _build_return_code_enum(): """ Creates an IntEnum containing all the XTT return codes. Finds all return codes by scanning the FFI for items whose names match the pattern "XTT_RETURN_<X>". The name of the result enum value is the suffix "<X>". """ prefix = 'XTT_RETURN_' codes = {k[l...
python
def _build_return_code_enum(): """ Creates an IntEnum containing all the XTT return codes. Finds all return codes by scanning the FFI for items whose names match the pattern "XTT_RETURN_<X>". The name of the result enum value is the suffix "<X>". """ prefix = 'XTT_RETURN_' codes = {k[l...
[ "def", "_build_return_code_enum", "(", ")", ":", "prefix", "=", "'XTT_RETURN_'", "codes", "=", "{", "k", "[", "len", "(", "prefix", ")", ":", "]", ":", "v", "for", "(", "k", ",", "v", ")", "in", "vars", "(", "_lib", ")", ".", "items", "(", ")", ...
Creates an IntEnum containing all the XTT return codes. Finds all return codes by scanning the FFI for items whose names match the pattern "XTT_RETURN_<X>". The name of the result enum value is the suffix "<X>".
[ "Creates", "an", "IntEnum", "containing", "all", "the", "XTT", "return", "codes", "." ]
train
https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/xtt/exceptions.py#L33-L43
20c/twentyc.database
twentyc/database/base.py
Client
def Client(engine="couchbase", host="", auth="", database="", logger=None, verbose=True): """ Return new database client Arguments engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" host <str|couchdb.Server> host url, when using couchdb this can also be a server instan...
python
def Client(engine="couchbase", host="", auth="", database="", logger=None, verbose=True): """ Return new database client Arguments engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" host <str|couchdb.Server> host url, when using couchdb this can also be a server instan...
[ "def", "Client", "(", "engine", "=", "\"couchbase\"", ",", "host", "=", "\"\"", ",", "auth", "=", "\"\"", ",", "database", "=", "\"\"", ",", "logger", "=", "None", ",", "verbose", "=", "True", ")", ":", "if", "engine", "==", "\"couchbase\"", ":", "fr...
Return new database client Arguments engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" host <str|couchdb.Server> host url, when using couchdb this can also be a server instance auth <str> bucket_auth for couchbase, auth for couchdb database <str> database name for couchd...
[ "Return", "new", "database", "client" ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/base.py#L8-L36
20c/twentyc.database
twentyc/database/base.py
ClientFromConfig
def ClientFromConfig(engine, config, database, logger=None, verbose=True): """ Return new database client from valid [couchdb] or [couchbase] config section. engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" config <dict> [couchdb] or [couchbase] section from config dat...
python
def ClientFromConfig(engine, config, database, logger=None, verbose=True): """ Return new database client from valid [couchdb] or [couchbase] config section. engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" config <dict> [couchdb] or [couchbase] section from config dat...
[ "def", "ClientFromConfig", "(", "engine", ",", "config", ",", "database", ",", "logger", "=", "None", ",", "verbose", "=", "True", ")", ":", "if", "type", "(", "config", ")", "==", "list", ":", "config", "=", "dict", "(", "config", ")", "if", "engine...
Return new database client from valid [couchdb] or [couchbase] config section. engine <str> defines which engine to use, currently supports "couchdb" and "couchbase" config <dict> [couchdb] or [couchbase] section from config database <str> token to use with bucket_%s or db_%s config property
[ "Return", "new", "database", "client", "from", "valid", "[", "couchdb", "]", "or", "[", "couchbase", "]", "config", "section", "." ]
train
https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/base.py#L39-L82
sassoo/goldman
goldman/serializers/jsonapi.py
Serializer.serialize
def serialize(self, data): """ Determine & invoke the proper serializer method If data is a list then the serialize_datas method will be run otherwise serialize_data. """ super(Serializer, self).serialize(data) body = { 'jsonapi': { 'version...
python
def serialize(self, data): """ Determine & invoke the proper serializer method If data is a list then the serialize_datas method will be run otherwise serialize_data. """ super(Serializer, self).serialize(data) body = { 'jsonapi': { 'version...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "super", "(", "Serializer", ",", "self", ")", ".", "serialize", "(", "data", ")", "body", "=", "{", "'jsonapi'", ":", "{", "'version'", ":", "goldman", ".", "config", ".", "JSONAPI_VERSION", ",", ...
Determine & invoke the proper serializer method If data is a list then the serialize_datas method will be run otherwise serialize_data.
[ "Determine", "&", "invoke", "the", "proper", "serializer", "method" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L24-L63
sassoo/goldman
goldman/serializers/jsonapi.py
Serializer._serialize_data
def _serialize_data(self, data): """ Turn the data into a JSON API compliant resource object WARN: This function has both side effects & a return. It's complete shit because it mutates data & yet returns a new doc. FIX. :spec: jsonapi.org/format/#documen...
python
def _serialize_data(self, data): """ Turn the data into a JSON API compliant resource object WARN: This function has both side effects & a return. It's complete shit because it mutates data & yet returns a new doc. FIX. :spec: jsonapi.org/format/#documen...
[ "def", "_serialize_data", "(", "self", ",", "data", ")", ":", "rels", "=", "{", "}", "rlink", "=", "rid_url", "(", "data", "[", "'rtype'", "]", ",", "data", "[", "'rid'", "]", ")", "doc", "=", "{", "'id'", ":", "data", ".", "pop", "(", "'rid'", ...
Turn the data into a JSON API compliant resource object WARN: This function has both side effects & a return. It's complete shit because it mutates data & yet returns a new doc. FIX. :spec: jsonapi.org/format/#document-resource-objects :param data: ...
[ "Turn", "the", "data", "into", "a", "JSON", "API", "compliant", "resource", "object" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L78-L117
sassoo/goldman
goldman/serializers/jsonapi.py
Serializer._serialize_pages
def _serialize_pages(self): """ Return a JSON API compliant pagination links section If the paginator has a value for a given link then this method will also add the same links to the response objects `link` header according to the guidance of RFC 5988. Falcon has a nat...
python
def _serialize_pages(self): """ Return a JSON API compliant pagination links section If the paginator has a value for a given link then this method will also add the same links to the response objects `link` header according to the guidance of RFC 5988. Falcon has a nat...
[ "def", "_serialize_pages", "(", "self", ")", ":", "pages", "=", "self", ".", "req", ".", "pages", ".", "to_dict", "(", ")", "links", "=", "{", "}", "for", "key", ",", "val", "in", "pages", ".", "items", "(", ")", ":", "if", "val", ":", "params", ...
Return a JSON API compliant pagination links section If the paginator has a value for a given link then this method will also add the same links to the response objects `link` header according to the guidance of RFC 5988. Falcon has a native add_link helper for forming the ...
[ "Return", "a", "JSON", "API", "compliant", "pagination", "links", "section" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L119-L145
sassoo/goldman
goldman/serializers/jsonapi.py
Serializer._serialize_to_many
def _serialize_to_many(self, key, vals, rlink): """ Make a to_many JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param vals: array of dict's containing `rid`...
python
def _serialize_to_many(self, key, vals, rlink): """ Make a to_many JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param vals: array of dict's containing `rid`...
[ "def", "_serialize_to_many", "(", "self", ",", "key", ",", "vals", ",", "rlink", ")", ":", "rel", "=", "{", "key", ":", "{", "'data'", ":", "[", "]", ",", "'links'", ":", "{", "'related'", ":", "rlink", "+", "'/'", "+", "key", "}", "}", "}", "t...
Make a to_many JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param vals: array of dict's containing `rid` & `rtype` keys for the to_many, empty array if ...
[ "Make", "a", "to_many", "JSON", "API", "compliant" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L147-L180
sassoo/goldman
goldman/serializers/jsonapi.py
Serializer._serialize_to_one
def _serialize_to_one(self, key, val, rlink): """ Make a to_one JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param val: dict containing `rid` & `rtype` keys...
python
def _serialize_to_one(self, key, val, rlink): """ Make a to_one JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param val: dict containing `rid` & `rtype` keys...
[ "def", "_serialize_to_one", "(", "self", ",", "key", ",", "val", ",", "rlink", ")", ":", "data", "=", "None", "if", "val", "and", "val", "[", "'rid'", "]", ":", "data", "=", "{", "'id'", ":", "val", "[", "'rid'", "]", ",", "'type'", ":", "val", ...
Make a to_one JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param val: dict containing `rid` & `rtype` keys for the to_one & None if the to_one is null ...
[ "Make", "a", "to_one", "JSON", "API", "compliant" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L182-L207
sassoo/goldman
goldman/validators/__init__.py
validate_int
def validate_int(value): """ Integer validator """ if value and not isinstance(value, int): try: int(str(value)) except (TypeError, ValueError): raise ValidationError('not a valid number') return value
python
def validate_int(value): """ Integer validator """ if value and not isinstance(value, int): try: int(str(value)) except (TypeError, ValueError): raise ValidationError('not a valid number') return value
[ "def", "validate_int", "(", "value", ")", ":", "if", "value", "and", "not", "isinstance", "(", "value", ",", "int", ")", ":", "try", ":", "int", "(", "str", "(", "value", ")", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "raise", "...
Integer validator
[ "Integer", "validator" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/validators/__init__.py#L13-L21
sassoo/goldman
goldman/validators/__init__.py
validate_uuid
def validate_uuid(value): """ UUID 128-bit validator """ if value and not isinstance(value, UUID): try: return UUID(str(value), version=4) except (AttributeError, ValueError): raise ValidationError('not a valid UUID') return value
python
def validate_uuid(value): """ UUID 128-bit validator """ if value and not isinstance(value, UUID): try: return UUID(str(value), version=4) except (AttributeError, ValueError): raise ValidationError('not a valid UUID') return value
[ "def", "validate_uuid", "(", "value", ")", ":", "if", "value", "and", "not", "isinstance", "(", "value", ",", "UUID", ")", ":", "try", ":", "return", "UUID", "(", "str", "(", "value", ")", ",", "version", "=", "4", ")", "except", "(", "AttributeError...
UUID 128-bit validator
[ "UUID", "128", "-", "bit", "validator" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/validators/__init__.py#L24-L32