repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
aichaos/rivescript-python
rivescript/rivescript.py
RiveScript._dump
def _dump(self): """For debugging, dump the entire data structure.""" pp = pprint.PrettyPrinter(indent=4) print("=== Variables ===") print("-- Globals --") pp.pprint(self._global) print("-- Bot vars --") pp.pprint(self._var) print("-- Substitutions --") ...
python
def _dump(self): """For debugging, dump the entire data structure.""" pp = pprint.PrettyPrinter(indent=4) print("=== Variables ===") print("-- Globals --") pp.pprint(self._global) print("-- Bot vars --") pp.pprint(self._var) print("-- Substitutions --") ...
[ "def", "_dump", "(", "self", ")", ":", "pp", "=", "pprint", ".", "PrettyPrinter", "(", "indent", "=", "4", ")", "print", "(", "\"=== Variables ===\"", ")", "print", "(", "\"-- Globals --\"", ")", "pp", ".", "pprint", "(", "self", ".", "_global", ")", "...
For debugging, dump the entire data structure.
[ "For", "debugging", "dump", "the", "entire", "data", "structure", "." ]
train
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/rivescript.py#L992-L1023
aichaos/rivescript-python
rivescript/parser.py
Parser.parse
def parse(self, filename, code): """Read and parse a RiveScript document. Returns a data structure that represents all of the useful contents of the document, in this format:: { "begin": { # "begin" data "global": {}, # map of !global vars ...
python
def parse(self, filename, code): """Read and parse a RiveScript document. Returns a data structure that represents all of the useful contents of the document, in this format:: { "begin": { # "begin" data "global": {}, # map of !global vars ...
[ "def", "parse", "(", "self", ",", "filename", ",", "code", ")", ":", "# Eventual returned structure (\"abstract syntax tree\" but not really)", "ast", "=", "{", "\"begin\"", ":", "{", "\"global\"", ":", "{", "}", ",", "\"var\"", ":", "{", "}", ",", "\"sub\"", ...
Read and parse a RiveScript document. Returns a data structure that represents all of the useful contents of the document, in this format:: { "begin": { # "begin" data "global": {}, # map of !global vars "var": {}, # bot !var's ...
[ "Read", "and", "parse", "a", "RiveScript", "document", "." ]
train
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/parser.py#L62-L505
aichaos/rivescript-python
rivescript/parser.py
Parser.check_syntax
def check_syntax(self, cmd, line): """Syntax check a line of RiveScript code. Args: str cmd: The command symbol for the line of code, such as one of ``+``, ``-``, ``*``, ``>``, etc. str line: The remainder of the line of code, such as the text of ...
python
def check_syntax(self, cmd, line): """Syntax check a line of RiveScript code. Args: str cmd: The command symbol for the line of code, such as one of ``+``, ``-``, ``*``, ``>``, etc. str line: The remainder of the line of code, such as the text of ...
[ "def", "check_syntax", "(", "self", ",", "cmd", ",", "line", ")", ":", "# Run syntax checks based on the type of command.", "if", "cmd", "==", "'!'", ":", "# ! Definition", "# - Must be formatted like this:", "# ! type name = value", "# OR", "# ! type = value", ...
Syntax check a line of RiveScript code. Args: str cmd: The command symbol for the line of code, such as one of ``+``, ``-``, ``*``, ``>``, etc. str line: The remainder of the line of code, such as the text of a trigger or reply. Return: ...
[ "Syntax", "check", "a", "line", "of", "RiveScript", "code", "." ]
train
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/parser.py#L507-L625
semente/django-smuggler
smuggler/views.py
dump_to_response
def dump_to_response(request, app_label=None, exclude=None, filename_prefix=None): """Utility function that dumps the given app/model to an HttpResponse. """ app_label = app_label or [] exclude = exclude try: filename = '%s.%s' % (datetime.now().isoformat(), ...
python
def dump_to_response(request, app_label=None, exclude=None, filename_prefix=None): """Utility function that dumps the given app/model to an HttpResponse. """ app_label = app_label or [] exclude = exclude try: filename = '%s.%s' % (datetime.now().isoformat(), ...
[ "def", "dump_to_response", "(", "request", ",", "app_label", "=", "None", ",", "exclude", "=", "None", ",", "filename_prefix", "=", "None", ")", ":", "app_label", "=", "app_label", "or", "[", "]", "exclude", "=", "exclude", "try", ":", "filename", "=", "...
Utility function that dumps the given app/model to an HttpResponse.
[ "Utility", "function", "that", "dumps", "the", "given", "app", "/", "model", "to", "an", "HttpResponse", "." ]
train
https://github.com/semente/django-smuggler/blob/3be76f4e94e50e927a55a60741fac1a793df83de/smuggler/views.py#L31-L51
semente/django-smuggler
smuggler/views.py
dump_data
def dump_data(request): """Exports data from whole project. """ # Try to grab app_label data app_label = request.GET.get('app_label', []) if app_label: app_label = app_label.split(',') return dump_to_response(request, app_label=app_label, exclude=settings.SMUG...
python
def dump_data(request): """Exports data from whole project. """ # Try to grab app_label data app_label = request.GET.get('app_label', []) if app_label: app_label = app_label.split(',') return dump_to_response(request, app_label=app_label, exclude=settings.SMUG...
[ "def", "dump_data", "(", "request", ")", ":", "# Try to grab app_label data", "app_label", "=", "request", ".", "GET", ".", "get", "(", "'app_label'", ",", "[", "]", ")", "if", "app_label", ":", "app_label", "=", "app_label", ".", "split", "(", "','", ")",...
Exports data from whole project.
[ "Exports", "data", "from", "whole", "project", "." ]
train
https://github.com/semente/django-smuggler/blob/3be76f4e94e50e927a55a60741fac1a793df83de/smuggler/views.py#L63-L71
semente/django-smuggler
smuggler/views.py
dump_model_data
def dump_model_data(request, app_label, model_label): """Exports data from a model. """ return dump_to_response(request, '%s.%s' % (app_label, model_label), [], '-'.join((app_label, model_label)))
python
def dump_model_data(request, app_label, model_label): """Exports data from a model. """ return dump_to_response(request, '%s.%s' % (app_label, model_label), [], '-'.join((app_label, model_label)))
[ "def", "dump_model_data", "(", "request", ",", "app_label", ",", "model_label", ")", ":", "return", "dump_to_response", "(", "request", ",", "'%s.%s'", "%", "(", "app_label", ",", "model_label", ")", ",", "[", "]", ",", "'-'", ".", "join", "(", "(", "app...
Exports data from a model.
[ "Exports", "data", "from", "a", "model", "." ]
train
https://github.com/semente/django-smuggler/blob/3be76f4e94e50e927a55a60741fac1a793df83de/smuggler/views.py#L83-L87
mozilla/crontabber
crontabber/base.py
toposort
def toposort(data): """Dependencies are expressed as a dictionary whose keys are items and whose values are a set of dependent items. Output is a list of sets in topological order. The first set consists of items with no dependences, each subsequent set consists of items that depend upon items in the preceeding set...
python
def toposort(data): """Dependencies are expressed as a dictionary whose keys are items and whose values are a set of dependent items. Output is a list of sets in topological order. The first set consists of items with no dependences, each subsequent set consists of items that depend upon items in the preceeding set...
[ "def", "toposort", "(", "data", ")", ":", "# Special case empty input.", "if", "len", "(", "data", ")", "==", "0", ":", "return", "# Copy the input so as to leave it unmodified.", "data", "=", "data", ".", "copy", "(", ")", "# Ignore self dependencies.", "for", "k...
Dependencies are expressed as a dictionary whose keys are items and whose values are a set of dependent items. Output is a list of sets in topological order. The first set consists of items with no dependences, each subsequent set consists of items that depend upon items in the preceeding sets.
[ "Dependencies", "are", "expressed", "as", "a", "dictionary", "whose", "keys", "are", "items", "and", "whose", "values", "are", "a", "set", "of", "dependent", "items", ".", "Output", "is", "a", "list", "of", "sets", "in", "topological", "order", ".", "The",...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/base.py#L30-L69
mozilla/crontabber
crontabber/base.py
reorder_dag
def reorder_dag(sequence, depends_getter=lambda x: x.depends_on, name_getter=lambda x: x.app_name, impatience_max=100): """ DAG = Directed Acyclic Graph If we have something like: C depends on B B depends on A A doesn't depend on any ...
python
def reorder_dag(sequence, depends_getter=lambda x: x.depends_on, name_getter=lambda x: x.app_name, impatience_max=100): """ DAG = Directed Acyclic Graph If we have something like: C depends on B B depends on A A doesn't depend on any ...
[ "def", "reorder_dag", "(", "sequence", ",", "depends_getter", "=", "lambda", "x", ":", "x", ".", "depends_on", ",", "name_getter", "=", "lambda", "x", ":", "x", ".", "app_name", ",", "impatience_max", "=", "100", ")", ":", "jobs", "=", "collections", "."...
DAG = Directed Acyclic Graph If we have something like: C depends on B B depends on A A doesn't depend on any Given the order of [C, B, A] expect it to return [A, B, C] parameters: :sequence: some sort of iterable list :depends_getter: a callable that extracts the...
[ "DAG", "=", "Directed", "Acyclic", "Graph", "If", "we", "have", "something", "like", ":", "C", "depends", "on", "B", "B", "depends", "on", "A", "A", "doesn", "t", "depend", "on", "any" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/base.py#L84-L135
mozilla/crontabber
crontabber/base.py
convert_frequency
def convert_frequency(frequency): """return the number of seconds that a certain frequency string represents. For example: `1d` means 1 day which means 60 * 60 * 24 seconds. The recognized formats are: 10d : 10 days 3m : 3 minutes 12h : 12 hours """ number = int(re.findal...
python
def convert_frequency(frequency): """return the number of seconds that a certain frequency string represents. For example: `1d` means 1 day which means 60 * 60 * 24 seconds. The recognized formats are: 10d : 10 days 3m : 3 minutes 12h : 12 hours """ number = int(re.findal...
[ "def", "convert_frequency", "(", "frequency", ")", ":", "number", "=", "int", "(", "re", ".", "findall", "(", "'\\d+'", ",", "frequency", ")", "[", "0", "]", ")", "unit", "=", "re", ".", "findall", "(", "'[^\\d]+'", ",", "frequency", ")", "[", "0", ...
return the number of seconds that a certain frequency string represents. For example: `1d` means 1 day which means 60 * 60 * 24 seconds. The recognized formats are: 10d : 10 days 3m : 3 minutes 12h : 12 hours
[ "return", "the", "number", "of", "seconds", "that", "a", "certain", "frequency", "string", "represents", ".", "For", "example", ":", "1d", "means", "1", "day", "which", "means", "60", "*", "60", "*", "24", "seconds", ".", "The", "recognized", "formats", ...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/base.py#L139-L157
mozilla/crontabber
crontabber/datetimeutil.py
timesince
def timesince(d, now): """ Taken from django.utils.timesince and modified to simpler requirements. Takes two datetime objects and returns the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, then "0 minutes" is returned. Units used are years, month...
python
def timesince(d, now): """ Taken from django.utils.timesince and modified to simpler requirements. Takes two datetime objects and returns the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, then "0 minutes" is returned. Units used are years, month...
[ "def", "timesince", "(", "d", ",", "now", ")", ":", "def", "pluralize", "(", "a", ",", "b", ")", ":", "def", "inner", "(", "n", ")", ":", "if", "n", "==", "1", ":", "return", "a", "%", "n", "return", "b", "%", "n", "return", "inner", "def", ...
Taken from django.utils.timesince and modified to simpler requirements. Takes two datetime objects and returns the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, then "0 minutes" is returned. Units used are years, months, weeks, days, hours, and minutes....
[ "Taken", "from", "django", ".", "utils", ".", "timesince", "and", "modified", "to", "simpler", "requirements", "." ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/datetimeutil.py#L48-L117
mozilla/crontabber
crontabber/connection_factory.py
ConnectionFactory.connection
def connection(self, name=None): """return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connecti...
python
def connection(self, name=None): """return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connecti...
[ "def", "connection", "(", "self", ",", "name", "=", "None", ")", ":", "if", "not", "name", ":", "name", "=", "self", ".", "_get_default_connection_name", "(", ")", "if", "name", "in", "self", ".", "pool", ":", "return", "self", ".", "pool", "[", "nam...
return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connection. parameters: name - ...
[ "return", "a", "named", "connection", "." ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/connection_factory.py#L94-L110
mozilla/crontabber
crontabber/connection_factory.py
ConnectionFactory.close_connection
def close_connection(self, connection, force=False): """overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.""" if force: try: connection.close() ...
python
def close_connection(self, connection, force=False): """overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.""" if force: try: connection.close() ...
[ "def", "close_connection", "(", "self", ",", "connection", ",", "force", "=", "False", ")", ":", "if", "force", ":", "try", ":", "connection", ".", "close", "(", ")", "except", "self", ".", "operational_exceptions", ":", "self", ".", "config", ".", "logg...
overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.
[ "overriding", "the", "baseclass", "function", "this", "routine", "will", "decline", "to", "close", "a", "connection", "at", "the", "end", "of", "a", "transaction", "context", ".", "This", "allows", "for", "reuse", "of", "connections", "." ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/connection_factory.py#L129-L143
mozilla/crontabber
crontabber/generic_app.py
respond_to_SIGHUP
def respond_to_SIGHUP(signal_number, frame, logger=None): """raise the KeyboardInterrupt which will cause the app to effectively shutdown, closing all it resources. Then, because it sets 'restart' to True, the app will reread all the configuration information, rebuild all of its structures and resource...
python
def respond_to_SIGHUP(signal_number, frame, logger=None): """raise the KeyboardInterrupt which will cause the app to effectively shutdown, closing all it resources. Then, because it sets 'restart' to True, the app will reread all the configuration information, rebuild all of its structures and resource...
[ "def", "respond_to_SIGHUP", "(", "signal_number", ",", "frame", ",", "logger", "=", "None", ")", ":", "global", "restart", "restart", "=", "True", "if", "logger", ":", "logger", ".", "info", "(", "'detected SIGHUP'", ")", "raise", "KeyboardInterrupt" ]
raise the KeyboardInterrupt which will cause the app to effectively shutdown, closing all it resources. Then, because it sets 'restart' to True, the app will reread all the configuration information, rebuild all of its structures and resources and start running again
[ "raise", "the", "KeyboardInterrupt", "which", "will", "cause", "the", "app", "to", "effectively", "shutdown", "closing", "all", "it", "resources", ".", "Then", "because", "it", "sets", "restart", "to", "True", "the", "app", "will", "reread", "all", "the", "c...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/generic_app.py#L195-L204
mozilla/crontabber
crontabber/transaction_executor.py
TransactionExecutorWithInfiniteBackoff.backoff_generator
def backoff_generator(self): """Generate a series of integers used for the length of the sleep between retries. It produces after exhausting the list, it repeats the last value from the list forever. This generator will never raise the StopIteration exception.""" for x in self....
python
def backoff_generator(self): """Generate a series of integers used for the length of the sleep between retries. It produces after exhausting the list, it repeats the last value from the list forever. This generator will never raise the StopIteration exception.""" for x in self....
[ "def", "backoff_generator", "(", "self", ")", ":", "for", "x", "in", "self", ".", "config", ".", "backoff_delays", ":", "yield", "x", "while", "True", ":", "yield", "self", ".", "config", ".", "backoff_delays", "[", "-", "1", "]" ]
Generate a series of integers used for the length of the sleep between retries. It produces after exhausting the list, it repeats the last value from the list forever. This generator will never raise the StopIteration exception.
[ "Generate", "a", "series", "of", "integers", "used", "for", "the", "length", "of", "the", "sleep", "between", "retries", ".", "It", "produces", "after", "exhausting", "the", "list", "it", "repeats", "the", "last", "value", "from", "the", "list", "forever", ...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/transaction_executor.py#L76-L84
mozilla/crontabber
crontabber/transaction_executor.py
TransactionExecutorWithInfiniteBackoff.responsive_sleep
def responsive_sleep(self, seconds, wait_reason=''): """Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.""" for x in xrange(int(seconds)): if (self.config.wait_log_interval and not x % self.config.wait_log_in...
python
def responsive_sleep(self, seconds, wait_reason=''): """Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.""" for x in xrange(int(seconds)): if (self.config.wait_log_interval and not x % self.config.wait_log_in...
[ "def", "responsive_sleep", "(", "self", ",", "seconds", ",", "wait_reason", "=", "''", ")", ":", "for", "x", "in", "xrange", "(", "int", "(", "seconds", ")", ")", ":", "if", "(", "self", ".", "config", ".", "wait_log_interval", "and", "not", "x", "%"...
Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.
[ "Sleep", "for", "the", "specified", "number", "of", "seconds", "logging", "every", "wait_log_interval", "seconds", "with", "progress", "info", "." ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/transaction_executor.py#L87-L97
mozilla/crontabber
crontabber/mixins.py
as_backfill_cron_app
def as_backfill_cron_app(cls): """a class decorator for Crontabber Apps. This decorator embues a CronApp with the parts necessary to be a backfill CronApp. It adds a main method that forces the base class to use a value of False for 'once'. That means it will do the work of a backfilling app. """...
python
def as_backfill_cron_app(cls): """a class decorator for Crontabber Apps. This decorator embues a CronApp with the parts necessary to be a backfill CronApp. It adds a main method that forces the base class to use a value of False for 'once'. That means it will do the work of a backfilling app. """...
[ "def", "as_backfill_cron_app", "(", "cls", ")", ":", "#----------------------------------------------------------------------", "def", "main", "(", "self", ",", "function", "=", "None", ")", ":", "return", "super", "(", "cls", ",", "self", ")", ".", "main", "(", ...
a class decorator for Crontabber Apps. This decorator embues a CronApp with the parts necessary to be a backfill CronApp. It adds a main method that forces the base class to use a value of False for 'once'. That means it will do the work of a backfilling app.
[ "a", "class", "decorator", "for", "Crontabber", "Apps", ".", "This", "decorator", "embues", "a", "CronApp", "with", "the", "parts", "necessary", "to", "be", "a", "backfill", "CronApp", ".", "It", "adds", "a", "main", "method", "that", "forces", "the", "bas...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/mixins.py#L14-L28
mozilla/crontabber
crontabber/mixins.py
with_transactional_resource
def with_transactional_resource( transactional_resource_class, resource_name, reference_value_from=None ): """a class decorator for Crontabber Apps. This decorator will give access to a resource connection source. Configuration will be automatically set up and the cron app can expect to have a...
python
def with_transactional_resource( transactional_resource_class, resource_name, reference_value_from=None ): """a class decorator for Crontabber Apps. This decorator will give access to a resource connection source. Configuration will be automatically set up and the cron app can expect to have a...
[ "def", "with_transactional_resource", "(", "transactional_resource_class", ",", "resource_name", ",", "reference_value_from", "=", "None", ")", ":", "def", "class_decorator", "(", "cls", ")", ":", "if", "not", "issubclass", "(", "cls", ",", "RequiredConfig", ")", ...
a class decorator for Crontabber Apps. This decorator will give access to a resource connection source. Configuration will be automatically set up and the cron app can expect to have attributes: self.{resource_name}_connection_factory self.{resource_name}_transaction_executor available to ...
[ "a", "class", "decorator", "for", "Crontabber", "Apps", ".", "This", "decorator", "will", "give", "access", "to", "a", "resource", "connection", "source", ".", "Configuration", "will", "be", "automatically", "set", "up", "and", "the", "cron", "app", "can", "...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/mixins.py#L32-L114
mozilla/crontabber
crontabber/mixins.py
with_resource_connection_as_argument
def with_resource_connection_as_argument(resource_name): """a class decorator for Crontabber Apps. This decorator will a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's run method. The connection will automatically be closed when the ConApp's run me...
python
def with_resource_connection_as_argument(resource_name): """a class decorator for Crontabber Apps. This decorator will a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's run method. The connection will automatically be closed when the ConApp's run me...
[ "def", "with_resource_connection_as_argument", "(", "resource_name", ")", ":", "connection_factory_attr_name", "=", "'%s_connection_factory'", "%", "resource_name", "def", "class_decorator", "(", "cls", ")", ":", "def", "_run_proxy", "(", "self", ",", "*", "args", ","...
a class decorator for Crontabber Apps. This decorator will a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's run method. The connection will automatically be closed when the ConApp's run method ends. In order for this dectorator to function properl...
[ "a", "class", "decorator", "for", "Crontabber", "Apps", ".", "This", "decorator", "will", "a", "class", "a", "_run_proxy", "method", "that", "passes", "a", "databsase", "connection", "as", "a", "context", "manager", "into", "the", "CronApp", "s", "run", "met...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/mixins.py#L118-L141
mozilla/crontabber
crontabber/mixins.py
with_single_transaction
def with_single_transaction(resource_name): """a class decorator for Crontabber Apps. This decorator will give a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's 'run' method. The run method may then use the connection at will knowing that after if '...
python
def with_single_transaction(resource_name): """a class decorator for Crontabber Apps. This decorator will give a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's 'run' method. The run method may then use the connection at will knowing that after if '...
[ "def", "with_single_transaction", "(", "resource_name", ")", ":", "transaction_executor_attr_name", "=", "\"%s_transaction_executor\"", "%", "resource_name", "def", "class_decorator", "(", "cls", ")", ":", "def", "_run_proxy", "(", "self", ",", "*", "args", ",", "*"...
a class decorator for Crontabber Apps. This decorator will give a class a _run_proxy method that passes a databsase connection as a context manager into the CronApp's 'run' method. The run method may then use the connection at will knowing that after if 'run' exits normally, the connection will automa...
[ "a", "class", "decorator", "for", "Crontabber", "Apps", ".", "This", "decorator", "will", "give", "a", "class", "a", "_run_proxy", "method", "that", "passes", "a", "databsase", "connection", "as", "a", "context", "manager", "into", "the", "CronApp", "s", "ru...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/mixins.py#L145-L169
mozilla/crontabber
crontabber/mixins.py
with_subprocess
def with_subprocess(cls): """a class decorator for Crontabber Apps. This decorator gives the CronApp a _run_proxy method that will execute the cron app as a single PG transaction. Commit and Rollback are automatic. The cron app should do no transaction management of its own. The cron app should be s...
python
def with_subprocess(cls): """a class decorator for Crontabber Apps. This decorator gives the CronApp a _run_proxy method that will execute the cron app as a single PG transaction. Commit and Rollback are automatic. The cron app should do no transaction management of its own. The cron app should be s...
[ "def", "with_subprocess", "(", "cls", ")", ":", "def", "run_process", "(", "self", ",", "command", ",", "input", "=", "None", ")", ":", "\"\"\"\n Run the command and return a tuple of three things.\n\n 1. exit code - an integer number\n 2. stdout - all output...
a class decorator for Crontabber Apps. This decorator gives the CronApp a _run_proxy method that will execute the cron app as a single PG transaction. Commit and Rollback are automatic. The cron app should do no transaction management of its own. The cron app should be short so that the transaction ...
[ "a", "class", "decorator", "for", "Crontabber", "Apps", ".", "This", "decorator", "gives", "the", "CronApp", "a", "_run_proxy", "method", "that", "will", "execute", "the", "cron", "app", "as", "a", "single", "PG", "transaction", ".", "Commit", "and", "Rollba...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/mixins.py#L173-L201
mozilla/crontabber
crontabber/app.py
classes_in_namespaces_converter_with_compression
def classes_in_namespaces_converter_with_compression( reference_namespace={}, template_for_namespace="class-%(name)s", list_splitter_fn=_default_list_splitter, class_extractor=_default_class_extractor, extra_extractor=_default_extra_extractor): """ parameters: tem...
python
def classes_in_namespaces_converter_with_compression( reference_namespace={}, template_for_namespace="class-%(name)s", list_splitter_fn=_default_list_splitter, class_extractor=_default_class_extractor, extra_extractor=_default_extra_extractor): """ parameters: tem...
[ "def", "classes_in_namespaces_converter_with_compression", "(", "reference_namespace", "=", "{", "}", ",", "template_for_namespace", "=", "\"class-%(name)s\"", ",", "list_splitter_fn", "=", "_default_list_splitter", ",", "class_extractor", "=", "_default_class_extractor", ",", ...
parameters: template_for_namespace - a template for the names of the namespaces that will contain the classes and their associated required config options. There are two template variables available: %(name)s - ...
[ "parameters", ":", "template_for_namespace", "-", "a", "template", "for", "the", "names", "of", "the", "namespaces", "that", "will", "contain", "the", "classes", "and", "their", "associated", "required", "config", "options", ".", "There", "are", "two", "template...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L503-L605
mozilla/crontabber
crontabber/app.py
check_time
def check_time(value): """check that it's a value like 03:45 or 1:1""" try: h, m = value.split(':') h = int(h) m = int(m) if h >= 24 or h < 0: raise ValueError if m >= 60 or m < 0: raise ValueError except ValueError: raise TimeDefinitio...
python
def check_time(value): """check that it's a value like 03:45 or 1:1""" try: h, m = value.split(':') h = int(h) m = int(m) if h >= 24 or h < 0: raise ValueError if m >= 60 or m < 0: raise ValueError except ValueError: raise TimeDefinitio...
[ "def", "check_time", "(", "value", ")", ":", "try", ":", "h", ",", "m", "=", "value", ".", "split", "(", "':'", ")", "h", "=", "int", "(", "h", ")", "m", "=", "int", "(", "m", ")", "if", "h", ">=", "24", "or", "h", "<", "0", ":", "raise",...
check that it's a value like 03:45 or 1:1
[ "check", "that", "it", "s", "a", "value", "like", "03", ":", "45", "or", "1", ":", "1" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L640-L651
mozilla/crontabber
crontabber/app.py
JobStateDatabase.keys
def keys(self): """return a list of all app_names""" keys = [] for app_name, __ in self.items(): keys.append(app_name) return keys
python
def keys(self): """return a list of all app_names""" keys = [] for app_name, __ in self.items(): keys.append(app_name) return keys
[ "def", "keys", "(", "self", ")", ":", "keys", "=", "[", "]", "for", "app_name", ",", "__", "in", "self", ".", "items", "(", ")", ":", "keys", ".", "append", "(", "app_name", ")", "return", "keys" ]
return a list of all app_names
[ "return", "a", "list", "of", "all", "app_names" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L257-L262
mozilla/crontabber
crontabber/app.py
JobStateDatabase.items
def items(self): """return all the app_names and their values as tuples""" sql = """ SELECT app_name, next_run, first_run, last_run, last_success, depends_on, error_count, ...
python
def items(self): """return all the app_names and their values as tuples""" sql = """ SELECT app_name, next_run, first_run, last_run, last_success, depends_on, error_count, ...
[ "def", "items", "(", "self", ")", ":", "sql", "=", "\"\"\"\n SELECT\n app_name,\n next_run,\n first_run,\n last_run,\n last_success,\n depends_on,\n error_count,\n last_...
return all the app_names and their values as tuples
[ "return", "all", "the", "app_names", "and", "their", "values", "as", "tuples" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L264-L286
mozilla/crontabber
crontabber/app.py
JobStateDatabase.values
def values(self): """return a list of all state values""" values = [] for __, data in self.items(): values.append(data) return values
python
def values(self): """return a list of all state values""" values = [] for __, data in self.items(): values.append(data) return values
[ "def", "values", "(", "self", ")", ":", "values", "=", "[", "]", "for", "__", ",", "data", "in", "self", ".", "items", "(", ")", ":", "values", ".", "append", "(", "data", ")", "return", "values" ]
return a list of all state values
[ "return", "a", "list", "of", "all", "state", "values" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L288-L293
mozilla/crontabber
crontabber/app.py
JobStateDatabase.pop
def pop(self, key, default=_marker): """remove the item by key If not default is specified, raise KeyError if nothing could be removed. Return 'default' if specified and nothing could be removed """ try: popped = self[key] del self[key] ...
python
def pop(self, key, default=_marker): """remove the item by key If not default is specified, raise KeyError if nothing could be removed. Return 'default' if specified and nothing could be removed """ try: popped = self[key] del self[key] ...
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "_marker", ")", ":", "try", ":", "popped", "=", "self", "[", "key", "]", "del", "self", "[", "key", "]", "return", "popped", "except", "KeyError", ":", "if", "default", "==", "_marker", ":...
remove the item by key If not default is specified, raise KeyError if nothing could be removed. Return 'default' if specified and nothing could be removed
[ "remove", "the", "item", "by", "key", "If", "not", "default", "is", "specified", "raise", "KeyError", "if", "nothing", "could", "be", "removed", ".", "Return", "default", "if", "specified", "and", "nothing", "could", "be", "removed" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L451-L464
mozilla/crontabber
crontabber/app.py
CronTabberBase.nagios
def nagios(self, stream=sys.stdout): """ return 0 (OK) if there are no errors in the state. return 1 (WARNING) if a backfill app only has 1 error. return 2 (CRITICAL) if a backfill app has > 1 error. return 2 (CRITICAL) if a non-backfill app has 1 error. """ warni...
python
def nagios(self, stream=sys.stdout): """ return 0 (OK) if there are no errors in the state. return 1 (WARNING) if a backfill app only has 1 error. return 2 (CRITICAL) if a backfill app has > 1 error. return 2 (CRITICAL) if a non-backfill app has 1 error. """ warni...
[ "def", "nagios", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "warnings", "=", "[", "]", "criticals", "=", "[", "]", "for", "class_name", ",", "job_class", "in", "self", ".", "config", ".", "crontabber", ".", "jobs", ".", "class_l...
return 0 (OK) if there are no errors in the state. return 1 (WARNING) if a backfill app only has 1 error. return 2 (CRITICAL) if a backfill app has > 1 error. return 2 (CRITICAL) if a non-backfill app has 1 error.
[ "return", "0", "(", "OK", ")", "if", "there", "are", "no", "errors", "in", "the", "state", ".", "return", "1", "(", "WARNING", ")", "if", "a", "backfill", "app", "only", "has", "1", "error", ".", "return", "2", "(", "CRITICAL", ")", "if", "a", "b...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L876-L921
mozilla/crontabber
crontabber/app.py
CronTabberBase.reset_job
def reset_job(self, description): """remove the job from the state. if means that next time we run, this job will start over from scratch. """ class_list = self.config.crontabber.jobs.class_list class_list = self._reorder_class_list(class_list) for class_name, job_class i...
python
def reset_job(self, description): """remove the job from the state. if means that next time we run, this job will start over from scratch. """ class_list = self.config.crontabber.jobs.class_list class_list = self._reorder_class_list(class_list) for class_name, job_class i...
[ "def", "reset_job", "(", "self", ",", "description", ")", ":", "class_list", "=", "self", ".", "config", ".", "crontabber", ".", "jobs", ".", "class_list", "class_list", "=", "self", ".", "_reorder_class_list", "(", "class_list", ")", "for", "class_name", ",...
remove the job from the state. if means that next time we run, this job will start over from scratch.
[ "remove", "the", "job", "from", "the", "state", ".", "if", "means", "that", "next", "time", "we", "run", "this", "job", "will", "start", "over", "from", "scratch", "." ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L987-L1004
mozilla/crontabber
crontabber/app.py
CronTabberBase.time_to_run
def time_to_run(self, class_, time_): """return true if it's time to run the job. This is true if there is no previous information about its last run or if the last time it ran and set its next_run to a date that is now past. """ app_name = class_.app_name try: ...
python
def time_to_run(self, class_, time_): """return true if it's time to run the job. This is true if there is no previous information about its last run or if the last time it ran and set its next_run to a date that is now past. """ app_name = class_.app_name try: ...
[ "def", "time_to_run", "(", "self", ",", "class_", ",", "time_", ")", ":", "app_name", "=", "class_", ".", "app_name", "try", ":", "info", "=", "self", ".", "job_state_database", "[", "app_name", "]", "except", "KeyError", ":", "if", "time_", ":", "h", ...
return true if it's time to run the job. This is true if there is no previous information about its last run or if the last time it ran and set its next_run to a date that is now past.
[ "return", "true", "if", "it", "s", "time", "to", "run", "the", "job", ".", "This", "is", "true", "if", "there", "is", "no", "previous", "information", "about", "its", "last", "run", "or", "if", "the", "last", "time", "it", "ran", "and", "set", "its",...
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L1195-L1232
mozilla/crontabber
crontabber/app.py
CronTabberBase.audit_ghosts
def audit_ghosts(self): """compare the list of configured jobs with the jobs in the state""" print_header = True for app_name in self._get_ghosts(): if print_header: print_header = False print ( "Found the following in the state dat...
python
def audit_ghosts(self): """compare the list of configured jobs with the jobs in the state""" print_header = True for app_name in self._get_ghosts(): if print_header: print_header = False print ( "Found the following in the state dat...
[ "def", "audit_ghosts", "(", "self", ")", ":", "print_header", "=", "True", "for", "app_name", "in", "self", ".", "_get_ghosts", "(", ")", ":", "if", "print_header", ":", "print_header", "=", "False", "print", "(", "\"Found the following in the state database but n...
compare the list of configured jobs with the jobs in the state
[ "compare", "the", "list", "of", "configured", "jobs", "with", "the", "jobs", "in", "the", "state" ]
train
https://github.com/mozilla/crontabber/blob/b510be349e71f165c1a9506db95bda0b88728f8b/crontabber/app.py#L1385-L1395
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.export_js
def export_js( self, js_module_name=JS_MODULE_NAME, js_template=JS_ES6_IMPORT_EXPORT_TEMPLATE, js_indent=JS_INDENTATION): '''Export the grammar to a JavaScript file which can be used with the js-lrparsing module. Two templates are available: ...
python
def export_js( self, js_module_name=JS_MODULE_NAME, js_template=JS_ES6_IMPORT_EXPORT_TEMPLATE, js_indent=JS_INDENTATION): '''Export the grammar to a JavaScript file which can be used with the js-lrparsing module. Two templates are available: ...
[ "def", "export_js", "(", "self", ",", "js_module_name", "=", "JS_MODULE_NAME", ",", "js_template", "=", "JS_ES6_IMPORT_EXPORT_TEMPLATE", ",", "js_indent", "=", "JS_INDENTATION", ")", ":", "language", "=", "[", "]", "refs", "=", "[", "]", "classes", "=", "{", ...
Export the grammar to a JavaScript file which can be used with the js-lrparsing module. Two templates are available: Grammar.JS_WINDOW_TEMPLATE Grammar.JS_ES6_IMPORT_EXPORT_TEMPLATE (default)
[ "Export", "the", "grammar", "to", "a", "JavaScript", "file", "which", "can", "be", "used", "with", "the", "js", "-", "lrparsing", "module", "." ]
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L341-L402
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.export_py
def export_py( self, py_module_name=PY_MODULE_NAME, py_template=PY_TEMPLATE, py_indent=PY_INDENTATION): '''Export the grammar to a python file which can be used with the pyleri module. This can be useful when python code if used to auto-create a gr...
python
def export_py( self, py_module_name=PY_MODULE_NAME, py_template=PY_TEMPLATE, py_indent=PY_INDENTATION): '''Export the grammar to a python file which can be used with the pyleri module. This can be useful when python code if used to auto-create a gr...
[ "def", "export_py", "(", "self", ",", "py_module_name", "=", "PY_MODULE_NAME", ",", "py_template", "=", "PY_TEMPLATE", ",", "py_indent", "=", "PY_INDENTATION", ")", ":", "language", "=", "[", "]", "classes", "=", "{", "'Grammar'", "}", "indent", "=", "0", ...
Export the grammar to a python file which can be used with the pyleri module. This can be useful when python code if used to auto-create a grammar and an export of the final result is required.
[ "Export", "the", "grammar", "to", "a", "python", "file", "which", "can", "be", "used", "with", "the", "pyleri", "module", ".", "This", "can", "be", "useful", "when", "python", "code", "if", "used", "to", "auto", "-", "create", "a", "grammar", "and", "a...
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L404-L450
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.export_c
def export_c(self, target=C_TARGET, c_indent=C_INDENTATION, headerf=None): '''Export the grammar to a c (source and header) file which can be used with the libcleri module.''' language = [] indent = 0 enums = set() for name in self._order: elem = getattr(self,...
python
def export_c(self, target=C_TARGET, c_indent=C_INDENTATION, headerf=None): '''Export the grammar to a c (source and header) file which can be used with the libcleri module.''' language = [] indent = 0 enums = set() for name in self._order: elem = getattr(self,...
[ "def", "export_c", "(", "self", ",", "target", "=", "C_TARGET", ",", "c_indent", "=", "C_INDENTATION", ",", "headerf", "=", "None", ")", ":", "language", "=", "[", "]", "indent", "=", "0", "enums", "=", "set", "(", ")", "for", "name", "in", "self", ...
Export the grammar to a c (source and header) file which can be used with the libcleri module.
[ "Export", "the", "grammar", "to", "a", "c", "(", "source", "and", "header", ")", "file", "which", "can", "be", "used", "with", "the", "libcleri", "module", "." ]
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L452-L514
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.export_go
def export_go( self, go_template=GO_TEMPLATE, go_indent=GO_INDENTATION, go_package=GO_PACKAGE): '''Export the grammar to a Go file which can be used with the goleri module.''' language = [] enums = set() indent = 0 pattern ...
python
def export_go( self, go_template=GO_TEMPLATE, go_indent=GO_INDENTATION, go_package=GO_PACKAGE): '''Export the grammar to a Go file which can be used with the goleri module.''' language = [] enums = set() indent = 0 pattern ...
[ "def", "export_go", "(", "self", ",", "go_template", "=", "GO_TEMPLATE", ",", "go_indent", "=", "GO_INDENTATION", ",", "go_package", "=", "GO_PACKAGE", ")", ":", "language", "=", "[", "]", "enums", "=", "set", "(", ")", "indent", "=", "0", "pattern", "="...
Export the grammar to a Go file which can be used with the goleri module.
[ "Export", "the", "grammar", "to", "a", "Go", "file", "which", "can", "be", "used", "with", "the", "goleri", "module", "." ]
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L516-L564
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.export_java
def export_java( self, java_template=JAVA_TEMPLATE, java_indent=JAVA_INDENTATION, java_package=JAVA_PACKAGE, is_public=True): '''Export the grammar to a Java file which can be used with the jleri module.''' language = [] enums ...
python
def export_java( self, java_template=JAVA_TEMPLATE, java_indent=JAVA_INDENTATION, java_package=JAVA_PACKAGE, is_public=True): '''Export the grammar to a Java file which can be used with the jleri module.''' language = [] enums ...
[ "def", "export_java", "(", "self", ",", "java_template", "=", "JAVA_TEMPLATE", ",", "java_indent", "=", "JAVA_INDENTATION", ",", "java_package", "=", "JAVA_PACKAGE", ",", "is_public", "=", "True", ")", ":", "language", "=", "[", "]", "enums", "=", "set", "("...
Export the grammar to a Java file which can be used with the jleri module.
[ "Export", "the", "grammar", "to", "a", "Java", "file", "which", "can", "be", "used", "with", "the", "jleri", "module", "." ]
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L566-L630
transceptor-technology/pyleri
pyleri/grammar.py
Grammar.parse
def parse(self, string): '''Parse some string to the Grammar. Returns a nodeResult with the following attributes: - is_valid: True when the string is successfully parsed by the Grammar. - pos: position in the string where parsing ended. (this is th...
python
def parse(self, string): '''Parse some string to the Grammar. Returns a nodeResult with the following attributes: - is_valid: True when the string is successfully parsed by the Grammar. - pos: position in the string where parsing ended. (this is th...
[ "def", "parse", "(", "self", ",", "string", ")", ":", "self", ".", "_string", "=", "string", "self", ".", "_expecting", "=", "Expecting", "(", ")", "self", ".", "_cached_kw_match", ".", "clear", "(", ")", "self", ".", "_len_string", "=", "len", "(", ...
Parse some string to the Grammar. Returns a nodeResult with the following attributes: - is_valid: True when the string is successfully parsed by the Grammar. - pos: position in the string where parsing ended. (this is the end of the string when is_valid is...
[ "Parse", "some", "string", "to", "the", "Grammar", "." ]
train
https://github.com/transceptor-technology/pyleri/blob/af754300d42a5a79bcdfc7852ee4cc75ce245f39/pyleri/grammar.py#L632-L678
cheind/tf-matplotlib
tfmpl/figure.py
figure_buffer
def figure_buffer(figs): '''Extract raw image buffer from matplotlib figure shaped as 1xHxWx3.''' assert len(figs) > 0, 'No figure buffers given. Forgot to return from draw call?' buffers = [] w, h = figs[0].canvas.get_width_height() for f in figs: wf, hf = f.canvas.get_width_height() ...
python
def figure_buffer(figs): '''Extract raw image buffer from matplotlib figure shaped as 1xHxWx3.''' assert len(figs) > 0, 'No figure buffers given. Forgot to return from draw call?' buffers = [] w, h = figs[0].canvas.get_width_height() for f in figs: wf, hf = f.canvas.get_width_height() ...
[ "def", "figure_buffer", "(", "figs", ")", ":", "assert", "len", "(", "figs", ")", ">", "0", ",", "'No figure buffers given. Forgot to return from draw call?'", "buffers", "=", "[", "]", "w", ",", "h", "=", "figs", "[", "0", "]", ".", "canvas", ".", "get_wi...
Extract raw image buffer from matplotlib figure shaped as 1xHxWx3.
[ "Extract", "raw", "image", "buffer", "from", "matplotlib", "figure", "shaped", "as", "1xHxWx3", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/figure.py#L14-L24
cheind/tf-matplotlib
tfmpl/figure.py
figure_tensor
def figure_tensor(func, **tf_pyfunc_kwargs): '''Decorate matplotlib drawing routines. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) -> figure or iterable of figures w...
python
def figure_tensor(func, **tf_pyfunc_kwargs): '''Decorate matplotlib drawing routines. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) -> figure or iterable of figures w...
[ "def", "figure_tensor", "(", "func", ",", "*", "*", "tf_pyfunc_kwargs", ")", ":", "name", "=", "tf_pyfunc_kwargs", ".", "pop", "(", "'name'", ",", "func", ".", "__name__", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "func_args", ",...
Decorate matplotlib drawing routines. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) -> figure or iterable of figures where `*args` can be any positional argument and `**k...
[ "Decorate", "matplotlib", "drawing", "routines", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/figure.py#L27-L64
cheind/tf-matplotlib
tfmpl/figure.py
blittable_figure_tensor
def blittable_figure_tensor(func, init_func, **tf_pyfunc_kwargs): '''Decorate matplotlib drawing routines with blitting support. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) ...
python
def blittable_figure_tensor(func, init_func, **tf_pyfunc_kwargs): '''Decorate matplotlib drawing routines with blitting support. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) ...
[ "def", "blittable_figure_tensor", "(", "func", ",", "init_func", ",", "*", "*", "tf_pyfunc_kwargs", ")", ":", "name", "=", "tf_pyfunc_kwargs", ".", "pop", "(", "'name'", ",", "func", ".", "__name__", ")", "assert", "callable", "(", "init_func", ")", ",", "...
Decorate matplotlib drawing routines with blitting support. This dectorator is meant to decorate functions that return matplotlib figures. The decorated function has to have the following signature def decorated(*args, **kwargs) -> iterable of artists where `*args` can be any positional argum...
[ "Decorate", "matplotlib", "drawing", "routines", "with", "blitting", "support", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/figure.py#L67-L139
cheind/tf-matplotlib
tfmpl/samples/mnist.py
draw_confusion_matrix
def draw_confusion_matrix(matrix): '''Draw confusion matrix for MNIST.''' fig = tfmpl.create_figure(figsize=(7,7)) ax = fig.add_subplot(111) ax.set_title('Confusion matrix for MNIST classification') tfmpl.plots.confusion_matrix.draw( ax, matrix, axis_labels=['Digit ' + str(x) fo...
python
def draw_confusion_matrix(matrix): '''Draw confusion matrix for MNIST.''' fig = tfmpl.create_figure(figsize=(7,7)) ax = fig.add_subplot(111) ax.set_title('Confusion matrix for MNIST classification') tfmpl.plots.confusion_matrix.draw( ax, matrix, axis_labels=['Digit ' + str(x) fo...
[ "def", "draw_confusion_matrix", "(", "matrix", ")", ":", "fig", "=", "tfmpl", ".", "create_figure", "(", "figsize", "=", "(", "7", ",", "7", ")", ")", "ax", "=", "fig", ".", "add_subplot", "(", "111", ")", "ax", ".", "set_title", "(", "'Confusion matri...
Draw confusion matrix for MNIST.
[ "Draw", "confusion", "matrix", "for", "MNIST", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/samples/mnist.py#L24-L36
cheind/tf-matplotlib
tfmpl/plots/confusion_matrix.py
from_labels_and_predictions
def from_labels_and_predictions(labels, predictions, num_classes): '''Compute a confusion matrix from labels and predictions. A drop-in replacement for tf.confusion_matrix that works on CPU data and not tensors. Params ------ labels : array-like 1-D array of real labels for classi...
python
def from_labels_and_predictions(labels, predictions, num_classes): '''Compute a confusion matrix from labels and predictions. A drop-in replacement for tf.confusion_matrix that works on CPU data and not tensors. Params ------ labels : array-like 1-D array of real labels for classi...
[ "def", "from_labels_and_predictions", "(", "labels", ",", "predictions", ",", "num_classes", ")", ":", "assert", "len", "(", "labels", ")", "==", "len", "(", "predictions", ")", "cm", "=", "np", ".", "zeros", "(", "(", "num_classes", ",", "num_classes", ")...
Compute a confusion matrix from labels and predictions. A drop-in replacement for tf.confusion_matrix that works on CPU data and not tensors. Params ------ labels : array-like 1-D array of real labels for classification predicitions: array-like 1-D array of predicted label...
[ "Compute", "a", "confusion", "matrix", "from", "labels", "and", "predictions", ".", "A", "drop", "-", "in", "replacement", "for", "tf", ".", "confusion_matrix", "that", "works", "on", "CPU", "data", "and", "not", "tensors", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/plots/confusion_matrix.py#L11-L35
cheind/tf-matplotlib
tfmpl/plots/confusion_matrix.py
draw
def draw(ax, cm, axis_labels=None, normalize=False): '''Plot a confusion matrix. Inspired by https://stackoverflow.com/questions/41617463/tensorflow-confusion-matrix-in-tensorboard Params ------ ax : axis Axis to plot on cm : NxN array Confusion matrix Kwargs -...
python
def draw(ax, cm, axis_labels=None, normalize=False): '''Plot a confusion matrix. Inspired by https://stackoverflow.com/questions/41617463/tensorflow-confusion-matrix-in-tensorboard Params ------ ax : axis Axis to plot on cm : NxN array Confusion matrix Kwargs -...
[ "def", "draw", "(", "ax", ",", "cm", ",", "axis_labels", "=", "None", ",", "normalize", "=", "False", ")", ":", "cm", "=", "np", ".", "asarray", "(", "cm", ")", "num_classes", "=", "cm", ".", "shape", "[", "0", "]", "if", "normalize", ":", "with"...
Plot a confusion matrix. Inspired by https://stackoverflow.com/questions/41617463/tensorflow-confusion-matrix-in-tensorboard Params ------ ax : axis Axis to plot on cm : NxN array Confusion matrix Kwargs ------ axis_labels : array-like Array of size N c...
[ "Plot", "a", "confusion", "matrix", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/plots/confusion_matrix.py#L37-L98
cheind/tf-matplotlib
tfmpl/create.py
create_figure
def create_figure(*fig_args, **fig_kwargs): '''Create a single figure. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in th...
python
def create_figure(*fig_args, **fig_kwargs): '''Create a single figure. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in th...
[ "def", "create_figure", "(", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", ":", "fig", "=", "Figure", "(", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", "# Attach canvas", "FigureCanvas", "(", "fig", ")", "return", "fig" ]
Create a single figure. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in their respective thread, avoid usage of pyplot wh...
[ "Create", "a", "single", "figure", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/create.py#L9-L23
cheind/tf-matplotlib
tfmpl/create.py
create_figures
def create_figures(n, *fig_args, **fig_kwargs): '''Create multiple figures. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs ...
python
def create_figures(n, *fig_args, **fig_kwargs): '''Create multiple figures. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs ...
[ "def", "create_figures", "(", "n", ",", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", ":", "return", "[", "create_figure", "(", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", "for", "_", "in", "range", "(", "n", ")", "]" ]
Create multiple figures. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in their respective thread, avoid usage of pyplot w...
[ "Create", "multiple", "figures", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/create.py#L25-L35
cheind/tf-matplotlib
tfmpl/meta.py
vararg_decorator
def vararg_decorator(f): '''Decorator to handle variable argument decorators.''' @wraps(f) def decorator(*args, **kwargs): if len(args) == 1 and len(kwargs) == 0 and callable(args[0]): return f(args[0]) else: return lambda realf: f(realf, *args, **kwargs) return...
python
def vararg_decorator(f): '''Decorator to handle variable argument decorators.''' @wraps(f) def decorator(*args, **kwargs): if len(args) == 1 and len(kwargs) == 0 and callable(args[0]): return f(args[0]) else: return lambda realf: f(realf, *args, **kwargs) return...
[ "def", "vararg_decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "len", "(", "kwargs", ")", "==", "0", "and", ...
Decorator to handle variable argument decorators.
[ "Decorator", "to", "handle", "variable", "argument", "decorators", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/meta.py#L11-L21
cheind/tf-matplotlib
tfmpl/meta.py
as_list
def as_list(x): '''Ensure `x` is of list type.''' if x is None: x = [] elif not isinstance(x, Sequence): x = [x] return list(x)
python
def as_list(x): '''Ensure `x` is of list type.''' if x is None: x = [] elif not isinstance(x, Sequence): x = [x] return list(x)
[ "def", "as_list", "(", "x", ")", ":", "if", "x", "is", "None", ":", "x", "=", "[", "]", "elif", "not", "isinstance", "(", "x", ",", "Sequence", ")", ":", "x", "=", "[", "x", "]", "return", "list", "(", "x", ")" ]
Ensure `x` is of list type.
[ "Ensure", "x", "is", "of", "list", "type", "." ]
train
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/meta.py#L40-L47
yakupadakli/python-unsplash
unsplash/photo.py
Photo.all
def all(self, page=1, per_page=10, order_by="latest"): """ Get a single page from the list of all photos. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :param order_by [string]:...
python
def all(self, page=1, per_page=10, order_by="latest"): """ Get a single page from the list of all photos. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :param order_by [string]:...
[ "def", "all", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ",", "order_by", "=", "\"latest\"", ")", ":", "return", "self", ".", "_all", "(", "\"/photos\"", ",", "page", "=", "page", ",", "per_page", "=", "per_page", ",", "order_by"...
Get a single page from the list of all photos. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :param order_by [string]: How to sort the photos. Optional. (Valid values: latest, oldest, p...
[ "Get", "a", "single", "page", "from", "the", "list", "of", "all", "photos", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L34-L44
yakupadakli/python-unsplash
unsplash/photo.py
Photo.curated
def curated(self, page=1, per_page=10, order_by="latest"): """ Get a single page from the list of the curated photos (front-page’s photos). :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10)...
python
def curated(self, page=1, per_page=10, order_by="latest"): """ Get a single page from the list of the curated photos (front-page’s photos). :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10)...
[ "def", "curated", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ",", "order_by", "=", "\"latest\"", ")", ":", "return", "self", ".", "_all", "(", "\"/photos/curated\"", ",", "page", "=", "page", ",", "per_page", "=", "per_page", ",", ...
Get a single page from the list of the curated photos (front-page’s photos). :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :param order_by [string]: How to sort the photos. Optional. (V...
[ "Get", "a", "single", "page", "from", "the", "list", "of", "the", "curated", "photos", "(", "front", "-", "page’s", "photos", ")", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L46-L56
yakupadakli/python-unsplash
unsplash/photo.py
Photo.get
def get(self, photo_id, width=None, height=None, rect=None): """ Retrieve a single photo. Note: Supplying the optional w or h parameters will result in the custom photo URL being added to the 'urls' object: :param photo_id [string]: The photo’s ID. Required. :param widt...
python
def get(self, photo_id, width=None, height=None, rect=None): """ Retrieve a single photo. Note: Supplying the optional w or h parameters will result in the custom photo URL being added to the 'urls' object: :param photo_id [string]: The photo’s ID. Required. :param widt...
[ "def", "get", "(", "self", ",", "photo_id", ",", "width", "=", "None", ",", "height", "=", "None", ",", "rect", "=", "None", ")", ":", "url", "=", "\"/photos/%s\"", "%", "photo_id", "params", "=", "{", "\"w\"", ":", "width", ",", "\"h\"", ":", "hei...
Retrieve a single photo. Note: Supplying the optional w or h parameters will result in the custom photo URL being added to the 'urls' object: :param photo_id [string]: The photo’s ID. Required. :param width [integer]: Image width in pixels. :param height [integer]: Image height...
[ "Retrieve", "a", "single", "photo", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L58-L78
yakupadakli/python-unsplash
unsplash/photo.py
Photo.search
def search(self, query, category=None, orientation=None, page=1, per_page=10): """ Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s. Note: If supplying multiple category ID’s, the resulting photos will be t...
python
def search(self, query, category=None, orientation=None, page=1, per_page=10): """ Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s. Note: If supplying multiple category ID’s, the resulting photos will be t...
[ "def", "search", "(", "self", ",", "query", ",", "category", "=", "None", ",", "orientation", "=", "None", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "if", "orientation", "and", "orientation", "not", "in", "self", ".", "orientation_va...
Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s. Note: If supplying multiple category ID’s, the resulting photos will be those that match all of the given categories, not ones that match any category. :pa...
[ "Get", "a", "single", "page", "from", "a", "photo", "search", ".", "Optionally", "limit", "your", "search", "to", "a", "set", "of", "categories", "by", "supplying", "the", "category", "ID’s", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L80-L109
yakupadakli/python-unsplash
unsplash/photo.py
Photo.random
def random(self, count=1, **kwargs): """ Retrieve a single random photo, given optional filters. Note: If supplying multiple category ID’s, the resulting photos will be those that match all of the given categories, not ones that match any category. Note: You can’t use t...
python
def random(self, count=1, **kwargs): """ Retrieve a single random photo, given optional filters. Note: If supplying multiple category ID’s, the resulting photos will be those that match all of the given categories, not ones that match any category. Note: You can’t use t...
[ "def", "random", "(", "self", ",", "count", "=", "1", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "\"count\"", ":", "count", "}", ")", "orientation", "=", "kwargs", ".", "get", "(", "\"orientation\"", ",", "None", ")", "if...
Retrieve a single random photo, given optional filters. Note: If supplying multiple category ID’s, the resulting photos will be those that match all of the given categories, not ones that match any category. Note: You can’t use the collections and query parameters in the same request ...
[ "Retrieve", "a", "single", "random", "photo", "given", "optional", "filters", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L111-L147
yakupadakli/python-unsplash
unsplash/photo.py
Photo.stats
def stats(self, photo_id): """ Retrieve a single photo’s stats. :param photo_id [string]: The photo’s ID. Required. :return: [Stat]: The Unsplash Stat. """ url = "/photos/%s/stats" % photo_id result = self._get(url) return StatModel.parse(result)
python
def stats(self, photo_id): """ Retrieve a single photo’s stats. :param photo_id [string]: The photo’s ID. Required. :return: [Stat]: The Unsplash Stat. """ url = "/photos/%s/stats" % photo_id result = self._get(url) return StatModel.parse(result)
[ "def", "stats", "(", "self", ",", "photo_id", ")", ":", "url", "=", "\"/photos/%s/stats\"", "%", "photo_id", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "StatModel", ".", "parse", "(", "result", ")" ]
Retrieve a single photo’s stats. :param photo_id [string]: The photo’s ID. Required. :return: [Stat]: The Unsplash Stat.
[ "Retrieve", "a", "single", "photo’s", "stats", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L149-L158
yakupadakli/python-unsplash
unsplash/photo.py
Photo.like
def like(self, photo_id): """ Like a photo on behalf of the logged-in user. This requires the 'write_likes' scope. Note: This action is idempotent; sending the POST request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ...
python
def like(self, photo_id): """ Like a photo on behalf of the logged-in user. This requires the 'write_likes' scope. Note: This action is idempotent; sending the POST request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ...
[ "def", "like", "(", "self", ",", "photo_id", ")", ":", "url", "=", "\"/photos/%s/like\"", "%", "photo_id", "result", "=", "self", ".", "_post", "(", "url", ")", "return", "PhotoModel", ".", "parse", "(", "result", ")" ]
Like a photo on behalf of the logged-in user. This requires the 'write_likes' scope. Note: This action is idempotent; sending the POST request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ID. Required. :return: [Photo]: The Un...
[ "Like", "a", "photo", "on", "behalf", "of", "the", "logged", "-", "in", "user", ".", "This", "requires", "the", "write_likes", "scope", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L179-L192
yakupadakli/python-unsplash
unsplash/photo.py
Photo.unlike
def unlike(self, photo_id): """ Remove a user’s like of a photo. Note: This action is idempotent; sending the DELETE request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ID. Required. :return: [Photo]: The Unsplash Pho...
python
def unlike(self, photo_id): """ Remove a user’s like of a photo. Note: This action is idempotent; sending the DELETE request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ID. Required. :return: [Photo]: The Unsplash Pho...
[ "def", "unlike", "(", "self", ",", "photo_id", ")", ":", "url", "=", "\"/photos/%s/like\"", "%", "photo_id", "result", "=", "self", ".", "_delete", "(", "url", ")", "return", "PhotoModel", ".", "parse", "(", "result", ")" ]
Remove a user’s like of a photo. Note: This action is idempotent; sending the DELETE request to a single photo multiple times has no additional effect. :param photo_id [string]: The photo’s ID. Required. :return: [Photo]: The Unsplash Photo.
[ "Remove", "a", "user’s", "like", "of", "a", "photo", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L194-L206
yakupadakli/python-unsplash
unsplash/search.py
Search.photos
def photos(self, query, page=1, per_page=10): """ Get a single page of photo results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: ...
python
def photos(self, query, page=1, per_page=10): """ Get a single page of photo results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: ...
[ "def", "photos", "(", "self", ",", "query", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/search/photos\"", "data", "=", "self", ".", "_search", "(", "url", ",", "query", ",", "page", "=", "page", ",", "per_page", "="...
Get a single page of photo results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [dict]: {u'total': 0, u'total_pages': 0, u're...
[ "Get", "a", "single", "page", "of", "photo", "results", "for", "a", "query", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/search.py#L19-L31
yakupadakli/python-unsplash
unsplash/search.py
Search.collections
def collections(self, query, page=1, per_page=10): """ Get a single page of collection results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional;...
python
def collections(self, query, page=1, per_page=10): """ Get a single page of collection results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional;...
[ "def", "collections", "(", "self", ",", "query", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/search/collections\"", "data", "=", "self", ".", "_search", "(", "url", ",", "query", ",", "page", "=", "page", ",", "per_pa...
Get a single page of collection results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [dict]: {u'total': 0, u'total_pages': 0,...
[ "Get", "a", "single", "page", "of", "collection", "results", "for", "a", "query", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/search.py#L33-L45
yakupadakli/python-unsplash
unsplash/search.py
Search.users
def users(self, query, page=1, per_page=10): """ Get a single page of user results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10...
python
def users(self, query, page=1, per_page=10): """ Get a single page of user results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10...
[ "def", "users", "(", "self", ",", "query", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/search/users\"", "data", "=", "self", ".", "_search", "(", "url", ",", "query", ",", "page", "=", "page", ",", "per_page", "=", ...
Get a single page of user results for a query. :param query [string]: Search terms. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [dict]: {u'total': 0, u'total_pages': 0, u'res...
[ "Get", "a", "single", "page", "of", "user", "results", "for", "a", "query", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/search.py#L47-L59
yakupadakli/python-unsplash
unsplash/collection.py
Collection.all
def all(self, page=1, per_page=10): """ Get a single page from the list of all collections. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [Array]: A single page of the ...
python
def all(self, page=1, per_page=10): """ Get a single page from the list of all collections. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [Array]: A single page of the ...
[ "def", "all", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/collections\"", "result", "=", "self", ".", "_all", "(", "url", ",", "page", "=", "page", ",", "per_page", "=", "per_page", ")", "return", "Coll...
Get a single page from the list of all collections. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [Array]: A single page of the Collection list.
[ "Get", "a", "single", "page", "from", "the", "list", "of", "all", "collections", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L29-L39
yakupadakli/python-unsplash
unsplash/collection.py
Collection.get
def get(self, collection_id): """ Retrieve a single collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection. """ url ...
python
def get(self, collection_id): """ Retrieve a single collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection. """ url ...
[ "def", "get", "(", "self", ",", "collection_id", ")", ":", "url", "=", "\"/collections/%s\"", "%", "collection_id", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "CollectionModel", ".", "parse", "(", "result", ")" ]
Retrieve a single collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection.
[ "Retrieve", "a", "single", "collection", ".", "To", "view", "a", "user’s", "private", "collections", "the", "read_collections", "scope", "is", "required", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L65-L75
yakupadakli/python-unsplash
unsplash/collection.py
Collection.get_curated
def get_curated(self, collection_id): """ Retrieve a single curated collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection. ...
python
def get_curated(self, collection_id): """ Retrieve a single curated collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection. ...
[ "def", "get_curated", "(", "self", ",", "collection_id", ")", ":", "url", "=", "\"/collections/curated/%s\"", "%", "collection_id", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "CollectionModel", ".", "parse", "(", "result", ")" ]
Retrieve a single curated collection. To view a user’s private collections, the 'read_collections' scope is required. :param collection_id [string]: The collections’s ID. Required. :return: [Collection]: The Unsplash Collection.
[ "Retrieve", "a", "single", "curated", "collection", ".", "To", "view", "a", "user’s", "private", "collections", "the", "read_collections", "scope", "is", "required", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L77-L87
yakupadakli/python-unsplash
unsplash/collection.py
Collection.photos
def photos(self, collection_id, page=1, per_page=10): """ Retrieve a collection’s photos. :param collection_id [string]: The collection’s ID. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Op...
python
def photos(self, collection_id, page=1, per_page=10): """ Retrieve a collection’s photos. :param collection_id [string]: The collection’s ID. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Op...
[ "def", "photos", "(", "self", ",", "collection_id", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/collections/%s/photos\"", "%", "collection_id", "result", "=", "self", ".", "_all", "(", "url", ",", "page", "=", "page", "...
Retrieve a collection’s photos. :param collection_id [string]: The collection’s ID. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [Array]: A single page of the Photo ...
[ "Retrieve", "a", "collection’s", "photos", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L89-L100
yakupadakli/python-unsplash
unsplash/collection.py
Collection.related
def related(self, collection_id): """ Retrieve a list of collections related to this one. :param collection_id [string]: The collection’s ID. Required. :return: [Array]: A single page of the Collection list. """ url = "/collections/%s/related" % collection_id res...
python
def related(self, collection_id): """ Retrieve a list of collections related to this one. :param collection_id [string]: The collection’s ID. Required. :return: [Array]: A single page of the Collection list. """ url = "/collections/%s/related" % collection_id res...
[ "def", "related", "(", "self", ",", "collection_id", ")", ":", "url", "=", "\"/collections/%s/related\"", "%", "collection_id", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "CollectionModel", ".", "parse_list", "(", "result", ")" ]
Retrieve a list of collections related to this one. :param collection_id [string]: The collection’s ID. Required. :return: [Array]: A single page of the Collection list.
[ "Retrieve", "a", "list", "of", "collections", "related", "to", "this", "one", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L115-L124
yakupadakli/python-unsplash
unsplash/collection.py
Collection.create
def create(self, title, description=None, private=False): """ Create a new collection. This requires the 'write_collections' scope. :param title [string]: The title of the collection. (Required.) :param description [string]: The collection’s description. (Optional.) :par...
python
def create(self, title, description=None, private=False): """ Create a new collection. This requires the 'write_collections' scope. :param title [string]: The title of the collection. (Required.) :param description [string]: The collection’s description. (Optional.) :par...
[ "def", "create", "(", "self", ",", "title", ",", "description", "=", "None", ",", "private", "=", "False", ")", ":", "url", "=", "\"/collections\"", "data", "=", "{", "\"title\"", ":", "title", ",", "\"description\"", ":", "description", ",", "\"private\""...
Create a new collection. This requires the 'write_collections' scope. :param title [string]: The title of the collection. (Required.) :param description [string]: The collection’s description. (Optional.) :param private [boolean]: Whether to make this collection private. (Optional; defa...
[ "Create", "a", "new", "collection", ".", "This", "requires", "the", "write_collections", "scope", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L126-L143
yakupadakli/python-unsplash
unsplash/collection.py
Collection.update
def update(self, collection_id, title=None, description=None, private=False): """ Update an existing collection belonging to the logged-in user. This requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param title [string]: The ...
python
def update(self, collection_id, title=None, description=None, private=False): """ Update an existing collection belonging to the logged-in user. This requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param title [string]: The ...
[ "def", "update", "(", "self", ",", "collection_id", ",", "title", "=", "None", ",", "description", "=", "None", ",", "private", "=", "False", ")", ":", "url", "=", "\"/collections/%s\"", "%", "collection_id", "data", "=", "{", "\"title\"", ":", "title", ...
Update an existing collection belonging to the logged-in user. This requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param title [string]: The title of the collection. (Required.) :param description [string]: The collection’s descrip...
[ "Update", "an", "existing", "collection", "belonging", "to", "the", "logged", "-", "in", "user", ".", "This", "requires", "the", "write_collections", "scope", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L145-L163
yakupadakli/python-unsplash
unsplash/collection.py
Collection.add_photo
def add_photo(self, collection_id, photo_id): """ Add a photo to one of the logged-in user’s collections. Requires the 'write_collections' scope. Note: If the photo is already in the collection, this acion has no effect. :param collection_id [string]: The collection’s ID. Requi...
python
def add_photo(self, collection_id, photo_id): """ Add a photo to one of the logged-in user’s collections. Requires the 'write_collections' scope. Note: If the photo is already in the collection, this acion has no effect. :param collection_id [string]: The collection’s ID. Requi...
[ "def", "add_photo", "(", "self", ",", "collection_id", ",", "photo_id", ")", ":", "url", "=", "\"/collections/%s/add\"", "%", "collection_id", "data", "=", "{", "\"collection_id\"", ":", "collection_id", ",", "\"photo_id\"", ":", "photo_id", "}", "result", "=", ...
Add a photo to one of the logged-in user’s collections. Requires the 'write_collections' scope. Note: If the photo is already in the collection, this acion has no effect. :param collection_id [string]: The collection’s ID. Required. :param photo_id [string]: The photo’s ID. Required. ...
[ "Add", "a", "photo", "to", "one", "of", "the", "logged", "-", "in", "user’s", "collections", ".", "Requires", "the", "write_collections", "scope", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L176-L193
yakupadakli/python-unsplash
unsplash/collection.py
Collection.remove_photo
def remove_photo(self, collection_id, photo_id): """ Remove a photo from one of the logged-in user’s collections. Requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param photo_id [string]: The photo’s ID. Required. :re...
python
def remove_photo(self, collection_id, photo_id): """ Remove a photo from one of the logged-in user’s collections. Requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param photo_id [string]: The photo’s ID. Required. :re...
[ "def", "remove_photo", "(", "self", ",", "collection_id", ",", "photo_id", ")", ":", "url", "=", "\"/collections/%s/remove\"", "%", "collection_id", "data", "=", "{", "\"collection_id\"", ":", "collection_id", ",", "\"photo_id\"", ":", "photo_id", "}", "result", ...
Remove a photo from one of the logged-in user’s collections. Requires the 'write_collections' scope. :param collection_id [string]: The collection’s ID. Required. :param photo_id [string]: The photo’s ID. Required. :return: [Tuple]: The Unsplash Collection and Photo
[ "Remove", "a", "photo", "from", "one", "of", "the", "logged", "-", "in", "user’s", "collections", ".", "Requires", "the", "write_collections", "scope", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/collection.py#L195-L210
yakupadakli/python-unsplash
unsplash/stat.py
Stat.total
def total(self): """ Get a list of counts for all of Unsplash :return [Stat]: The Unsplash Stat. """ url = "/stats/total" result = self._get(url) return StatModel.parse(result)
python
def total(self): """ Get a list of counts for all of Unsplash :return [Stat]: The Unsplash Stat. """ url = "/stats/total" result = self._get(url) return StatModel.parse(result)
[ "def", "total", "(", "self", ")", ":", "url", "=", "\"/stats/total\"", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "StatModel", ".", "parse", "(", "result", ")" ]
Get a list of counts for all of Unsplash :return [Stat]: The Unsplash Stat.
[ "Get", "a", "list", "of", "counts", "for", "all", "of", "Unsplash" ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/stat.py#L11-L19
yakupadakli/python-unsplash
unsplash/stat.py
Stat.month
def month(self): """ Get the overall Unsplash stats for the past 30 days. :return [Stat]: The Unsplash Stat. """ url = "/stats/month" result = self._get(url) return StatModel.parse(result)
python
def month(self): """ Get the overall Unsplash stats for the past 30 days. :return [Stat]: The Unsplash Stat. """ url = "/stats/month" result = self._get(url) return StatModel.parse(result)
[ "def", "month", "(", "self", ")", ":", "url", "=", "\"/stats/month\"", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "StatModel", ".", "parse", "(", "result", ")" ]
Get the overall Unsplash stats for the past 30 days. :return [Stat]: The Unsplash Stat.
[ "Get", "the", "overall", "Unsplash", "stats", "for", "the", "past", "30", "days", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/stat.py#L21-L29
yakupadakli/python-unsplash
unsplash/auth.py
Auth.get_access_token
def get_access_token(self, code): """ Getting access token :param code [string]: The authorization code supplied to the callback by Unsplash. :return [string]: access token """ self.token = self.oauth.fetch_token( token_url=self.access_token_url, c...
python
def get_access_token(self, code): """ Getting access token :param code [string]: The authorization code supplied to the callback by Unsplash. :return [string]: access token """ self.token = self.oauth.fetch_token( token_url=self.access_token_url, c...
[ "def", "get_access_token", "(", "self", ",", "code", ")", ":", "self", ".", "token", "=", "self", ".", "oauth", ".", "fetch_token", "(", "token_url", "=", "self", ".", "access_token_url", ",", "client_id", "=", "self", ".", "client_id", ",", "client_secret...
Getting access token :param code [string]: The authorization code supplied to the callback by Unsplash. :return [string]: access token
[ "Getting", "access", "token", ":", "param", "code", "[", "string", "]", ":", "The", "authorization", "code", "supplied", "to", "the", "callback", "by", "Unsplash", ".", ":", "return", "[", "string", "]", ":", "access", "token" ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/auth.py#L61-L74
yakupadakli/python-unsplash
unsplash/auth.py
Auth.refresh_token
def refresh_token(self): """ Refreshing the current expired access token """ self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token()) self.access_token = self.token.get("access_token")
python
def refresh_token(self): """ Refreshing the current expired access token """ self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token()) self.access_token = self.token.get("access_token")
[ "def", "refresh_token", "(", "self", ")", ":", "self", ".", "token", "=", "self", ".", "oauth", ".", "refresh_token", "(", "self", ".", "access_token_url", ",", "refresh_token", "=", "self", ".", "get_refresh_token", "(", ")", ")", "self", ".", "access_tok...
Refreshing the current expired access token
[ "Refreshing", "the", "current", "expired", "access", "token" ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/auth.py#L83-L88
yakupadakli/python-unsplash
unsplash/models.py
Model.parse_list
def parse_list(cls, data): """Parse a list of JSON objects into a result set of model instances.""" results = ResultSet() data = data or [] for obj in data: if obj: results.append(cls.parse(obj)) return results
python
def parse_list(cls, data): """Parse a list of JSON objects into a result set of model instances.""" results = ResultSet() data = data or [] for obj in data: if obj: results.append(cls.parse(obj)) return results
[ "def", "parse_list", "(", "cls", ",", "data", ")", ":", "results", "=", "ResultSet", "(", ")", "data", "=", "data", "or", "[", "]", "for", "obj", "in", "data", ":", "if", "obj", ":", "results", ".", "append", "(", "cls", ".", "parse", "(", "obj",...
Parse a list of JSON objects into a result set of model instances.
[ "Parse", "a", "list", "of", "JSON", "objects", "into", "a", "result", "set", "of", "model", "instances", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/models.py#L18-L25
yakupadakli/python-unsplash
unsplash/client.py
Client.get_auth_header
def get_auth_header(self): """ Getting the authorization header according to the authentication procedure :return [dict]: Authorization header """ if self.api.is_authenticated: return {"Authorization": "Bearer %s" % self.api.access_token} return {"Authorizati...
python
def get_auth_header(self): """ Getting the authorization header according to the authentication procedure :return [dict]: Authorization header """ if self.api.is_authenticated: return {"Authorization": "Bearer %s" % self.api.access_token} return {"Authorizati...
[ "def", "get_auth_header", "(", "self", ")", ":", "if", "self", ".", "api", ".", "is_authenticated", ":", "return", "{", "\"Authorization\"", ":", "\"Bearer %s\"", "%", "self", ".", "api", ".", "access_token", "}", "return", "{", "\"Authorization\"", ":", "\"...
Getting the authorization header according to the authentication procedure :return [dict]: Authorization header
[ "Getting", "the", "authorization", "header", "according", "to", "the", "authentication", "procedure" ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/client.py#L52-L60
yakupadakli/python-unsplash
unsplash/user.py
User.me
def me(self): """ Get the currently-logged in user. Note: To access a user’s private data, the user is required to authorize the 'read_user' scope. Without it, this request will return a '403 Forbidden' response. Note: Without a Bearer token (i.e. using a Client-ID toke...
python
def me(self): """ Get the currently-logged in user. Note: To access a user’s private data, the user is required to authorize the 'read_user' scope. Without it, this request will return a '403 Forbidden' response. Note: Without a Bearer token (i.e. using a Client-ID toke...
[ "def", "me", "(", "self", ")", ":", "url", "=", "\"/me\"", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "UserModel", ".", "parse", "(", "result", ")" ]
Get the currently-logged in user. Note: To access a user’s private data, the user is required to authorize the 'read_user' scope. Without it, this request will return a '403 Forbidden' response. Note: Without a Bearer token (i.e. using a Client-ID token) this request will retur...
[ "Get", "the", "currently", "-", "logged", "in", "user", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L25-L40
yakupadakli/python-unsplash
unsplash/user.py
User.update
def update(self, **kwargs): """ Update the currently-logged in user. Note: This action requires the write_user scope. Without it, it will return a 403 Forbidden response. All parameters are optional. :param username [string]: Username. :param first_name [string]...
python
def update(self, **kwargs): """ Update the currently-logged in user. Note: This action requires the write_user scope. Without it, it will return a 403 Forbidden response. All parameters are optional. :param username [string]: Username. :param first_name [string]...
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "url", "=", "\"/me\"", "result", "=", "self", ".", "_put", "(", "url", ",", "data", "=", "kwargs", ")", "return", "UserModel", ".", "parse", "(", "result", ")" ]
Update the currently-logged in user. Note: This action requires the write_user scope. Without it, it will return a 403 Forbidden response. All parameters are optional. :param username [string]: Username. :param first_name [string]: First name. :param last_name [string]:...
[ "Update", "the", "currently", "-", "logged", "in", "user", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L42-L62
yakupadakli/python-unsplash
unsplash/user.py
User.get
def get(self, username, width=None, height=None): """ Retrieve public details on a given user. Note: Supplying the optional w or h parameters will result in the 'custom' photo URL being added to the 'profile_image' object: :param username [string]: The user’s username. Required...
python
def get(self, username, width=None, height=None): """ Retrieve public details on a given user. Note: Supplying the optional w or h parameters will result in the 'custom' photo URL being added to the 'profile_image' object: :param username [string]: The user’s username. Required...
[ "def", "get", "(", "self", ",", "username", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "url", "=", "\"/users/{username}\"", ".", "format", "(", "username", "=", "username", ")", "params", "=", "{", "\"w\"", ":", "width", ",", "\...
Retrieve public details on a given user. Note: Supplying the optional w or h parameters will result in the 'custom' photo URL being added to the 'profile_image' object: :param username [string]: The user’s username. Required. :param width [integer]: Profile image width in pixels. ...
[ "Retrieve", "public", "details", "on", "a", "given", "user", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L64-L82
yakupadakli/python-unsplash
unsplash/user.py
User.portfolio
def portfolio(self, username): """ Retrieve a single user’s portfolio link. :param username [string]: The user’s username. Required. :return: [Link]: The Unsplash Link. """ url = "/users/{username}/portfolio".format(username=username) result = self._get(url) ...
python
def portfolio(self, username): """ Retrieve a single user’s portfolio link. :param username [string]: The user’s username. Required. :return: [Link]: The Unsplash Link. """ url = "/users/{username}/portfolio".format(username=username) result = self._get(url) ...
[ "def", "portfolio", "(", "self", ",", "username", ")", ":", "url", "=", "\"/users/{username}/portfolio\"", ".", "format", "(", "username", "=", "username", ")", "result", "=", "self", ".", "_get", "(", "url", ")", "return", "LinkModel", ".", "parse", "(", ...
Retrieve a single user’s portfolio link. :param username [string]: The user’s username. Required. :return: [Link]: The Unsplash Link.
[ "Retrieve", "a", "single", "user’s", "portfolio", "link", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L84-L93
yakupadakli/python-unsplash
unsplash/user.py
User.photos
def photos(self, username, page=1, per_page=10, order_by="latest"): """ Get a list of photos uploaded by a user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of i...
python
def photos(self, username, page=1, per_page=10, order_by="latest"): """ Get a list of photos uploaded by a user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of i...
[ "def", "photos", "(", "self", ",", "username", ",", "page", "=", "1", ",", "per_page", "=", "10", ",", "order_by", "=", "\"latest\"", ")", ":", "url", "=", "\"/users/{username}/photos\"", ".", "format", "(", "username", "=", "username", ")", "result", "=...
Get a list of photos uploaded by a user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :param order_by [string]: How to sort the...
[ "Get", "a", "list", "of", "photos", "uploaded", "by", "a", "user", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L105-L118
yakupadakli/python-unsplash
unsplash/user.py
User.collections
def collections(self, username, page=1, per_page=10): """ Get a list of collections created by the user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per...
python
def collections(self, username, page=1, per_page=10): """ Get a list of collections created by the user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per...
[ "def", "collections", "(", "self", ",", "username", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "url", "=", "\"/users/{username}/collections\"", ".", "format", "(", "username", "=", "username", ")", "params", "=", "{", "\"page\"", ":", "...
Get a list of collections created by the user. :param username [string]: The user’s username. Required. :param page [integer]: Page number to retrieve. (Optional; default: 1) :param per_page [integer]: Number of items per page. (Optional; default: 10) :return: [Array]: A single page of ...
[ "Get", "a", "list", "of", "collections", "created", "by", "the", "user", "." ]
train
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/user.py#L135-L150
pri22296/beautifultable
beautifultable/ansi.py
ANSIMultiByteString.wrap
def wrap(self, width): """Returns a partition of the string based on `width`""" res = [] prev_state = set() part = [] cwidth = 0 for char, _width, state in zip(self._string, self._width, self._state): if cwidth + _width > width: if prev_state: ...
python
def wrap(self, width): """Returns a partition of the string based on `width`""" res = [] prev_state = set() part = [] cwidth = 0 for char, _width, state in zip(self._string, self._width, self._state): if cwidth + _width > width: if prev_state: ...
[ "def", "wrap", "(", "self", ",", "width", ")", ":", "res", "=", "[", "]", "prev_state", "=", "set", "(", ")", "part", "=", "[", "]", "cwidth", "=", "0", "for", "char", ",", "_width", ",", "state", "in", "zip", "(", "self", ".", "_string", ",", ...
Returns a partition of the string based on `width`
[ "Returns", "a", "partition", "of", "the", "string", "based", "on", "width" ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/ansi.py#L87-L115
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.max_table_width
def max_table_width(self): """get/set the maximum width of the table. The width of the table is guaranteed to not exceed this value. If it is not possible to print a given table with the width provided, this value will automatically adjust. """ offset = ((self._column_co...
python
def max_table_width(self): """get/set the maximum width of the table. The width of the table is guaranteed to not exceed this value. If it is not possible to print a given table with the width provided, this value will automatically adjust. """ offset = ((self._column_co...
[ "def", "max_table_width", "(", "self", ")", ":", "offset", "=", "(", "(", "self", ".", "_column_count", "-", "1", ")", "*", "termwidth", "(", "self", ".", "column_separator_char", ")", ")", "offset", "+=", "termwidth", "(", "self", ".", "left_border_char",...
get/set the maximum width of the table. The width of the table is guaranteed to not exceed this value. If it is not possible to print a given table with the width provided, this value will automatically adjust.
[ "get", "/", "set", "the", "maximum", "width", "of", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L401-L414
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable._initialize_table
def _initialize_table(self, column_count): """Sets the column count of the table. This method is called to set the number of columns for the first time. Parameters ---------- column_count : int number of columns in the table """ header = [''] * colum...
python
def _initialize_table(self, column_count): """Sets the column count of the table. This method is called to set the number of columns for the first time. Parameters ---------- column_count : int number of columns in the table """ header = [''] * colum...
[ "def", "_initialize_table", "(", "self", ",", "column_count", ")", ":", "header", "=", "[", "''", "]", "*", "column_count", "alignment", "=", "[", "self", ".", "default_alignment", "]", "*", "column_count", "width", "=", "[", "0", "]", "*", "column_count",...
Sets the column count of the table. This method is called to set the number of columns for the first time. Parameters ---------- column_count : int number of columns in the table
[ "Sets", "the", "column", "count", "of", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L422-L442
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.set_style
def set_style(self, style): """Set the style of the table from a predefined set of styles. Parameters ---------- style: Style It can be one of the following: * beautifulTable.STYLE_DEFAULT * beautifultable.STYLE_NONE * beautifulTable.STY...
python
def set_style(self, style): """Set the style of the table from a predefined set of styles. Parameters ---------- style: Style It can be one of the following: * beautifulTable.STYLE_DEFAULT * beautifultable.STYLE_NONE * beautifulTable.STY...
[ "def", "set_style", "(", "self", ",", "style", ")", ":", "if", "not", "isinstance", "(", "style", ",", "enums", ".", "Style", ")", ":", "allowed", "=", "(", "\"{}.{}\"", ".", "format", "(", "type", "(", "self", ")", ".", "__name__", ",", "i", ".", ...
Set the style of the table from a predefined set of styles. Parameters ---------- style: Style It can be one of the following: * beautifulTable.STYLE_DEFAULT * beautifultable.STYLE_NONE * beautifulTable.STYLE_DOTTED * beautifulTable....
[ "Set", "the", "style", "of", "the", "table", "from", "a", "predefined", "set", "of", "styles", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L580-L627
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable._calculate_column_widths
def _calculate_column_widths(self): """Calculate width of column automatically based on data.""" table_width = self.get_table_width() lpw, rpw = self._left_padding_widths, self._right_padding_widths pad_widths = [(lpw[i] + rpw[i]) for i in range(self._column_count)] max_widths = ...
python
def _calculate_column_widths(self): """Calculate width of column automatically based on data.""" table_width = self.get_table_width() lpw, rpw = self._left_padding_widths, self._right_padding_widths pad_widths = [(lpw[i] + rpw[i]) for i in range(self._column_count)] max_widths = ...
[ "def", "_calculate_column_widths", "(", "self", ")", ":", "table_width", "=", "self", ".", "get_table_width", "(", ")", "lpw", ",", "rpw", "=", "self", ".", "_left_padding_widths", ",", "self", ".", "_right_padding_widths", "pad_widths", "=", "[", "(", "lpw", ...
Calculate width of column automatically based on data.
[ "Calculate", "width", "of", "column", "automatically", "based", "on", "data", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L629-L701
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.sort
def sort(self, key, reverse=False): """Stable sort of the table *IN-PLACE* with respect to a column. Parameters ---------- key: int, str index or header of the column. Normal list rules apply. reverse : bool If `True` then table is sorted as if each compa...
python
def sort(self, key, reverse=False): """Stable sort of the table *IN-PLACE* with respect to a column. Parameters ---------- key: int, str index or header of the column. Normal list rules apply. reverse : bool If `True` then table is sorted as if each compa...
[ "def", "sort", "(", "self", ",", "key", ",", "reverse", "=", "False", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "index", "=", "key", "elif", "isinstance", "(", "key", ",", "basestring", ")", ":", "index", "=", "self", ".", "...
Stable sort of the table *IN-PLACE* with respect to a column. Parameters ---------- key: int, str index or header of the column. Normal list rules apply. reverse : bool If `True` then table is sorted as if each comparison was reversed.
[ "Stable", "sort", "of", "the", "table", "*", "IN", "-", "PLACE", "*", "with", "respect", "to", "a", "column", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L718-L734
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.get_column_index
def get_column_index(self, header): """Get index of a column from it's header. Parameters ---------- header: str header of the column. Raises ------ ValueError: If no column could be found corresponding to `header`. """ tr...
python
def get_column_index(self, header): """Get index of a column from it's header. Parameters ---------- header: str header of the column. Raises ------ ValueError: If no column could be found corresponding to `header`. """ tr...
[ "def", "get_column_index", "(", "self", ",", "header", ")", ":", "try", ":", "index", "=", "self", ".", "_column_headers", ".", "index", "(", "header", ")", "return", "index", "except", "ValueError", ":", "raise_suppressed", "(", "KeyError", "(", "(", "\"'...
Get index of a column from it's header. Parameters ---------- header: str header of the column. Raises ------ ValueError: If no column could be found corresponding to `header`.
[ "Get", "index", "of", "a", "column", "from", "it", "s", "header", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L756-L774
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.get_column
def get_column(self, key): """Return an iterator to a column. Parameters ---------- key : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ TypeError: ...
python
def get_column(self, key): """Return an iterator to a column. Parameters ---------- key : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ TypeError: ...
[ "def", "get_column", "(", "self", ",", "key", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "index", "=", "key", "elif", "isinstance", "(", "key", ",", "basestring", ")", ":", "index", "=", "self", ".", "get_column_index", "(", "key...
Return an iterator to a column. Parameters ---------- key : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ TypeError: If key is not of type `int`, or `str`...
[ "Return", "an", "iterator", "to", "a", "column", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L776-L802
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.pop_column
def pop_column(self, index=-1): """Remove and return row at index (default last). Parameters ---------- index : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ ...
python
def pop_column(self, index=-1): """Remove and return row at index (default last). Parameters ---------- index : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ ...
[ "def", "pop_column", "(", "self", ",", "index", "=", "-", "1", ")", ":", "if", "isinstance", "(", "index", ",", "int", ")", ":", "pass", "elif", "isinstance", "(", "index", ",", "basestring", ")", ":", "index", "=", "self", ".", "get_column_index", "...
Remove and return row at index (default last). Parameters ---------- index : int, str index of the column, or the header of the column. If index is specified, then normal list rules apply. Raises ------ TypeError: If index is not an i...
[ "Remove", "and", "return", "row", "at", "index", "(", "default", "last", ")", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L819-L858
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.insert_row
def insert_row(self, index, row): """Insert a row before index in the table. Parameters ---------- index : int List index rules apply row : iterable Any iterable of appropriate length. Raises ------ TypeError: If `row...
python
def insert_row(self, index, row): """Insert a row before index in the table. Parameters ---------- index : int List index rules apply row : iterable Any iterable of appropriate length. Raises ------ TypeError: If `row...
[ "def", "insert_row", "(", "self", ",", "index", ",", "row", ")", ":", "row", "=", "self", ".", "_validate_row", "(", "row", ")", "row_obj", "=", "RowData", "(", "self", ",", "row", ")", "self", ".", "_table", ".", "insert", "(", "index", ",", "row_...
Insert a row before index in the table. Parameters ---------- index : int List index rules apply row : iterable Any iterable of appropriate length. Raises ------ TypeError: If `row` is not an iterable. ValueError: ...
[ "Insert", "a", "row", "before", "index", "in", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L860-L882
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.update_row
def update_row(self, key, value): """Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- key : int or slice index of the row,...
python
def update_row(self, key, value): """Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- key : int or slice index of the row,...
[ "def", "update_row", "(", "self", ",", "key", ",", "value", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "row", "=", "self", ".", "_validate_row", "(", "value", ",", "init_table_if_required", "=", "False", ")", "row_obj", "=", "RowDa...
Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- key : int or slice index of the row, or a slice object. value : iterable...
[ "Update", "a", "column", "named", "header", "in", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L895-L933
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.update_column
def update_column(self, header, column): """Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- header : str Header of the co...
python
def update_column(self, header, column): """Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- header : str Header of the co...
[ "def", "update_column", "(", "self", ",", "header", ",", "column", ")", ":", "index", "=", "self", ".", "get_column_index", "(", "header", ")", "if", "not", "isinstance", "(", "header", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"header must...
Update a column named `header` in the table. If length of column is smaller than number of rows, lets say `k`, only the first `k` values in the column is updated. Parameters ---------- header : str Header of the column column : iterable Any iter...
[ "Update", "a", "column", "named", "header", "in", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L935-L961
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.insert_column
def insert_column(self, index, header, column): """Insert a column before `index` in the table. If length of column is bigger than number of rows, lets say `k`, only the first `k` values of `column` is considered. If column is shorter than 'k', ValueError is raised. Note that T...
python
def insert_column(self, index, header, column): """Insert a column before `index` in the table. If length of column is bigger than number of rows, lets say `k`, only the first `k` values of `column` is considered. If column is shorter than 'k', ValueError is raised. Note that T...
[ "def", "insert_column", "(", "self", ",", "index", ",", "header", ",", "column", ")", ":", "if", "self", ".", "_column_count", "==", "0", ":", "self", ".", "column_headers", "=", "HeaderData", "(", "self", ",", "[", "header", "]", ")", "self", ".", "...
Insert a column before `index` in the table. If length of column is bigger than number of rows, lets say `k`, only the first `k` values of `column` is considered. If column is shorter than 'k', ValueError is raised. Note that Table remains in consistent state even if column is ...
[ "Insert", "a", "column", "before", "index", "in", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L963-L1016
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.append_column
def append_column(self, header, column): """Append a column to end of the table. Parameters ---------- header : str Title of the column column : iterable Any iterable of appropriate length. """ self.insert_column(self._column_count, heade...
python
def append_column(self, header, column): """Append a column to end of the table. Parameters ---------- header : str Title of the column column : iterable Any iterable of appropriate length. """ self.insert_column(self._column_count, heade...
[ "def", "append_column", "(", "self", ",", "header", ",", "column", ")", ":", "self", ".", "insert_column", "(", "self", ".", "_column_count", ",", "header", ",", "column", ")" ]
Append a column to end of the table. Parameters ---------- header : str Title of the column column : iterable Any iterable of appropriate length.
[ "Append", "a", "column", "to", "end", "of", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L1018-L1029
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable._get_horizontal_line
def _get_horizontal_line(self, char, intersect_left, intersect_mid, intersect_right): """Get a horizontal line for the table. Internal method used to actually get all horizontal lines in the table. Column width should be set prior to calling this method. This method...
python
def _get_horizontal_line(self, char, intersect_left, intersect_mid, intersect_right): """Get a horizontal line for the table. Internal method used to actually get all horizontal lines in the table. Column width should be set prior to calling this method. This method...
[ "def", "_get_horizontal_line", "(", "self", ",", "char", ",", "intersect_left", ",", "intersect_mid", ",", "intersect_right", ")", ":", "width", "=", "self", ".", "get_table_width", "(", ")", "try", ":", "line", "=", "list", "(", "char", "*", "(", "int", ...
Get a horizontal line for the table. Internal method used to actually get all horizontal lines in the table. Column width should be set prior to calling this method. This method detects intersection and handles it according to the values of `intersect_*_*` attributes. Parameter...
[ "Get", "a", "horizontal", "line", "for", "the", "table", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L1049-L1110
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.get_table_width
def get_table_width(self): """Get the width of the table as number of characters. Column width should be set prior to calling this method. Returns ------- int Width of the table as number of characters. """ if self.column_count == 0: retu...
python
def get_table_width(self): """Get the width of the table as number of characters. Column width should be set prior to calling this method. Returns ------- int Width of the table as number of characters. """ if self.column_count == 0: retu...
[ "def", "get_table_width", "(", "self", ")", ":", "if", "self", ".", "column_count", "==", "0", ":", "return", "0", "width", "=", "sum", "(", "self", ".", "_column_widths", ")", "width", "+=", "(", "(", "self", ".", "_column_count", "-", "1", ")", "*"...
Get the width of the table as number of characters. Column width should be set prior to calling this method. Returns ------- int Width of the table as number of characters.
[ "Get", "the", "width", "of", "the", "table", "as", "number", "of", "characters", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L1188-L1205
pri22296/beautifultable
beautifultable/beautifultable.py
BeautifulTable.get_string
def get_string(self, recalculate_width=True): """Get the table as a String. Parameters ---------- recalculate_width : bool, optional If width for each column should be recalculated(default True). Note that width is always calculated if it wasn't set e...
python
def get_string(self, recalculate_width=True): """Get the table as a String. Parameters ---------- recalculate_width : bool, optional If width for each column should be recalculated(default True). Note that width is always calculated if it wasn't set e...
[ "def", "get_string", "(", "self", ",", "recalculate_width", "=", "True", ")", ":", "# Empty table. returning empty string.", "if", "len", "(", "self", ".", "_table", ")", "==", "0", ":", "return", "''", "if", "self", ".", "serialno", "and", "self", ".", "c...
Get the table as a String. Parameters ---------- recalculate_width : bool, optional If width for each column should be recalculated(default True). Note that width is always calculated if it wasn't set explicitly when this method is called for the first time ,...
[ "Get", "the", "table", "as", "a", "String", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L1207-L1269
pri22296/beautifultable
beautifultable/utils.py
_convert_to_numeric
def _convert_to_numeric(item): """ Helper method to convert a string to float or int if possible. If the conversion is not possible, it simply returns the string. """ if PY3: num_types = (int, float) else: # pragma: no cover num_types = (int, long...
python
def _convert_to_numeric(item): """ Helper method to convert a string to float or int if possible. If the conversion is not possible, it simply returns the string. """ if PY3: num_types = (int, float) else: # pragma: no cover num_types = (int, long...
[ "def", "_convert_to_numeric", "(", "item", ")", ":", "if", "PY3", ":", "num_types", "=", "(", "int", ",", "float", ")", "else", ":", "# pragma: no cover", "num_types", "=", "(", "int", ",", "long", ",", "float", ")", "# noqa: F821", "# We don't wan't to perf...
Helper method to convert a string to float or int if possible. If the conversion is not possible, it simply returns the string.
[ "Helper", "method", "to", "convert", "a", "string", "to", "float", "or", "int", "if", "possible", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/utils.py#L11-L40
pri22296/beautifultable
beautifultable/utils.py
get_output_str
def get_output_str(item, detect_numerics, precision, sign_value): """Returns the final string which should be displayed""" if detect_numerics: item = _convert_to_numeric(item) if isinstance(item, float): item = round(item, precision) try: item = '{:{sign}}'.format(item, sign=sign...
python
def get_output_str(item, detect_numerics, precision, sign_value): """Returns the final string which should be displayed""" if detect_numerics: item = _convert_to_numeric(item) if isinstance(item, float): item = round(item, precision) try: item = '{:{sign}}'.format(item, sign=sign...
[ "def", "get_output_str", "(", "item", ",", "detect_numerics", ",", "precision", ",", "sign_value", ")", ":", "if", "detect_numerics", ":", "item", "=", "_convert_to_numeric", "(", "item", ")", "if", "isinstance", "(", "item", ",", "float", ")", ":", "item", ...
Returns the final string which should be displayed
[ "Returns", "the", "final", "string", "which", "should", "be", "displayed" ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/utils.py#L43-L53
pri22296/beautifultable
beautifultable/rows.py
RowData._get_row_within_width
def _get_row_within_width(self, row): """Process a row so that it is clamped by column_width. Parameters ---------- row : array_like A single row. Returns ------- list of list: List representation of the `row` after it has been processed...
python
def _get_row_within_width(self, row): """Process a row so that it is clamped by column_width. Parameters ---------- row : array_like A single row. Returns ------- list of list: List representation of the `row` after it has been processed...
[ "def", "_get_row_within_width", "(", "self", ",", "row", ")", ":", "table", "=", "self", ".", "_table", "lpw", ",", "rpw", "=", "table", ".", "left_padding_widths", ",", "table", ".", "right_padding_widths", "wep", "=", "table", ".", "width_exceed_policy", "...
Process a row so that it is clamped by column_width. Parameters ---------- row : array_like A single row. Returns ------- list of list: List representation of the `row` after it has been processed according to width exceed policy.
[ "Process", "a", "row", "so", "that", "it", "is", "clamped", "by", "column_width", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/rows.py#L9-L63
pri22296/beautifultable
beautifultable/rows.py
RowData._clamp_string
def _clamp_string(self, row_item, column_index, delimiter=''): """Clamp `row_item` to fit in column referred by column_index. This method considers padding and appends the delimiter if `row_item` needs to be truncated. Parameters ---------- row_item: str Str...
python
def _clamp_string(self, row_item, column_index, delimiter=''): """Clamp `row_item` to fit in column referred by column_index. This method considers padding and appends the delimiter if `row_item` needs to be truncated. Parameters ---------- row_item: str Str...
[ "def", "_clamp_string", "(", "self", ",", "row_item", ",", "column_index", ",", "delimiter", "=", "''", ")", ":", "width", "=", "(", "self", ".", "_table", ".", "column_widths", "[", "column_index", "]", "-", "self", ".", "_table", ".", "left_padding_width...
Clamp `row_item` to fit in column referred by column_index. This method considers padding and appends the delimiter if `row_item` needs to be truncated. Parameters ---------- row_item: str String which should be clamped. column_index: int Index ...
[ "Clamp", "row_item", "to", "fit", "in", "column", "referred", "by", "column_index", "." ]
train
https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/rows.py#L65-L99
icq-bot/python-icq-bot
icq/bot.py
ICQBot.send_im
def send_im(self, target, message, mentions=None, parse=None, update_msg_id=None, wrap_length=5000): """ Send text message. :param target: Target user UIN or chat ID. :param message: Message text. :param mentions: Iterable with UINs to mention in message. :param parse: I...
python
def send_im(self, target, message, mentions=None, parse=None, update_msg_id=None, wrap_length=5000): """ Send text message. :param target: Target user UIN or chat ID. :param message: Message text. :param mentions: Iterable with UINs to mention in message. :param parse: I...
[ "def", "send_im", "(", "self", ",", "target", ",", "message", ",", "mentions", "=", "None", ",", "parse", "=", "None", ",", "update_msg_id", "=", "None", ",", "wrap_length", "=", "5000", ")", ":", "try", ":", "responses", "=", "set", "(", ")", "for",...
Send text message. :param target: Target user UIN or chat ID. :param message: Message text. :param mentions: Iterable with UINs to mention in message. :param parse: Iterable with several values from :class:`icq.constant.MessageParseType` specifying which message items should...
[ "Send", "text", "message", "." ]
train
https://github.com/icq-bot/python-icq-bot/blob/1d278cc91f8eba5481bb8d70f80fc74160a40c8b/icq/bot.py#L459-L503