repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
pepkit/peppy
peppy/utils.py
standard_stream_redirector
def standard_stream_redirector(stream): """ Temporarily redirect stdout and stderr to another stream. This can be useful for capturing messages for easier inspection, or for rerouting and essentially ignoring them, with the destination as something like an opened os.devnull. :param FileIO[str]...
python
def standard_stream_redirector(stream): """ Temporarily redirect stdout and stderr to another stream. This can be useful for capturing messages for easier inspection, or for rerouting and essentially ignoring them, with the destination as something like an opened os.devnull. :param FileIO[str]...
[ "def", "standard_stream_redirector", "(", "stream", ")", ":", "import", "sys", "genuine_stdout", ",", "genuine_stderr", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "sys", ".", "stdout", ",", "sys", ".", "stderr", "=", "stream", ",", "stream", "tr...
Temporarily redirect stdout and stderr to another stream. This can be useful for capturing messages for easier inspection, or for rerouting and essentially ignoring them, with the destination as something like an opened os.devnull. :param FileIO[str] stream: temporary proxy for standard streams
[ "Temporarily", "redirect", "stdout", "and", "stderr", "to", "another", "stream", "." ]
f0f725e1557936b81c86573a77400e6f8da78f05
https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L393-L409
train
momozor/python-pixabay
pixabay.py
Video.search
def search( self, q="yellow flower", lang="en", video_type="all", category="", min_width=0, min_height=0, editors_choice="false", safesearch="false", order="popular", page=1, p...
python
def search( self, q="yellow flower", lang="en", video_type="all", category="", min_width=0, min_height=0, editors_choice="false", safesearch="false", order="popular", page=1, p...
[ "def", "search", "(", "self", ",", "q", "=", "\"yellow flower\"", ",", "lang", "=", "\"en\"", ",", "video_type", "=", "\"all\"", ",", "category", "=", "\"\"", ",", "min_width", "=", "0", ",", "min_height", "=", "0", ",", "editors_choice", "=", "\"false\"...
returns videos API data in dict Videos search :param q :type str :desc A URL encoded search term. If omitted, all images are returned. This value may not exceed 100 characters. Example: "yellow+flower" Default: "yellow+flower" :param lang :type str :desc Language code ...
[ "returns", "videos", "API", "data", "in", "dict" ]
4985ed3b816c041c0e4381e3f6bf97bfda7796e1
https://github.com/momozor/python-pixabay/blob/4985ed3b816c041c0e4381e3f6bf97bfda7796e1/pixabay.py#L168-L273
train
bamthomas/aioimaplib
aioimaplib/aioimaplib.py
quoted
def quoted(arg): """ Given a string, return a quoted string as per RFC 3501, section 9. Implementation copied from https://github.com/mjs/imapclient (imapclient/imapclient.py), 3-clause BSD license """ if isinstance(arg, str): arg = arg.replace('\\', '\\\\') arg = arg.replac...
python
def quoted(arg): """ Given a string, return a quoted string as per RFC 3501, section 9. Implementation copied from https://github.com/mjs/imapclient (imapclient/imapclient.py), 3-clause BSD license """ if isinstance(arg, str): arg = arg.replace('\\', '\\\\') arg = arg.replac...
[ "def", "quoted", "(", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "str", ")", ":", "arg", "=", "arg", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", "arg", "=", "arg", ".", "replace", "(", "'\"'", ",", "'\\\\\"'", ")", "q", "=",...
Given a string, return a quoted string as per RFC 3501, section 9. Implementation copied from https://github.com/mjs/imapclient (imapclient/imapclient.py), 3-clause BSD license
[ "Given", "a", "string", "return", "a", "quoted", "string", "as", "per", "RFC", "3501", "section", "9", "." ]
9670d43950cafc4d41aab7a36824b8051fa89899
https://github.com/bamthomas/aioimaplib/blob/9670d43950cafc4d41aab7a36824b8051fa89899/aioimaplib/aioimaplib.py#L100-L114
train
bamthomas/aioimaplib
aioimaplib/aioimaplib.py
int2ap
def int2ap(num): """Convert integer to A-P string representation.""" val = '' ap = 'ABCDEFGHIJKLMNOP' num = int(abs(num)) while num: num, mod = divmod(num, 16) val += ap[mod:mod + 1] return val
python
def int2ap(num): """Convert integer to A-P string representation.""" val = '' ap = 'ABCDEFGHIJKLMNOP' num = int(abs(num)) while num: num, mod = divmod(num, 16) val += ap[mod:mod + 1] return val
[ "def", "int2ap", "(", "num", ")", ":", "val", "=", "''", "ap", "=", "'ABCDEFGHIJKLMNOP'", "num", "=", "int", "(", "abs", "(", "num", ")", ")", "while", "num", ":", "num", ",", "mod", "=", "divmod", "(", "num", ",", "16", ")", "val", "+=", "ap",...
Convert integer to A-P string representation.
[ "Convert", "integer", "to", "A", "-", "P", "string", "representation", "." ]
9670d43950cafc4d41aab7a36824b8051fa89899
https://github.com/bamthomas/aioimaplib/blob/9670d43950cafc4d41aab7a36824b8051fa89899/aioimaplib/aioimaplib.py#L864-L872
train
bamthomas/aioimaplib
aioimaplib/aioimaplib.py
time2internaldate
def time2internaldate(date_time): """Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time...
python
def time2internaldate(date_time): """Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time...
[ "def", "time2internaldate", "(", "date_time", ")", ":", "if", "isinstance", "(", "date_time", ",", "(", "int", ",", "float", ")", ")", ":", "dt", "=", "datetime", ".", "fromtimestamp", "(", "date_time", ",", "timezone", ".", "utc", ")", ".", "astimezone"...
Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time, an instance of time.struct_time (as ...
[ "Convert", "date_time", "to", "IMAP4", "INTERNALDATE", "representation", "." ]
9670d43950cafc4d41aab7a36824b8051fa89899
https://github.com/bamthomas/aioimaplib/blob/9670d43950cafc4d41aab7a36824b8051fa89899/aioimaplib/aioimaplib.py#L877-L912
train
mozilla/django-post-request-task
post_request_task/task.py
_send_tasks_and_stop_queuing
def _send_tasks_and_stop_queuing(**kwargs): """Sends all delayed Celery tasks and stop queuing new ones for now.""" log.info('Stopping queueing tasks and sending already queued ones.') _stop_queuing_tasks() task_queue = _get_task_queue() while task_queue: task, args, kwargs, extrakw = task_q...
python
def _send_tasks_and_stop_queuing(**kwargs): """Sends all delayed Celery tasks and stop queuing new ones for now.""" log.info('Stopping queueing tasks and sending already queued ones.') _stop_queuing_tasks() task_queue = _get_task_queue() while task_queue: task, args, kwargs, extrakw = task_q...
[ "def", "_send_tasks_and_stop_queuing", "(", "**", "kwargs", ")", ":", "log", ".", "info", "(", "'Stopping queueing tasks and sending already queued ones.'", ")", "_stop_queuing_tasks", "(", ")", "task_queue", "=", "_get_task_queue", "(", ")", "while", "task_queue", ":",...
Sends all delayed Celery tasks and stop queuing new ones for now.
[ "Sends", "all", "delayed", "Celery", "tasks", "and", "stop", "queuing", "new", "ones", "for", "now", "." ]
9ea9d7004f5f93e82311ab170afcf6e51fbf82ff
https://github.com/mozilla/django-post-request-task/blob/9ea9d7004f5f93e82311ab170afcf6e51fbf82ff/post_request_task/task.py#L47-L54
train
mozilla/django-post-request-task
post_request_task/task.py
_append_task
def _append_task(t): """Append a task to the queue. Expected argument is a tuple of the following form: (task class, args, kwargs, extra kwargs). This doesn't append to queue if the argument is already in the queue. """ task_queue = _get_task_queue() if t not in task_queue: log.de...
python
def _append_task(t): """Append a task to the queue. Expected argument is a tuple of the following form: (task class, args, kwargs, extra kwargs). This doesn't append to queue if the argument is already in the queue. """ task_queue = _get_task_queue() if t not in task_queue: log.de...
[ "def", "_append_task", "(", "t", ")", ":", "task_queue", "=", "_get_task_queue", "(", ")", "if", "t", "not", "in", "task_queue", ":", "log", ".", "debug", "(", "'Appended new task to the queue: %s.'", ",", "t", ")", "task_queue", ".", "append", "(", "t", "...
Append a task to the queue. Expected argument is a tuple of the following form: (task class, args, kwargs, extra kwargs). This doesn't append to queue if the argument is already in the queue.
[ "Append", "a", "task", "to", "the", "queue", "." ]
9ea9d7004f5f93e82311ab170afcf6e51fbf82ff
https://github.com/mozilla/django-post-request-task/blob/9ea9d7004f5f93e82311ab170afcf6e51fbf82ff/post_request_task/task.py#L64-L79
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Task.create_from_tuple
def create_from_tuple(cls, tube, the_tuple): """ Create task from tuple. Returns `Task` instance. """ if the_tuple is None: return if not the_tuple.rowcount: raise Queue.ZeroTupleException("Error creating task") row = the_tuple[0] ...
python
def create_from_tuple(cls, tube, the_tuple): """ Create task from tuple. Returns `Task` instance. """ if the_tuple is None: return if not the_tuple.rowcount: raise Queue.ZeroTupleException("Error creating task") row = the_tuple[0] ...
[ "def", "create_from_tuple", "(", "cls", ",", "tube", ",", "the_tuple", ")", ":", "if", "the_tuple", "is", "None", ":", "return", "if", "not", "the_tuple", ".", "rowcount", ":", "raise", "Queue", ".", "ZeroTupleException", "(", "\"Error creating task\"", ")", ...
Create task from tuple. Returns `Task` instance.
[ "Create", "task", "from", "tuple", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L52-L71
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Task.update_from_tuple
def update_from_tuple(self, the_tuple): """ Update task from tuple. """ if not the_tuple.rowcount: raise Queue.ZeroTupleException("Error updating task") row = the_tuple[0] if self.task_id != row[0]: raise Queue.BadTupleException("Wrong task: id's...
python
def update_from_tuple(self, the_tuple): """ Update task from tuple. """ if not the_tuple.rowcount: raise Queue.ZeroTupleException("Error updating task") row = the_tuple[0] if self.task_id != row[0]: raise Queue.BadTupleException("Wrong task: id's...
[ "def", "update_from_tuple", "(", "self", ",", "the_tuple", ")", ":", "if", "not", "the_tuple", ".", "rowcount", ":", "raise", "Queue", ".", "ZeroTupleException", "(", "\"Error updating task\"", ")", "row", "=", "the_tuple", "[", "0", "]", "if", "self", ".", ...
Update task from tuple.
[ "Update", "task", "from", "tuple", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L73-L86
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Task.peek
async def peek(self): """ Look at a task without changing its state. Always returns `True`. """ the_tuple = await self.queue.peek(self.tube, self.task_id) self.update_from_tuple(the_tuple) return True
python
async def peek(self): """ Look at a task without changing its state. Always returns `True`. """ the_tuple = await self.queue.peek(self.tube, self.task_id) self.update_from_tuple(the_tuple) return True
[ "async", "def", "peek", "(", "self", ")", ":", "the_tuple", "=", "await", "self", ".", "queue", ".", "peek", "(", "self", ".", "tube", ",", "self", ".", "task_id", ")", "self", ".", "update_from_tuple", "(", "the_tuple", ")", "return", "True" ]
Look at a task without changing its state. Always returns `True`.
[ "Look", "at", "a", "task", "without", "changing", "its", "state", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L118-L128
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Tube.cmd
def cmd(self, cmd_name): """ Returns tarantool queue command name for current tube. """ return "{0}.tube.{1}:{2}".format(self.queue.lua_queue_name, self.name, cmd_name)
python
def cmd(self, cmd_name): """ Returns tarantool queue command name for current tube. """ return "{0}.tube.{1}:{2}".format(self.queue.lua_queue_name, self.name, cmd_name)
[ "def", "cmd", "(", "self", ",", "cmd_name", ")", ":", "return", "\"{0}.tube.{1}:{2}\"", ".", "format", "(", "self", ".", "queue", ".", "lua_queue_name", ",", "self", ".", "name", ",", "cmd_name", ")" ]
Returns tarantool queue command name for current tube.
[ "Returns", "tarantool", "queue", "command", "name", "for", "current", "tube", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L151-L155
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Queue.ack
async def ack(self, tube, task_id): """ Report task successful execution. Ack is accepted only from the consumer, which took the task for execution. If a consumer disconnects, all tasks taken by this consumer are put back to READY state (released). Returns tarantool tup...
python
async def ack(self, tube, task_id): """ Report task successful execution. Ack is accepted only from the consumer, which took the task for execution. If a consumer disconnects, all tasks taken by this consumer are put back to READY state (released). Returns tarantool tup...
[ "async", "def", "ack", "(", "self", ",", "tube", ",", "task_id", ")", ":", "cmd", "=", "tube", ".", "cmd", "(", "\"ack\"", ")", "args", "=", "(", "task_id", ",", ")", "res", "=", "await", "self", ".", "tnt", ".", "call", "(", "cmd", ",", "args"...
Report task successful execution. Ack is accepted only from the consumer, which took the task for execution. If a consumer disconnects, all tasks taken by this consumer are put back to READY state (released). Returns tarantool tuple object.
[ "Report", "task", "successful", "execution", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L297-L311
train
shveenkov/aiotarantool-queue-python
aiotarantool_queue/queue.py
Queue.tube
def tube(self, name): """ Create tube object, if not created before. Returns `Tube` object. """ tube = self.tubes.get(name) if tube is None: tube = Tube(self, name) self.tubes[name] = tube return tube
python
def tube(self, name): """ Create tube object, if not created before. Returns `Tube` object. """ tube = self.tubes.get(name) if tube is None: tube = Tube(self, name) self.tubes[name] = tube return tube
[ "def", "tube", "(", "self", ",", "name", ")", ":", "tube", "=", "self", ".", "tubes", ".", "get", "(", "name", ")", "if", "tube", "is", "None", ":", "tube", "=", "Tube", "(", "self", ",", "name", ")", "self", ".", "tubes", "[", "name", "]", "...
Create tube object, if not created before. Returns `Tube` object.
[ "Create", "tube", "object", "if", "not", "created", "before", "." ]
b84a1e704f63f7b8cb14cbca5ec99ab8047d1715
https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L370-L382
train
cronofy/pycronofy
pycronofy/request_handler.py
RequestHandler.post
def post(self, endpoint='', url='', data=None, use_api_key=False, omit_api_version=False): """Perform a post to an API endpoint. :param string endpoint: Target endpoint. (Optional). :param string url: Override the endpoint and provide the full url (eg for pagination). (Optional). :param...
python
def post(self, endpoint='', url='', data=None, use_api_key=False, omit_api_version=False): """Perform a post to an API endpoint. :param string endpoint: Target endpoint. (Optional). :param string url: Override the endpoint and provide the full url (eg for pagination). (Optional). :param...
[ "def", "post", "(", "self", ",", "endpoint", "=", "''", ",", "url", "=", "''", ",", "data", "=", "None", ",", "use_api_key", "=", "False", ",", "omit_api_version", "=", "False", ")", ":", "return", "self", ".", "_request", "(", "'post'", ",", "endpoi...
Perform a post to an API endpoint. :param string endpoint: Target endpoint. (Optional). :param string url: Override the endpoint and provide the full url (eg for pagination). (Optional). :param dict data: Data to pass to the post. (Optional). :return: Response. :rtype: ``Respons...
[ "Perform", "a", "post", "to", "an", "API", "endpoint", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/request_handler.py#L44-L53
train
cronofy/pycronofy
pycronofy/request_handler.py
RequestHandler._request
def _request(self, request_method, endpoint='', url='', data=None, params=None, use_api_key=False, omit_api_version=False): """Perform a http request via the specified method to an API endpoint. :param string request_method: Request method. :param string endpoint: Target endpoint. (Optional). ...
python
def _request(self, request_method, endpoint='', url='', data=None, params=None, use_api_key=False, omit_api_version=False): """Perform a http request via the specified method to an API endpoint. :param string request_method: Request method. :param string endpoint: Target endpoint. (Optional). ...
[ "def", "_request", "(", "self", ",", "request_method", ",", "endpoint", "=", "''", ",", "url", "=", "''", ",", "data", "=", "None", ",", "params", "=", "None", ",", "use_api_key", "=", "False", ",", "omit_api_version", "=", "False", ")", ":", "if", "...
Perform a http request via the specified method to an API endpoint. :param string request_method: Request method. :param string endpoint: Target endpoint. (Optional). :param string url: Override the endpoint and provide the full url (eg for pagination). (Optional). :param dict params: P...
[ "Perform", "a", "http", "request", "via", "the", "specified", "method", "to", "an", "API", "endpoint", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/request_handler.py#L55-L101
train
cronofy/pycronofy
pycronofy/client.py
Client.change_participation_status
def change_participation_status(self, calendar_id, event_uid, status): """Changes the participation status for a calendar event :param string calendar_id: The String Cronofy ID for the calendar to delete the event from. :param string event_uid: A String uniquely identifying the event for your ...
python
def change_participation_status(self, calendar_id, event_uid, status): """Changes the participation status for a calendar event :param string calendar_id: The String Cronofy ID for the calendar to delete the event from. :param string event_uid: A String uniquely identifying the event for your ...
[ "def", "change_participation_status", "(", "self", ",", "calendar_id", ",", "event_uid", ",", "status", ")", ":", "data", "=", "{", "'status'", ":", "status", "}", "self", ".", "request_handler", ".", "post", "(", "'calendars/%s/events/%s/participation_status'", "...
Changes the participation status for a calendar event :param string calendar_id: The String Cronofy ID for the calendar to delete the event from. :param string event_uid: A String uniquely identifying the event for your application (note: this is NOT an ID generated by Cronofy). :param ...
[ "Changes", "the", "participation", "status", "for", "a", "calendar", "event" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L73-L84
train
cronofy/pycronofy
pycronofy/client.py
Client.create_notification_channel
def create_notification_channel(self, callback_url, calendar_ids=()): """Create a new channel for receiving push notifications. :param string callback_url: The url that will receive push notifications. Must not be longer than 128 characters and should be HTTPS. :param tuple calendar_ids...
python
def create_notification_channel(self, callback_url, calendar_ids=()): """Create a new channel for receiving push notifications. :param string callback_url: The url that will receive push notifications. Must not be longer than 128 characters and should be HTTPS. :param tuple calendar_ids...
[ "def", "create_notification_channel", "(", "self", ",", "callback_url", ",", "calendar_ids", "=", "(", ")", ")", ":", "data", "=", "{", "'callback_url'", ":", "callback_url", "}", "if", "calendar_ids", ":", "data", "[", "'filters'", "]", "=", "{", "'calendar...
Create a new channel for receiving push notifications. :param string callback_url: The url that will receive push notifications. Must not be longer than 128 characters and should be HTTPS. :param tuple calendar_ids: List of calendar ids to create notification channels for. (Optional. Default em...
[ "Create", "a", "new", "channel", "for", "receiving", "push", "notifications", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L86-L99
train
cronofy/pycronofy
pycronofy/client.py
Client.delete_all_events
def delete_all_events(self, calendar_ids=()): """Deletes all events managed through Cronofy from the all of the user's calendars. :param tuple calendar_ids: List of calendar ids to delete events for. (Optional. Default empty tuple) """ params = {'delete_all': True} if calendar_i...
python
def delete_all_events(self, calendar_ids=()): """Deletes all events managed through Cronofy from the all of the user's calendars. :param tuple calendar_ids: List of calendar ids to delete events for. (Optional. Default empty tuple) """ params = {'delete_all': True} if calendar_i...
[ "def", "delete_all_events", "(", "self", ",", "calendar_ids", "=", "(", ")", ")", ":", "params", "=", "{", "'delete_all'", ":", "True", "}", "if", "calendar_ids", ":", "params", "=", "{", "'calendar_ids[]'", ":", "calendar_ids", "}", "self", ".", "request_...
Deletes all events managed through Cronofy from the all of the user's calendars. :param tuple calendar_ids: List of calendar ids to delete events for. (Optional. Default empty tuple)
[ "Deletes", "all", "events", "managed", "through", "Cronofy", "from", "the", "all", "of", "the", "user", "s", "calendars", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L101-L110
train
cronofy/pycronofy
pycronofy/client.py
Client.delete_event
def delete_event(self, calendar_id, event_id): """Delete an event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_id: ID of event to delete. """ self.request_handler.delete(endpoint='calendars/%s/events' % calendar_id, d...
python
def delete_event(self, calendar_id, event_id): """Delete an event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_id: ID of event to delete. """ self.request_handler.delete(endpoint='calendars/%s/events' % calendar_id, d...
[ "def", "delete_event", "(", "self", ",", "calendar_id", ",", "event_id", ")", ":", "self", ".", "request_handler", ".", "delete", "(", "endpoint", "=", "'calendars/%s/events'", "%", "calendar_id", ",", "data", "=", "{", "'event_id'", ":", "event_id", "}", ")...
Delete an event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_id: ID of event to delete.
[ "Delete", "an", "event", "from", "the", "specified", "calendar", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L112-L118
train
cronofy/pycronofy
pycronofy/client.py
Client.delete_external_event
def delete_external_event(self, calendar_id, event_uid): """Delete an external event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_uid: ID of event to delete. """ self.request_handler.delete(endpoint='calendars/%s/even...
python
def delete_external_event(self, calendar_id, event_uid): """Delete an external event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_uid: ID of event to delete. """ self.request_handler.delete(endpoint='calendars/%s/even...
[ "def", "delete_external_event", "(", "self", ",", "calendar_id", ",", "event_uid", ")", ":", "self", ".", "request_handler", ".", "delete", "(", "endpoint", "=", "'calendars/%s/events'", "%", "calendar_id", ",", "data", "=", "{", "'event_uid'", ":", "event_uid",...
Delete an external event from the specified calendar. :param string calendar_id: ID of calendar to delete from. :param string event_uid: ID of event to delete.
[ "Delete", "an", "external", "event", "from", "the", "specified", "calendar", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L120-L126
train
cronofy/pycronofy
pycronofy/client.py
Client.elevated_permissions
def elevated_permissions(self, permissions, redirect_uri=None): """Requests elevated permissions for a set of calendars. :param tuple permissions - calendar permission dicts set each dict must contain values for both `calendar_id` and `permission_level` :param string redirect_uri - A u...
python
def elevated_permissions(self, permissions, redirect_uri=None): """Requests elevated permissions for a set of calendars. :param tuple permissions - calendar permission dicts set each dict must contain values for both `calendar_id` and `permission_level` :param string redirect_uri - A u...
[ "def", "elevated_permissions", "(", "self", ",", "permissions", ",", "redirect_uri", "=", "None", ")", ":", "body", "=", "{", "'permissions'", ":", "permissions", "}", "if", "redirect_uri", ":", "body", "[", "'redirect_uri'", "]", "=", "redirect_uri", "return"...
Requests elevated permissions for a set of calendars. :param tuple permissions - calendar permission dicts set each dict must contain values for both `calendar_id` and `permission_level` :param string redirect_uri - A uri to redirect the end user back to after they have either granted ...
[ "Requests", "elevated", "permissions", "for", "a", "set", "of", "calendars", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L128-L153
train
cronofy/pycronofy
pycronofy/client.py
Client.get_smart_invite
def get_smart_invite(self, smart_invite_id, recipient_email): """Gets the details for a smart invite. :param string smart_invite_id: - A String uniquely identifying the event for your application (note: this is NOT an ID generated by Cronofy). :param stri...
python
def get_smart_invite(self, smart_invite_id, recipient_email): """Gets the details for a smart invite. :param string smart_invite_id: - A String uniquely identifying the event for your application (note: this is NOT an ID generated by Cronofy). :param stri...
[ "def", "get_smart_invite", "(", "self", ",", "smart_invite_id", ",", "recipient_email", ")", ":", "params", "=", "{", "'smart_invite_id'", ":", "smart_invite_id", ",", "'recipient_email'", ":", "recipient_email", "}", "return", "self", ".", "request_handler", ".", ...
Gets the details for a smart invite. :param string smart_invite_id: - A String uniquely identifying the event for your application (note: this is NOT an ID generated by Cronofy). :param string recipient_email: - The email address for the recipient to get details ...
[ "Gets", "the", "details", "for", "a", "smart", "invite", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L218-L230
train
cronofy/pycronofy
pycronofy/client.py
Client.application_calendar
def application_calendar(self, application_calendar_id): """Creates and Retrieves authorization for an application calendar :param string application_calendar_id: The Id for this application calendar :return: Dictionary containing auth tokens, expiration info, and response status. :rtyp...
python
def application_calendar(self, application_calendar_id): """Creates and Retrieves authorization for an application calendar :param string application_calendar_id: The Id for this application calendar :return: Dictionary containing auth tokens, expiration info, and response status. :rtyp...
[ "def", "application_calendar", "(", "self", ",", "application_calendar_id", ")", ":", "response", "=", "self", ".", "request_handler", ".", "post", "(", "endpoint", "=", "'application_calendar'", ",", "data", "=", "{", "'client_id'", ":", "self", ".", "auth", ...
Creates and Retrieves authorization for an application calendar :param string application_calendar_id: The Id for this application calendar :return: Dictionary containing auth tokens, expiration info, and response status. :rtype: ``dict``
[ "Creates", "and", "Retrieves", "authorization", "for", "an", "application", "calendar" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L263-L290
train
cronofy/pycronofy
pycronofy/client.py
Client.refresh_authorization
def refresh_authorization(self): """Refreshes the authorization tokens. :return: Dictionary containing auth tokens, expiration info, and response status. :rtype: ``dict`` """ response = self.request_handler.post( endpoint='oauth/token', omit_api_version=T...
python
def refresh_authorization(self): """Refreshes the authorization tokens. :return: Dictionary containing auth tokens, expiration info, and response status. :rtype: ``dict`` """ response = self.request_handler.post( endpoint='oauth/token', omit_api_version=T...
[ "def", "refresh_authorization", "(", "self", ")", ":", "response", "=", "self", ".", "request_handler", ".", "post", "(", "endpoint", "=", "'oauth/token'", ",", "omit_api_version", "=", "True", ",", "data", "=", "{", "'grant_type'", ":", "'refresh_token'", ","...
Refreshes the authorization tokens. :return: Dictionary containing auth tokens, expiration info, and response status. :rtype: ``dict``
[ "Refreshes", "the", "authorization", "tokens", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L463-L490
train
cronofy/pycronofy
pycronofy/client.py
Client.revoke_authorization
def revoke_authorization(self): """Revokes Oauth authorization.""" self.request_handler.post( endpoint='oauth/token/revoke', omit_api_version=True, data={ 'client_id': self.auth.client_id, 'client_secret': self.auth.client_secret, ...
python
def revoke_authorization(self): """Revokes Oauth authorization.""" self.request_handler.post( endpoint='oauth/token/revoke', omit_api_version=True, data={ 'client_id': self.auth.client_id, 'client_secret': self.auth.client_secret, ...
[ "def", "revoke_authorization", "(", "self", ")", ":", "self", ".", "request_handler", ".", "post", "(", "endpoint", "=", "'oauth/token/revoke'", ",", "omit_api_version", "=", "True", ",", "data", "=", "{", "'client_id'", ":", "self", ".", "auth", ".", "clien...
Revokes Oauth authorization.
[ "Revokes", "Oauth", "authorization", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L492-L507
train
cronofy/pycronofy
pycronofy/client.py
Client.upsert_event
def upsert_event(self, calendar_id, event): """Inserts or updates an event for the specified calendar. :param string calendar_id: ID of calendar to insert/update event into. :param dict event: Dictionary of event data to send to cronofy. """ event['start'] = format_event_time(ev...
python
def upsert_event(self, calendar_id, event): """Inserts or updates an event for the specified calendar. :param string calendar_id: ID of calendar to insert/update event into. :param dict event: Dictionary of event data to send to cronofy. """ event['start'] = format_event_time(ev...
[ "def", "upsert_event", "(", "self", ",", "calendar_id", ",", "event", ")", ":", "event", "[", "'start'", "]", "=", "format_event_time", "(", "event", "[", "'start'", "]", ")", "event", "[", "'end'", "]", "=", "format_event_time", "(", "event", "[", "'end...
Inserts or updates an event for the specified calendar. :param string calendar_id: ID of calendar to insert/update event into. :param dict event: Dictionary of event data to send to cronofy.
[ "Inserts", "or", "updates", "an", "event", "for", "the", "specified", "calendar", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L509-L518
train
cronofy/pycronofy
pycronofy/client.py
Client.authorize_with_service_account
def authorize_with_service_account(self, email, scope, callback_url, state=None): """ Attempts to authorize the email with impersonation from a service account :param string email: the email address to impersonate :param string callback_url: URL to callback with the OAuth code. :param s...
python
def authorize_with_service_account(self, email, scope, callback_url, state=None): """ Attempts to authorize the email with impersonation from a service account :param string email: the email address to impersonate :param string callback_url: URL to callback with the OAuth code. :param s...
[ "def", "authorize_with_service_account", "(", "self", ",", "email", ",", "scope", ",", "callback_url", ",", "state", "=", "None", ")", ":", "params", "=", "{", "'email'", ":", "email", ",", "'scope'", ":", "scope", ",", "'callback_url'", ":", "callback_url",...
Attempts to authorize the email with impersonation from a service account :param string email: the email address to impersonate :param string callback_url: URL to callback with the OAuth code. :param string scope: The scope of the privileges you want the eventual access_token to grant. ...
[ "Attempts", "to", "authorize", "the", "email", "with", "impersonation", "from", "a", "service", "account" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L520-L539
train
cronofy/pycronofy
pycronofy/client.py
Client.real_time_scheduling
def real_time_scheduling(self, availability, oauth, event, target_calendars=()): """Generates an real time scheduling link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :pa...
python
def real_time_scheduling(self, availability, oauth, event, target_calendars=()): """Generates an real time scheduling link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :pa...
[ "def", "real_time_scheduling", "(", "self", ",", "availability", ",", "oauth", ",", "event", ",", "target_calendars", "=", "(", ")", ")", ":", "args", "=", "{", "'oauth'", ":", "oauth", ",", "'event'", ":", "event", ",", "'target_calendars'", ":", "target_...
Generates an real time scheduling link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :participants - A dict stating who is required for the availability ...
[ "Generates", "an", "real", "time", "scheduling", "link", "to", "start", "the", "OAuth", "process", "with", "an", "event", "to", "be", "automatically", "upserted" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L541-L582
train
cronofy/pycronofy
pycronofy/client.py
Client.real_time_sequencing
def real_time_sequencing(self, availability, oauth, event, target_calendars=()): """Generates an real time sequencing link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :s...
python
def real_time_sequencing(self, availability, oauth, event, target_calendars=()): """Generates an real time sequencing link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :s...
[ "def", "real_time_sequencing", "(", "self", ",", "availability", ",", "oauth", ",", "event", ",", "target_calendars", "=", "(", ")", ")", ":", "args", "=", "{", "'oauth'", ":", "oauth", ",", "'event'", ":", "event", ",", "'target_calendars'", ":", "target_...
Generates an real time sequencing link to start the OAuth process with an event to be automatically upserted :param dict availability: - A dict describing the availability details for the event: :sequence: An Array of dics representing sequences to find availability for ...
[ "Generates", "an", "real", "time", "sequencing", "link", "to", "start", "the", "OAuth", "process", "with", "an", "event", "to", "be", "automatically", "upserted" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L584-L629
train
cronofy/pycronofy
pycronofy/client.py
Client.user_auth_link
def user_auth_link(self, redirect_uri, scope='', state='', avoid_linking=False): """Generates a URL to send the user for OAuth 2.0 :param string redirect_uri: URL to redirect the user to after auth. :param string scope: The scope of the privileges you want the eventual access_token to grant. ...
python
def user_auth_link(self, redirect_uri, scope='', state='', avoid_linking=False): """Generates a URL to send the user for OAuth 2.0 :param string redirect_uri: URL to redirect the user to after auth. :param string scope: The scope of the privileges you want the eventual access_token to grant. ...
[ "def", "user_auth_link", "(", "self", ",", "redirect_uri", ",", "scope", "=", "''", ",", "state", "=", "''", ",", "avoid_linking", "=", "False", ")", ":", "if", "not", "scope", ":", "scope", "=", "' '", ".", "join", "(", "settings", ".", "DEFAULT_OAUTH...
Generates a URL to send the user for OAuth 2.0 :param string redirect_uri: URL to redirect the user to after auth. :param string scope: The scope of the privileges you want the eventual access_token to grant. :param string state: A value that will be returned to you unaltered along with the use...
[ "Generates", "a", "URL", "to", "send", "the", "user", "for", "OAuth", "2", ".", "0" ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L631-L657
train
cronofy/pycronofy
pycronofy/client.py
Client.validate
def validate(self, method, *args, **kwargs): """Validate authentication and values passed to the specified method. Raises a PyCronofyValidationError on error. :param string method: Method name to check. :param *args: Arguments for "Method". :param **kwargs: Keyword arguments for...
python
def validate(self, method, *args, **kwargs): """Validate authentication and values passed to the specified method. Raises a PyCronofyValidationError on error. :param string method: Method name to check. :param *args: Arguments for "Method". :param **kwargs: Keyword arguments for...
[ "def", "validate", "(", "self", ",", "method", ",", "*", "args", ",", "**", "kwargs", ")", ":", "validate", "(", "method", ",", "self", ".", "auth", ",", "*", "args", ",", "**", "kwargs", ")" ]
Validate authentication and values passed to the specified method. Raises a PyCronofyValidationError on error. :param string method: Method name to check. :param *args: Arguments for "Method". :param **kwargs: Keyword arguments for "Method".
[ "Validate", "authentication", "and", "values", "passed", "to", "the", "specified", "method", ".", "Raises", "a", "PyCronofyValidationError", "on", "error", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/client.py#L659-L667
train
cronofy/pycronofy
pycronofy/pagination.py
Pages.all
def all(self): """Return all results as a list by automatically fetching all pages. :return: All results. :rtype: ``list`` """ results = self.data[self.data_type] while self.current < self.total: self.fetch_next_page() results.extend(self.data[sel...
python
def all(self): """Return all results as a list by automatically fetching all pages. :return: All results. :rtype: ``list`` """ results = self.data[self.data_type] while self.current < self.total: self.fetch_next_page() results.extend(self.data[sel...
[ "def", "all", "(", "self", ")", ":", "results", "=", "self", ".", "data", "[", "self", ".", "data_type", "]", "while", "self", ".", "current", "<", "self", ".", "total", ":", "self", ".", "fetch_next_page", "(", ")", "results", ".", "extend", "(", ...
Return all results as a list by automatically fetching all pages. :return: All results. :rtype: ``list``
[ "Return", "all", "results", "as", "a", "list", "by", "automatically", "fetching", "all", "pages", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/pagination.py#L27-L37
train
cronofy/pycronofy
pycronofy/pagination.py
Pages.fetch_next_page
def fetch_next_page(self): """Retrieves the next page of data and refreshes Pages instance.""" result = self.request_handler.get(url=self.next_page_url).json() self.__init__(self.request_handler, result, self.data_type, self.automatic_pagination)
python
def fetch_next_page(self): """Retrieves the next page of data and refreshes Pages instance.""" result = self.request_handler.get(url=self.next_page_url).json() self.__init__(self.request_handler, result, self.data_type, self.automatic_pagination)
[ "def", "fetch_next_page", "(", "self", ")", ":", "result", "=", "self", ".", "request_handler", ".", "get", "(", "url", "=", "self", ".", "next_page_url", ")", ".", "json", "(", ")", "self", ".", "__init__", "(", "self", ".", "request_handler", ",", "r...
Retrieves the next page of data and refreshes Pages instance.
[ "Retrieves", "the", "next", "page", "of", "data", "and", "refreshes", "Pages", "instance", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/pagination.py#L47-L51
train
cronofy/pycronofy
pycronofy/validation.py
check_datetime
def check_datetime(method, dictionary, fields, label=None): """Checks if the specified fields are formatted correctly if they have a value. Throws an exception on incorrectly formatted fields. :param dict dictionary: Dictionary to check. :param typle fields: Fields to check. :param string label: Di...
python
def check_datetime(method, dictionary, fields, label=None): """Checks if the specified fields are formatted correctly if they have a value. Throws an exception on incorrectly formatted fields. :param dict dictionary: Dictionary to check. :param typle fields: Fields to check. :param string label: Di...
[ "def", "check_datetime", "(", "method", ",", "dictionary", ",", "fields", ",", "label", "=", "None", ")", ":", "improperly_formatted", "=", "[", "]", "values", "=", "[", "]", "for", "field", "in", "fields", ":", "if", "field", "in", "dictionary", "and", ...
Checks if the specified fields are formatted correctly if they have a value. Throws an exception on incorrectly formatted fields. :param dict dictionary: Dictionary to check. :param typle fields: Fields to check. :param string label: Dictionary name.
[ "Checks", "if", "the", "specified", "fields", "are", "formatted", "correctly", "if", "they", "have", "a", "value", ".", "Throws", "an", "exception", "on", "incorrectly", "formatted", "fields", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/validation.py#L116-L139
train
cronofy/pycronofy
pycronofy/validation.py
validate
def validate(method, auth, *args, **kwargs): """Validate a method based on the METHOD_RULES above. Raises a PyCronofyValidationError on error. :param string method: Method being validated. :param Auth auth: Auth instance. :param *args: Positional arguments for method. :param **kwargs: Keyword ...
python
def validate(method, auth, *args, **kwargs): """Validate a method based on the METHOD_RULES above. Raises a PyCronofyValidationError on error. :param string method: Method being validated. :param Auth auth: Auth instance. :param *args: Positional arguments for method. :param **kwargs: Keyword ...
[ "def", "validate", "(", "method", ",", "auth", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "method", "not", "in", "METHOD_RULES", ":", "raise", "PyCronofyValidationError", "(", "'Method \"%s\" not found.'", "%", "method", ",", "method", ")", "m", ...
Validate a method based on the METHOD_RULES above. Raises a PyCronofyValidationError on error. :param string method: Method being validated. :param Auth auth: Auth instance. :param *args: Positional arguments for method. :param **kwargs: Keyword arguments for method.
[ "Validate", "a", "method", "based", "on", "the", "METHOD_RULES", "above", "." ]
3d807603029478fa9387a9dfb6c3acd9faa4f08e
https://github.com/cronofy/pycronofy/blob/3d807603029478fa9387a9dfb6c3acd9faa4f08e/pycronofy/validation.py#L162-L195
train
AWegnerGitHub/stackapi
fabfile.py
release
def release(part='patch'): """ Automated software release workflow * (Configurably) bumps the version number * Tags the release You can run it like:: $ fab release which, by default, will create a 'patch' release (0.0.1 => 0.0.2). You can also specify a patch level (patch, minor, ma...
python
def release(part='patch'): """ Automated software release workflow * (Configurably) bumps the version number * Tags the release You can run it like:: $ fab release which, by default, will create a 'patch' release (0.0.1 => 0.0.2). You can also specify a patch level (patch, minor, ma...
[ "def", "release", "(", "part", "=", "'patch'", ")", ":", "bumpver", "=", "subprocess", ".", "check_output", "(", "[", "'bumpversion'", ",", "part", ",", "'--dry-run'", ",", "'--verbose'", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "m", "=...
Automated software release workflow * (Configurably) bumps the version number * Tags the release You can run it like:: $ fab release which, by default, will create a 'patch' release (0.0.1 => 0.0.2). You can also specify a patch level (patch, minor, major) to change to:: $ fab ...
[ "Automated", "software", "release", "workflow" ]
146c2c5a201aa51dc8218a6e03d3e903b1d2c36d
https://github.com/AWegnerGitHub/stackapi/blob/146c2c5a201aa51dc8218a6e03d3e903b1d2c36d/fabfile.py#L12-L47
train
Commonists/CommonsDownloader
commonsdownloader/thumbnaildownload.py
make_thumbnail_name
def make_thumbnail_name(image_name, extension): """Return name of the downloaded thumbnail, based on the extension.""" file_name, _ = os.path.splitext(image_name) return file_name + '.' + clean_extension(extension)
python
def make_thumbnail_name(image_name, extension): """Return name of the downloaded thumbnail, based on the extension.""" file_name, _ = os.path.splitext(image_name) return file_name + '.' + clean_extension(extension)
[ "def", "make_thumbnail_name", "(", "image_name", ",", "extension", ")", ":", "file_name", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "image_name", ")", "return", "file_name", "+", "'.'", "+", "clean_extension", "(", "extension", ")" ]
Return name of the downloaded thumbnail, based on the extension.
[ "Return", "name", "of", "the", "downloaded", "thumbnail", "based", "on", "the", "extension", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/thumbnaildownload.py#L65-L68
train
Commonists/CommonsDownloader
commonsdownloader/thumbnaildownload.py
get_thumbnail_of_file
def get_thumbnail_of_file(image_name, width): """Return the file contents of the thumbnail of the given file.""" hdr = {'User-Agent': 'Python urllib2'} url = make_thumb_url(image_name, width) req = urllib2.Request(url, headers=hdr) try: logging.debug("Retrieving %s", url) opened = ur...
python
def get_thumbnail_of_file(image_name, width): """Return the file contents of the thumbnail of the given file.""" hdr = {'User-Agent': 'Python urllib2'} url = make_thumb_url(image_name, width) req = urllib2.Request(url, headers=hdr) try: logging.debug("Retrieving %s", url) opened = ur...
[ "def", "get_thumbnail_of_file", "(", "image_name", ",", "width", ")", ":", "hdr", "=", "{", "'User-Agent'", ":", "'Python urllib2'", "}", "url", "=", "make_thumb_url", "(", "image_name", ",", "width", ")", "req", "=", "urllib2", ".", "Request", "(", "url", ...
Return the file contents of the thumbnail of the given file.
[ "Return", "the", "file", "contents", "of", "the", "thumbnail", "of", "the", "given", "file", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/thumbnaildownload.py#L71-L83
train
Commonists/CommonsDownloader
commonsdownloader/thumbnaildownload.py
get_exception_based_on_api_message
def get_exception_based_on_api_message(message, image_name=""): """Return the exception matching the given API error message.""" msg_bigger_than_source = re.compile('Image was not scaled, is the requested width bigger than the source?') msg_does_not_exist = re.compile('The source file .* does not exist') ...
python
def get_exception_based_on_api_message(message, image_name=""): """Return the exception matching the given API error message.""" msg_bigger_than_source = re.compile('Image was not scaled, is the requested width bigger than the source?') msg_does_not_exist = re.compile('The source file .* does not exist') ...
[ "def", "get_exception_based_on_api_message", "(", "message", ",", "image_name", "=", "\"\"", ")", ":", "msg_bigger_than_source", "=", "re", ".", "compile", "(", "'Image was not scaled, is the requested width bigger than the source?'", ")", "msg_does_not_exist", "=", "re", "...
Return the exception matching the given API error message.
[ "Return", "the", "exception", "matching", "the", "given", "API", "error", "message", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/thumbnaildownload.py#L101-L116
train
Commonists/CommonsDownloader
commonsdownloader/thumbnaildownload.py
download_file
def download_file(image_name, output_path, width=DEFAULT_WIDTH): """Download a given Wikimedia Commons file.""" image_name = clean_up_filename(image_name) logging.info("Downloading %s with width %s", image_name, width) try: contents, output_file_name = get_thumbnail_of_file(image_name, width) ...
python
def download_file(image_name, output_path, width=DEFAULT_WIDTH): """Download a given Wikimedia Commons file.""" image_name = clean_up_filename(image_name) logging.info("Downloading %s with width %s", image_name, width) try: contents, output_file_name = get_thumbnail_of_file(image_name, width) ...
[ "def", "download_file", "(", "image_name", ",", "output_path", ",", "width", "=", "DEFAULT_WIDTH", ")", ":", "image_name", "=", "clean_up_filename", "(", "image_name", ")", "logging", ".", "info", "(", "\"Downloading %s with width %s\"", ",", "image_name", ",", "w...
Download a given Wikimedia Commons file.
[ "Download", "a", "given", "Wikimedia", "Commons", "file", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/thumbnaildownload.py#L119-L143
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
get_category_files_from_api
def get_category_files_from_api(category_name): """Yield the file names of a category by querying the MediaWiki API.""" import mwclient site = mwclient.Site('commons.wikimedia.org') category = site.Categories[category_name] return (x.page_title.encode('utf-8') for x in category.members(n...
python
def get_category_files_from_api(category_name): """Yield the file names of a category by querying the MediaWiki API.""" import mwclient site = mwclient.Site('commons.wikimedia.org') category = site.Categories[category_name] return (x.page_title.encode('utf-8') for x in category.members(n...
[ "def", "get_category_files_from_api", "(", "category_name", ")", ":", "import", "mwclient", "site", "=", "mwclient", ".", "Site", "(", "'commons.wikimedia.org'", ")", "category", "=", "site", ".", "Categories", "[", "category_name", "]", "return", "(", "x", ".",...
Yield the file names of a category by querying the MediaWiki API.
[ "Yield", "the", "file", "names", "of", "a", "category", "by", "querying", "the", "MediaWiki", "API", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L18-L24
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
download_from_category
def download_from_category(category_name, output_path, width): """Download files of a given category.""" file_names = get_category_files_from_api(category_name) files_to_download = izip_longest(file_names, [], fillvalue=width) download_files_if_not_in_manifest(files_to_download, output_path)
python
def download_from_category(category_name, output_path, width): """Download files of a given category.""" file_names = get_category_files_from_api(category_name) files_to_download = izip_longest(file_names, [], fillvalue=width) download_files_if_not_in_manifest(files_to_download, output_path)
[ "def", "download_from_category", "(", "category_name", ",", "output_path", ",", "width", ")", ":", "file_names", "=", "get_category_files_from_api", "(", "category_name", ")", "files_to_download", "=", "izip_longest", "(", "file_names", ",", "[", "]", ",", "fillvalu...
Download files of a given category.
[ "Download", "files", "of", "a", "given", "category", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L27-L31
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
get_files_from_textfile
def get_files_from_textfile(textfile_handler): """Yield the file names and widths by parsing a text file handler.""" for line in textfile_handler: line = line.rstrip() try: (image_name, width) = line.rsplit(',', 1) width = int(width) except ValueError: ...
python
def get_files_from_textfile(textfile_handler): """Yield the file names and widths by parsing a text file handler.""" for line in textfile_handler: line = line.rstrip() try: (image_name, width) = line.rsplit(',', 1) width = int(width) except ValueError: ...
[ "def", "get_files_from_textfile", "(", "textfile_handler", ")", ":", "for", "line", "in", "textfile_handler", ":", "line", "=", "line", ".", "rstrip", "(", ")", "try", ":", "(", "image_name", ",", "width", ")", "=", "line", ".", "rsplit", "(", "','", ","...
Yield the file names and widths by parsing a text file handler.
[ "Yield", "the", "file", "names", "and", "widths", "by", "parsing", "a", "text", "file", "handler", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L34-L44
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
download_from_files
def download_from_files(files, output_path, width): """Download files from a given file list.""" files_to_download = get_files_from_arguments(files, width) download_files_if_not_in_manifest(files_to_download, output_path)
python
def download_from_files(files, output_path, width): """Download files from a given file list.""" files_to_download = get_files_from_arguments(files, width) download_files_if_not_in_manifest(files_to_download, output_path)
[ "def", "download_from_files", "(", "files", ",", "output_path", ",", "width", ")", ":", "files_to_download", "=", "get_files_from_arguments", "(", "files", ",", "width", ")", "download_files_if_not_in_manifest", "(", "files_to_download", ",", "output_path", ")" ]
Download files from a given file list.
[ "Download", "files", "from", "a", "given", "file", "list", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L58-L61
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
read_local_manifest
def read_local_manifest(output_path): """Return the contents of the local manifest, as a dictionary.""" local_manifest_path = get_local_manifest_path(output_path) try: with open(local_manifest_path, 'r') as f: manifest = dict(get_files_from_textfile(f)) logging.debug('Retriev...
python
def read_local_manifest(output_path): """Return the contents of the local manifest, as a dictionary.""" local_manifest_path = get_local_manifest_path(output_path) try: with open(local_manifest_path, 'r') as f: manifest = dict(get_files_from_textfile(f)) logging.debug('Retriev...
[ "def", "read_local_manifest", "(", "output_path", ")", ":", "local_manifest_path", "=", "get_local_manifest_path", "(", "output_path", ")", "try", ":", "with", "open", "(", "local_manifest_path", ",", "'r'", ")", "as", "f", ":", "manifest", "=", "dict", "(", "...
Return the contents of the local manifest, as a dictionary.
[ "Return", "the", "contents", "of", "the", "local", "manifest", "as", "a", "dictionary", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L69-L79
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
write_file_to_manifest
def write_file_to_manifest(file_name, width, manifest_fh): """Write the given file in manifest.""" manifest_fh.write("%s,%s\n" % (file_name, str(width))) logging.debug("Wrote file %s to manifest", file_name)
python
def write_file_to_manifest(file_name, width, manifest_fh): """Write the given file in manifest.""" manifest_fh.write("%s,%s\n" % (file_name, str(width))) logging.debug("Wrote file %s to manifest", file_name)
[ "def", "write_file_to_manifest", "(", "file_name", ",", "width", ",", "manifest_fh", ")", ":", "manifest_fh", ".", "write", "(", "\"%s,%s\\n\"", "%", "(", "file_name", ",", "str", "(", "width", ")", ")", ")", "logging", ".", "debug", "(", "\"Wrote file %s to...
Write the given file in manifest.
[ "Write", "the", "given", "file", "in", "manifest", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L87-L90
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
download_files_if_not_in_manifest
def download_files_if_not_in_manifest(files_iterator, output_path): """Download the given files to the given path, unless in manifest.""" local_manifest = read_local_manifest(output_path) with open(get_local_manifest_path(output_path), 'a') as manifest_fh: for (file_name, width) in files_iterator: ...
python
def download_files_if_not_in_manifest(files_iterator, output_path): """Download the given files to the given path, unless in manifest.""" local_manifest = read_local_manifest(output_path) with open(get_local_manifest_path(output_path), 'a') as manifest_fh: for (file_name, width) in files_iterator: ...
[ "def", "download_files_if_not_in_manifest", "(", "files_iterator", ",", "output_path", ")", ":", "local_manifest", "=", "read_local_manifest", "(", "output_path", ")", "with", "open", "(", "get_local_manifest_path", "(", "output_path", ")", ",", "'a'", ")", "as", "m...
Download the given files to the given path, unless in manifest.
[ "Download", "the", "given", "files", "to", "the", "given", "path", "unless", "in", "manifest", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L93-L105
train
Commonists/CommonsDownloader
commonsdownloader/commonsdownloader.py
main
def main(): """Main method, entry point of the script.""" from argparse import ArgumentParser description = "Download a bunch of thumbnails from Wikimedia Commons" parser = ArgumentParser(description=description) source_group = parser.add_mutually_exclusive_group() source_group.add_argument("-l"...
python
def main(): """Main method, entry point of the script.""" from argparse import ArgumentParser description = "Download a bunch of thumbnails from Wikimedia Commons" parser = ArgumentParser(description=description) source_group = parser.add_mutually_exclusive_group() source_group.add_argument("-l"...
[ "def", "main", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", "description", "=", "\"Download a bunch of thumbnails from Wikimedia Commons\"", "parser", "=", "ArgumentParser", "(", "description", "=", "description", ")", "source_group", "=", "parser", "....
Main method, entry point of the script.
[ "Main", "method", "entry", "point", "of", "the", "script", "." ]
ac8147432b31ce3cdee5f7a75d0c48b788ee4666
https://github.com/Commonists/CommonsDownloader/blob/ac8147432b31ce3cdee5f7a75d0c48b788ee4666/commonsdownloader/commonsdownloader.py#L122-L175
train
lnoor/sphinx-jsonschema
sphinx-jsonschema/__init__.py
JsonSchema.ordered_load
def ordered_load(self, stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): """Allows you to use `pyyaml` to load as OrderedDict. Taken from https://stackoverflow.com/a/21912744/1927102 """ class OrderedLoader(Loader): pass def construct_mapping(loader, node)...
python
def ordered_load(self, stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): """Allows you to use `pyyaml` to load as OrderedDict. Taken from https://stackoverflow.com/a/21912744/1927102 """ class OrderedLoader(Loader): pass def construct_mapping(loader, node)...
[ "def", "ordered_load", "(", "self", ",", "stream", ",", "Loader", "=", "yaml", ".", "Loader", ",", "object_pairs_hook", "=", "OrderedDict", ")", ":", "class", "OrderedLoader", "(", "Loader", ")", ":", "pass", "def", "construct_mapping", "(", "loader", ",", ...
Allows you to use `pyyaml` to load as OrderedDict. Taken from https://stackoverflow.com/a/21912744/1927102
[ "Allows", "you", "to", "use", "pyyaml", "to", "load", "as", "OrderedDict", "." ]
e348b7ecf2ff67ab40dc80b02d0cb17e983aa445
https://github.com/lnoor/sphinx-jsonschema/blob/e348b7ecf2ff67ab40dc80b02d0cb17e983aa445/sphinx-jsonschema/__init__.py#L83-L109
train
fgimian/paramiko-expect
paramiko_expect.py
SSHClientInteraction.send
def send(self, send_string, newline=None): """Saves and sends the send string provided.""" self.current_send_string = send_string newline = newline if newline is not None else self.newline self.channel.send(send_string + newline)
python
def send(self, send_string, newline=None): """Saves and sends the send string provided.""" self.current_send_string = send_string newline = newline if newline is not None else self.newline self.channel.send(send_string + newline)
[ "def", "send", "(", "self", ",", "send_string", ",", "newline", "=", "None", ")", ":", "self", ".", "current_send_string", "=", "send_string", "newline", "=", "newline", "if", "newline", "is", "not", "None", "else", "self", ".", "newline", "self", ".", "...
Saves and sends the send string provided.
[ "Saves", "and", "sends", "the", "send", "string", "provided", "." ]
33dd3af745eb420d41e4ae7145b2ed536b2fccf0
https://github.com/fgimian/paramiko-expect/blob/33dd3af745eb420d41e4ae7145b2ed536b2fccf0/paramiko_expect.py#L208-L213
train
fgimian/paramiko-expect
paramiko_expect.py
SSHClientInteraction.tail
def tail( self, line_prefix=None, callback=None, output_callback=None, stop_callback=lambda x: False, timeout=None ): """ This function takes control of an SSH channel and displays line by line of output as \n is recieved. This function is specifically made for tail-...
python
def tail( self, line_prefix=None, callback=None, output_callback=None, stop_callback=lambda x: False, timeout=None ): """ This function takes control of an SSH channel and displays line by line of output as \n is recieved. This function is specifically made for tail-...
[ "def", "tail", "(", "self", ",", "line_prefix", "=", "None", ",", "callback", "=", "None", ",", "output_callback", "=", "None", ",", "stop_callback", "=", "lambda", "x", ":", "False", ",", "timeout", "=", "None", ")", ":", "output_callback", "=", "output...
This function takes control of an SSH channel and displays line by line of output as \n is recieved. This function is specifically made for tail-like commands. :param line_prefix: Text to append to the left of each line of output. This is especially useful if you ar...
[ "This", "function", "takes", "control", "of", "an", "SSH", "channel", "and", "displays", "line", "by", "line", "of", "output", "as", "\\", "n", "is", "recieved", ".", "This", "function", "is", "specifically", "made", "for", "tail", "-", "like", "commands",...
33dd3af745eb420d41e4ae7145b2ed536b2fccf0
https://github.com/fgimian/paramiko-expect/blob/33dd3af745eb420d41e4ae7145b2ed536b2fccf0/paramiko_expect.py#L215-L286
train
fgimian/paramiko-expect
paramiko_expect.py
SSHClientInteraction.take_control
def take_control(self): """ This function is a better documented and touched up version of the posix_shell function found in the interactive.py demo script that ships with Paramiko. """ if has_termios: # Get attributes of the shell you were in before going to...
python
def take_control(self): """ This function is a better documented and touched up version of the posix_shell function found in the interactive.py demo script that ships with Paramiko. """ if has_termios: # Get attributes of the shell you were in before going to...
[ "def", "take_control", "(", "self", ")", ":", "if", "has_termios", ":", "original_tty", "=", "termios", ".", "tcgetattr", "(", "sys", ".", "stdin", ")", "try", ":", "tty", ".", "setraw", "(", "sys", ".", "stdin", ".", "fileno", "(", ")", ")", "tty", ...
This function is a better documented and touched up version of the posix_shell function found in the interactive.py demo script that ships with Paramiko.
[ "This", "function", "is", "a", "better", "documented", "and", "touched", "up", "version", "of", "the", "posix_shell", "function", "found", "in", "the", "interactive", ".", "py", "demo", "script", "that", "ships", "with", "Paramiko", "." ]
33dd3af745eb420d41e4ae7145b2ed536b2fccf0
https://github.com/fgimian/paramiko-expect/blob/33dd3af745eb420d41e4ae7145b2ed536b2fccf0/paramiko_expect.py#L288-L354
train
Celeo/Preston
preston/preston.py
Preston._get_access_from_refresh
def _get_access_from_refresh(self) -> Tuple[str, float]: """Uses the stored refresh token to get a new access token. This method assumes that the refresh token exists. Args: None Returns: new access token and expiration time (from now) """ heade...
python
def _get_access_from_refresh(self) -> Tuple[str, float]: """Uses the stored refresh token to get a new access token. This method assumes that the refresh token exists. Args: None Returns: new access token and expiration time (from now) """ heade...
[ "def", "_get_access_from_refresh", "(", "self", ")", "->", "Tuple", "[", "str", ",", "float", "]", ":", "headers", "=", "self", ".", "_get_authorization_headers", "(", ")", "data", "=", "{", "'grant_type'", ":", "'refresh_token'", ",", "'refresh_token'", ":", ...
Uses the stored refresh token to get a new access token. This method assumes that the refresh token exists. Args: None Returns: new access token and expiration time (from now)
[ "Uses", "the", "stored", "refresh", "token", "to", "get", "a", "new", "access", "token", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L91-L109
train
Celeo/Preston
preston/preston.py
Preston._get_authorization_headers
def _get_authorization_headers(self) -> dict: """Constructs and returns the Authorization header for the client app. Args: None Returns: header dict for communicating with the authorization endpoints """ auth = base64.encodestring((self.client_id + ':' +...
python
def _get_authorization_headers(self) -> dict: """Constructs and returns the Authorization header for the client app. Args: None Returns: header dict for communicating with the authorization endpoints """ auth = base64.encodestring((self.client_id + ':' +...
[ "def", "_get_authorization_headers", "(", "self", ")", "->", "dict", ":", "auth", "=", "base64", ".", "encodestring", "(", "(", "self", ".", "client_id", "+", "':'", "+", "self", ".", "client_secret", ")", ".", "encode", "(", "'latin-1'", ")", ")", ".", ...
Constructs and returns the Authorization header for the client app. Args: None Returns: header dict for communicating with the authorization endpoints
[ "Constructs", "and", "returns", "the", "Authorization", "header", "for", "the", "client", "app", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L111-L124
train
Celeo/Preston
preston/preston.py
Preston._try_refresh_access_token
def _try_refresh_access_token(self) -> None: """Attempts to get a new access token using the refresh token, if needed. If the access token is expired and this instance has a stored refresh token, then the refresh token is in the API call to get a new access token. If successful, this in...
python
def _try_refresh_access_token(self) -> None: """Attempts to get a new access token using the refresh token, if needed. If the access token is expired and this instance has a stored refresh token, then the refresh token is in the API call to get a new access token. If successful, this in...
[ "def", "_try_refresh_access_token", "(", "self", ")", "->", "None", ":", "if", "self", ".", "refresh_token", ":", "if", "not", "self", ".", "access_token", "or", "self", ".", "_is_access_token_expired", "(", ")", ":", "self", ".", "access_token", ",", "self"...
Attempts to get a new access token using the refresh token, if needed. If the access token is expired and this instance has a stored refresh token, then the refresh token is in the API call to get a new access token. If successful, this instance is modified in-place with that new access token. ...
[ "Attempts", "to", "get", "a", "new", "access", "token", "using", "the", "refresh", "token", "if", "needed", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L126-L142
train
Celeo/Preston
preston/preston.py
Preston.authenticate
def authenticate(self, code: str) -> 'Preston': """Authenticates using the code from the EVE SSO. A new Preston object is returned; this object is not modified. The intended usage is: auth = preston.authenticate('some_code_here') Args: code: SSO code ...
python
def authenticate(self, code: str) -> 'Preston': """Authenticates using the code from the EVE SSO. A new Preston object is returned; this object is not modified. The intended usage is: auth = preston.authenticate('some_code_here') Args: code: SSO code ...
[ "def", "authenticate", "(", "self", ",", "code", ":", "str", ")", "->", "'Preston'", ":", "headers", "=", "self", ".", "_get_authorization_headers", "(", ")", "data", "=", "{", "'grant_type'", ":", "'authorization_code'", ",", "'code'", ":", "code", "}", "...
Authenticates using the code from the EVE SSO. A new Preston object is returned; this object is not modified. The intended usage is: auth = preston.authenticate('some_code_here') Args: code: SSO code Returns: new Preston, authenticated
[ "Authenticates", "using", "the", "code", "from", "the", "EVE", "SSO", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L173-L201
train
Celeo/Preston
preston/preston.py
Preston._get_spec
def _get_spec(self) -> dict: """Fetches the OpenAPI spec from the server. If the spec has already been fetched, the cached version is returned instead. ArgS: None Returns: OpenAPI spec data """ if self.spec: return self.spec ...
python
def _get_spec(self) -> dict: """Fetches the OpenAPI spec from the server. If the spec has already been fetched, the cached version is returned instead. ArgS: None Returns: OpenAPI spec data """ if self.spec: return self.spec ...
[ "def", "_get_spec", "(", "self", ")", "->", "dict", ":", "if", "self", ".", "spec", ":", "return", "self", ".", "spec", "self", ".", "spec", "=", "requests", ".", "get", "(", "self", ".", "SPEC_URL", ".", "format", "(", "self", ".", "version", ")",...
Fetches the OpenAPI spec from the server. If the spec has already been fetched, the cached version is returned instead. ArgS: None Returns: OpenAPI spec data
[ "Fetches", "the", "OpenAPI", "spec", "from", "the", "server", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L220-L234
train
Celeo/Preston
preston/preston.py
Preston._get_path_for_op_id
def _get_path_for_op_id(self, id: str) -> Optional[str]: """Searches the spec for a path matching the operation id. Args: id: operation id Returns: path to the endpoint, or None if not found """ for path_key, path_value in self._get_spec()['paths'].items...
python
def _get_path_for_op_id(self, id: str) -> Optional[str]: """Searches the spec for a path matching the operation id. Args: id: operation id Returns: path to the endpoint, or None if not found """ for path_key, path_value in self._get_spec()['paths'].items...
[ "def", "_get_path_for_op_id", "(", "self", ",", "id", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "for", "path_key", ",", "path_value", "in", "self", ".", "_get_spec", "(", ")", "[", "'paths'", "]", ".", "items", "(", ")", ":", "for", ...
Searches the spec for a path matching the operation id. Args: id: operation id Returns: path to the endpoint, or None if not found
[ "Searches", "the", "spec", "for", "a", "path", "matching", "the", "operation", "id", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L236-L251
train
Celeo/Preston
preston/preston.py
Preston._insert_vars
def _insert_vars(self, path: str, data: dict) -> str: """Inserts variables into the ESI URL path. Args: path: raw ESI URL path data: data to insert into the URL Returns: path with variables filled """ data = data.copy() while True: ...
python
def _insert_vars(self, path: str, data: dict) -> str: """Inserts variables into the ESI URL path. Args: path: raw ESI URL path data: data to insert into the URL Returns: path with variables filled """ data = data.copy() while True: ...
[ "def", "_insert_vars", "(", "self", ",", "path", ":", "str", ",", "data", ":", "dict", ")", "->", "str", ":", "data", "=", "data", ".", "copy", "(", ")", "while", "True", ":", "match", "=", "re", ".", "search", "(", "self", ".", "VAR_REPLACE_REGEX"...
Inserts variables into the ESI URL path. Args: path: raw ESI URL path data: data to insert into the URL Returns: path with variables filled
[ "Inserts", "variables", "into", "the", "ESI", "URL", "path", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L253-L270
train
Celeo/Preston
preston/preston.py
Preston.whoami
def whoami(self) -> dict: """Returns the basic information about the authenticated character. Obviously doesn't do anything if this Preston instance is not authenticated, so it returns an empty dict. Args: None Returns: character info if authenticated, ...
python
def whoami(self) -> dict: """Returns the basic information about the authenticated character. Obviously doesn't do anything if this Preston instance is not authenticated, so it returns an empty dict. Args: None Returns: character info if authenticated, ...
[ "def", "whoami", "(", "self", ")", "->", "dict", ":", "if", "not", "self", ".", "access_token", ":", "return", "{", "}", "self", ".", "_try_refresh_access_token", "(", ")", "return", "self", ".", "session", ".", "get", "(", "self", ".", "WHOAMI_URL", "...
Returns the basic information about the authenticated character. Obviously doesn't do anything if this Preston instance is not authenticated, so it returns an empty dict. Args: None Returns: character info if authenticated, otherwise an empty dict
[ "Returns", "the", "basic", "information", "about", "the", "authenticated", "character", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L272-L287
train
Celeo/Preston
preston/preston.py
Preston.get_path
def get_path(self, path: str, data: dict) -> Tuple[dict, dict]: """Queries the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: path: raw ESI URL pa...
python
def get_path(self, path: str, data: dict) -> Tuple[dict, dict]: """Queries the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: path: raw ESI URL pa...
[ "def", "get_path", "(", "self", ",", "path", ":", "str", ",", "data", ":", "dict", ")", "->", "Tuple", "[", "dict", ",", "dict", "]", ":", "path", "=", "self", ".", "_insert_vars", "(", "path", ",", "data", ")", "path", "=", "self", ".", "BASE_UR...
Queries the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: path: raw ESI URL path data: data to insert into the URL Returns: ...
[ "Queries", "the", "ESI", "by", "an", "endpoint", "URL", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L289-L311
train
Celeo/Preston
preston/preston.py
Preston.get_op
def get_op(self, id: str, **kwargs: str) -> dict: """Queries the ESI by looking up an operation id. Endpoints are cached, so calls to this method for the same op and args will return the data from the cache instead of making the API call. Args: id: operation id ...
python
def get_op(self, id: str, **kwargs: str) -> dict: """Queries the ESI by looking up an operation id. Endpoints are cached, so calls to this method for the same op and args will return the data from the cache instead of making the API call. Args: id: operation id ...
[ "def", "get_op", "(", "self", ",", "id", ":", "str", ",", "**", "kwargs", ":", "str", ")", "->", "dict", ":", "path", "=", "self", ".", "_get_path_for_op_id", "(", "id", ")", "return", "self", ".", "get_path", "(", "path", ",", "kwargs", ")" ]
Queries the ESI by looking up an operation id. Endpoints are cached, so calls to this method for the same op and args will return the data from the cache instead of making the API call. Args: id: operation id kwargs: data to populate the endpoint's URL variables...
[ "Queries", "the", "ESI", "by", "looking", "up", "an", "operation", "id", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L313-L328
train
Celeo/Preston
preston/preston.py
Preston.post_path
def post_path(self, path: str, path_data: Union[dict, None], post_data: Any) -> dict: """Modifies the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: ...
python
def post_path(self, path: str, path_data: Union[dict, None], post_data: Any) -> dict: """Modifies the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: ...
[ "def", "post_path", "(", "self", ",", "path", ":", "str", ",", "path_data", ":", "Union", "[", "dict", ",", "None", "]", ",", "post_data", ":", "Any", ")", "->", "dict", ":", "path", "=", "self", ".", "_insert_vars", "(", "path", ",", "path_data", ...
Modifies the ESI by an endpoint URL. This method is not marked "private" as it _can_ be used by consuming code, but it's probably easier to call the `get_op` method instead. Args: path: raw ESI URL path path_data: data to format the path with (can be None) ...
[ "Modifies", "the", "ESI", "by", "an", "endpoint", "URL", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L330-L348
train
Celeo/Preston
preston/preston.py
Preston.post_op
def post_op(self, id: str, path_data: Union[dict, None], post_data: Any) -> dict: """Modifies the ESI by looking up an operation id. Args: path: raw ESI URL path path_data: data to format the path with (can be None) post_data: data to send to ESI Returns: ...
python
def post_op(self, id: str, path_data: Union[dict, None], post_data: Any) -> dict: """Modifies the ESI by looking up an operation id. Args: path: raw ESI URL path path_data: data to format the path with (can be None) post_data: data to send to ESI Returns: ...
[ "def", "post_op", "(", "self", ",", "id", ":", "str", ",", "path_data", ":", "Union", "[", "dict", ",", "None", "]", ",", "post_data", ":", "Any", ")", "->", "dict", ":", "path", "=", "self", ".", "_get_path_for_op_id", "(", "id", ")", "return", "s...
Modifies the ESI by looking up an operation id. Args: path: raw ESI URL path path_data: data to format the path with (can be None) post_data: data to send to ESI Returns: ESI data
[ "Modifies", "the", "ESI", "by", "looking", "up", "an", "operation", "id", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/preston.py#L350-L362
train
Celeo/Preston
preston/cache.py
Cache._get_expiration
def _get_expiration(self, headers: dict) -> int: """Gets the expiration time of the data from the response headers. Args: headers: dictionary of headers from ESI Returns: value of seconds from now the data expires """ expiration_str = headers.get('expire...
python
def _get_expiration(self, headers: dict) -> int: """Gets the expiration time of the data from the response headers. Args: headers: dictionary of headers from ESI Returns: value of seconds from now the data expires """ expiration_str = headers.get('expire...
[ "def", "_get_expiration", "(", "self", ",", "headers", ":", "dict", ")", "->", "int", ":", "expiration_str", "=", "headers", ".", "get", "(", "'expires'", ")", "if", "not", "expiration_str", ":", "return", "0", "expiration", "=", "datetime", ".", "strptime...
Gets the expiration time of the data from the response headers. Args: headers: dictionary of headers from ESI Returns: value of seconds from now the data expires
[ "Gets", "the", "expiration", "time", "of", "the", "data", "from", "the", "response", "headers", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/cache.py#L23-L37
train
Celeo/Preston
preston/cache.py
Cache.set
def set(self, response: 'requests.Response') -> None: """Adds a response to the cache. Args: response: response from ESI Returns: None """ self.data[response.url] = SavedEndpoint( response.json(), self._get_expiration(response.hea...
python
def set(self, response: 'requests.Response') -> None: """Adds a response to the cache. Args: response: response from ESI Returns: None """ self.data[response.url] = SavedEndpoint( response.json(), self._get_expiration(response.hea...
[ "def", "set", "(", "self", ",", "response", ":", "'requests.Response'", ")", "->", "None", ":", "self", ".", "data", "[", "response", ".", "url", "]", "=", "SavedEndpoint", "(", "response", ".", "json", "(", ")", ",", "self", ".", "_get_expiration", "(...
Adds a response to the cache. Args: response: response from ESI Returns: None
[ "Adds", "a", "response", "to", "the", "cache", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/cache.py#L39-L51
train
Celeo/Preston
preston/cache.py
Cache._check_expiration
def _check_expiration(self, url: str, data: 'SavedEndpoint') -> 'SavedEndpoint': """Checks the expiration time for data for a url. If the data has expired, it is deleted from the cache. Args: url: url to check data: page of data for that url Returns: ...
python
def _check_expiration(self, url: str, data: 'SavedEndpoint') -> 'SavedEndpoint': """Checks the expiration time for data for a url. If the data has expired, it is deleted from the cache. Args: url: url to check data: page of data for that url Returns: ...
[ "def", "_check_expiration", "(", "self", ",", "url", ":", "str", ",", "data", ":", "'SavedEndpoint'", ")", "->", "'SavedEndpoint'", ":", "if", "data", ".", "expires_after", "<", "time", ".", "time", "(", ")", ":", "del", "self", ".", "data", "[", "url"...
Checks the expiration time for data for a url. If the data has expired, it is deleted from the cache. Args: url: url to check data: page of data for that url Returns: value of either the passed data or None if it expired
[ "Checks", "the", "expiration", "time", "for", "data", "for", "a", "url", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/cache.py#L53-L68
train
Celeo/Preston
preston/cache.py
Cache.check
def check(self, url: str) -> Optional[dict]: """Check if data for a url has expired. Data is not fetched again if it has expired. Args: url: url to check expiration on Returns: value of the data, possibly None """ data = self.data.get(url) ...
python
def check(self, url: str) -> Optional[dict]: """Check if data for a url has expired. Data is not fetched again if it has expired. Args: url: url to check expiration on Returns: value of the data, possibly None """ data = self.data.get(url) ...
[ "def", "check", "(", "self", ",", "url", ":", "str", ")", "->", "Optional", "[", "dict", "]", ":", "data", "=", "self", ".", "data", ".", "get", "(", "url", ")", "if", "data", ":", "data", "=", "self", ".", "_check_expiration", "(", "url", ",", ...
Check if data for a url has expired. Data is not fetched again if it has expired. Args: url: url to check expiration on Returns: value of the data, possibly None
[ "Check", "if", "data", "for", "a", "url", "has", "expired", "." ]
7c94bf0b7dabecad0bd8b66229b2906dabdb8e79
https://github.com/Celeo/Preston/blob/7c94bf0b7dabecad0bd8b66229b2906dabdb8e79/preston/cache.py#L70-L84
train
gplepage/gvar
src/gvar/linalg.py
eigvalsh
def eigvalsh(a, eigvec=False): """ Eigenvalues of Hermitian matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric matrix). ...
python
def eigvalsh(a, eigvec=False): """ Eigenvalues of Hermitian matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric matrix). ...
[ "def", "eigvalsh", "(", "a", ",", "eigvec", "=", "False", ")", ":", "if", "eigvec", "==", "True", ":", "val", ",", "vec", "=", "eigh", "(", "a", ",", "eigvec", "=", "True", ")", "return", "val", ",", "gvar", ".", "mean", "(", "vec", ")", "else"...
Eigenvalues of Hermitian matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric matrix). eigvec (bool): If ``True``, method re...
[ "Eigenvalues", "of", "Hermitian", "matrix", "a", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/linalg.py#L62-L90
train
gplepage/gvar
src/gvar/linalg.py
eigh
def eigh(a, eigvec=True, rcond=None): """ Eigenvalues and eigenvectors of symmetric matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric ...
python
def eigh(a, eigvec=True, rcond=None): """ Eigenvalues and eigenvectors of symmetric matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric ...
[ "def", "eigh", "(", "a", ",", "eigvec", "=", "True", ",", "rcond", "=", "None", ")", ":", "a", "=", "numpy", ".", "asarray", "(", "a", ")", "if", "a", ".", "dtype", "!=", "object", ":", "val", ",", "vec", "=", "numpy", ".", "linalg", ".", "ei...
Eigenvalues and eigenvectors of symmetric matrix ``a``. Args: a: Two-dimensional, square Hermitian matrix/array of numbers and/or :class:`gvar.GVar`\s. Array elements must be real-valued if `gvar.GVar`\s are involved (i.e., symmetric matrix). eigvec (bool): If ``...
[ "Eigenvalues", "and", "eigenvectors", "of", "symmetric", "matrix", "a", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/linalg.py#L93-L149
train
gplepage/gvar
src/gvar/linalg.py
svd
def svd(a, compute_uv=True, rcond=None): """ svd decomposition of matrix ``a`` containing |GVar|\s. Args: a: Two-dimensional matrix/array of numbers and/or :class:`gvar.GVar`\s. compute_uv (bool): It ``True`` (default), returns tuple ``(u,s,vT)`` where matrix ``a = u @ n...
python
def svd(a, compute_uv=True, rcond=None): """ svd decomposition of matrix ``a`` containing |GVar|\s. Args: a: Two-dimensional matrix/array of numbers and/or :class:`gvar.GVar`\s. compute_uv (bool): It ``True`` (default), returns tuple ``(u,s,vT)`` where matrix ``a = u @ n...
[ "def", "svd", "(", "a", ",", "compute_uv", "=", "True", ",", "rcond", "=", "None", ")", ":", "a", "=", "numpy", ".", "asarray", "(", "a", ")", "if", "a", ".", "dtype", "!=", "object", ":", "return", "numpy", ".", "linalg", ".", "svd", "(", "a",...
svd decomposition of matrix ``a`` containing |GVar|\s. Args: a: Two-dimensional matrix/array of numbers and/or :class:`gvar.GVar`\s. compute_uv (bool): It ``True`` (default), returns tuple ``(u,s,vT)`` where matrix ``a = u @ np.diag(s) @ vT`` where matrices ``u``...
[ "svd", "decomposition", "of", "matrix", "a", "containing", "|GVar|", "\\", "s", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/linalg.py#L151-L224
train
gplepage/gvar
src/gvar/linalg.py
inv
def inv(a): """ Inverse of matrix ``a``. Args: a: Two-dimensional, square matrix/array of numbers and/or :class:`gvar.GVar`\s. Returns: The inverse of matrix ``a``. Raises: ValueError: If matrix is not square and two-dimensional. """ amean = gvar.mean(a) ...
python
def inv(a): """ Inverse of matrix ``a``. Args: a: Two-dimensional, square matrix/array of numbers and/or :class:`gvar.GVar`\s. Returns: The inverse of matrix ``a``. Raises: ValueError: If matrix is not square and two-dimensional. """ amean = gvar.mean(a) ...
[ "def", "inv", "(", "a", ")", ":", "amean", "=", "gvar", ".", "mean", "(", "a", ")", "if", "amean", ".", "ndim", "!=", "2", "or", "amean", ".", "shape", "[", "0", "]", "!=", "amean", ".", "shape", "[", "1", "]", ":", "raise", "ValueError", "("...
Inverse of matrix ``a``. Args: a: Two-dimensional, square matrix/array of numbers and/or :class:`gvar.GVar`\s. Returns: The inverse of matrix ``a``. Raises: ValueError: If matrix is not square and two-dimensional.
[ "Inverse", "of", "matrix", "a", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/linalg.py#L296-L314
train
gplepage/gvar
src/gvar/__init__.py
ranseed
def ranseed(seed=None): """ Seed random number generators with tuple ``seed``. Argument ``seed`` is an integer or a :class:`tuple` of integers that is used to seed the random number generators used by :mod:`numpy` and :mod:`random` (and therefore by :mod:`gvar`). Reusing the same ``seed`` resul...
python
def ranseed(seed=None): """ Seed random number generators with tuple ``seed``. Argument ``seed`` is an integer or a :class:`tuple` of integers that is used to seed the random number generators used by :mod:`numpy` and :mod:`random` (and therefore by :mod:`gvar`). Reusing the same ``seed`` resul...
[ "def", "ranseed", "(", "seed", "=", "None", ")", ":", "if", "seed", "is", "None", ":", "seed", "=", "numpy", ".", "random", ".", "randint", "(", "1", ",", "int", "(", "2e9", ")", ",", "size", "=", "3", ")", "try", ":", "seed", "=", "tuple", "...
Seed random number generators with tuple ``seed``. Argument ``seed`` is an integer or a :class:`tuple` of integers that is used to seed the random number generators used by :mod:`numpy` and :mod:`random` (and therefore by :mod:`gvar`). Reusing the same ``seed`` results in the same set of random num...
[ "Seed", "random", "number", "generators", "with", "tuple", "seed", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L146-L174
train
gplepage/gvar
src/gvar/__init__.py
erf
def erf(x): """ Error function. Works for floats, |GVar|\s, and :mod:`numpy` arrays. """ try: return math.erf(x) except TypeError: pass if isinstance(x, GVar): f = math.erf(x.mean) dfdx = 2. * math.exp(- x.mean ** 2) / math.sqrt(math.pi) return gvar_funct...
python
def erf(x): """ Error function. Works for floats, |GVar|\s, and :mod:`numpy` arrays. """ try: return math.erf(x) except TypeError: pass if isinstance(x, GVar): f = math.erf(x.mean) dfdx = 2. * math.exp(- x.mean ** 2) / math.sqrt(math.pi) return gvar_funct...
[ "def", "erf", "(", "x", ")", ":", "try", ":", "return", "math", ".", "erf", "(", "x", ")", "except", "TypeError", ":", "pass", "if", "isinstance", "(", "x", ",", "GVar", ")", ":", "f", "=", "math", ".", "erf", "(", "x", ".", "mean", ")", "dfd...
Error function. Works for floats, |GVar|\s, and :mod:`numpy` arrays.
[ "Error", "function", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L805-L829
train
gplepage/gvar
src/gvar/__init__.py
make_fake_data
def make_fake_data(g, fac=1.0): """ Make fake data based on ``g``. This function replaces the |GVar|\s in ``g`` by new |GVar|\s with similar means and a similar covariance matrix, but multiplied by ``fac**2`` (so standard deviations are ``fac`` times smaller). The changes are random. The function ...
python
def make_fake_data(g, fac=1.0): """ Make fake data based on ``g``. This function replaces the |GVar|\s in ``g`` by new |GVar|\s with similar means and a similar covariance matrix, but multiplied by ``fac**2`` (so standard deviations are ``fac`` times smaller). The changes are random. The function ...
[ "def", "make_fake_data", "(", "g", ",", "fac", "=", "1.0", ")", ":", "if", "hasattr", "(", "g", ",", "'keys'", ")", ":", "if", "not", "isinstance", "(", "g", ",", "BufferDict", ")", ":", "g", "=", "BufferDict", "(", "g", ")", "return", "BufferDict"...
Make fake data based on ``g``. This function replaces the |GVar|\s in ``g`` by new |GVar|\s with similar means and a similar covariance matrix, but multiplied by ``fac**2`` (so standard deviations are ``fac`` times smaller). The changes are random. The function was designed to create fake data for tes...
[ "Make", "fake", "data", "based", "on", "g", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L1327-L1361
train
gplepage/gvar
src/gvar/__init__.py
PDF.p2x
def p2x(self, p): """ Map parameters ``p`` to vector in x-space. x-space is a vector space of dimension ``p.size``. Its axes are in the directions specified by the eigenvectors of ``p``'s covariance matrix, and distance along an axis is in units of the standard deviation in that...
python
def p2x(self, p): """ Map parameters ``p`` to vector in x-space. x-space is a vector space of dimension ``p.size``. Its axes are in the directions specified by the eigenvectors of ``p``'s covariance matrix, and distance along an axis is in units of the standard deviation in that...
[ "def", "p2x", "(", "self", ",", "p", ")", ":", "if", "hasattr", "(", "p", ",", "'keys'", ")", ":", "dp", "=", "BufferDict", "(", "p", ",", "keys", "=", "self", ".", "g", ".", "keys", "(", ")", ")", ".", "_buf", "[", ":", "self", ".", "meanf...
Map parameters ``p`` to vector in x-space. x-space is a vector space of dimension ``p.size``. Its axes are in the directions specified by the eigenvectors of ``p``'s covariance matrix, and distance along an axis is in units of the standard deviation in that direction.
[ "Map", "parameters", "p", "to", "vector", "in", "x", "-", "space", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L896-L908
train
gplepage/gvar
src/gvar/__init__.py
PDFHistogram.count
def count(self, data): """ Compute histogram of data. Counts the number of elements from array ``data`` in each bin of the histogram. Results are returned in an array, call it ``h``, of length ``nbin+2`` where ``h[0]`` is the number of data elements that fall below the range of ...
python
def count(self, data): """ Compute histogram of data. Counts the number of elements from array ``data`` in each bin of the histogram. Results are returned in an array, call it ``h``, of length ``nbin+2`` where ``h[0]`` is the number of data elements that fall below the range of ...
[ "def", "count", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "float", ")", "or", "isinstance", "(", "data", ",", "int", ")", ":", "hist", "=", "numpy", ".", "zeros", "(", "self", ".", "nbin", "+", "2", ",", "float", ...
Compute histogram of data. Counts the number of elements from array ``data`` in each bin of the histogram. Results are returned in an array, call it ``h``, of length ``nbin+2`` where ``h[0]`` is the number of data elements that fall below the range of the histogram, ``h[-1]`` (i...
[ "Compute", "histogram", "of", "data", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L1018-L1057
train
gplepage/gvar
src/gvar/__init__.py
PDFHistogram.gaussian_pdf
def gaussian_pdf(x, g): """ Gaussian probability density function at ``x`` for |GVar| ``g``. """ return ( numpy.exp(-(x - g.mean) ** 2 / 2. /g.var) / numpy.sqrt(g.var * 2 * numpy.pi) )
python
def gaussian_pdf(x, g): """ Gaussian probability density function at ``x`` for |GVar| ``g``. """ return ( numpy.exp(-(x - g.mean) ** 2 / 2. /g.var) / numpy.sqrt(g.var * 2 * numpy.pi) )
[ "def", "gaussian_pdf", "(", "x", ",", "g", ")", ":", "return", "(", "numpy", ".", "exp", "(", "-", "(", "x", "-", "g", ".", "mean", ")", "**", "2", "/", "2.", "/", "g", ".", "var", ")", "/", "numpy", ".", "sqrt", "(", "g", ".", "var", "*"...
Gaussian probability density function at ``x`` for |GVar| ``g``.
[ "Gaussian", "probability", "density", "function", "at", "x", "for", "|GVar|", "g", "." ]
d6671697319eb6280de3793c9a1c2b616c6f2ae0
https://github.com/gplepage/gvar/blob/d6671697319eb6280de3793c9a1c2b616c6f2ae0/src/gvar/__init__.py#L1102-L1107
train
brandon-rhodes/python-sgp4
sgp4/io.py
verify_checksum
def verify_checksum(*lines): """Verify the checksum of one or more TLE lines. Raises `ValueError` if any of the lines fails its checksum, and includes the failing line in the error message. """ for line in lines: checksum = line[68:69] if not checksum.isdigit(): continu...
python
def verify_checksum(*lines): """Verify the checksum of one or more TLE lines. Raises `ValueError` if any of the lines fails its checksum, and includes the failing line in the error message. """ for line in lines: checksum = line[68:69] if not checksum.isdigit(): continu...
[ "def", "verify_checksum", "(", "*", "lines", ")", ":", "for", "line", "in", "lines", ":", "checksum", "=", "line", "[", "68", ":", "69", "]", "if", "not", "checksum", ".", "isdigit", "(", ")", ":", "continue", "checksum", "=", "int", "(", "checksum",...
Verify the checksum of one or more TLE lines. Raises `ValueError` if any of the lines fails its checksum, and includes the failing line in the error message.
[ "Verify", "the", "checksum", "of", "one", "or", "more", "TLE", "lines", "." ]
a1e19e32831d6814b3ab34f55b39b8520d291c4e
https://github.com/brandon-rhodes/python-sgp4/blob/a1e19e32831d6814b3ab34f55b39b8520d291c4e/sgp4/io.py#L234-L250
train
brandon-rhodes/python-sgp4
sgp4/io.py
compute_checksum
def compute_checksum(line): """Compute the TLE checksum for the given line.""" return sum((int(c) if c.isdigit() else c == '-') for c in line[0:68]) % 10
python
def compute_checksum(line): """Compute the TLE checksum for the given line.""" return sum((int(c) if c.isdigit() else c == '-') for c in line[0:68]) % 10
[ "def", "compute_checksum", "(", "line", ")", ":", "return", "sum", "(", "(", "int", "(", "c", ")", "if", "c", ".", "isdigit", "(", ")", "else", "c", "==", "'-'", ")", "for", "c", "in", "line", "[", "0", ":", "68", "]", ")", "%", "10" ]
Compute the TLE checksum for the given line.
[ "Compute", "the", "TLE", "checksum", "for", "the", "given", "line", "." ]
a1e19e32831d6814b3ab34f55b39b8520d291c4e
https://github.com/brandon-rhodes/python-sgp4/blob/a1e19e32831d6814b3ab34f55b39b8520d291c4e/sgp4/io.py#L261-L263
train
brandon-rhodes/python-sgp4
sgp4/model.py
Satellite.propagate
def propagate(self, year, month=1, day=1, hour=0, minute=0, second=0.0): """Return a position and velocity vector for a given date and time.""" j = jday(year, month, day, hour, minute, second) m = (j - self.jdsatepoch) * minutes_per_day r, v = sgp4(self, m) return r, v
python
def propagate(self, year, month=1, day=1, hour=0, minute=0, second=0.0): """Return a position and velocity vector for a given date and time.""" j = jday(year, month, day, hour, minute, second) m = (j - self.jdsatepoch) * minutes_per_day r, v = sgp4(self, m) return r, v
[ "def", "propagate", "(", "self", ",", "year", ",", "month", "=", "1", ",", "day", "=", "1", ",", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0.0", ")", ":", "j", "=", "jday", "(", "year", ",", "month", ",", "day", ",", "...
Return a position and velocity vector for a given date and time.
[ "Return", "a", "position", "and", "velocity", "vector", "for", "a", "given", "date", "and", "time", "." ]
a1e19e32831d6814b3ab34f55b39b8520d291c4e
https://github.com/brandon-rhodes/python-sgp4/blob/a1e19e32831d6814b3ab34f55b39b8520d291c4e/sgp4/model.py#L44-L50
train
ratcashdev/mitemp
mitemp_bt/mitemp_bt_poller.py
MiTempBtPoller.name
def name(self): """Return the name of the sensor.""" with self._bt_interface.connect(self._mac) as connection: name = connection.read_handle(_HANDLE_READ_NAME) # pylint: disable=no-member if not name: raise BluetoothBackendException("Could not read NAME using handle %s"...
python
def name(self): """Return the name of the sensor.""" with self._bt_interface.connect(self._mac) as connection: name = connection.read_handle(_HANDLE_READ_NAME) # pylint: disable=no-member if not name: raise BluetoothBackendException("Could not read NAME using handle %s"...
[ "def", "name", "(", "self", ")", ":", "with", "self", ".", "_bt_interface", ".", "connect", "(", "self", ".", "_mac", ")", "as", "connection", ":", "name", "=", "connection", ".", "read_handle", "(", "_HANDLE_READ_NAME", ")", "if", "not", "name", ":", ...
Return the name of the sensor.
[ "Return", "the", "name", "of", "the", "sensor", "." ]
bd6ffed5bfd9a3a52dd8a4b96e896fa79b5c5f10
https://github.com/ratcashdev/mitemp/blob/bd6ffed5bfd9a3a52dd8a4b96e896fa79b5c5f10/mitemp_bt/mitemp_bt_poller.py#L45-L53
train
ratcashdev/mitemp
mitemp_bt/mitemp_bt_poller.py
MiTempBtPoller.handleNotification
def handleNotification(self, handle, raw_data): # pylint: disable=unused-argument,invalid-name """ gets called by the bluepy backend when using wait_for_notification """ if raw_data is None: return data = raw_data.decode("utf-8").strip(' \n\t') self._cache = data ...
python
def handleNotification(self, handle, raw_data): # pylint: disable=unused-argument,invalid-name """ gets called by the bluepy backend when using wait_for_notification """ if raw_data is None: return data = raw_data.decode("utf-8").strip(' \n\t') self._cache = data ...
[ "def", "handleNotification", "(", "self", ",", "handle", ",", "raw_data", ")", ":", "if", "raw_data", "is", "None", ":", "return", "data", "=", "raw_data", ".", "decode", "(", "\"utf-8\"", ")", ".", "strip", "(", "' \\n\\t'", ")", "self", ".", "_cache", ...
gets called by the bluepy backend when using wait_for_notification
[ "gets", "called", "by", "the", "bluepy", "backend", "when", "using", "wait_for_notification" ]
bd6ffed5bfd9a3a52dd8a4b96e896fa79b5c5f10
https://github.com/ratcashdev/mitemp/blob/bd6ffed5bfd9a3a52dd8a4b96e896fa79b5c5f10/mitemp_bt/mitemp_bt_poller.py#L188-L201
train
scieloorg/articlemetaapi
articlemeta/client.py
ThriftClient.add_journal
def add_journal(self, data): """ This method include new journals to the ArticleMeta. data: legacy SciELO Documents JSON Type 3. """ journal = self.dispatcher( 'add_journal', data, self._admintoken ) return json.loads(journal...
python
def add_journal(self, data): """ This method include new journals to the ArticleMeta. data: legacy SciELO Documents JSON Type 3. """ journal = self.dispatcher( 'add_journal', data, self._admintoken ) return json.loads(journal...
[ "def", "add_journal", "(", "self", ",", "data", ")", ":", "journal", "=", "self", ".", "dispatcher", "(", "'add_journal'", ",", "data", ",", "self", ".", "_admintoken", ")", "return", "json", ".", "loads", "(", "journal", ")" ]
This method include new journals to the ArticleMeta. data: legacy SciELO Documents JSON Type 3.
[ "This", "method", "include", "new", "journals", "to", "the", "ArticleMeta", "." ]
7ff87a615951bfdcc6fd535ce7f7c65065f64caa
https://github.com/scieloorg/articlemetaapi/blob/7ff87a615951bfdcc6fd535ce7f7c65065f64caa/articlemeta/client.py#L689-L702
train
mrstephenneal/pdfconduit
pdf/api/routes.py
watermark_process
def watermark_process(): """Apply a watermark to a PDF file.""" # Redirect to watermark page that contains form if not request.method == 'POST': abort(403) # Check if the post request has the file part if 'pdf' not in request.files: abort(403) # Retrieve PDF file and parameters...
python
def watermark_process(): """Apply a watermark to a PDF file.""" # Redirect to watermark page that contains form if not request.method == 'POST': abort(403) # Check if the post request has the file part if 'pdf' not in request.files: abort(403) # Retrieve PDF file and parameters...
[ "def", "watermark_process", "(", ")", ":", "if", "not", "request", ".", "method", "==", "'POST'", ":", "abort", "(", "403", ")", "if", "'pdf'", "not", "in", "request", ".", "files", ":", "abort", "(", "403", ")", "file", "=", "request", ".", "files",...
Apply a watermark to a PDF file.
[ "Apply", "a", "watermark", "to", "a", "PDF", "file", "." ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/api/routes.py#L39-L78
train
mrstephenneal/pdfconduit
pdf/transform/slice.py
slicer
def slicer(document, first_page=None, last_page=None, suffix='sliced', tempdir=None): """Slice a PDF document to remove pages.""" # Set output file name if tempdir: with NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False) as temp: output = temp.name elif suffix: outp...
python
def slicer(document, first_page=None, last_page=None, suffix='sliced', tempdir=None): """Slice a PDF document to remove pages.""" # Set output file name if tempdir: with NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False) as temp: output = temp.name elif suffix: outp...
[ "def", "slicer", "(", "document", ",", "first_page", "=", "None", ",", "last_page", "=", "None", ",", "suffix", "=", "'sliced'", ",", "tempdir", "=", "None", ")", ":", "if", "tempdir", ":", "with", "NamedTemporaryFile", "(", "suffix", "=", "'.pdf'", ",",...
Slice a PDF document to remove pages.
[ "Slice", "a", "PDF", "document", "to", "remove", "pages", "." ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/transform/slice.py#L11-L40
train
mrstephenneal/pdfconduit
pdf/utils/info.py
Info._reader
def _reader(path, password, prompt): """Read PDF and decrypt if encrypted.""" pdf = PdfFileReader(path) if not isinstance(path, PdfFileReader) else path # Check that PDF is encrypted if pdf.isEncrypted: # Check that password is none if not password: ...
python
def _reader(path, password, prompt): """Read PDF and decrypt if encrypted.""" pdf = PdfFileReader(path) if not isinstance(path, PdfFileReader) else path # Check that PDF is encrypted if pdf.isEncrypted: # Check that password is none if not password: ...
[ "def", "_reader", "(", "path", ",", "password", ",", "prompt", ")", ":", "pdf", "=", "PdfFileReader", "(", "path", ")", "if", "not", "isinstance", "(", "path", ",", "PdfFileReader", ")", "else", "path", "if", "pdf", ".", "isEncrypted", ":", "if", "not"...
Read PDF and decrypt if encrypted.
[ "Read", "PDF", "and", "decrypt", "if", "encrypted", "." ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/utils/info.py#L10-L25
train
mrstephenneal/pdfconduit
pdf/utils/info.py
Info._resolved_objects
def _resolved_objects(pdf, xobject): """Retrieve rotatation info.""" return [pdf.getPage(i).get(xobject) for i in range(pdf.getNumPages())][0]
python
def _resolved_objects(pdf, xobject): """Retrieve rotatation info.""" return [pdf.getPage(i).get(xobject) for i in range(pdf.getNumPages())][0]
[ "def", "_resolved_objects", "(", "pdf", ",", "xobject", ")", ":", "return", "[", "pdf", ".", "getPage", "(", "i", ")", ".", "get", "(", "xobject", ")", "for", "i", "in", "range", "(", "pdf", ".", "getNumPages", "(", ")", ")", "]", "[", "0", "]" ]
Retrieve rotatation info.
[ "Retrieve", "rotatation", "info", "." ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/utils/info.py#L28-L30
train
mrstephenneal/pdfconduit
pdf/utils/info.py
Info.resources
def resources(self): """Retrieve contents of each page of PDF""" return [self.pdf.getPage(i) for i in range(self.pdf.getNumPages())]
python
def resources(self): """Retrieve contents of each page of PDF""" return [self.pdf.getPage(i) for i in range(self.pdf.getNumPages())]
[ "def", "resources", "(", "self", ")", ":", "return", "[", "self", ".", "pdf", ".", "getPage", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "pdf", ".", "getNumPages", "(", ")", ")", "]" ]
Retrieve contents of each page of PDF
[ "Retrieve", "contents", "of", "each", "page", "of", "PDF" ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/utils/info.py#L52-L54
train
mrstephenneal/pdfconduit
pdf/utils/info.py
Info.security
def security(self): """Print security object information for a pdf document""" return {k: v for i in self.pdf.resolvedObjects.items() for k, v in i[1].items()}
python
def security(self): """Print security object information for a pdf document""" return {k: v for i in self.pdf.resolvedObjects.items() for k, v in i[1].items()}
[ "def", "security", "(", "self", ")", ":", "return", "{", "k", ":", "v", "for", "i", "in", "self", ".", "pdf", ".", "resolvedObjects", ".", "items", "(", ")", "for", "k", ",", "v", "in", "i", "[", "1", "]", ".", "items", "(", ")", "}" ]
Print security object information for a pdf document
[ "Print", "security", "object", "information", "for", "a", "pdf", "document" ]
993421cc087eefefe01ff09afabd893bcc2718ec
https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/utils/info.py#L57-L59
train
datadesk/python-documentcloud
documentcloud/__init__.py
BaseDocumentCloudClient._make_request
def _make_request(self, url, params=None, opener=None): """ Configure a HTTP request, fire it off and return the response. """ # Create the request object args = [i for i in [url, params] if i] request = urllib.request.Request(*args) # If the client has credential...
python
def _make_request(self, url, params=None, opener=None): """ Configure a HTTP request, fire it off and return the response. """ # Create the request object args = [i for i in [url, params] if i] request = urllib.request.Request(*args) # If the client has credential...
[ "def", "_make_request", "(", "self", ",", "url", ",", "params", "=", "None", ",", "opener", "=", "None", ")", ":", "args", "=", "[", "i", "for", "i", "in", "[", "url", ",", "params", "]", "if", "i", "]", "request", "=", "urllib", ".", "request", ...
Configure a HTTP request, fire it off and return the response.
[ "Configure", "a", "HTTP", "request", "fire", "it", "off", "and", "return", "the", "response", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L53-L89
train
datadesk/python-documentcloud
documentcloud/__init__.py
BaseDocumentCloudClient.put
def put(self, method, params): """ Post changes back to DocumentCloud """ # Prepare the params, first by adding a custom command to # simulate a PUT request even though we are actually POSTing. # This is something DocumentCloud expects. params['_method'] = 'put' ...
python
def put(self, method, params): """ Post changes back to DocumentCloud """ # Prepare the params, first by adding a custom command to # simulate a PUT request even though we are actually POSTing. # This is something DocumentCloud expects. params['_method'] = 'put' ...
[ "def", "put", "(", "self", ",", "method", ",", "params", ")", ":", "params", "[", "'_method'", "]", "=", "'put'", "if", "params", ".", "get", "(", "\"document_ids\"", ",", "None", ")", ":", "document_ids", "=", "params", ".", "get", "(", "\"document_id...
Post changes back to DocumentCloud
[ "Post", "changes", "back", "to", "DocumentCloud" ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L92-L136
train
datadesk/python-documentcloud
documentcloud/__init__.py
BaseDocumentCloudClient.fetch
def fetch(self, method, params=None): """ Fetch an url. """ # Encode params if they exist if params: params = urllib.parse.urlencode(params, doseq=True).encode("utf-8") content = self._make_request( self.BASE_URI + method, params, ...
python
def fetch(self, method, params=None): """ Fetch an url. """ # Encode params if they exist if params: params = urllib.parse.urlencode(params, doseq=True).encode("utf-8") content = self._make_request( self.BASE_URI + method, params, ...
[ "def", "fetch", "(", "self", ",", "method", ",", "params", "=", "None", ")", ":", "if", "params", ":", "params", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "doseq", "=", "True", ")", ".", "encode", "(", "\"utf-8\"", ")", "co...
Fetch an url.
[ "Fetch", "an", "url", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L138-L150
train
datadesk/python-documentcloud
documentcloud/__init__.py
DocumentClient._get_search_page
def _get_search_page( self, query, page, per_page=1000, mentions=3, data=False, ): """ Retrieve one page of search results from the DocumentCloud API. """ if mentions > 10: raise ValueError("You cannot search for more than 1...
python
def _get_search_page( self, query, page, per_page=1000, mentions=3, data=False, ): """ Retrieve one page of search results from the DocumentCloud API. """ if mentions > 10: raise ValueError("You cannot search for more than 1...
[ "def", "_get_search_page", "(", "self", ",", "query", ",", "page", ",", "per_page", "=", "1000", ",", "mentions", "=", "3", ",", "data", "=", "False", ",", ")", ":", "if", "mentions", ">", "10", ":", "raise", "ValueError", "(", "\"You cannot search for m...
Retrieve one page of search results from the DocumentCloud API.
[ "Retrieve", "one", "page", "of", "search", "results", "from", "the", "DocumentCloud", "API", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L195-L217
train
datadesk/python-documentcloud
documentcloud/__init__.py
DocumentClient.search
def search(self, query, page=None, per_page=1000, mentions=3, data=False): """ Retrieve all objects that make a search query. Will loop through all pages that match unless you provide the number of pages you'd like to restrict the search to. Example usage: >> docum...
python
def search(self, query, page=None, per_page=1000, mentions=3, data=False): """ Retrieve all objects that make a search query. Will loop through all pages that match unless you provide the number of pages you'd like to restrict the search to. Example usage: >> docum...
[ "def", "search", "(", "self", ",", "query", ",", "page", "=", "None", ",", "per_page", "=", "1000", ",", "mentions", "=", "3", ",", "data", "=", "False", ")", ":", "if", "page", ":", "document_list", "=", "self", ".", "_get_search_page", "(", "query"...
Retrieve all objects that make a search query. Will loop through all pages that match unless you provide the number of pages you'd like to restrict the search to. Example usage: >> documentcloud.documents.search('salazar')
[ "Retrieve", "all", "objects", "that", "make", "a", "search", "query", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L219-L265
train
datadesk/python-documentcloud
documentcloud/__init__.py
DocumentClient.get
def get(self, id): """ Retrieve a particular document using it's unique identifier. Example usage: >> documentcloud.documents.get('71072-oir-final-report') """ data = self.fetch('documents/%s.json' % id).get("document") data['_connection'] = self._connection...
python
def get(self, id): """ Retrieve a particular document using it's unique identifier. Example usage: >> documentcloud.documents.get('71072-oir-final-report') """ data = self.fetch('documents/%s.json' % id).get("document") data['_connection'] = self._connection...
[ "def", "get", "(", "self", ",", "id", ")", ":", "data", "=", "self", ".", "fetch", "(", "'documents/%s.json'", "%", "id", ")", ".", "get", "(", "\"document\"", ")", "data", "[", "'_connection'", "]", "=", "self", ".", "_connection", "return", "Document...
Retrieve a particular document using it's unique identifier. Example usage: >> documentcloud.documents.get('71072-oir-final-report')
[ "Retrieve", "a", "particular", "document", "using", "it", "s", "unique", "identifier", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L267-L277
train
datadesk/python-documentcloud
documentcloud/__init__.py
DocumentClient.upload
def upload( self, pdf, title=None, source=None, description=None, related_article=None, published_url=None, access='private', project=None, data=None, secure=False, force_ocr=False ): """ Upload a PDF or other image file to DocumentCloud. You can submit either a pdf ...
python
def upload( self, pdf, title=None, source=None, description=None, related_article=None, published_url=None, access='private', project=None, data=None, secure=False, force_ocr=False ): """ Upload a PDF or other image file to DocumentCloud. You can submit either a pdf ...
[ "def", "upload", "(", "self", ",", "pdf", ",", "title", "=", "None", ",", "source", "=", "None", ",", "description", "=", "None", ",", "related_article", "=", "None", ",", "published_url", "=", "None", ",", "access", "=", "'private'", ",", "project", "...
Upload a PDF or other image file to DocumentCloud. You can submit either a pdf opened as a file object or a path to a pdf file. Example usage: # From a file path >> documentcloud.documents.upload( >> "/home/ben/sample.pdf", >> "sample title" ...
[ "Upload", "a", "PDF", "or", "other", "image", "file", "to", "DocumentCloud", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L280-L367
train
datadesk/python-documentcloud
documentcloud/__init__.py
DocumentClient.upload_directory
def upload_directory( self, path, source=None, description=None, related_article=None, published_url=None, access='private', project=None, data=None, secure=False, force_ocr=False ): """ Uploads all the PDFs in the provided directory. Example usage: >> d...
python
def upload_directory( self, path, source=None, description=None, related_article=None, published_url=None, access='private', project=None, data=None, secure=False, force_ocr=False ): """ Uploads all the PDFs in the provided directory. Example usage: >> d...
[ "def", "upload_directory", "(", "self", ",", "path", ",", "source", "=", "None", ",", "description", "=", "None", ",", "related_article", "=", "None", ",", "published_url", "=", "None", ",", "access", "=", "'private'", ",", "project", "=", "None", ",", "...
Uploads all the PDFs in the provided directory. Example usage: >> documentcloud.documents.upload_directory("/home/ben/pdfs/") Returns a list of the documents created during the upload. Based on code developed by Mitchell Kotler and refined by Christopher Groskopf.
[ "Uploads", "all", "the", "PDFs", "in", "the", "provided", "directory", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L370-L405
train
datadesk/python-documentcloud
documentcloud/__init__.py
ProjectClient.all
def all(self): """ Retrieve all your projects. Requires authentication. Example usage: >> documentcloud.projects.all() """ project_list = self.fetch('projects.json').get("projects") obj_list = [] for proj in project_list: proj['_connectio...
python
def all(self): """ Retrieve all your projects. Requires authentication. Example usage: >> documentcloud.projects.all() """ project_list = self.fetch('projects.json').get("projects") obj_list = [] for proj in project_list: proj['_connectio...
[ "def", "all", "(", "self", ")", ":", "project_list", "=", "self", ".", "fetch", "(", "'projects.json'", ")", ".", "get", "(", "\"projects\"", ")", "obj_list", "=", "[", "]", "for", "proj", "in", "project_list", ":", "proj", "[", "'_connection'", "]", "...
Retrieve all your projects. Requires authentication. Example usage: >> documentcloud.projects.all()
[ "Retrieve", "all", "your", "projects", ".", "Requires", "authentication", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L430-L444
train
datadesk/python-documentcloud
documentcloud/__init__.py
ProjectClient.get
def get(self, id=None, title=None): """ Retrieve a particular project using its unique identifier or it's title. But not both. Example usage: >> documentcloud.projects.get('arizona-shootings') """ # Make sure the kwargs are kosher if id and ...
python
def get(self, id=None, title=None): """ Retrieve a particular project using its unique identifier or it's title. But not both. Example usage: >> documentcloud.projects.get('arizona-shootings') """ # Make sure the kwargs are kosher if id and ...
[ "def", "get", "(", "self", ",", "id", "=", "None", ",", "title", "=", "None", ")", ":", "if", "id", "and", "title", ":", "raise", "ValueError", "(", "\"You can only retrieve a Project by id or \\ title, not by both\"", ")", "elif", "not", "id", "a...
Retrieve a particular project using its unique identifier or it's title. But not both. Example usage: >> documentcloud.projects.get('arizona-shootings')
[ "Retrieve", "a", "particular", "project", "using", "its", "unique", "identifier", "or", "it", "s", "title", "." ]
0d7f42cbf1edf5c61fca37ed846362cba4abfd76
https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L446-L482
train