repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
liip/taxi
taxi/timesheet/timesheet.py
TimesheetCollection.get_new_timesheets_contents
def get_new_timesheets_contents(self): """ Return the initial text to be inserted in new timesheets. """ popular_aliases = self.get_popular_aliases() template = ['# Recently used aliases:'] if popular_aliases: contents = '\n'.join(template + ['# ' + entry for...
python
def get_new_timesheets_contents(self): """ Return the initial text to be inserted in new timesheets. """ popular_aliases = self.get_popular_aliases() template = ['# Recently used aliases:'] if popular_aliases: contents = '\n'.join(template + ['# ' + entry for...
[ "def", "get_new_timesheets_contents", "(", "self", ")", ":", "popular_aliases", "=", "self", ".", "get_popular_aliases", "(", ")", "template", "=", "[", "'# Recently used aliases:'", "]", "if", "popular_aliases", ":", "contents", "=", "'\\n'", ".", "join", "(", ...
Return the initial text to be inserted in new timesheets.
[ "Return", "the", "initial", "text", "to", "be", "inserted", "in", "new", "timesheets", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/timesheet.py#L299-L311
liip/taxi
taxi/timesheet/timesheet.py
TimesheetCollection.entries
def entries(self): """ Return the entries (as a {date: entries} dict) of all timesheets in the collection. """ entries_list = self._timesheets_callback('entries')() return reduce(lambda x, y: x + y, entries_list)
python
def entries(self): """ Return the entries (as a {date: entries} dict) of all timesheets in the collection. """ entries_list = self._timesheets_callback('entries')() return reduce(lambda x, y: x + y, entries_list)
[ "def", "entries", "(", "self", ")", ":", "entries_list", "=", "self", ".", "_timesheets_callback", "(", "'entries'", ")", "(", ")", "return", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "+", "y", ",", "entries_list", ")" ]
Return the entries (as a {date: entries} dict) of all timesheets in the collection.
[ "Return", "the", "entries", "(", "as", "a", "{", "date", ":", "entries", "}", "dict", ")", "of", "all", "timesheets", "in", "the", "collection", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/timesheet.py#L314-L321
liip/taxi
taxi/timesheet/timesheet.py
TimesheetCollection.get_popular_aliases
def get_popular_aliases(self, *args, **kwargs): """ Return the aggregated results of :meth:`Timesheet.get_popular_aliases`. """ aliases_count_total = defaultdict(int) aliases_counts = self._timesheets_callback('get_popular_aliases')(*args, **kwargs) for aliases_count in ...
python
def get_popular_aliases(self, *args, **kwargs): """ Return the aggregated results of :meth:`Timesheet.get_popular_aliases`. """ aliases_count_total = defaultdict(int) aliases_counts = self._timesheets_callback('get_popular_aliases')(*args, **kwargs) for aliases_count in ...
[ "def", "get_popular_aliases", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "aliases_count_total", "=", "defaultdict", "(", "int", ")", "aliases_counts", "=", "self", ".", "_timesheets_callback", "(", "'get_popular_aliases'", ")", "(", "*",...
Return the aggregated results of :meth:`Timesheet.get_popular_aliases`.
[ "Return", "the", "aggregated", "results", "of", ":", "meth", ":", "Timesheet", ".", "get_popular_aliases", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/timesheet.py#L329-L342
liip/taxi
taxi/commands/show.py
show
def show(ctx, search): """ Resolves any object passed to it (aliases, projects, etc). This will resolve the following: \b - Aliases (my_alias) - Mappings (123/456) - Project ids (123) """ matches = {'aliases': [], 'mappings': [], 'projects': []} projects_db = ctx.ob...
python
def show(ctx, search): """ Resolves any object passed to it (aliases, projects, etc). This will resolve the following: \b - Aliases (my_alias) - Mappings (123/456) - Project ids (123) """ matches = {'aliases': [], 'mappings': [], 'projects': []} projects_db = ctx.ob...
[ "def", "show", "(", "ctx", ",", "search", ")", ":", "matches", "=", "{", "'aliases'", ":", "[", "]", ",", "'mappings'", ":", "[", "]", ",", "'projects'", ":", "[", "]", "}", "projects_db", "=", "ctx", ".", "obj", "[", "'projects_db'", "]", "matches...
Resolves any object passed to it (aliases, projects, etc). This will resolve the following: \b - Aliases (my_alias) - Mappings (123/456) - Project ids (123)
[ "Resolves", "any", "object", "passed", "to", "it", "(", "aliases", "projects", "etc", ")", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/show.py#L15-L33
liip/taxi
taxi/commands/status.py
status
def status(ctx, date, f, pushed): """ Shows the summary of what's going to be committed to the server. """ try: timesheet_collection = get_timesheet_collection_for_context(ctx, f) except ParseError as e: ctx.obj['view'].err(e) else: ctx.obj['view'].show_status( ...
python
def status(ctx, date, f, pushed): """ Shows the summary of what's going to be committed to the server. """ try: timesheet_collection = get_timesheet_collection_for_context(ctx, f) except ParseError as e: ctx.obj['view'].err(e) else: ctx.obj['view'].show_status( ...
[ "def", "status", "(", "ctx", ",", "date", ",", "f", ",", "pushed", ")", ":", "try", ":", "timesheet_collection", "=", "get_timesheet_collection_for_context", "(", "ctx", ",", "f", ")", "except", "ParseError", "as", "e", ":", "ctx", ".", "obj", "[", "'vie...
Shows the summary of what's going to be committed to the server.
[ "Shows", "the", "summary", "of", "what", "s", "going", "to", "be", "committed", "to", "the", "server", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/status.py#L15-L29
liip/taxi
taxi/commands/edit.py
edit
def edit(ctx, file_to_edit, previous_file): """ Opens your timesheet file in your favourite editor. The PREVIOUS_FILE argument can be used to specify which nth previous file to edit. A value of 1 will edit the previous file, 2 will edit the second-previous file, etc. """ timesheet_collectio...
python
def edit(ctx, file_to_edit, previous_file): """ Opens your timesheet file in your favourite editor. The PREVIOUS_FILE argument can be used to specify which nth previous file to edit. A value of 1 will edit the previous file, 2 will edit the second-previous file, etc. """ timesheet_collectio...
[ "def", "edit", "(", "ctx", ",", "file_to_edit", ",", "previous_file", ")", ":", "timesheet_collection", "=", "None", "autofill", "=", "not", "bool", "(", "file_to_edit", ")", "and", "previous_file", "==", "0", "if", "not", "file_to_edit", ":", "file_to_edit", ...
Opens your timesheet file in your favourite editor. The PREVIOUS_FILE argument can be used to specify which nth previous file to edit. A value of 1 will edit the previous file, 2 will edit the second-previous file, etc.
[ "Opens", "your", "timesheet", "file", "in", "your", "favourite", "editor", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/edit.py#L16-L75
liip/taxi
taxi/aliases.py
AliasesDatabase.get_reversed_aliases
def get_reversed_aliases(self): """ Return the reversed aliases dict. Instead of being in the form {'alias': mapping}, the dict is in the form {mapping: 'alias'}. """ return dict((v, k) for k, v in six.iteritems(self.aliases))
python
def get_reversed_aliases(self): """ Return the reversed aliases dict. Instead of being in the form {'alias': mapping}, the dict is in the form {mapping: 'alias'}. """ return dict((v, k) for k, v in six.iteritems(self.aliases))
[ "def", "get_reversed_aliases", "(", "self", ")", ":", "return", "dict", "(", "(", "v", ",", "k", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self", ".", "aliases", ")", ")" ]
Return the reversed aliases dict. Instead of being in the form {'alias': mapping}, the dict is in the form {mapping: 'alias'}.
[ "Return", "the", "reversed", "aliases", "dict", ".", "Instead", "of", "being", "in", "the", "form", "{", "alias", ":", "mapping", "}", "the", "dict", "is", "in", "the", "form", "{", "mapping", ":", "alias", "}", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/aliases.py#L80-L85
liip/taxi
taxi/aliases.py
AliasesDatabase.filter_from_mapping
def filter_from_mapping(self, mapping, backend=None): """ Return mappings that either exactly correspond to the given `mapping` tuple, or, if the second item of `mapping` is `None`, include mappings that only match the first item of `mapping` (useful to show all mappings for a gi...
python
def filter_from_mapping(self, mapping, backend=None): """ Return mappings that either exactly correspond to the given `mapping` tuple, or, if the second item of `mapping` is `None`, include mappings that only match the first item of `mapping` (useful to show all mappings for a gi...
[ "def", "filter_from_mapping", "(", "self", ",", "mapping", ",", "backend", "=", "None", ")", ":", "def", "mapping_filter", "(", "key_item", ")", ":", "key", ",", "item", "=", "key_item", "return", "(", "(", "mapping", "is", "None", "or", "item", ".", "...
Return mappings that either exactly correspond to the given `mapping` tuple, or, if the second item of `mapping` is `None`, include mappings that only match the first item of `mapping` (useful to show all mappings for a given project).
[ "Return", "mappings", "that", "either", "exactly", "correspond", "to", "the", "given", "mapping", "tuple", "or", "if", "the", "second", "item", "of", "mapping", "is", "None", "include", "mappings", "that", "only", "match", "the", "first", "item", "of", "mapp...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/aliases.py#L94-L117
liip/taxi
taxi/aliases.py
AliasesDatabase.filter_from_alias
def filter_from_alias(self, alias, backend=None): """ Return aliases that start with the given `alias`, optionally filtered by backend. """ def alias_filter(key_item): key, item = key_item return ((alias is None or alias in key) and (b...
python
def filter_from_alias(self, alias, backend=None): """ Return aliases that start with the given `alias`, optionally filtered by backend. """ def alias_filter(key_item): key, item = key_item return ((alias is None or alias in key) and (b...
[ "def", "filter_from_alias", "(", "self", ",", "alias", ",", "backend", "=", "None", ")", ":", "def", "alias_filter", "(", "key_item", ")", ":", "key", ",", "item", "=", "key_item", "return", "(", "(", "alias", "is", "None", "or", "alias", "in", "key", ...
Return aliases that start with the given `alias`, optionally filtered by backend.
[ "Return", "aliases", "that", "start", "with", "the", "given", "alias", "optionally", "filtered", "by", "backend", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/aliases.py#L119-L134
liip/taxi
taxi/commands/clean_aliases.py
clean_aliases
def clean_aliases(ctx, force_yes): """ Removes aliases from your config file that point to inactive projects. """ inactive_aliases = [] for (alias, mapping) in six.iteritems(aliases_database): # Ignore local aliases if mapping.mapping is None: continue project =...
python
def clean_aliases(ctx, force_yes): """ Removes aliases from your config file that point to inactive projects. """ inactive_aliases = [] for (alias, mapping) in six.iteritems(aliases_database): # Ignore local aliases if mapping.mapping is None: continue project =...
[ "def", "clean_aliases", "(", "ctx", ",", "force_yes", ")", ":", "inactive_aliases", "=", "[", "]", "for", "(", "alias", ",", "mapping", ")", "in", "six", ".", "iteritems", "(", "aliases_database", ")", ":", "# Ignore local aliases", "if", "mapping", ".", "...
Removes aliases from your config file that point to inactive projects.
[ "Removes", "aliases", "from", "your", "config", "file", "that", "point", "to", "inactive", "projects", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/clean_aliases.py#L16-L48
liip/taxi
taxi/commands/plugin.py
get_plugin_info
def get_plugin_info(plugin): """ Fetch information about the given package on PyPI and return it as a dict. If the package cannot be found on PyPI, :exc:`NameError` will be raised. """ url = 'https://pypi.python.org/pypi/{}/json'.format(plugin) try: resp = request.urlopen(url) excep...
python
def get_plugin_info(plugin): """ Fetch information about the given package on PyPI and return it as a dict. If the package cannot be found on PyPI, :exc:`NameError` will be raised. """ url = 'https://pypi.python.org/pypi/{}/json'.format(plugin) try: resp = request.urlopen(url) excep...
[ "def", "get_plugin_info", "(", "plugin", ")", ":", "url", "=", "'https://pypi.python.org/pypi/{}/json'", ".", "format", "(", "plugin", ")", "try", ":", "resp", "=", "request", ".", "urlopen", "(", "url", ")", "except", "HTTPError", "as", "e", ":", "if", "e...
Fetch information about the given package on PyPI and return it as a dict. If the package cannot be found on PyPI, :exc:`NameError` will be raised.
[ "Fetch", "information", "about", "the", "given", "package", "on", "PyPI", "and", "return", "it", "as", "a", "dict", ".", "If", "the", "package", "cannot", "be", "found", "on", "PyPI", ":", "exc", ":", "NameError", "will", "be", "raised", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/plugin.py#L26-L54
liip/taxi
taxi/commands/plugin.py
get_installed_plugins
def get_installed_plugins(): """ Return a dict {plugin_name: version} of installed plugins. """ return { # Strip the first five characters from the plugin name since all # plugins are expected to start with `taxi-` backend.dist.project_name[5:]: backend.dist.version for b...
python
def get_installed_plugins(): """ Return a dict {plugin_name: version} of installed plugins. """ return { # Strip the first five characters from the plugin name since all # plugins are expected to start with `taxi-` backend.dist.project_name[5:]: backend.dist.version for b...
[ "def", "get_installed_plugins", "(", ")", ":", "return", "{", "# Strip the first five characters from the plugin name since all", "# plugins are expected to start with `taxi-`", "backend", ".", "dist", ".", "project_name", "[", "5", ":", "]", ":", "backend", ".", "dist", ...
Return a dict {plugin_name: version} of installed plugins.
[ "Return", "a", "dict", "{", "plugin_name", ":", "version", "}", "of", "installed", "plugins", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/plugin.py#L57-L67
liip/taxi
taxi/commands/plugin.py
list_
def list_(ctx): """ Lists installed plugins. """ plugins = plugins_registry.get_plugins() click.echo("\n".join( ["%s (%s)" % p for p in plugins.items()] ))
python
def list_(ctx): """ Lists installed plugins. """ plugins = plugins_registry.get_plugins() click.echo("\n".join( ["%s (%s)" % p for p in plugins.items()] ))
[ "def", "list_", "(", "ctx", ")", ":", "plugins", "=", "plugins_registry", ".", "get_plugins", "(", ")", "click", ".", "echo", "(", "\"\\n\"", ".", "join", "(", "[", "\"%s (%s)\"", "%", "p", "for", "p", "in", "plugins", ".", "items", "(", ")", "]", ...
Lists installed plugins.
[ "Lists", "installed", "plugins", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/plugin.py#L97-L105
liip/taxi
taxi/commands/plugin.py
install
def install(ctx, plugin): """ Install the given plugin. """ ensure_inside_venv(ctx) plugin_name = get_plugin_name(plugin) try: info = get_plugin_info(plugin_name) except NameError: echo_error("Plugin {} could not be found.".format(plugin)) sys.exit(1) except Valu...
python
def install(ctx, plugin): """ Install the given plugin. """ ensure_inside_venv(ctx) plugin_name = get_plugin_name(plugin) try: info = get_plugin_info(plugin_name) except NameError: echo_error("Plugin {} could not be found.".format(plugin)) sys.exit(1) except Valu...
[ "def", "install", "(", "ctx", ",", "plugin", ")", ":", "ensure_inside_venv", "(", "ctx", ")", "plugin_name", "=", "get_plugin_name", "(", "plugin", ")", "try", ":", "info", "=", "get_plugin_info", "(", "plugin_name", ")", "except", "NameError", ":", "echo_er...
Install the given plugin.
[ "Install", "the", "given", "plugin", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/plugin.py#L111-L149
liip/taxi
taxi/commands/plugin.py
uninstall
def uninstall(ctx, plugin): """ Uninstall the given plugin. """ ensure_inside_venv(ctx) if plugin not in get_installed_plugins(): echo_error("Plugin {} does not seem to be installed.".format(plugin)) sys.exit(1) plugin_name = get_plugin_name(plugin) try: run_command...
python
def uninstall(ctx, plugin): """ Uninstall the given plugin. """ ensure_inside_venv(ctx) if plugin not in get_installed_plugins(): echo_error("Plugin {} does not seem to be installed.".format(plugin)) sys.exit(1) plugin_name = get_plugin_name(plugin) try: run_command...
[ "def", "uninstall", "(", "ctx", ",", "plugin", ")", ":", "ensure_inside_venv", "(", "ctx", ")", "if", "plugin", "not", "in", "get_installed_plugins", "(", ")", ":", "echo_error", "(", "\"Plugin {} does not seem to be installed.\"", ".", "format", "(", "plugin", ...
Uninstall the given plugin.
[ "Uninstall", "the", "given", "plugin", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/plugin.py#L155-L176
liip/taxi
taxi/timesheet/entry.py
Entry.hours
def hours(self): """ Return the number of hours this entry has lasted. If the duration is a tuple with a start and an end time, the difference between the two times will be calculated. If the duration is a number, it will be returned as-is. """ if not isinstance(self.dura...
python
def hours(self): """ Return the number of hours this entry has lasted. If the duration is a tuple with a start and an end time, the difference between the two times will be calculated. If the duration is a number, it will be returned as-is. """ if not isinstance(self.dura...
[ "def", "hours", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "duration", ",", "tuple", ")", ":", "return", "self", ".", "duration", "if", "self", ".", "duration", "[", "1", "]", "is", "None", ":", "return", "0", "time_start", ...
Return the number of hours this entry has lasted. If the duration is a tuple with a start and an end time, the difference between the two times will be calculated. If the duration is a number, it will be returned as-is.
[ "Return", "the", "number", "of", "hours", "this", "entry", "has", "lasted", ".", "If", "the", "duration", "is", "a", "tuple", "with", "a", "start", "and", "an", "end", "time", "the", "difference", "between", "the", "two", "times", "will", "be", "calculat...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L84-L115
liip/taxi
taxi/timesheet/entry.py
Entry.get_start_time
def get_start_time(self): """ Return the start time of the entry as a :class:`datetime.time` object. If the start time is `None`, the end time of the previous entry will be returned instead. If the current entry doesn't have a duration in the form of a tuple, if there's no previo...
python
def get_start_time(self): """ Return the start time of the entry as a :class:`datetime.time` object. If the start time is `None`, the end time of the previous entry will be returned instead. If the current entry doesn't have a duration in the form of a tuple, if there's no previo...
[ "def", "get_start_time", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "duration", ",", "tuple", ")", ":", "return", "None", "if", "self", ".", "duration", "[", "0", "]", "is", "not", "None", ":", "return", "self", ".", "duratio...
Return the start time of the entry as a :class:`datetime.time` object. If the start time is `None`, the end time of the previous entry will be returned instead. If the current entry doesn't have a duration in the form of a tuple, if there's no previous entry or if the previous entry has ...
[ "Return", "the", "start", "time", "of", "the", "entry", "as", "a", ":", "class", ":", "datetime", ".", "time", "object", ".", "If", "the", "start", "time", "is", "None", "the", "end", "time", "of", "the", "previous", "entry", "will", "be", "returned", ...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L125-L144
liip/taxi
taxi/timesheet/entry.py
Entry.hash
def hash(self): """ Return a value that's used to uniquely identify an entry in a date so we can regroup all entries that share the same hash. """ return u''.join([ self.alias, self.description, str(self.ignored), str(self.flags), ...
python
def hash(self): """ Return a value that's used to uniquely identify an entry in a date so we can regroup all entries that share the same hash. """ return u''.join([ self.alias, self.description, str(self.ignored), str(self.flags), ...
[ "def", "hash", "(", "self", ")", ":", "return", "u''", ".", "join", "(", "[", "self", ".", "alias", ",", "self", ".", "description", ",", "str", "(", "self", ".", "ignored", ")", ",", "str", "(", "self", ".", "flags", ")", ",", "]", ")" ]
Return a value that's used to uniquely identify an entry in a date so we can regroup all entries that share the same hash.
[ "Return", "a", "value", "that", "s", "used", "to", "uniquely", "identify", "an", "entry", "in", "a", "date", "so", "we", "can", "regroup", "all", "entries", "that", "share", "the", "same", "hash", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L147-L157
liip/taxi
taxi/timesheet/entry.py
Entry.add_flag
def add_flag(self, flag): """ Add flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text. """ super(Entry, self).add_flag(flag) self._changed_attrs.add('flags')
python
def add_flag(self, flag): """ Add flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text. """ super(Entry, self).add_flag(flag) self._changed_attrs.add('flags')
[ "def", "add_flag", "(", "self", ",", "flag", ")", ":", "super", "(", "Entry", ",", "self", ")", ".", "add_flag", "(", "flag", ")", "self", ".", "_changed_attrs", ".", "add", "(", "'flags'", ")" ]
Add flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text.
[ "Add", "flag", "to", "the", "flags", "and", "memorize", "this", "attribute", "has", "changed", "so", "we", "can", "regenerate", "it", "when", "outputting", "text", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L159-L165
liip/taxi
taxi/timesheet/entry.py
Entry.remove_flag
def remove_flag(self, flag): """ Remove flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text. """ super(Entry, self).remove_flag(flag) self._changed_attrs.add('flags')
python
def remove_flag(self, flag): """ Remove flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text. """ super(Entry, self).remove_flag(flag) self._changed_attrs.add('flags')
[ "def", "remove_flag", "(", "self", ",", "flag", ")", ":", "super", "(", "Entry", ",", "self", ")", ".", "remove_flag", "(", "flag", ")", "self", ".", "_changed_attrs", ".", "add", "(", "'flags'", ")" ]
Remove flag to the flags and memorize this attribute has changed so we can regenerate it when outputting text.
[ "Remove", "flag", "to", "the", "flags", "and", "memorize", "this", "attribute", "has", "changed", "so", "we", "can", "regenerate", "it", "when", "outputting", "text", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L167-L173
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.add_entry
def add_entry(self, date, entry): """ Add the given entry to the textual representation. """ in_date = False insert_at = 0 for (lineno, line) in enumerate(self.lines): # Search for the date of the entry if isinstance(line, DateLine) and line.date ...
python
def add_entry(self, date, entry): """ Add the given entry to the textual representation. """ in_date = False insert_at = 0 for (lineno, line) in enumerate(self.lines): # Search for the date of the entry if isinstance(line, DateLine) and line.date ...
[ "def", "add_entry", "(", "self", ",", "date", ",", "entry", ")", ":", "in_date", "=", "False", "insert_at", "=", "0", "for", "(", "lineno", ",", "line", ")", "in", "enumerate", "(", "self", ".", "lines", ")", ":", "# Search for the date of the entry", "i...
Add the given entry to the textual representation.
[ "Add", "the", "given", "entry", "to", "the", "textual", "representation", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L317-L343
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.delete_entries
def delete_entries(self, entries): """ Remove the given entries from the textual representation. """ self.lines = trim([ line for line in self.lines if not isinstance(line, Entry) or line not in entries ])
python
def delete_entries(self, entries): """ Remove the given entries from the textual representation. """ self.lines = trim([ line for line in self.lines if not isinstance(line, Entry) or line not in entries ])
[ "def", "delete_entries", "(", "self", ",", "entries", ")", ":", "self", ".", "lines", "=", "trim", "(", "[", "line", "for", "line", "in", "self", ".", "lines", "if", "not", "isinstance", "(", "line", ",", "Entry", ")", "or", "line", "not", "in", "e...
Remove the given entries from the textual representation.
[ "Remove", "the", "given", "entries", "from", "the", "textual", "representation", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L352-L359
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.delete_date
def delete_date(self, date): """ Remove the date line from the textual representation. This doesn't remove any entry line. """ self.lines = [ line for line in self.lines if not isinstance(line, DateLine) or line.date != date ] self.lines =...
python
def delete_date(self, date): """ Remove the date line from the textual representation. This doesn't remove any entry line. """ self.lines = [ line for line in self.lines if not isinstance(line, DateLine) or line.date != date ] self.lines =...
[ "def", "delete_date", "(", "self", ",", "date", ")", ":", "self", ".", "lines", "=", "[", "line", "for", "line", "in", "self", ".", "lines", "if", "not", "isinstance", "(", "line", ",", "DateLine", ")", "or", "line", ".", "date", "!=", "date", "]",...
Remove the date line from the textual representation. This doesn't remove any entry line.
[ "Remove", "the", "date", "line", "from", "the", "textual", "representation", ".", "This", "doesn", "t", "remove", "any", "entry", "line", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L365-L375
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.add_date
def add_date(self, date): """ Add the given date to the textual representation. """ self.lines = self.parser.add_date(date, self.lines)
python
def add_date(self, date): """ Add the given date to the textual representation. """ self.lines = self.parser.add_date(date, self.lines)
[ "def", "add_date", "(", "self", ",", "date", ")", ":", "self", ".", "lines", "=", "self", ".", "parser", ".", "add_date", "(", "date", ",", "self", ".", "lines", ")" ]
Add the given date to the textual representation.
[ "Add", "the", "given", "date", "to", "the", "textual", "representation", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L378-L382
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.init_from_str
def init_from_str(self, entries): """ Initialize the structured and textual data based on a string representing the entries. For detailed information about the format of this string, refer to the :func:`~taxi.timesheet.parser.parse_text` function. """ self.lines =...
python
def init_from_str(self, entries): """ Initialize the structured and textual data based on a string representing the entries. For detailed information about the format of this string, refer to the :func:`~taxi.timesheet.parser.parse_text` function. """ self.lines =...
[ "def", "init_from_str", "(", "self", ",", "entries", ")", ":", "self", ".", "lines", "=", "self", ".", "parser", ".", "parse_text", "(", "entries", ")", "for", "line", "in", "self", ".", "lines", ":", "if", "isinstance", "(", "line", ",", "DateLine", ...
Initialize the structured and textual data based on a string representing the entries. For detailed information about the format of this string, refer to the :func:`~taxi.timesheet.parser.parse_text` function.
[ "Initialize", "the", "structured", "and", "textual", "data", "based", "on", "a", "string", "representing", "the", "entries", ".", "For", "detailed", "information", "about", "the", "format", "of", "this", "string", "refer", "to", "the", ":", "func", ":", "~ta...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L384-L402
liip/taxi
taxi/timesheet/entry.py
EntriesCollection.filter
def filter(self, date=None, regroup=False, ignored=None, pushed=None, unmapped=None, current_workday=None): """ Return the entries as a dict of {:class:`datetime.date`: :class:`~taxi.timesheet.lines.Entry`} items. `date` can either be a single :class:`datetime.date` object to filter onl...
python
def filter(self, date=None, regroup=False, ignored=None, pushed=None, unmapped=None, current_workday=None): """ Return the entries as a dict of {:class:`datetime.date`: :class:`~taxi.timesheet.lines.Entry`} items. `date` can either be a single :class:`datetime.date` object to filter onl...
[ "def", "filter", "(", "self", ",", "date", "=", "None", ",", "regroup", "=", "False", ",", "ignored", "=", "None", ",", "pushed", "=", "None", ",", "unmapped", "=", "None", ",", "current_workday", "=", "None", ")", ":", "def", "entry_filter", "(", "e...
Return the entries as a dict of {:class:`datetime.date`: :class:`~taxi.timesheet.lines.Entry`} items. `date` can either be a single :class:`datetime.date` object to filter only entries from the given date, or a tuple of :class:`datetime.date` objects representing `(from, to)`. `filter_callback`...
[ "Return", "the", "entries", "as", "a", "dict", "of", "{", ":", "class", ":", "datetime", ".", "date", ":", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "}", "items", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L411-L509
liip/taxi
taxi/timesheet/entry.py
EntriesList.append
def append(self, x): """ Append the given element to the list and synchronize the textual representation. """ super(EntriesList, self).append(x) if self.entries_collection is not None: self.entries_collection.add_entry(self.date, x)
python
def append(self, x): """ Append the given element to the list and synchronize the textual representation. """ super(EntriesList, self).append(x) if self.entries_collection is not None: self.entries_collection.add_entry(self.date, x)
[ "def", "append", "(", "self", ",", "x", ")", ":", "super", "(", "EntriesList", ",", "self", ")", ".", "append", "(", "x", ")", "if", "self", ".", "entries_collection", "is", "not", "None", ":", "self", ".", "entries_collection", ".", "add_entry", "(", ...
Append the given element to the list and synchronize the textual representation.
[ "Append", "the", "given", "element", "to", "the", "list", "and", "synchronize", "the", "textual", "representation", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/entry.py#L540-L548
liip/taxi
taxi/ui/__init__.py
BaseUi.projects_database_update_success
def projects_database_update_success(self, aliases_after_update, projects_db): """ Display the results of the projects/aliases database update. We need the projects db to extract the name of the projects / activities. """ def show_aliases(...
python
def projects_database_update_success(self, aliases_after_update, projects_db): """ Display the results of the projects/aliases database update. We need the projects db to extract the name of the projects / activities. """ def show_aliases(...
[ "def", "projects_database_update_success", "(", "self", ",", "aliases_after_update", ",", "projects_db", ")", ":", "def", "show_aliases", "(", "aliases", ")", ":", "\"\"\"\n Display the given list of aliases in the following form:\n\n my_alias\n p...
Display the results of the projects/aliases database update. We need the projects db to extract the name of the projects / activities.
[ "Display", "the", "results", "of", "the", "projects", "/", "aliases", "database", "update", ".", "We", "need", "the", "projects", "db", "to", "extract", "the", "name", "of", "the", "projects", "/", "activities", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/ui/__init__.py#L396-L446
liip/taxi
taxi/timesheet/utils.py
is_top_down
def is_top_down(lines): """ Return `True` if dates in the given lines go in an ascending order, or `False` if they go in a descending order. If no order can be determined, return `None`. The given `lines` must be a list of lines, ie. :class:`~taxi.timesheet.lines.TextLine`, :class:`taxi.timesheet.lines....
python
def is_top_down(lines): """ Return `True` if dates in the given lines go in an ascending order, or `False` if they go in a descending order. If no order can be determined, return `None`. The given `lines` must be a list of lines, ie. :class:`~taxi.timesheet.lines.TextLine`, :class:`taxi.timesheet.lines....
[ "def", "is_top_down", "(", "lines", ")", ":", "date_lines", "=", "[", "line", "for", "line", "in", "lines", "if", "hasattr", "(", "line", ",", "'is_date_line'", ")", "and", "line", ".", "is_date_line", "]", "if", "len", "(", "date_lines", ")", "<", "2"...
Return `True` if dates in the given lines go in an ascending order, or `False` if they go in a descending order. If no order can be determined, return `None`. The given `lines` must be a list of lines, ie. :class:`~taxi.timesheet.lines.TextLine`, :class:`taxi.timesheet.lines.Entry` or :class:`~taxi.timeshee...
[ "Return", "True", "if", "dates", "in", "the", "given", "lines", "go", "in", "an", "ascending", "order", "or", "False", "if", "they", "go", "in", "a", "descending", "order", ".", "If", "no", "order", "can", "be", "determined", "return", "None", ".", "Th...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/utils.py#L4-L18
liip/taxi
taxi/timesheet/utils.py
trim
def trim(lines): """ Remove lines at the start and at the end of the given `lines` that are :class:`~taxi.timesheet.lines.TextLine` instances and don't have any text. """ trim_top = None trim_bottom = None _lines = lines[:] for (lineno, line) in enumerate(_lines): if hasattr(lin...
python
def trim(lines): """ Remove lines at the start and at the end of the given `lines` that are :class:`~taxi.timesheet.lines.TextLine` instances and don't have any text. """ trim_top = None trim_bottom = None _lines = lines[:] for (lineno, line) in enumerate(_lines): if hasattr(lin...
[ "def", "trim", "(", "lines", ")", ":", "trim_top", "=", "None", "trim_bottom", "=", "None", "_lines", "=", "lines", "[", ":", "]", "for", "(", "lineno", ",", "line", ")", "in", "enumerate", "(", "_lines", ")", ":", "if", "hasattr", "(", "line", ","...
Remove lines at the start and at the end of the given `lines` that are :class:`~taxi.timesheet.lines.TextLine` instances and don't have any text.
[ "Remove", "lines", "at", "the", "start", "and", "at", "the", "end", "of", "the", "given", "lines", "that", "are", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "TextLine", "instances", "and", "don", "t", "have", "any", "text", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/utils.py#L21-L49
liip/taxi
taxi/commands/commit.py
commit
def commit(ctx, f, force_yes, date): """ Commits your work to the server. The [date] option can be used either as a single date (eg. 20.01.2014), as a range (eg. 20.01.2014-22.01.2014), or as a range with one of the dates omitted (eg. -22.01.2014). """ timesheet_collection = get_timesheet_collec...
python
def commit(ctx, f, force_yes, date): """ Commits your work to the server. The [date] option can be used either as a single date (eg. 20.01.2014), as a range (eg. 20.01.2014-22.01.2014), or as a range with one of the dates omitted (eg. -22.01.2014). """ timesheet_collection = get_timesheet_collec...
[ "def", "commit", "(", "ctx", ",", "f", ",", "force_yes", ",", "date", ")", ":", "timesheet_collection", "=", "get_timesheet_collection_for_context", "(", "ctx", ",", "f", ")", "if", "not", "date", "and", "not", "force_yes", ":", "non_workday_entries", "=", "...
Commits your work to the server. The [date] option can be used either as a single date (eg. 20.01.2014), as a range (eg. 20.01.2014-22.01.2014), or as a range with one of the dates omitted (eg. -22.01.2014).
[ "Commits", "your", "work", "to", "the", "server", ".", "The", "[", "date", "]", "option", "can", "be", "used", "either", "as", "a", "single", "date", "(", "eg", ".", "20", ".", "01", ".", "2014", ")", "as", "a", "range", "(", "eg", ".", "20", "...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/commit.py#L24-L84
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam._request
async def _request(self, path): """Make the actual request and return the parsed response.""" url = '{}{}'.format(self.base_url, path) data = None try: async with self.websession.get(url, auth=self._auth, timeout=self._timeout) as response: if response.status...
python
async def _request(self, path): """Make the actual request and return the parsed response.""" url = '{}{}'.format(self.base_url, path) data = None try: async with self.websession.get(url, auth=self._auth, timeout=self._timeout) as response: if response.status...
[ "async", "def", "_request", "(", "self", ",", "path", ")", ":", "url", "=", "'{}{}'", ".", "format", "(", "self", ".", "base_url", ",", "path", ")", "data", "=", "None", "try", ":", "async", "with", "self", ".", "websession", ".", "get", "(", "url"...
Make the actual request and return the parsed response.
[ "Make", "the", "actual", "request", "and", "return", "the", "parsed", "response", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L54-L75
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.update
async def update(self): """Fetch the latest data from IP Webcam.""" status_data = await self._request('/status.json?show_avail=1') if status_data: self.status_data = status_data sensor_data = await self._request('/sensors.json') if sensor_data: ...
python
async def update(self): """Fetch the latest data from IP Webcam.""" status_data = await self._request('/status.json?show_avail=1') if status_data: self.status_data = status_data sensor_data = await self._request('/sensors.json') if sensor_data: ...
[ "async", "def", "update", "(", "self", ")", ":", "status_data", "=", "await", "self", ".", "_request", "(", "'/status.json?show_avail=1'", ")", "if", "status_data", ":", "self", ".", "status_data", "=", "status_data", "sensor_data", "=", "await", "self", ".", ...
Fetch the latest data from IP Webcam.
[ "Fetch", "the", "latest", "data", "from", "IP", "Webcam", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L77-L86
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.current_settings
def current_settings(self): """Return dict with all config include.""" settings = {} if not self.status_data: return settings for (key, val) in self.status_data.get('curvals', {}).items(): try: val = float(val) except ValueError: ...
python
def current_settings(self): """Return dict with all config include.""" settings = {} if not self.status_data: return settings for (key, val) in self.status_data.get('curvals', {}).items(): try: val = float(val) except ValueError: ...
[ "def", "current_settings", "(", "self", ")", ":", "settings", "=", "{", "}", "if", "not", "self", ".", "status_data", ":", "return", "settings", "for", "(", "key", ",", "val", ")", "in", "self", ".", "status_data", ".", "get", "(", "'curvals'", ",", ...
Return dict with all config include.
[ "Return", "dict", "with", "all", "config", "include", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L89-L106
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.available_settings
def available_settings(self): """Return dict of lists with all available config settings.""" available = {} if not self.status_data: return available for (key, val) in self.status_data.get('avail', {}).items(): available[key] = [] for subval in val: ...
python
def available_settings(self): """Return dict of lists with all available config settings.""" available = {} if not self.status_data: return available for (key, val) in self.status_data.get('avail', {}).items(): available[key] = [] for subval in val: ...
[ "def", "available_settings", "(", "self", ")", ":", "available", "=", "{", "}", "if", "not", "self", ".", "status_data", ":", "return", "available", "for", "(", "key", ",", "val", ")", "in", "self", ".", "status_data", ".", "get", "(", "'avail'", ",", ...
Return dict of lists with all available config settings.
[ "Return", "dict", "of", "lists", "with", "all", "available", "config", "settings", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L123-L142
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.export_sensor
def export_sensor(self, sensor): """Return (value, unit) from a sensor node.""" value = None unit = None try: container = self.sensor_data.get(sensor) unit = container.get('unit') data_point = container.get('data', [[0, [0.0]]]) if data_poi...
python
def export_sensor(self, sensor): """Return (value, unit) from a sensor node.""" value = None unit = None try: container = self.sensor_data.get(sensor) unit = container.get('unit') data_point = container.get('data', [[0, [0.0]]]) if data_poi...
[ "def", "export_sensor", "(", "self", ",", "sensor", ")", ":", "value", "=", "None", "unit", "=", "None", "try", ":", "container", "=", "self", ".", "sensor_data", ".", "get", "(", "sensor", ")", "unit", "=", "container", ".", "get", "(", "'unit'", ")...
Return (value, unit) from a sensor node.
[ "Return", "(", "value", "unit", ")", "from", "a", "sensor", "node", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L144-L157
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.change_setting
def change_setting(self, key, val): """Change a setting. Return a coroutine. """ if isinstance(val, bool): payload = 'on' if val else 'off' else: payload = val return self._request('/settings/{}?set={}'.format(key, payload))
python
def change_setting(self, key, val): """Change a setting. Return a coroutine. """ if isinstance(val, bool): payload = 'on' if val else 'off' else: payload = val return self._request('/settings/{}?set={}'.format(key, payload))
[ "def", "change_setting", "(", "self", ",", "key", ",", "val", ")", ":", "if", "isinstance", "(", "val", ",", "bool", ")", ":", "payload", "=", "'on'", "if", "val", "else", "'off'", "else", ":", "payload", "=", "val", "return", "self", ".", "_request"...
Change a setting. Return a coroutine.
[ "Change", "a", "setting", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L159-L168
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.record
def record(self, record=True, tag=None): """Enable/disable recording. Return a coroutine. """ path = '/startvideo?force=1' if record else '/stopvideo?force=1' if record and tag is not None: path = '/startvideo?force=1&tag={}'.format(URL(tag).raw_path) return...
python
def record(self, record=True, tag=None): """Enable/disable recording. Return a coroutine. """ path = '/startvideo?force=1' if record else '/stopvideo?force=1' if record and tag is not None: path = '/startvideo?force=1&tag={}'.format(URL(tag).raw_path) return...
[ "def", "record", "(", "self", ",", "record", "=", "True", ",", "tag", "=", "None", ")", ":", "path", "=", "'/startvideo?force=1'", "if", "record", "else", "'/stopvideo?force=1'", "if", "record", "and", "tag", "is", "not", "None", ":", "path", "=", "'/sta...
Enable/disable recording. Return a coroutine.
[ "Enable", "/", "disable", "recording", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L186-L195
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.set_orientation
def set_orientation(self, orientation='landscape'): """Set the video orientation. Return a coroutine. """ if orientation not in ALLOWED_ORIENTATIONS: _LOGGER.debug('%s is not a valid orientation', orientation) return False return self.change_setting('orie...
python
def set_orientation(self, orientation='landscape'): """Set the video orientation. Return a coroutine. """ if orientation not in ALLOWED_ORIENTATIONS: _LOGGER.debug('%s is not a valid orientation', orientation) return False return self.change_setting('orie...
[ "def", "set_orientation", "(", "self", ",", "orientation", "=", "'landscape'", ")", ":", "if", "orientation", "not", "in", "ALLOWED_ORIENTATIONS", ":", "_LOGGER", ".", "debug", "(", "'%s is not a valid orientation'", ",", "orientation", ")", "return", "False", "re...
Set the video orientation. Return a coroutine.
[ "Set", "the", "video", "orientation", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L238-L246
pvizeli/pydroid-ipcam
pydroid_ipcam.py
PyDroidIPCam.set_scenemode
def set_scenemode(self, scenemode='auto'): """Set the video scene mode. Return a coroutine. """ if scenemode not in self.available_settings['scenemode']: _LOGGER.debug('%s is not a valid scenemode', scenemode) return False return self.change_setting('scen...
python
def set_scenemode(self, scenemode='auto'): """Set the video scene mode. Return a coroutine. """ if scenemode not in self.available_settings['scenemode']: _LOGGER.debug('%s is not a valid scenemode', scenemode) return False return self.change_setting('scen...
[ "def", "set_scenemode", "(", "self", ",", "scenemode", "=", "'auto'", ")", ":", "if", "scenemode", "not", "in", "self", ".", "available_settings", "[", "'scenemode'", "]", ":", "_LOGGER", ".", "debug", "(", "'%s is not a valid scenemode'", ",", "scenemode", ")...
Set the video scene mode. Return a coroutine.
[ "Set", "the", "video", "scene", "mode", "." ]
train
https://github.com/pvizeli/pydroid-ipcam/blob/42275a77fafa01e027d0752664f382b813a6f9b0/pydroid_ipcam.py#L255-L263
liip/taxi
taxi/commands/base.py
get_timesheet_collection_for_context
def get_timesheet_collection_for_context(ctx, entries_file=None): """ Return a :class:`~taxi.timesheet.TimesheetCollection` object with the current timesheet(s). Since this depends on the settings (to get the entries files path, the number of previous files, etc) this uses the settings object from the c...
python
def get_timesheet_collection_for_context(ctx, entries_file=None): """ Return a :class:`~taxi.timesheet.TimesheetCollection` object with the current timesheet(s). Since this depends on the settings (to get the entries files path, the number of previous files, etc) this uses the settings object from the c...
[ "def", "get_timesheet_collection_for_context", "(", "ctx", ",", "entries_file", "=", "None", ")", ":", "if", "not", "entries_file", ":", "entries_file", "=", "ctx", ".", "obj", "[", "'settings'", "]", ".", "get_entries_file_path", "(", "False", ")", "parser", ...
Return a :class:`~taxi.timesheet.TimesheetCollection` object with the current timesheet(s). Since this depends on the settings (to get the entries files path, the number of previous files, etc) this uses the settings object from the current command context. If `entries_file` is set, this forces the path of the ...
[ "Return", "a", ":", "class", ":", "~taxi", ".", "timesheet", ".", "TimesheetCollection", "object", "with", "the", "current", "timesheet", "(", "s", ")", ".", "Since", "this", "depends", "on", "the", "settings", "(", "to", "get", "the", "entries", "files", ...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/base.py#L30-L45
liip/taxi
taxi/commands/base.py
create_config_file
def create_config_file(filename): """ Create main configuration file if it doesn't exist. """ import textwrap from six.moves.urllib import parse if not os.path.exists(filename): old_default_config_file = os.path.join(os.path.dirname(filename), ...
python
def create_config_file(filename): """ Create main configuration file if it doesn't exist. """ import textwrap from six.moves.urllib import parse if not os.path.exists(filename): old_default_config_file = os.path.join(os.path.dirname(filename), ...
[ "def", "create_config_file", "(", "filename", ")", ":", "import", "textwrap", "from", "six", ".", "moves", ".", "urllib", "import", "parse", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "old_default_config_file", "=", "os", "."...
Create main configuration file if it doesn't exist.
[ "Create", "main", "configuration", "file", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/base.py#L57-L146
liip/taxi
taxi/commands/base.py
date_options
def date_options(func): """ Decorator to add support for `--today/--not-today`, `--from` and `--to` options to the given command. The calculated date is then passed as a parameter named `date`. """ @click.option( '--until', type=Date(), help="Only show entries until the given date." ) ...
python
def date_options(func): """ Decorator to add support for `--today/--not-today`, `--from` and `--to` options to the given command. The calculated date is then passed as a parameter named `date`. """ @click.option( '--until', type=Date(), help="Only show entries until the given date." ) ...
[ "def", "date_options", "(", "func", ")", ":", "@", "click", ".", "option", "(", "'--until'", ",", "type", "=", "Date", "(", ")", ",", "help", "=", "\"Only show entries until the given date.\"", ")", "@", "click", ".", "option", "(", "'--since'", ",", "type...
Decorator to add support for `--today/--not-today`, `--from` and `--to` options to the given command. The calculated date is then passed as a parameter named `date`.
[ "Decorator", "to", "add", "support", "for", "--", "today", "/", "--", "not", "-", "today", "--", "from", "and", "--", "to", "options", "to", "the", "given", "command", ".", "The", "calculated", "date", "is", "then", "passed", "as", "a", "parameter", "n...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/base.py#L191-L224
liip/taxi
taxi/utils/date.py
months_ago
def months_ago(date, nb_months=1): """ Return the given `date` with `nb_months` substracted from it. """ nb_years = nb_months // 12 nb_months = nb_months % 12 month_diff = date.month - nb_months if month_diff > 0: new_month = month_diff else: new_month = 12 + month_diff...
python
def months_ago(date, nb_months=1): """ Return the given `date` with `nb_months` substracted from it. """ nb_years = nb_months // 12 nb_months = nb_months % 12 month_diff = date.month - nb_months if month_diff > 0: new_month = month_diff else: new_month = 12 + month_diff...
[ "def", "months_ago", "(", "date", ",", "nb_months", "=", "1", ")", ":", "nb_years", "=", "nb_months", "//", "12", "nb_months", "=", "nb_months", "%", "12", "month_diff", "=", "date", ".", "month", "-", "nb_months", "if", "month_diff", ">", "0", ":", "n...
Return the given `date` with `nb_months` substracted from it.
[ "Return", "the", "given", "date", "with", "nb_months", "substracted", "from", "it", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/utils/date.py#L34-L49
liip/taxi
taxi/utils/date.py
time_ago_to_date
def time_ago_to_date(value): """ Parse a date and return it as ``datetime.date`` objects. Examples of valid dates: * Relative: 2 days ago, today, yesterday, 1 week ago * Absolute: 25.10.2017 """ today = datetime.date.today() if value == 'today': return today elif value ...
python
def time_ago_to_date(value): """ Parse a date and return it as ``datetime.date`` objects. Examples of valid dates: * Relative: 2 days ago, today, yesterday, 1 week ago * Absolute: 25.10.2017 """ today = datetime.date.today() if value == 'today': return today elif value ...
[ "def", "time_ago_to_date", "(", "value", ")", ":", "today", "=", "datetime", ".", "date", ".", "today", "(", ")", "if", "value", "==", "'today'", ":", "return", "today", "elif", "value", "==", "'yesterday'", ":", "return", "today", "-", "datetime", ".", ...
Parse a date and return it as ``datetime.date`` objects. Examples of valid dates: * Relative: 2 days ago, today, yesterday, 1 week ago * Absolute: 25.10.2017
[ "Parse", "a", "date", "and", "return", "it", "as", "datetime", ".", "date", "objects", ".", "Examples", "of", "valid", "dates", ":" ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/utils/date.py#L52-L80
liip/taxi
taxi/commands/alias.py
list_
def list_(ctx, search_string, reverse, backend, used, inactive): """ List configured aliases. Aliases in red belong to inactive projects and trying to push entries to these aliases will probably result in an error. """ if not reverse: list_aliases(ctx, search_string, backend, used, inactive=...
python
def list_(ctx, search_string, reverse, backend, used, inactive): """ List configured aliases. Aliases in red belong to inactive projects and trying to push entries to these aliases will probably result in an error. """ if not reverse: list_aliases(ctx, search_string, backend, used, inactive=...
[ "def", "list_", "(", "ctx", ",", "search_string", ",", "reverse", ",", "backend", ",", "used", ",", "inactive", ")", ":", "if", "not", "reverse", ":", "list_aliases", "(", "ctx", ",", "search_string", ",", "backend", ",", "used", ",", "inactive", "=", ...
List configured aliases. Aliases in red belong to inactive projects and trying to push entries to these aliases will probably result in an error.
[ "List", "configured", "aliases", ".", "Aliases", "in", "red", "belong", "to", "inactive", "projects", "and", "trying", "to", "push", "entries", "to", "these", "aliases", "will", "probably", "result", "in", "an", "error", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/alias.py#L34-L42
liip/taxi
taxi/commands/alias.py
add
def add(ctx, alias, mapping, backend): """ Add a new alias to your configuration file. """ if not backend: backends_list = ctx.obj['settings'].get_backends() if len(backends_list) > 1: raise click.UsageError( "You're using more than 1 backend. Please set the b...
python
def add(ctx, alias, mapping, backend): """ Add a new alias to your configuration file. """ if not backend: backends_list = ctx.obj['settings'].get_backends() if len(backends_list) > 1: raise click.UsageError( "You're using more than 1 backend. Please set the b...
[ "def", "add", "(", "ctx", ",", "alias", ",", "mapping", ",", "backend", ")", ":", "if", "not", "backend", ":", "backends_list", "=", "ctx", ".", "obj", "[", "'settings'", "]", ".", "get_backends", "(", ")", "if", "len", "(", "backends_list", ")", ">"...
Add a new alias to your configuration file.
[ "Add", "a", "new", "alias", "to", "your", "configuration", "file", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/alias.py#L50-L63
liip/taxi
taxi/settings.py
Settings.convert_to_4
def convert_to_4(self): """ Convert a pre-4.0 configuration file to a 4.0 configuration file. """ from six.moves.urllib import parse if not self.config.has_section('backends'): self.config.add_section('backends') site = parse.urlparse(self.get('site', defaul...
python
def convert_to_4(self): """ Convert a pre-4.0 configuration file to a 4.0 configuration file. """ from six.moves.urllib import parse if not self.config.has_section('backends'): self.config.add_section('backends') site = parse.urlparse(self.get('site', defaul...
[ "def", "convert_to_4", "(", "self", ")", ":", "from", "six", ".", "moves", ".", "urllib", "import", "parse", "if", "not", "self", ".", "config", ".", "has_section", "(", "'backends'", ")", ":", "self", ".", "config", ".", "add_section", "(", "'backends'"...
Convert a pre-4.0 configuration file to a 4.0 configuration file.
[ "Convert", "a", "pre", "-", "4", ".", "0", "configuration", "file", "to", "a", "4", ".", "0", "configuration", "file", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/settings.py#L195-L233
liip/taxi
taxi/commands/autofill.py
autofill
def autofill(ctx, f): """ Fills your timesheet up to today, for the defined auto_fill_days. """ auto_fill_days = ctx.obj['settings']['auto_fill_days'] if not auto_fill_days: ctx.obj['view'].view.err("The parameter `auto_fill_days` must be set " "to use this ...
python
def autofill(ctx, f): """ Fills your timesheet up to today, for the defined auto_fill_days. """ auto_fill_days = ctx.obj['settings']['auto_fill_days'] if not auto_fill_days: ctx.obj['view'].view.err("The parameter `auto_fill_days` must be set " "to use this ...
[ "def", "autofill", "(", "ctx", ",", "f", ")", ":", "auto_fill_days", "=", "ctx", ".", "obj", "[", "'settings'", "]", "[", "'auto_fill_days'", "]", "if", "not", "auto_fill_days", ":", "ctx", ".", "obj", "[", "'view'", "]", ".", "view", ".", "err", "("...
Fills your timesheet up to today, for the defined auto_fill_days.
[ "Fills", "your", "timesheet", "up", "to", "today", "for", "the", "defined", "auto_fill_days", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/autofill.py#L15-L37
liip/taxi
taxi/commands/project.py
list_
def list_(ctx, search, backend): """ Searches for a project by its name. The letter in the first column indicates the status of the project: [N]ot started, [A]ctive, [F]inished, [C]ancelled. """ projects = ctx.obj['projects_db'].search(search, backend=backend) projects = sorted(projects, key...
python
def list_(ctx, search, backend): """ Searches for a project by its name. The letter in the first column indicates the status of the project: [N]ot started, [A]ctive, [F]inished, [C]ancelled. """ projects = ctx.obj['projects_db'].search(search, backend=backend) projects = sorted(projects, key...
[ "def", "list_", "(", "ctx", ",", "search", ",", "backend", ")", ":", "projects", "=", "ctx", ".", "obj", "[", "'projects_db'", "]", ".", "search", "(", "search", ",", "backend", "=", "backend", ")", "projects", "=", "sorted", "(", "projects", ",", "k...
Searches for a project by its name. The letter in the first column indicates the status of the project: [N]ot started, [A]ctive, [F]inished, [C]ancelled.
[ "Searches", "for", "a", "project", "by", "its", "name", ".", "The", "letter", "in", "the", "first", "column", "indicates", "the", "status", "of", "the", "project", ":", "[", "N", "]", "ot", "started", "[", "A", "]", "ctive", "[", "F", "]", "inished",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/project.py#L24-L32
liip/taxi
taxi/commands/project.py
alias
def alias(ctx, search, backend): """ Searches for the given project and interactively add an alias for it. """ projects = ctx.obj['projects_db'].search(search, active_only=True) projects = sorted(projects, key=lambda project: project.name) if len(projects) == 0: ctx.obj['view'].msg( ...
python
def alias(ctx, search, backend): """ Searches for the given project and interactively add an alias for it. """ projects = ctx.obj['projects_db'].search(search, active_only=True) projects = sorted(projects, key=lambda project: project.name) if len(projects) == 0: ctx.obj['view'].msg( ...
[ "def", "alias", "(", "ctx", ",", "search", ",", "backend", ")", ":", "projects", "=", "ctx", ".", "obj", "[", "'projects_db'", "]", ".", "search", "(", "search", ",", "active_only", "=", "True", ")", "projects", "=", "sorted", "(", "projects", ",", "...
Searches for the given project and interactively add an alias for it.
[ "Searches", "for", "the", "given", "project", "and", "interactively", "add", "an", "alias", "for", "it", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/project.py#L39-L95
liip/taxi
taxi/commands/project.py
show
def show(ctx, project_id, backend): """ Shows the details of the given project id. """ try: project = ctx.obj['projects_db'].get(project_id, backend) except IOError: raise Exception("Error: the projects database file doesn't exist. " "Please run `taxi update` ...
python
def show(ctx, project_id, backend): """ Shows the details of the given project id. """ try: project = ctx.obj['projects_db'].get(project_id, backend) except IOError: raise Exception("Error: the projects database file doesn't exist. " "Please run `taxi update` ...
[ "def", "show", "(", "ctx", ",", "project_id", ",", "backend", ")", ":", "try", ":", "project", "=", "ctx", ".", "obj", "[", "'projects_db'", "]", ".", "get", "(", "project_id", ",", "backend", ")", "except", "IOError", ":", "raise", "Exception", "(", ...
Shows the details of the given project id.
[ "Shows", "the", "details", "of", "the", "given", "project", "id", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/project.py#L103-L118
liip/taxi
taxi/commands/stop.py
stop
def stop(ctx, description, f): """ Use it when you stop working on the current task. You can add a description to what you've done. """ description = ' '.join(description) try: timesheet_collection = get_timesheet_collection_for_context(ctx, f) current_timesheet = timesheet_colle...
python
def stop(ctx, description, f): """ Use it when you stop working on the current task. You can add a description to what you've done. """ description = ' '.join(description) try: timesheet_collection = get_timesheet_collection_for_context(ctx, f) current_timesheet = timesheet_colle...
[ "def", "stop", "(", "ctx", ",", "description", ",", "f", ")", ":", "description", "=", "' '", ".", "join", "(", "description", ")", "try", ":", "timesheet_collection", "=", "get_timesheet_collection_for_context", "(", "ctx", ",", "f", ")", "current_timesheet",...
Use it when you stop working on the current task. You can add a description to what you've done.
[ "Use", "it", "when", "you", "stop", "working", "on", "the", "current", "task", ".", "You", "can", "add", "a", "description", "to", "what", "you", "ve", "done", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/stop.py#L16-L37
liip/taxi
taxi/commands/start.py
start
def start(ctx, alias, description, f): """ Use it when you start working on the given activity. This will add the activity and the current time to your entries file. When you're finished, use the stop command. """ today = datetime.date.today() try: timesheet_collection = get_timeshe...
python
def start(ctx, alias, description, f): """ Use it when you start working on the given activity. This will add the activity and the current time to your entries file. When you're finished, use the stop command. """ today = datetime.date.today() try: timesheet_collection = get_timeshe...
[ "def", "start", "(", "ctx", ",", "alias", ",", "description", ",", "f", ")", ":", "today", "=", "datetime", ".", "date", ".", "today", "(", ")", "try", ":", "timesheet_collection", "=", "get_timesheet_collection_for_context", "(", "ctx", ",", "f", ")", "...
Use it when you start working on the given activity. This will add the activity and the current time to your entries file. When you're finished, use the stop command.
[ "Use", "it", "when", "you", "start", "working", "on", "the", "given", "activity", ".", "This", "will", "add", "the", "activity", "and", "the", "current", "time", "to", "your", "entries", "file", ".", "When", "you", "re", "finished", "use", "the", "stop",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/start.py#L18-L49
liip/taxi
taxi/timesheet/parser.py
create_time_from_text
def create_time_from_text(text): """ Parse a time in the form ``hh:mm`` or ``hhmm`` (or even ``hmm``) and return a :class:`datetime.time` object. If no valid time can be extracted from the given string, :exc:`ValueError` will be raised. """ text = text.replace(':', '') if not re.match('^\d{3,}$...
python
def create_time_from_text(text): """ Parse a time in the form ``hh:mm`` or ``hhmm`` (or even ``hmm``) and return a :class:`datetime.time` object. If no valid time can be extracted from the given string, :exc:`ValueError` will be raised. """ text = text.replace(':', '') if not re.match('^\d{3,}$...
[ "def", "create_time_from_text", "(", "text", ")", ":", "text", "=", "text", ".", "replace", "(", "':'", ",", "''", ")", "if", "not", "re", ".", "match", "(", "'^\\d{3,}$'", ",", "text", ")", ":", "raise", "ValueError", "(", "\"Time must be numeric\"", ")...
Parse a time in the form ``hh:mm`` or ``hhmm`` (or even ``hmm``) and return a :class:`datetime.time` object. If no valid time can be extracted from the given string, :exc:`ValueError` will be raised.
[ "Parse", "a", "time", "in", "the", "form", "hh", ":", "mm", "or", "hhmm", "(", "or", "even", "hmm", ")", "and", "return", "a", ":", "class", ":", "datetime", ".", "time", "object", ".", "If", "no", "valid", "time", "can", "be", "extracted", "from",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L13-L26
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.duration_to_text
def duration_to_text(self, duration): """ Return the textual representation of the given `duration`. The duration can either be a tuple of :class:`datetime.time` objects, or a simple number. The returned text will be either a hhmm-hhmm string (if the given `duration` is a tuple) or a num...
python
def duration_to_text(self, duration): """ Return the textual representation of the given `duration`. The duration can either be a tuple of :class:`datetime.time` objects, or a simple number. The returned text will be either a hhmm-hhmm string (if the given `duration` is a tuple) or a num...
[ "def", "duration_to_text", "(", "self", ",", "duration", ")", ":", "if", "isinstance", "(", "duration", ",", "tuple", ")", ":", "start", "=", "(", "duration", "[", "0", "]", ".", "strftime", "(", "self", ".", "ENTRY_DURATION_FORMAT", ")", "if", "duration...
Return the textual representation of the given `duration`. The duration can either be a tuple of :class:`datetime.time` objects, or a simple number. The returned text will be either a hhmm-hhmm string (if the given `duration` is a tuple) or a number.
[ "Return", "the", "textual", "representation", "of", "the", "given", "duration", ".", "The", "duration", "can", "either", "be", "a", "tuple", "of", ":", "class", ":", "datetime", ".", "time", "objects", "or", "a", "simple", "number", ".", "The", "returned",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L101-L120
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.to_text
def to_text(self, line): """ Return the textual representation of the given `line`. """ return getattr(self, self.ENTRY_TRANSFORMERS[line.__class__])(line)
python
def to_text(self, line): """ Return the textual representation of the given `line`. """ return getattr(self, self.ENTRY_TRANSFORMERS[line.__class__])(line)
[ "def", "to_text", "(", "self", ",", "line", ")", ":", "return", "getattr", "(", "self", ",", "self", ".", "ENTRY_TRANSFORMERS", "[", "line", ".", "__class__", "]", ")", "(", "line", ")" ]
Return the textual representation of the given `line`.
[ "Return", "the", "textual", "representation", "of", "the", "given", "line", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L122-L126
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.date_line_to_text
def date_line_to_text(self, date_line): """ Return the textual representation of the given :class:`~taxi.timesheet.lines.DateLine` instance. The date format is set by the `date_format` parameter given when instanciating the parser instance. """ # Changing the date in a dateline i...
python
def date_line_to_text(self, date_line): """ Return the textual representation of the given :class:`~taxi.timesheet.lines.DateLine` instance. The date format is set by the `date_format` parameter given when instanciating the parser instance. """ # Changing the date in a dateline i...
[ "def", "date_line_to_text", "(", "self", ",", "date_line", ")", ":", "# Changing the date in a dateline is not supported yet, but if it gets implemented someday this will need to be", "# changed", "if", "date_line", ".", "_text", "is", "not", "None", ":", "return", "date_line",...
Return the textual representation of the given :class:`~taxi.timesheet.lines.DateLine` instance. The date format is set by the `date_format` parameter given when instanciating the parser instance.
[ "Return", "the", "textual", "representation", "of", "the", "given", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "DateLine", "instance", ".", "The", "date", "format", "is", "set", "by", "the", "date_format", "parameter", "given", "when", ...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L128-L138
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.entry_line_to_text
def entry_line_to_text(self, entry): """ Return the textual representation of an :class:`~taxi.timesheet.lines.Entry` instance. This method is a bit convoluted since we don't want to completely mess up the original formatting of the entry. """ line = [] # The entry is ne...
python
def entry_line_to_text(self, entry): """ Return the textual representation of an :class:`~taxi.timesheet.lines.Entry` instance. This method is a bit convoluted since we don't want to completely mess up the original formatting of the entry. """ line = [] # The entry is ne...
[ "def", "entry_line_to_text", "(", "self", ",", "entry", ")", ":", "line", "=", "[", "]", "# The entry is new, it didn't come from an existing line, so let's just return a simple text representation of", "# it", "if", "not", "entry", ".", "_text", ":", "flags_text", "=", "...
Return the textual representation of an :class:`~taxi.timesheet.lines.Entry` instance. This method is a bit convoluted since we don't want to completely mess up the original formatting of the entry.
[ "Return", "the", "textual", "representation", "of", "an", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "instance", ".", "This", "method", "is", "a", "bit", "convoluted", "since", "we", "don", "t", "want", "to", "completely", ...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L146-L187
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.create_entry_line_from_text
def create_entry_line_from_text(self, text): """ Try to parse the given text line and extract and entry. Return an :class:`~taxi.timesheet.lines.Entry` object if parsing is successful, otherwise raise :exc:`~taxi.exceptions.ParseError`. """ split_line = re.match(self.entry_line_r...
python
def create_entry_line_from_text(self, text): """ Try to parse the given text line and extract and entry. Return an :class:`~taxi.timesheet.lines.Entry` object if parsing is successful, otherwise raise :exc:`~taxi.exceptions.ParseError`. """ split_line = re.match(self.entry_line_r...
[ "def", "create_entry_line_from_text", "(", "self", ",", "text", ")", ":", "split_line", "=", "re", ".", "match", "(", "self", ".", "entry_line_regexp", ",", "text", ")", "if", "not", "split_line", ":", "raise", "ParseError", "(", "\"Line must have an alias, a du...
Try to parse the given text line and extract and entry. Return an :class:`~taxi.timesheet.lines.Entry` object if parsing is successful, otherwise raise :exc:`~taxi.exceptions.ParseError`.
[ "Try", "to", "parse", "the", "given", "text", "line", "and", "extract", "and", "entry", ".", "Return", "an", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "object", "if", "parsing", "is", "successful", "otherwise", "raise", ":...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L189-L260
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.create_date_from_text
def create_date_from_text(self, text): """ Parse a text in the form dd/mm/yyyy, dd/mm/yy or yyyy/mm/dd and return a corresponding :class:`datetime.date` object. If no date can be extracted from the given text, a :exc:`ValueError` will be raised. """ # Try to match dd/mm/yyyy form...
python
def create_date_from_text(self, text): """ Parse a text in the form dd/mm/yyyy, dd/mm/yy or yyyy/mm/dd and return a corresponding :class:`datetime.date` object. If no date can be extracted from the given text, a :exc:`ValueError` will be raised. """ # Try to match dd/mm/yyyy form...
[ "def", "create_date_from_text", "(", "self", ",", "text", ")", ":", "# Try to match dd/mm/yyyy format", "date_matches", "=", "re", ".", "match", "(", "self", ".", "DATE_LINE_REGEXP", ",", "text", ")", "# If no match, try with yyyy/mm/dd format", "if", "date_matches", ...
Parse a text in the form dd/mm/yyyy, dd/mm/yy or yyyy/mm/dd and return a corresponding :class:`datetime.date` object. If no date can be extracted from the given text, a :exc:`ValueError` will be raised.
[ "Parse", "a", "text", "in", "the", "form", "dd", "/", "mm", "/", "yyyy", "dd", "/", "mm", "/", "yy", "or", "yyyy", "/", "mm", "/", "dd", "and", "return", "a", "corresponding", ":", "class", ":", "datetime", ".", "date", "object", ".", "If", "no",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L262-L290
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.extract_flags_from_text
def extract_flags_from_text(self, text): """ Extract the flags from the given text and return a :class:`set` of flag values. See :class:`~taxi.timesheet.lines.Entry` for a list of existing flags. """ flags = set() reversed_flags_repr = {v: k for k, v in self.flags_repr.it...
python
def extract_flags_from_text(self, text): """ Extract the flags from the given text and return a :class:`set` of flag values. See :class:`~taxi.timesheet.lines.Entry` for a list of existing flags. """ flags = set() reversed_flags_repr = {v: k for k, v in self.flags_repr.it...
[ "def", "extract_flags_from_text", "(", "self", ",", "text", ")", ":", "flags", "=", "set", "(", ")", "reversed_flags_repr", "=", "{", "v", ":", "k", "for", "k", ",", "v", "in", "self", ".", "flags_repr", ".", "items", "(", ")", "}", "for", "flag_repr...
Extract the flags from the given text and return a :class:`set` of flag values. See :class:`~taxi.timesheet.lines.Entry` for a list of existing flags.
[ "Extract", "the", "flags", "from", "the", "given", "text", "and", "return", "a", ":", "class", ":", "set", "of", "flag", "values", ".", "See", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "for", "a", "list", "of", "existi...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L292-L305
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.parse_text
def parse_text(self, text): """ Parse the given text and return a list of :class:`~taxi.timesheet.lines.DateLine`, :class:`~taxi.timesheet.lines.Entry`, and :class:`~taxi.timesheet.lines.TextLine` objects. If there's an error during parsing, a :exc:`taxi.exceptions.ParseError` will be ra...
python
def parse_text(self, text): """ Parse the given text and return a list of :class:`~taxi.timesheet.lines.DateLine`, :class:`~taxi.timesheet.lines.Entry`, and :class:`~taxi.timesheet.lines.TextLine` objects. If there's an error during parsing, a :exc:`taxi.exceptions.ParseError` will be ra...
[ "def", "parse_text", "(", "self", ",", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "lines", "=", "text", ".", "splitlines", "(", ")", "parsed_lines", "=", "[", "]", "encountered_date", "=", "False", "for", "(", "lineno", ",", "line...
Parse the given text and return a list of :class:`~taxi.timesheet.lines.DateLine`, :class:`~taxi.timesheet.lines.Entry`, and :class:`~taxi.timesheet.lines.TextLine` objects. If there's an error during parsing, a :exc:`taxi.exceptions.ParseError` will be raised.
[ "Parse", "the", "given", "text", "and", "return", "a", "list", "of", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "DateLine", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "and", ":", "class", ":", "~ta...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L307-L334
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.parse_line
def parse_line(self, text): """ Parse the given `text` and return either a :class:`~taxi.timesheet.lines.DateLine`, an :class:`~taxi.timesheet.lines.Entry`, or a :class:`~taxi.timesheet.lines.TextLine`, or raise :exc:`taxi.exceptions.ParseError` if the line can't be parser. See the trans...
python
def parse_line(self, text): """ Parse the given `text` and return either a :class:`~taxi.timesheet.lines.DateLine`, an :class:`~taxi.timesheet.lines.Entry`, or a :class:`~taxi.timesheet.lines.TextLine`, or raise :exc:`taxi.exceptions.ParseError` if the line can't be parser. See the trans...
[ "def", "parse_line", "(", "self", ",", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", ".", "replace", "(", "'\\t'", ",", "' '", "*", "4", ")", "# The logic is: if the line starts with a #, consider it's a comment (TextLine), otherwise try to parse it a...
Parse the given `text` and return either a :class:`~taxi.timesheet.lines.DateLine`, an :class:`~taxi.timesheet.lines.Entry`, or a :class:`~taxi.timesheet.lines.TextLine`, or raise :exc:`taxi.exceptions.ParseError` if the line can't be parser. See the transformation methods :meth:`create_date_fro...
[ "Parse", "the", "given", "text", "and", "return", "either", "a", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "DateLine", "an", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "or", "a", ":", "class", ":"...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L336-L358
liip/taxi
taxi/timesheet/parser.py
TimesheetParser.add_date
def add_date(self, date, lines): """ Return the given `lines` with the `date` added in the right place (ie. to the beginning or to the end of the given lines, depending on the `add_date_to_bottom` property). """ _lines = lines[:] _lines = trim(_lines) if self.add...
python
def add_date(self, date, lines): """ Return the given `lines` with the `date` added in the right place (ie. to the beginning or to the end of the given lines, depending on the `add_date_to_bottom` property). """ _lines = lines[:] _lines = trim(_lines) if self.add...
[ "def", "add_date", "(", "self", ",", "date", ",", "lines", ")", ":", "_lines", "=", "lines", "[", ":", "]", "_lines", "=", "trim", "(", "_lines", ")", "if", "self", ".", "add_date_to_bottom", "is", "None", ":", "add_date_to_bottom", "=", "is_top_down", ...
Return the given `lines` with the `date` added in the right place (ie. to the beginning or to the end of the given lines, depending on the `add_date_to_bottom` property).
[ "Return", "the", "given", "lines", "with", "the", "date", "added", "in", "the", "right", "place", "(", "ie", ".", "to", "the", "beginning", "or", "to", "the", "end", "of", "the", "given", "lines", "depending", "on", "the", "add_date_to_bottom", "property",...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L360-L380
liip/taxi
taxi/commands/update.py
update
def update(ctx): """ Synchronizes your project database with the server and updates the shared aliases. """ ctx.obj['view'].updating_projects_database() projects = [] for backend_name, backend_uri in ctx.obj['settings'].get_backends(): backend = plugins_registry.get_backend(backend...
python
def update(ctx): """ Synchronizes your project database with the server and updates the shared aliases. """ ctx.obj['view'].updating_projects_database() projects = [] for backend_name, backend_uri in ctx.obj['settings'].get_backends(): backend = plugins_registry.get_backend(backend...
[ "def", "update", "(", "ctx", ")", ":", "ctx", ".", "obj", "[", "'view'", "]", ".", "updating_projects_database", "(", ")", "projects", "=", "[", "]", "for", "backend_name", ",", "backend_uri", "in", "ctx", ".", "obj", "[", "'settings'", "]", ".", "get_...
Synchronizes your project database with the server and updates the shared aliases.
[ "Synchronizes", "your", "project", "database", "with", "the", "server", "and", "updates", "the", "shared", "aliases", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/update.py#L13-L69
sebriois/biomart
biomart/dataset.py
BiomartDataset.attributes
def attributes(self): """ A dictionary mapping names of attributes to BiomartAttribute instances. This causes overwriting errors if there are diffferent pages which use the same attribute names, but is kept for backward compatibility. """ if not self._attribute_pages: ...
python
def attributes(self): """ A dictionary mapping names of attributes to BiomartAttribute instances. This causes overwriting errors if there are diffferent pages which use the same attribute names, but is kept for backward compatibility. """ if not self._attribute_pages: ...
[ "def", "attributes", "(", "self", ")", ":", "if", "not", "self", ".", "_attribute_pages", ":", "self", ".", "fetch_attributes", "(", ")", "result", "=", "{", "}", "for", "page", "in", "self", ".", "_attribute_pages", ".", "values", "(", ")", ":", "resu...
A dictionary mapping names of attributes to BiomartAttribute instances. This causes overwriting errors if there are diffferent pages which use the same attribute names, but is kept for backward compatibility.
[ "A", "dictionary", "mapping", "names", "of", "attributes", "to", "BiomartAttribute", "instances", "." ]
train
https://github.com/sebriois/biomart/blob/96d16abba314d8752d7014ee5f4761a0ad763fdf/biomart/dataset.py#L34-L46
liip/taxi
taxi/plugins.py
PluginsRegistry.get_backends_by_class
def get_backends_by_class(self, backend_class): """ Return a list of backends that are instances of the given `backend_class`. """ return [backend for backend in self._backends_registry.values() if isinstance(backend, backend_class)]
python
def get_backends_by_class(self, backend_class): """ Return a list of backends that are instances of the given `backend_class`. """ return [backend for backend in self._backends_registry.values() if isinstance(backend, backend_class)]
[ "def", "get_backends_by_class", "(", "self", ",", "backend_class", ")", ":", "return", "[", "backend", "for", "backend", "in", "self", ".", "_backends_registry", ".", "values", "(", ")", "if", "isinstance", "(", "backend", ",", "backend_class", ")", "]" ]
Return a list of backends that are instances of the given `backend_class`.
[ "Return", "a", "list", "of", "backends", "that", "are", "instances", "of", "the", "given", "backend_class", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/plugins.py#L68-L72
liip/taxi
taxi/plugins.py
PluginsRegistry.populate_backends
def populate_backends(self, backends, context): """ Iterate over the given backends list and instantiate every backend found. Can raise :exc:`BackendNotFoundError` if a backend could not be found in the registered entry points. The `backends` parameter should be a dict with back...
python
def populate_backends(self, backends, context): """ Iterate over the given backends list and instantiate every backend found. Can raise :exc:`BackendNotFoundError` if a backend could not be found in the registered entry points. The `backends` parameter should be a dict with back...
[ "def", "populate_backends", "(", "self", ",", "backends", ",", "context", ")", ":", "for", "name", ",", "uri", "in", "backends", ".", "items", "(", ")", ":", "self", ".", "_backends_registry", "[", "name", "]", "=", "self", ".", "_load_backend", "(", "...
Iterate over the given backends list and instantiate every backend found. Can raise :exc:`BackendNotFoundError` if a backend could not be found in the registered entry points. The `backends` parameter should be a dict with backend names as keys and URIs as values.
[ "Iterate", "over", "the", "given", "backends", "list", "and", "instantiate", "every", "backend", "found", ".", "Can", "raise", ":", "exc", ":", "BackendNotFoundError", "if", "a", "backend", "could", "not", "be", "found", "in", "the", "registered", "entry", "...
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/plugins.py#L74-L84
liip/taxi
taxi/plugins.py
PluginsRegistry._load_backend
def _load_backend(self, backend_uri, context): """ Return the instantiated backend object identified by the given `backend_uri`. The entry point that is used to create the backend object is determined by the protocol part of the given URI. """ parsed = parse.urlp...
python
def _load_backend(self, backend_uri, context): """ Return the instantiated backend object identified by the given `backend_uri`. The entry point that is used to create the backend object is determined by the protocol part of the given URI. """ parsed = parse.urlp...
[ "def", "_load_backend", "(", "self", ",", "backend_uri", ",", "context", ")", ":", "parsed", "=", "parse", ".", "urlparse", "(", "backend_uri", ")", "options", "=", "dict", "(", "parse", ".", "parse_qsl", "(", "parsed", ".", "query", ")", ")", "try", "...
Return the instantiated backend object identified by the given `backend_uri`. The entry point that is used to create the backend object is determined by the protocol part of the given URI.
[ "Return", "the", "instantiated", "backend", "object", "identified", "by", "the", "given", "backend_uri", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/plugins.py#L86-L114
liip/taxi
taxi/plugins.py
PluginsRegistry.register_commands
def register_commands(self): """ Load entry points for custom commands. """ for command in self._entry_points[self.COMMANDS_ENTRY_POINT].values(): command.load()
python
def register_commands(self): """ Load entry points for custom commands. """ for command in self._entry_points[self.COMMANDS_ENTRY_POINT].values(): command.load()
[ "def", "register_commands", "(", "self", ")", ":", "for", "command", "in", "self", ".", "_entry_points", "[", "self", ".", "COMMANDS_ENTRY_POINT", "]", ".", "values", "(", ")", ":", "command", ".", "load", "(", ")" ]
Load entry points for custom commands.
[ "Load", "entry", "points", "for", "custom", "commands", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/plugins.py#L116-L121
liip/taxi
taxi/timesheet/flags.py
FlaggableMixin._add_or_remove_flag
def _add_or_remove_flag(self, flag, add): """ Add the given `flag` if `add` is True, remove it otherwise. """ meth = self.add_flag if add else self.remove_flag meth(flag)
python
def _add_or_remove_flag(self, flag, add): """ Add the given `flag` if `add` is True, remove it otherwise. """ meth = self.add_flag if add else self.remove_flag meth(flag)
[ "def", "_add_or_remove_flag", "(", "self", ",", "flag", ",", "add", ")", ":", "meth", "=", "self", ".", "add_flag", "if", "add", "else", "self", ".", "remove_flag", "meth", "(", "flag", ")" ]
Add the given `flag` if `add` is True, remove it otherwise.
[ "Add", "the", "given", "flag", "if", "add", "is", "True", "remove", "it", "otherwise", "." ]
train
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/flags.py#L33-L38
IBMStreams/pypi.streamsx
streamsx/ec.py
get_application_configuration
def get_application_configuration(name): """Get a named application configuration. An application configuration is a named set of securely stored properties where each key and its value in the property set is a string. An application configuration object is used to store information that IBM Strea...
python
def get_application_configuration(name): """Get a named application configuration. An application configuration is a named set of securely stored properties where each key and its value in the property set is a string. An application configuration object is used to store information that IBM Strea...
[ "def", "get_application_configuration", "(", "name", ")", ":", "_check", "(", ")", "rc", "=", "_ec", ".", "get_application_configuration", "(", "name", ")", "if", "rc", "is", "False", ":", "raise", "ValueError", "(", "\"Application configuration {0} not found.\"", ...
Get a named application configuration. An application configuration is a named set of securely stored properties where each key and its value in the property set is a string. An application configuration object is used to store information that IBM Streams applications require, such as: * Databas...
[ "Get", "a", "named", "application", "configuration", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/ec.py#L238-L264
IBMStreams/pypi.streamsx
streamsx/ec.py
_submit
def _submit(primitive, port_index, tuple_): """Internal method to submit a tuple""" args = (_get_opc(primitive), port_index, tuple_) _ec._submit(args)
python
def _submit(primitive, port_index, tuple_): """Internal method to submit a tuple""" args = (_get_opc(primitive), port_index, tuple_) _ec._submit(args)
[ "def", "_submit", "(", "primitive", ",", "port_index", ",", "tuple_", ")", ":", "args", "=", "(", "_get_opc", "(", "primitive", ")", ",", "port_index", ",", "tuple_", ")", "_ec", ".", "_submit", "(", "args", ")" ]
Internal method to submit a tuple
[ "Internal", "method", "to", "submit", "a", "tuple" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/ec.py#L489-L492
IBMStreams/pypi.streamsx
streamsx/ec.py
CustomMetric.value
def value(self, value): """ Set the current value of the metric. """ args = (self.__ptr, int(value)) _ec.metric_set(args)
python
def value(self, value): """ Set the current value of the metric. """ args = (self.__ptr, int(value)) _ec.metric_set(args)
[ "def", "value", "(", "self", ",", "value", ")", ":", "args", "=", "(", "self", ".", "__ptr", ",", "int", "(", "value", ")", ")", "_ec", ".", "metric_set", "(", "args", ")" ]
Set the current value of the metric.
[ "Set", "the", "current", "value", "of", "the", "metric", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/ec.py#L444-L449
IBMStreams/pypi.streamsx
streamsx/_streams/_placement.py
_Placement.resource_tags
def resource_tags(self): """Resource tags for this processing logic. Tags are a mechanism for differentiating and identifying resources that have different physical characteristics or logical uses. For example a resource (host) that has external connectivity for public data sources may be tagged `inges...
python
def resource_tags(self): """Resource tags for this processing logic. Tags are a mechanism for differentiating and identifying resources that have different physical characteristics or logical uses. For example a resource (host) that has external connectivity for public data sources may be tagged `inges...
[ "def", "resource_tags", "(", "self", ")", ":", "try", ":", "plc", "=", "self", ".", "_op", "(", ")", ".", "_placement", "if", "not", "'resourceTags'", "in", "plc", ":", "plc", "[", "'resourceTags'", "]", "=", "set", "(", ")", "return", "plc", "[", ...
Resource tags for this processing logic. Tags are a mechanism for differentiating and identifying resources that have different physical characteristics or logical uses. For example a resource (host) that has external connectivity for public data sources may be tagged `ingest`. Processing logic can be...
[ "Resource", "tags", "for", "this", "processing", "logic", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/_streams/_placement.py#L41-L75
IBMStreams/pypi.streamsx
streamsx/topology/context.py
submit
def submit(ctxtype, graph, config=None, username=None, password=None): """ Submits a `Topology` (application) using the specified context type. Used to submit an application for compilation into a Streams application and execution within an Streaming Analytics service or IBM Streams instance. `ctx...
python
def submit(ctxtype, graph, config=None, username=None, password=None): """ Submits a `Topology` (application) using the specified context type. Used to submit an application for compilation into a Streams application and execution within an Streaming Analytics service or IBM Streams instance. `ctx...
[ "def", "submit", "(", "ctxtype", ",", "graph", ",", "config", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "streamsx", ".", "_streams", ".", "_version", ".", "_mismatch_check", "(", "__name__", ")", "graph", "=", "...
Submits a `Topology` (application) using the specified context type. Used to submit an application for compilation into a Streams application and execution within an Streaming Analytics service or IBM Streams instance. `ctxtype` defines how the application will be submitted, see :py:class:`ContextTypes`. ...
[ "Submits", "a", "Topology", "(", "application", ")", "using", "the", "specified", "context", "type", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L55-L89
IBMStreams/pypi.streamsx
streamsx/topology/context.py
_vcap_from_service_definition
def _vcap_from_service_definition(service_def): """Turn a service definition into a vcap services containing a single service. """ if 'credentials' in service_def: credentials = service_def['credentials'] else: credentials = service_def service = {} service['credentials'] = ...
python
def _vcap_from_service_definition(service_def): """Turn a service definition into a vcap services containing a single service. """ if 'credentials' in service_def: credentials = service_def['credentials'] else: credentials = service_def service = {} service['credentials'] = ...
[ "def", "_vcap_from_service_definition", "(", "service_def", ")", ":", "if", "'credentials'", "in", "service_def", ":", "credentials", "=", "service_def", "[", "'credentials'", "]", "else", ":", "credentials", "=", "service_def", "service", "=", "{", "}", "service"...
Turn a service definition into a vcap services containing a single service.
[ "Turn", "a", "service", "definition", "into", "a", "vcap", "services", "containing", "a", "single", "service", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L1341-L1354
IBMStreams/pypi.streamsx
streamsx/topology/context.py
_StreamingAnalyticsSubmitter._get_java_env
def _get_java_env(self): "Pass the VCAP through the environment to the java submission" env = super(_StreamingAnalyticsSubmitter, self)._get_java_env() vcap = streamsx.rest._get_vcap_services(self._vcap_services) env['VCAP_SERVICES'] = json.dumps(vcap) return env
python
def _get_java_env(self): "Pass the VCAP through the environment to the java submission" env = super(_StreamingAnalyticsSubmitter, self)._get_java_env() vcap = streamsx.rest._get_vcap_services(self._vcap_services) env['VCAP_SERVICES'] = json.dumps(vcap) return env
[ "def", "_get_java_env", "(", "self", ")", ":", "env", "=", "super", "(", "_StreamingAnalyticsSubmitter", ",", "self", ")", ".", "_get_java_env", "(", ")", "vcap", "=", "streamsx", ".", "rest", ".", "_get_vcap_services", "(", "self", ".", "_vcap_services", ")...
Pass the VCAP through the environment to the java submission
[ "Pass", "the", "VCAP", "through", "the", "environment", "to", "the", "java", "submission" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L409-L414
IBMStreams/pypi.streamsx
streamsx/topology/context.py
_DistributedSubmitter._get_java_env
def _get_java_env(self): "Set env vars from connection if set" env = super(_DistributedSubmitter, self)._get_java_env() if self._streams_connection is not None: # Need to sure the environment matches the connection. sc = self._streams_connection if isinstance(...
python
def _get_java_env(self): "Set env vars from connection if set" env = super(_DistributedSubmitter, self)._get_java_env() if self._streams_connection is not None: # Need to sure the environment matches the connection. sc = self._streams_connection if isinstance(...
[ "def", "_get_java_env", "(", "self", ")", ":", "env", "=", "super", "(", "_DistributedSubmitter", ",", "self", ")", ".", "_get_java_env", "(", ")", "if", "self", ".", "_streams_connection", "is", "not", "None", ":", "# Need to sure the environment matches the conn...
Set env vars from connection if set
[ "Set", "env", "vars", "from", "connection", "if", "set" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L485-L500
IBMStreams/pypi.streamsx
streamsx/topology/context.py
JobConfig.from_overlays
def from_overlays(overlays): """Create a `JobConfig` instance from a full job configuration overlays object. All logical items, such as ``comment`` and ``job_name``, are extracted from `overlays`. The remaining information in the single job config overlay in ``overlays`` is set ...
python
def from_overlays(overlays): """Create a `JobConfig` instance from a full job configuration overlays object. All logical items, such as ``comment`` and ``job_name``, are extracted from `overlays`. The remaining information in the single job config overlay in ``overlays`` is set ...
[ "def", "from_overlays", "(", "overlays", ")", ":", "jc", "=", "JobConfig", "(", ")", "jc", ".", "comment", "=", "overlays", ".", "get", "(", "'comment'", ")", "if", "'jobConfigOverlays'", "in", "overlays", ":", "if", "len", "(", "overlays", "[", "'jobCon...
Create a `JobConfig` instance from a full job configuration overlays object. All logical items, such as ``comment`` and ``job_name``, are extracted from `overlays`. The remaining information in the single job config overlay in ``overlays`` is set as ``raw_overlay``. Args: ...
[ "Create", "a", "JobConfig", "instance", "from", "a", "full", "job", "configuration", "overlays", "object", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L946-L992
IBMStreams/pypi.streamsx
streamsx/topology/context.py
JobConfig._add_overlays
def _add_overlays(self, config): """ Add this as a jobConfigOverlays JSON to config. """ if self._comment: config['comment'] = self._comment jco = {} config["jobConfigOverlays"] = [jco] if self._raw_overlay: jco.update(self._raw_overlay) ...
python
def _add_overlays(self, config): """ Add this as a jobConfigOverlays JSON to config. """ if self._comment: config['comment'] = self._comment jco = {} config["jobConfigOverlays"] = [jco] if self._raw_overlay: jco.update(self._raw_overlay) ...
[ "def", "_add_overlays", "(", "self", ",", "config", ")", ":", "if", "self", ".", "_comment", ":", "config", "[", "'comment'", "]", "=", "self", ".", "_comment", "jco", "=", "{", "}", "config", "[", "\"jobConfigOverlays\"", "]", "=", "[", "jco", "]", ...
Add this as a jobConfigOverlays JSON to config.
[ "Add", "this", "as", "a", "jobConfigOverlays", "JSON", "to", "config", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L1191-L1230
IBMStreams/pypi.streamsx
streamsx/topology/context.py
SubmissionResult.job
def job(self): """REST binding for the job associated with the submitted build. Returns: Job: REST binding for running job or ``None`` if connection information was not available or no job was submitted. """ if self._submitter and hasattr(self._submitter, '_job_access'): ...
python
def job(self): """REST binding for the job associated with the submitted build. Returns: Job: REST binding for running job or ``None`` if connection information was not available or no job was submitted. """ if self._submitter and hasattr(self._submitter, '_job_access'): ...
[ "def", "job", "(", "self", ")", ":", "if", "self", ".", "_submitter", "and", "hasattr", "(", "self", ".", "_submitter", ",", "'_job_access'", ")", ":", "return", "self", ".", "_submitter", ".", "_job_access", "(", ")", "return", "None" ]
REST binding for the job associated with the submitted build. Returns: Job: REST binding for running job or ``None`` if connection information was not available or no job was submitted.
[ "REST", "binding", "for", "the", "job", "associated", "with", "the", "submitted", "build", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L1241-L1249
IBMStreams/pypi.streamsx
streamsx/topology/context.py
SubmissionResult.cancel_job_button
def cancel_job_button(self, description=None): """Display a button that will cancel the submitted job. Used in a Jupyter IPython notebook to provide an interactive mechanism to cancel a job submitted from the notebook. Once clicked the button is disabled unless the cancel fails. ...
python
def cancel_job_button(self, description=None): """Display a button that will cancel the submitted job. Used in a Jupyter IPython notebook to provide an interactive mechanism to cancel a job submitted from the notebook. Once clicked the button is disabled unless the cancel fails. ...
[ "def", "cancel_job_button", "(", "self", ",", "description", "=", "None", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'jobId'", ")", ":", "return", "try", ":", "import", "ipywidgets", "as", "widgets", "if", "not", "description", ":", "description"...
Display a button that will cancel the submitted job. Used in a Jupyter IPython notebook to provide an interactive mechanism to cancel a job submitted from the notebook. Once clicked the button is disabled unless the cancel fails. A job may be cancelled directly using:: su...
[ "Display", "a", "button", "that", "will", "cancel", "the", "submitted", "job", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L1251-L1305
raphaelm/django-hierarkey
hierarkey/models.py
Hierarkey.add_default
def add_default(self, key: str, value: Optional[str], default_type: type = str) -> None: """ Adds a default value and a default type for a key. :param key: Key :param value: *Serialized* default value, i.e. a string or ``None``. :param default_type: The type to unserialize value...
python
def add_default(self, key: str, value: Optional[str], default_type: type = str) -> None: """ Adds a default value and a default type for a key. :param key: Key :param value: *Serialized* default value, i.e. a string or ``None``. :param default_type: The type to unserialize value...
[ "def", "add_default", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Optional", "[", "str", "]", ",", "default_type", ":", "type", "=", "str", ")", "->", "None", ":", "self", ".", "defaults", "[", "key", "]", "=", "HierarkeyDefault", "(", ...
Adds a default value and a default type for a key. :param key: Key :param value: *Serialized* default value, i.e. a string or ``None``. :param default_type: The type to unserialize values for this key to, defaults to ``str``.
[ "Adds", "a", "default", "value", "and", "a", "default", "type", "for", "a", "key", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/models.py#L49-L57
raphaelm/django-hierarkey
hierarkey/models.py
Hierarkey.add_type
def add_type(self, type: type, serialize: Callable[[Any], str], unserialize: Callable[[str], Any]) -> None: """ Adds serialization support for a new type. :param type: The type to add support for. :param serialize: A callable that takes an object of type ``type`` and returns a string. ...
python
def add_type(self, type: type, serialize: Callable[[Any], str], unserialize: Callable[[str], Any]) -> None: """ Adds serialization support for a new type. :param type: The type to add support for. :param serialize: A callable that takes an object of type ``type`` and returns a string. ...
[ "def", "add_type", "(", "self", ",", "type", ":", "type", ",", "serialize", ":", "Callable", "[", "[", "Any", "]", ",", "str", "]", ",", "unserialize", ":", "Callable", "[", "[", "str", "]", ",", "Any", "]", ")", "->", "None", ":", "self", ".", ...
Adds serialization support for a new type. :param type: The type to add support for. :param serialize: A callable that takes an object of type ``type`` and returns a string. :param unserialize: A callable that takes a string and returns an object of type ``type``.
[ "Adds", "serialization", "support", "for", "a", "new", "type", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/models.py#L59-L67
raphaelm/django-hierarkey
hierarkey/models.py
Hierarkey.set_global
def set_global(self, cache_namespace: str = None) -> type: """ Decorator. Attaches the global key-value store of this hierarchy to an object. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of th...
python
def set_global(self, cache_namespace: str = None) -> type: """ Decorator. Attaches the global key-value store of this hierarchy to an object. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of th...
[ "def", "set_global", "(", "self", ",", "cache_namespace", ":", "str", "=", "None", ")", "->", "type", ":", "if", "isinstance", "(", "cache_namespace", ",", "type", ")", ":", "raise", "ImproperlyConfigured", "(", "'Incorrect decorator usage, you need to use .add_glob...
Decorator. Attaches the global key-value store of this hierarchy to an object. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of the class this is applied to and the ``attribute_...
[ "Decorator", ".", "Attaches", "the", "global", "key", "-", "value", "store", "of", "this", "hierarchy", "to", "an", "object", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/models.py#L69-L125
raphaelm/django-hierarkey
hierarkey/models.py
Hierarkey.add
def add(self, cache_namespace: str = None, parent_field: str = None) -> type: """ Decorator. Attaches a global key-value store to a Django model. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name o...
python
def add(self, cache_namespace: str = None, parent_field: str = None) -> type: """ Decorator. Attaches a global key-value store to a Django model. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name o...
[ "def", "add", "(", "self", ",", "cache_namespace", ":", "str", "=", "None", ",", "parent_field", ":", "str", "=", "None", ")", "->", "type", ":", "if", "isinstance", "(", "cache_namespace", ",", "type", ")", ":", "raise", "ImproperlyConfigured", "(", "'I...
Decorator. Attaches a global key-value store to a Django model. :param cache_namespace: Optional. A custom namespace used for caching. By default this is constructed from the name of the class this is applied to and the ``attribute_name`` of this ...
[ "Decorator", ".", "Attaches", "a", "global", "key", "-", "value", "store", "to", "a", "Django", "model", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/models.py#L127-L185
IBMStreams/pypi.streamsx
streamsx/topology/graph.py
_as_spl_expr
def _as_spl_expr(value): """ Return value converted to an SPL expression if needed other otherwise value. """ import streamsx._streams._numpy if hasattr(value, 'spl_json'): return value if isinstance(value, Enum): value = streamsx.spl.op.Expression.expression(value.name) ...
python
def _as_spl_expr(value): """ Return value converted to an SPL expression if needed other otherwise value. """ import streamsx._streams._numpy if hasattr(value, 'spl_json'): return value if isinstance(value, Enum): value = streamsx.spl.op.Expression.expression(value.name) ...
[ "def", "_as_spl_expr", "(", "value", ")", ":", "import", "streamsx", ".", "_streams", ".", "_numpy", "if", "hasattr", "(", "value", ",", "'spl_json'", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "Enum", ")", ":", "value", "=", "...
Return value converted to an SPL expression if needed other otherwise value.
[ "Return", "value", "converted", "to", "an", "SPL", "expression", "if", "needed", "other", "otherwise", "value", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/graph.py#L45-L61
IBMStreams/pypi.streamsx
streamsx/topology/graph.py
SPLGraph._unique_id
def _unique_id(self, prefix): """ Generate a unique (within the graph) identifer internal to graph generation. """ _id = self._id_gen self._id_gen += 1 return prefix + str(_id)
python
def _unique_id(self, prefix): """ Generate a unique (within the graph) identifer internal to graph generation. """ _id = self._id_gen self._id_gen += 1 return prefix + str(_id)
[ "def", "_unique_id", "(", "self", ",", "prefix", ")", ":", "_id", "=", "self", ".", "_id_gen", "self", ".", "_id_gen", "+=", "1", "return", "prefix", "+", "str", "(", "_id", ")" ]
Generate a unique (within the graph) identifer internal to graph generation.
[ "Generate", "a", "unique", "(", "within", "the", "graph", ")", "identifer", "internal", "to", "graph", "generation", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/graph.py#L97-L104
IBMStreams/pypi.streamsx
streamsx/topology/graph.py
SPLGraph._requested_name
def _requested_name(self, name, action=None, func=None): """Create a unique name for an operator or a stream. """ if name is not None: if name in self._used_names: # start at 2 for the "second" one of this name n = 2 while True: ...
python
def _requested_name(self, name, action=None, func=None): """Create a unique name for an operator or a stream. """ if name is not None: if name in self._used_names: # start at 2 for the "second" one of this name n = 2 while True: ...
[ "def", "_requested_name", "(", "self", ",", "name", ",", "action", "=", "None", ",", "func", "=", "None", ")", ":", "if", "name", "is", "not", "None", ":", "if", "name", "in", "self", ".", "_used_names", ":", "# start at 2 for the \"second\" one of this name...
Create a unique name for an operator or a stream.
[ "Create", "a", "unique", "name", "for", "an", "operator", "or", "a", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/graph.py#L106-L141
IBMStreams/pypi.streamsx
streamsx/topology/graph.py
_SPLInvocation.colocate
def colocate(self, others, why): """ Colocate this operator with another. """ if isinstance(self, Marker): return colocate_tag = '__spl_' + why + '$' + str(self.index) self._colocate_tag(colocate_tag) for op in others: op._colocate_tag(colo...
python
def colocate(self, others, why): """ Colocate this operator with another. """ if isinstance(self, Marker): return colocate_tag = '__spl_' + why + '$' + str(self.index) self._colocate_tag(colocate_tag) for op in others: op._colocate_tag(colo...
[ "def", "colocate", "(", "self", ",", "others", ",", "why", ")", ":", "if", "isinstance", "(", "self", ",", "Marker", ")", ":", "return", "colocate_tag", "=", "'__spl_'", "+", "why", "+", "'$'", "+", "str", "(", "self", ".", "index", ")", "self", "....
Colocate this operator with another.
[ "Colocate", "this", "operator", "with", "another", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/graph.py#L501-L510
IBMStreams/pypi.streamsx
streamsx/spl/op.py
main_composite
def main_composite(kind, toolkits=None, name=None): """Wrap a main composite invocation as a `Topology`. Provides a bridge between an SPL application (main composite) and a `Topology`. Create a `Topology` that contains just the invocation of the main composite defined by `kind`. The returned `To...
python
def main_composite(kind, toolkits=None, name=None): """Wrap a main composite invocation as a `Topology`. Provides a bridge between an SPL application (main composite) and a `Topology`. Create a `Topology` that contains just the invocation of the main composite defined by `kind`. The returned `To...
[ "def", "main_composite", "(", "kind", ",", "toolkits", "=", "None", ",", "name", "=", "None", ")", ":", "if", "'::'", "in", "kind", ":", "ns", ",", "name", "=", "kind", ".", "rsplit", "(", "'::'", ",", "1", ")", "ns", "+=", "'._spl'", "else", ":"...
Wrap a main composite invocation as a `Topology`. Provides a bridge between an SPL application (main composite) and a `Topology`. Create a `Topology` that contains just the invocation of the main composite defined by `kind`. The returned `Topology` may be used like any other topology instance in...
[ "Wrap", "a", "main", "composite", "invocation", "as", "a", "Topology", ".", "Provides", "a", "bridge", "between", "an", "SPL", "application", "(", "main", "composite", ")", "and", "a", "Topology", ".", "Create", "a", "Topology", "that", "contains", "just", ...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L438-L475
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Invoke.attribute
def attribute(self, stream, name): """Expression for an input attribute. An input attribute is an attribute on one of the input ports of the operator invocation. `stream` must have been used to declare this invocation. Args: stream(Stream): Stream the attribute is f...
python
def attribute(self, stream, name): """Expression for an input attribute. An input attribute is an attribute on one of the input ports of the operator invocation. `stream` must have been used to declare this invocation. Args: stream(Stream): Stream the attribute is f...
[ "def", "attribute", "(", "self", ",", "stream", ",", "name", ")", ":", "if", "stream", "not", "in", "self", ".", "_inputs", ":", "raise", "ValueError", "(", "\"Stream is not an input of this operator.\"", ")", "if", "len", "(", "self", ".", "_inputs", ")", ...
Expression for an input attribute. An input attribute is an attribute on one of the input ports of the operator invocation. `stream` must have been used to declare this invocation. Args: stream(Stream): Stream the attribute is from. name(str): Name of the attrib...
[ "Expression", "for", "an", "input", "attribute", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L205-L225
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Invoke.output
def output(self, stream, value): """SPL output port assignment expression. Arguments: stream(Stream): Output stream the assignment is for. value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: ...
python
def output(self, stream, value): """SPL output port assignment expression. Arguments: stream(Stream): Output stream the assignment is for. value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: ...
[ "def", "output", "(", "self", ",", "stream", ",", "value", ")", ":", "if", "stream", "not", "in", "self", ".", "outputs", ":", "raise", "ValueError", "(", "\"Stream is not an output of this operator.\"", ")", "e", "=", "self", ".", "expression", "(", "value"...
SPL output port assignment expression. Arguments: stream(Stream): Output stream the assignment is for. value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment ex...
[ "SPL", "output", "port", "assignment", "expression", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L240-L254
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Source.output
def output(self, value): """SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a t...
python
def output(self, value): """SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a t...
[ "def", "output", "(", "self", ",", "value", ")", ":", "return", "super", "(", "Source", ",", "self", ")", ".", "output", "(", "self", ".", "stream", ",", "value", ")" ]
SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a the context of this operator.
[ "SPL", "output", "port", "assignment", "expression", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L309-L318
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Map.attribute
def attribute(self, name): """Expression for an input attribute. An input attribute is an attribute on the input port of the operator invocation. Args: name(str): Name of the attribute. Returns: Expression: Expression representing the input a...
python
def attribute(self, name): """Expression for an input attribute. An input attribute is an attribute on the input port of the operator invocation. Args: name(str): Name of the attribute. Returns: Expression: Expression representing the input a...
[ "def", "attribute", "(", "self", ",", "name", ")", ":", "return", "super", "(", "Map", ",", "self", ")", ".", "attribute", "(", "self", ".", "_inputs", "[", "0", "]", ",", "name", ")" ]
Expression for an input attribute. An input attribute is an attribute on the input port of the operator invocation. Args: name(str): Name of the attribute. Returns: Expression: Expression representing the input attribute.
[ "Expression", "for", "an", "input", "attribute", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L357-L369
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Map.output
def output(self, value): """SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a t...
python
def output(self, value): """SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a t...
[ "def", "output", "(", "self", ",", "value", ")", ":", "return", "super", "(", "Map", ",", "self", ")", ".", "output", "(", "self", ".", "stream", ",", "value", ")" ]
SPL output port assignment expression. Arguments: value(str): SPL expression used for an output assignment. This can be a string, a constant, or an :py:class:`Expression`. Returns: Expression: Output assignment expression that is valid as a the context of this operator.
[ "SPL", "output", "port", "assignment", "expression", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L371-L380
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Expression.expression
def expression(value): """Create an SPL expression. Args: value: Expression as a string or another `Expression`. If value is an instance of `Expression` then a new instance is returned containing the same type and value. Returns: Expression: SPL expression from `value`....
python
def expression(value): """Create an SPL expression. Args: value: Expression as a string or another `Expression`. If value is an instance of `Expression` then a new instance is returned containing the same type and value. Returns: Expression: SPL expression from `value`....
[ "def", "expression", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Expression", ")", ":", "# Clone the expression to allow it to", "# be used in multiple contexts", "return", "Expression", "(", "value", ".", "_type", ",", "value", ".", "_value", ...
Create an SPL expression. Args: value: Expression as a string or another `Expression`. If value is an instance of `Expression` then a new instance is returned containing the same type and value. Returns: Expression: SPL expression from `value`.
[ "Create", "an", "SPL", "expression", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L410-L426
IBMStreams/pypi.streamsx
streamsx/spl/op.py
Expression.spl_json
def spl_json(self): """Private method. May be removed at any time.""" _splj = {} _splj["type"] = self._type _splj["value"] = self._value return _splj
python
def spl_json(self): """Private method. May be removed at any time.""" _splj = {} _splj["type"] = self._type _splj["value"] = self._value return _splj
[ "def", "spl_json", "(", "self", ")", ":", "_splj", "=", "{", "}", "_splj", "[", "\"type\"", "]", "=", "self", ".", "_type", "_splj", "[", "\"value\"", "]", "=", "self", ".", "_value", "return", "_splj" ]
Private method. May be removed at any time.
[ "Private", "method", ".", "May", "be", "removed", "at", "any", "time", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/spl/op.py#L428-L433