repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
facelessuser/soupsieve
soupsieve/util.py
lower
def lower(string): """Lower.""" new_string = [] for c in string: o = ord(c) new_string.append(chr(o + 32) if UC_A <= o <= UC_Z else c) return ''.join(new_string)
python
def lower(string): """Lower.""" new_string = [] for c in string: o = ord(c) new_string.append(chr(o + 32) if UC_A <= o <= UC_Z else c) return ''.join(new_string)
[ "def", "lower", "(", "string", ")", ":", "new_string", "=", "[", "]", "for", "c", "in", "string", ":", "o", "=", "ord", "(", "c", ")", "new_string", ".", "append", "(", "chr", "(", "o", "+", "32", ")", "if", "UC_A", "<=", "o", "<=", "UC_Z", "...
Lower.
[ "Lower", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L45-L52
facelessuser/soupsieve
soupsieve/util.py
upper
def upper(string): # pragma: no cover """Lower.""" new_string = [] for c in string: o = ord(c) new_string.append(chr(o - 32) if LC_A <= o <= LC_Z else c) return ''.join(new_string)
python
def upper(string): # pragma: no cover """Lower.""" new_string = [] for c in string: o = ord(c) new_string.append(chr(o - 32) if LC_A <= o <= LC_Z else c) return ''.join(new_string)
[ "def", "upper", "(", "string", ")", ":", "# pragma: no cover", "new_string", "=", "[", "]", "for", "c", "in", "string", ":", "o", "=", "ord", "(", "c", ")", "new_string", ".", "append", "(", "chr", "(", "o", "-", "32", ")", "if", "LC_A", "<=", "o...
Lower.
[ "Lower", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L55-L62
facelessuser/soupsieve
soupsieve/util.py
uord
def uord(c): """Get Unicode ordinal.""" if len(c) == 2: # pragma: no cover high, low = [ord(p) for p in c] ordinal = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000 else: ordinal = ord(c) return ordinal
python
def uord(c): """Get Unicode ordinal.""" if len(c) == 2: # pragma: no cover high, low = [ord(p) for p in c] ordinal = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000 else: ordinal = ord(c) return ordinal
[ "def", "uord", "(", "c", ")", ":", "if", "len", "(", "c", ")", "==", "2", ":", "# pragma: no cover", "high", ",", "low", "=", "[", "ord", "(", "p", ")", "for", "p", "in", "c", "]", "ordinal", "=", "(", "high", "-", "0xD800", ")", "*", "0x400"...
Get Unicode ordinal.
[ "Get", "Unicode", "ordinal", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L74-L83
facelessuser/soupsieve
soupsieve/util.py
deprecated
def deprecated(message, stacklevel=2): # pragma: no cover """ Raise a `DeprecationWarning` when wrapped function/method is called. Borrowed from https://stackoverflow.com/a/48632082/866026 """ def _decorator(func): @wraps(func) def _func(*args, **kwargs): warnings.warn...
python
def deprecated(message, stacklevel=2): # pragma: no cover """ Raise a `DeprecationWarning` when wrapped function/method is called. Borrowed from https://stackoverflow.com/a/48632082/866026 """ def _decorator(func): @wraps(func) def _func(*args, **kwargs): warnings.warn...
[ "def", "deprecated", "(", "message", ",", "stacklevel", "=", "2", ")", ":", "# pragma: no cover", "def", "_decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnin...
Raise a `DeprecationWarning` when wrapped function/method is called. Borrowed from https://stackoverflow.com/a/48632082/866026
[ "Raise", "a", "DeprecationWarning", "when", "wrapped", "function", "/", "method", "is", "called", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L104-L121
facelessuser/soupsieve
soupsieve/util.py
warn_deprecated
def warn_deprecated(message, stacklevel=2): # pragma: no cover """Warn deprecated.""" warnings.warn( message, category=DeprecationWarning, stacklevel=stacklevel )
python
def warn_deprecated(message, stacklevel=2): # pragma: no cover """Warn deprecated.""" warnings.warn( message, category=DeprecationWarning, stacklevel=stacklevel )
[ "def", "warn_deprecated", "(", "message", ",", "stacklevel", "=", "2", ")", ":", "# pragma: no cover", "warnings", ".", "warn", "(", "message", ",", "category", "=", "DeprecationWarning", ",", "stacklevel", "=", "stacklevel", ")" ]
Warn deprecated.
[ "Warn", "deprecated", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L124-L131
facelessuser/soupsieve
soupsieve/util.py
get_pattern_context
def get_pattern_context(pattern, index): """Get the pattern context.""" last = 0 current_line = 1 col = 1 text = [] line = 1 # Split pattern by newline and handle the text before the newline for m in RE_PATTERN_LINE_SPLIT.finditer(pattern): linetext = pattern[last:m.start(0)] ...
python
def get_pattern_context(pattern, index): """Get the pattern context.""" last = 0 current_line = 1 col = 1 text = [] line = 1 # Split pattern by newline and handle the text before the newline for m in RE_PATTERN_LINE_SPLIT.finditer(pattern): linetext = pattern[last:m.start(0)] ...
[ "def", "get_pattern_context", "(", "pattern", ",", "index", ")", ":", "last", "=", "0", "current_line", "=", "1", "col", "=", "1", "text", "=", "[", "]", "line", "=", "1", "# Split pattern by newline and handle the text before the newline", "for", "m", "in", "...
Get the pattern context.
[ "Get", "the", "pattern", "context", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L134-L171
facelessuser/soupsieve
soupsieve/util.py
warn_quirks
def warn_quirks(message, recommend, pattern, index): """Warn quirks.""" import traceback import bs4 # noqa: F401 # Acquire source code line context paths = (MODULE, sys.modules['bs4'].__path__[0]) tb = traceback.extract_stack() previous = None filename = None lineno = None for...
python
def warn_quirks(message, recommend, pattern, index): """Warn quirks.""" import traceback import bs4 # noqa: F401 # Acquire source code line context paths = (MODULE, sys.modules['bs4'].__path__[0]) tb = traceback.extract_stack() previous = None filename = None lineno = None for...
[ "def", "warn_quirks", "(", "message", ",", "recommend", ",", "pattern", ",", "index", ")", ":", "import", "traceback", "import", "bs4", "# noqa: F401", "# Acquire source code line context", "paths", "=", "(", "MODULE", ",", "sys", ".", "modules", "[", "'bs4'", ...
Warn quirks.
[ "Warn", "quirks", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/util.py#L178-L213
facelessuser/soupsieve
soupsieve/__init__.py
compile
def compile(pattern, namespaces=None, flags=0, **kwargs): # noqa: A001 """Compile CSS pattern.""" if namespaces is not None: namespaces = ct.Namespaces(**namespaces) custom = kwargs.get('custom') if custom is not None: custom = ct.CustomSelectors(**custom) if isinstance(pattern, ...
python
def compile(pattern, namespaces=None, flags=0, **kwargs): # noqa: A001 """Compile CSS pattern.""" if namespaces is not None: namespaces = ct.Namespaces(**namespaces) custom = kwargs.get('custom') if custom is not None: custom = ct.CustomSelectors(**custom) if isinstance(pattern, ...
[ "def", "compile", "(", "pattern", ",", "namespaces", "=", "None", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "# noqa: A001", "if", "namespaces", "is", "not", "None", ":", "namespaces", "=", "ct", ".", "Namespaces", "(", "*", "*", "nam...
Compile CSS pattern.
[ "Compile", "CSS", "pattern", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L44-L63
facelessuser/soupsieve
soupsieve/__init__.py
closest
def closest(select, tag, namespaces=None, flags=0, **kwargs): """Match closest ancestor.""" return compile(select, namespaces, flags, **kwargs).closest(tag)
python
def closest(select, tag, namespaces=None, flags=0, **kwargs): """Match closest ancestor.""" return compile(select, namespaces, flags, **kwargs).closest(tag)
[ "def", "closest", "(", "select", ",", "tag", ",", "namespaces", "=", "None", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*", "*", "kwargs", ")", ".", "closest...
Match closest ancestor.
[ "Match", "closest", "ancestor", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L72-L75
facelessuser/soupsieve
soupsieve/__init__.py
match
def match(select, tag, namespaces=None, flags=0, **kwargs): """Match node.""" return compile(select, namespaces, flags, **kwargs).match(tag)
python
def match(select, tag, namespaces=None, flags=0, **kwargs): """Match node.""" return compile(select, namespaces, flags, **kwargs).match(tag)
[ "def", "match", "(", "select", ",", "tag", ",", "namespaces", "=", "None", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*", "*", "kwargs", ")", ".", "match", ...
Match node.
[ "Match", "node", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L78-L81
facelessuser/soupsieve
soupsieve/__init__.py
filter
def filter(select, iterable, namespaces=None, flags=0, **kwargs): # noqa: A001 """Filter list of nodes.""" return compile(select, namespaces, flags, **kwargs).filter(iterable)
python
def filter(select, iterable, namespaces=None, flags=0, **kwargs): # noqa: A001 """Filter list of nodes.""" return compile(select, namespaces, flags, **kwargs).filter(iterable)
[ "def", "filter", "(", "select", ",", "iterable", ",", "namespaces", "=", "None", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "# noqa: A001", "return", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*", "*", "kwargs", ...
Filter list of nodes.
[ "Filter", "list", "of", "nodes", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L84-L87
facelessuser/soupsieve
soupsieve/__init__.py
comments
def comments(tag, limit=0, flags=0, **kwargs): """Get comments only.""" return [comment for comment in cm.CommentsMatch(tag).get_comments(limit)]
python
def comments(tag, limit=0, flags=0, **kwargs): """Get comments only.""" return [comment for comment in cm.CommentsMatch(tag).get_comments(limit)]
[ "def", "comments", "(", "tag", ",", "limit", "=", "0", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "[", "comment", "for", "comment", "in", "cm", ".", "CommentsMatch", "(", "tag", ")", ".", "get_comments", "(", "limit", ")",...
Get comments only.
[ "Get", "comments", "only", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L91-L94
facelessuser/soupsieve
soupsieve/__init__.py
select_one
def select_one(select, tag, namespaces=None, flags=0, **kwargs): """Select a single tag.""" return compile(select, namespaces, flags, **kwargs).select_one(tag)
python
def select_one(select, tag, namespaces=None, flags=0, **kwargs): """Select a single tag.""" return compile(select, namespaces, flags, **kwargs).select_one(tag)
[ "def", "select_one", "(", "select", ",", "tag", ",", "namespaces", "=", "None", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*", "*", "kwargs", ")", ".", "sele...
Select a single tag.
[ "Select", "a", "single", "tag", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L105-L108
facelessuser/soupsieve
soupsieve/__init__.py
select
def select(select, tag, namespaces=None, limit=0, flags=0, **kwargs): """Select the specified tags.""" return compile(select, namespaces, flags, **kwargs).select(tag, limit)
python
def select(select, tag, namespaces=None, limit=0, flags=0, **kwargs): """Select the specified tags.""" return compile(select, namespaces, flags, **kwargs).select(tag, limit)
[ "def", "select", "(", "select", ",", "tag", ",", "namespaces", "=", "None", ",", "limit", "=", "0", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*", "*", "kw...
Select the specified tags.
[ "Select", "the", "specified", "tags", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L111-L114
facelessuser/soupsieve
soupsieve/__init__.py
iselect
def iselect(select, tag, namespaces=None, limit=0, flags=0, **kwargs): """Iterate the specified tags.""" for el in compile(select, namespaces, flags, **kwargs).iselect(tag, limit): yield el
python
def iselect(select, tag, namespaces=None, limit=0, flags=0, **kwargs): """Iterate the specified tags.""" for el in compile(select, namespaces, flags, **kwargs).iselect(tag, limit): yield el
[ "def", "iselect", "(", "select", ",", "tag", ",", "namespaces", "=", "None", ",", "limit", "=", "0", ",", "flags", "=", "0", ",", "*", "*", "kwargs", ")", ":", "for", "el", "in", "compile", "(", "select", ",", "namespaces", ",", "flags", ",", "*"...
Iterate the specified tags.
[ "Iterate", "the", "specified", "tags", "." ]
train
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__init__.py#L117-L121
bigcommerce/bigcommerce-api-python
bigcommerce/resources/base.py
ListableApiResource.all
def all(cls, connection=None, **params): """ Returns first page if no params passed in as a list. """ request = cls._make_request('GET', cls._get_all_path(), connection, params=params) return cls._create_object(request, connection=connection)
python
def all(cls, connection=None, **params): """ Returns first page if no params passed in as a list. """ request = cls._make_request('GET', cls._get_all_path(), connection, params=params) return cls._create_object(request, connection=connection)
[ "def", "all", "(", "cls", ",", "connection", "=", "None", ",", "*", "*", "params", ")", ":", "request", "=", "cls", ".", "_make_request", "(", "'GET'", ",", "cls", ".", "_get_all_path", "(", ")", ",", "connection", ",", "params", "=", "params", ")", ...
Returns first page if no params passed in as a list.
[ "Returns", "first", "page", "if", "no", "params", "passed", "in", "as", "a", "list", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/resources/base.py#L102-L108
bigcommerce/bigcommerce-api-python
bigcommerce/resources/base.py
ListableApiResource.iterall
def iterall(cls, connection=None, **kwargs): """ Returns a autopaging generator that yields each object returned one by one. """ try: limit = kwargs['limit'] except KeyError: limit = None try: page = kwargs['page'] except ...
python
def iterall(cls, connection=None, **kwargs): """ Returns a autopaging generator that yields each object returned one by one. """ try: limit = kwargs['limit'] except KeyError: limit = None try: page = kwargs['page'] except ...
[ "def", "iterall", "(", "cls", ",", "connection", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "limit", "=", "kwargs", "[", "'limit'", "]", "except", "KeyError", ":", "limit", "=", "None", "try", ":", "page", "=", "kwargs", "[", "'pag...
Returns a autopaging generator that yields each object returned one by one.
[ "Returns", "a", "autopaging", "generator", "that", "yields", "each", "object", "returned", "one", "by", "one", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/resources/base.py#L111-L148
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection.get
def get(self, resource="", rid=None, **query): """ Retrieves the resource with given id 'rid', or all resources of given type. Keep in mind that the API returns a list for any query that doesn't specify an ID, even when applying a limit=1 filter. Also be aware that float values t...
python
def get(self, resource="", rid=None, **query): """ Retrieves the resource with given id 'rid', or all resources of given type. Keep in mind that the API returns a list for any query that doesn't specify an ID, even when applying a limit=1 filter. Also be aware that float values t...
[ "def", "get", "(", "self", ",", "resource", "=", "\"\"", ",", "rid", "=", "None", ",", "*", "*", "query", ")", ":", "if", "rid", ":", "if", "resource", "[", "-", "1", "]", "!=", "'/'", ":", "resource", "+=", "'/'", "resource", "+=", "str", "(",...
Retrieves the resource with given id 'rid', or all resources of given type. Keep in mind that the API returns a list for any query that doesn't specify an ID, even when applying a limit=1 filter. Also be aware that float values tend to come back as strings ("2.0000" instead of 2.0) Keyw...
[ "Retrieves", "the", "resource", "with", "given", "id", "rid", "or", "all", "resources", "of", "given", "type", ".", "Keep", "in", "mind", "that", "the", "API", "returns", "a", "list", "for", "any", "query", "that", "doesn", "t", "specify", "an", "ID", ...
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L83-L99
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection.update
def update(self, resource, rid, updates): """ Updates the resource with id 'rid' with the given updates dictionary. """ if resource[-1] != '/': resource += '/' resource += str(rid) return self.put(resource, data=updates)
python
def update(self, resource, rid, updates): """ Updates the resource with id 'rid' with the given updates dictionary. """ if resource[-1] != '/': resource += '/' resource += str(rid) return self.put(resource, data=updates)
[ "def", "update", "(", "self", ",", "resource", ",", "rid", ",", "updates", ")", ":", "if", "resource", "[", "-", "1", "]", "!=", "'/'", ":", "resource", "+=", "'/'", "resource", "+=", "str", "(", "rid", ")", "return", "self", ".", "put", "(", "re...
Updates the resource with id 'rid' with the given updates dictionary.
[ "Updates", "the", "resource", "with", "id", "rid", "with", "the", "given", "updates", "dictionary", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L101-L108
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection.delete
def delete(self, resource, rid=None): # note that rid can't be 0 - problem? """ Deletes the resource with given id 'rid', or all resources of given type if rid is not supplied. """ if rid: if resource[-1] != '/': resource += '/' resource += str(ri...
python
def delete(self, resource, rid=None): # note that rid can't be 0 - problem? """ Deletes the resource with given id 'rid', or all resources of given type if rid is not supplied. """ if rid: if resource[-1] != '/': resource += '/' resource += str(ri...
[ "def", "delete", "(", "self", ",", "resource", ",", "rid", "=", "None", ")", ":", "# note that rid can't be 0 - problem?", "if", "rid", ":", "if", "resource", "[", "-", "1", "]", "!=", "'/'", ":", "resource", "+=", "'/'", "resource", "+=", "str", "(", ...
Deletes the resource with given id 'rid', or all resources of given type if rid is not supplied.
[ "Deletes", "the", "resource", "with", "given", "id", "rid", "or", "all", "resources", "of", "given", "type", "if", "rid", "is", "not", "supplied", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L116-L125
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection.put
def put(self, url, data): """ Make a PUT request to save data. data should be a dictionary. """ response = self._run_method('PUT', url, data=data) log.debug("OUTPUT: %s" % response.content) return self._handle_response(url, response)
python
def put(self, url, data): """ Make a PUT request to save data. data should be a dictionary. """ response = self._run_method('PUT', url, data=data) log.debug("OUTPUT: %s" % response.content) return self._handle_response(url, response)
[ "def", "put", "(", "self", ",", "url", ",", "data", ")", ":", "response", "=", "self", ".", "_run_method", "(", "'PUT'", ",", "url", ",", "data", "=", "data", ")", "log", ".", "debug", "(", "\"OUTPUT: %s\"", "%", "response", ".", "content", ")", "r...
Make a PUT request to save data. data should be a dictionary.
[ "Make", "a", "PUT", "request", "to", "save", "data", ".", "data", "should", "be", "a", "dictionary", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L133-L140
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection.post
def post(self, url, data, headers={}): """ POST request for creating new objects. data should be a dictionary. """ response = self._run_method('POST', url, data=data, headers=headers) return self._handle_response(url, response)
python
def post(self, url, data, headers={}): """ POST request for creating new objects. data should be a dictionary. """ response = self._run_method('POST', url, data=data, headers=headers) return self._handle_response(url, response)
[ "def", "post", "(", "self", ",", "url", ",", "data", ",", "headers", "=", "{", "}", ")", ":", "response", "=", "self", ".", "_run_method", "(", "'POST'", ",", "url", ",", "data", "=", "data", ",", "headers", "=", "headers", ")", "return", "self", ...
POST request for creating new objects. data should be a dictionary.
[ "POST", "request", "for", "creating", "new", "objects", ".", "data", "should", "be", "a", "dictionary", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L142-L148
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
Connection._handle_response
def _handle_response(self, url, res, suppress_empty=True): """ Returns parsed JSON or raises an exception appropriately. """ self._last_response = res result = {} if res.status_code in (200, 201, 202): try: result = res.json() excep...
python
def _handle_response(self, url, res, suppress_empty=True): """ Returns parsed JSON or raises an exception appropriately. """ self._last_response = res result = {} if res.status_code in (200, 201, 202): try: result = res.json() excep...
[ "def", "_handle_response", "(", "self", ",", "url", ",", "res", ",", "suppress_empty", "=", "True", ")", ":", "self", ".", "_last_response", "=", "res", "result", "=", "{", "}", "if", "res", ".", "status_code", "in", "(", "200", ",", "201", ",", "202...
Returns parsed JSON or raises an exception appropriately.
[ "Returns", "parsed", "JSON", "or", "raises", "an", "exception", "appropriately", "." ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L150-L172
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
OAuthConnection.verify_payload
def verify_payload(signed_payload, client_secret): """ Given a signed payload (usually passed as parameter in a GET request to the app's load URL) and a client secret, authenticates the payload and returns the user's data, or False on fail. Uses constant-time str comparison to prevent v...
python
def verify_payload(signed_payload, client_secret): """ Given a signed payload (usually passed as parameter in a GET request to the app's load URL) and a client secret, authenticates the payload and returns the user's data, or False on fail. Uses constant-time str comparison to prevent v...
[ "def", "verify_payload", "(", "signed_payload", ",", "client_secret", ")", ":", "encoded_json", ",", "encoded_hmac", "=", "signed_payload", ".", "split", "(", "'.'", ")", "dc_json", "=", "base64", ".", "b64decode", "(", "encoded_json", ")", "signature", "=", "...
Given a signed payload (usually passed as parameter in a GET request to the app's load URL) and a client secret, authenticates the payload and returns the user's data, or False on fail. Uses constant-time str comparison to prevent vulnerability to timing attacks.
[ "Given", "a", "signed", "payload", "(", "usually", "passed", "as", "parameter", "in", "a", "GET", "request", "to", "the", "app", "s", "load", "URL", ")", "and", "a", "client", "secret", "authenticates", "the", "payload", "and", "returns", "the", "user", ...
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L217-L229
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
OAuthConnection.fetch_token
def fetch_token(self, client_secret, code, context, scope, redirect_uri, token_url='https://login.bigcommerce.com/oauth2/token'): """ Fetches a token from given token_url, using given parameters, and sets up session headers for future requests. redirect_uri should be ...
python
def fetch_token(self, client_secret, code, context, scope, redirect_uri, token_url='https://login.bigcommerce.com/oauth2/token'): """ Fetches a token from given token_url, using given parameters, and sets up session headers for future requests. redirect_uri should be ...
[ "def", "fetch_token", "(", "self", ",", "client_secret", ",", "code", ",", "context", ",", "scope", ",", "redirect_uri", ",", "token_url", "=", "'https://login.bigcommerce.com/oauth2/token'", ")", ":", "res", "=", "self", ".", "post", "(", "token_url", ",", "{...
Fetches a token from given token_url, using given parameters, and sets up session headers for future requests. redirect_uri should be the same as your callback URL. code, context, and scope should be passed as parameters to your callback URL on app installation. Raises HttpException on ...
[ "Fetches", "a", "token", "from", "given", "token_url", "using", "given", "parameters", "and", "sets", "up", "session", "headers", "for", "future", "requests", ".", "redirect_uri", "should", "be", "the", "same", "as", "your", "callback", "URL", ".", "code", "...
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L231-L250
bigcommerce/bigcommerce-api-python
bigcommerce/connection.py
OAuthConnection._handle_response
def _handle_response(self, url, res, suppress_empty=True): """ Adds rate limiting information on to the response object """ result = Connection._handle_response(self, url, res, suppress_empty) if 'X-Rate-Limit-Time-Reset-Ms' in res.headers: self.rate_limit = dict(ms_u...
python
def _handle_response(self, url, res, suppress_empty=True): """ Adds rate limiting information on to the response object """ result = Connection._handle_response(self, url, res, suppress_empty) if 'X-Rate-Limit-Time-Reset-Ms' in res.headers: self.rate_limit = dict(ms_u...
[ "def", "_handle_response", "(", "self", ",", "url", ",", "res", ",", "suppress_empty", "=", "True", ")", ":", "result", "=", "Connection", ".", "_handle_response", "(", "self", ",", "url", ",", "res", ",", "suppress_empty", ")", "if", "'X-Rate-Limit-Time-Res...
Adds rate limiting information on to the response object
[ "Adds", "rate", "limiting", "information", "on", "to", "the", "response", "object" ]
train
https://github.com/bigcommerce/bigcommerce-api-python/blob/76a8f5d59fd44a4365f14a5959102e118cf35dee/bigcommerce/connection.py#L252-L274
FSX/misaka
misaka/api.py
escape_html
def escape_html(text, escape_slash=False): """ Binding for Hoedown's HTML escaping function. The implementation is inspired by the OWASP XSS Prevention recommendations: .. code-block:: none & --> &amp; < --> &lt; > --> &gt; " --> &quot; ' --> &#x27; / -...
python
def escape_html(text, escape_slash=False): """ Binding for Hoedown's HTML escaping function. The implementation is inspired by the OWASP XSS Prevention recommendations: .. code-block:: none & --> &amp; < --> &lt; > --> &gt; " --> &quot; ' --> &#x27; / -...
[ "def", "escape_html", "(", "text", ",", "escape_slash", "=", "False", ")", ":", "byte_str", "=", "text", ".", "encode", "(", "'utf-8'", ")", "ob", "=", "lib", ".", "hoedown_buffer_new", "(", "OUNIT", ")", "lib", ".", "hoedown_escape_html", "(", "ob", ","...
Binding for Hoedown's HTML escaping function. The implementation is inspired by the OWASP XSS Prevention recommendations: .. code-block:: none & --> &amp; < --> &lt; > --> &gt; " --> &quot; ' --> &#x27; / --> &#x2F; when escape_slash is set to True .. ver...
[ "Binding", "for", "Hoedown", "s", "HTML", "escaping", "function", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L69-L93
FSX/misaka
misaka/api.py
html
def html(text, extensions=0, render_flags=0): """ Convert markdown text to HTML. ``extensions`` can be a list or tuple of extensions (e.g. ``('fenced-code', 'footnotes', 'strikethrough')``) or an integer (e.g. ``EXT_FENCED_CODE | EXT_FOOTNOTES | EXT_STRIKETHROUGH``). ``render_flags`` can be a ...
python
def html(text, extensions=0, render_flags=0): """ Convert markdown text to HTML. ``extensions`` can be a list or tuple of extensions (e.g. ``('fenced-code', 'footnotes', 'strikethrough')``) or an integer (e.g. ``EXT_FENCED_CODE | EXT_FOOTNOTES | EXT_STRIKETHROUGH``). ``render_flags`` can be a ...
[ "def", "html", "(", "text", ",", "extensions", "=", "0", ",", "render_flags", "=", "0", ")", ":", "extensions", "=", "args_to_int", "(", "extension_map", ",", "extensions", ")", "render_flags", "=", "args_to_int", "(", "html_flag_map", ",", "render_flags", "...
Convert markdown text to HTML. ``extensions`` can be a list or tuple of extensions (e.g. ``('fenced-code', 'footnotes', 'strikethrough')``) or an integer (e.g. ``EXT_FENCED_CODE | EXT_FOOTNOTES | EXT_STRIKETHROUGH``). ``render_flags`` can be a list or tuple of flags (e.g. ``('skip-html', 'hard-wra...
[ "Convert", "markdown", "text", "to", "HTML", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L96-L125
FSX/misaka
misaka/api.py
smartypants
def smartypants(text): """ Transforms sequences of characters into HTML entities. =================================== ===================== ========= Markdown HTML Result =================================== ===================== ========= ``'s``...
python
def smartypants(text): """ Transforms sequences of characters into HTML entities. =================================== ===================== ========= Markdown HTML Result =================================== ===================== ========= ``'s``...
[ "def", "smartypants", "(", "text", ")", ":", "byte_str", "=", "text", ".", "encode", "(", "'utf-8'", ")", "ob", "=", "lib", ".", "hoedown_buffer_new", "(", "OUNIT", ")", "lib", ".", "hoedown_html_smartypants", "(", "ob", ",", "byte_str", ",", "len", "(",...
Transforms sequences of characters into HTML entities. =================================== ===================== ========= Markdown HTML Result =================================== ===================== ========= ``'s`` (s, t, m, d, re, ll, ve) &rsq...
[ "Transforms", "sequences", "of", "characters", "into", "HTML", "entities", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L128-L156
FSX/misaka
misaka/api.py
SaferHtmlRenderer.autolink
def autolink(self, raw_url, is_email): """ Filters links generated by the ``autolink`` extension. """ if self.check_url(raw_url): url = self.rewrite_url(('mailto:' if is_email else '') + raw_url) url = escape_html(url) return '<a href="%s">%s</a>' % (u...
python
def autolink(self, raw_url, is_email): """ Filters links generated by the ``autolink`` extension. """ if self.check_url(raw_url): url = self.rewrite_url(('mailto:' if is_email else '') + raw_url) url = escape_html(url) return '<a href="%s">%s</a>' % (u...
[ "def", "autolink", "(", "self", ",", "raw_url", ",", "is_email", ")", ":", "if", "self", ".", "check_url", "(", "raw_url", ")", ":", "url", "=", "self", ".", "rewrite_url", "(", "(", "'mailto:'", "if", "is_email", "else", "''", ")", "+", "raw_url", "...
Filters links generated by the ``autolink`` extension.
[ "Filters", "links", "generated", "by", "the", "autolink", "extension", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L304-L313
FSX/misaka
misaka/api.py
SaferHtmlRenderer.image
def image(self, raw_url, title='', alt=''): """ Filters the ``src`` attribute of an image. Note that filtering the source URL of an ``<img>`` tag is only a very basic protection, and it's mostly useless in modern browsers (they block JavaScript in there by default). An example o...
python
def image(self, raw_url, title='', alt=''): """ Filters the ``src`` attribute of an image. Note that filtering the source URL of an ``<img>`` tag is only a very basic protection, and it's mostly useless in modern browsers (they block JavaScript in there by default). An example o...
[ "def", "image", "(", "self", ",", "raw_url", ",", "title", "=", "''", ",", "alt", "=", "''", ")", ":", "if", "self", ".", "check_url", "(", "raw_url", ",", "is_image_src", "=", "True", ")", ":", "url", "=", "self", ".", "rewrite_url", "(", "raw_url...
Filters the ``src`` attribute of an image. Note that filtering the source URL of an ``<img>`` tag is only a very basic protection, and it's mostly useless in modern browsers (they block JavaScript in there by default). An example of attack that filtering does not thwart is phishing base...
[ "Filters", "the", "src", "attribute", "of", "an", "image", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L315-L335
FSX/misaka
misaka/api.py
SaferHtmlRenderer.link
def link(self, content, raw_url, title=''): """ Filters links. """ if self.check_url(raw_url): url = self.rewrite_url(raw_url) maybe_title = ' title="%s"' % escape_html(title) if title else '' url = escape_html(url) return ('<a href="%s"%s>...
python
def link(self, content, raw_url, title=''): """ Filters links. """ if self.check_url(raw_url): url = self.rewrite_url(raw_url) maybe_title = ' title="%s"' % escape_html(title) if title else '' url = escape_html(url) return ('<a href="%s"%s>...
[ "def", "link", "(", "self", ",", "content", ",", "raw_url", ",", "title", "=", "''", ")", ":", "if", "self", ".", "check_url", "(", "raw_url", ")", ":", "url", "=", "self", ".", "rewrite_url", "(", "raw_url", ")", "maybe_title", "=", "' title=\"%s\"'",...
Filters links.
[ "Filters", "links", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L337-L347
FSX/misaka
misaka/api.py
SaferHtmlRenderer.check_url
def check_url(self, url, is_image_src=False): """ This method is used to check a URL. Returns :obj:`True` if the URL is "safe", :obj:`False` otherwise. The default implementation only allows HTTP and HTTPS links. That means no ``mailto:``, no ``xmpp:``, no ``ftp:``, etc. ...
python
def check_url(self, url, is_image_src=False): """ This method is used to check a URL. Returns :obj:`True` if the URL is "safe", :obj:`False` otherwise. The default implementation only allows HTTP and HTTPS links. That means no ``mailto:``, no ``xmpp:``, no ``ftp:``, etc. ...
[ "def", "check_url", "(", "self", ",", "url", ",", "is_image_src", "=", "False", ")", ":", "return", "bool", "(", "self", ".", "_allowed_url_re", ".", "match", "(", "url", ")", ")" ]
This method is used to check a URL. Returns :obj:`True` if the URL is "safe", :obj:`False` otherwise. The default implementation only allows HTTP and HTTPS links. That means no ``mailto:``, no ``xmpp:``, no ``ftp:``, etc. This method exists specifically to allow easy customization of ...
[ "This", "method", "is", "used", "to", "check", "a", "URL", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L349-L365
FSX/misaka
misaka/api.py
SaferHtmlRenderer.rewrite_url
def rewrite_url(self, url, is_image_src=False): """ This method is called to rewrite URLs. It uses either ``self.link_rewrite`` or ``self.img_src_rewrite`` depending on the value of ``is_image_src``. The URL is returned unchanged if the corresponding attribute is :obj:`None`. ...
python
def rewrite_url(self, url, is_image_src=False): """ This method is called to rewrite URLs. It uses either ``self.link_rewrite`` or ``self.img_src_rewrite`` depending on the value of ``is_image_src``. The URL is returned unchanged if the corresponding attribute is :obj:`None`. ...
[ "def", "rewrite_url", "(", "self", ",", "url", ",", "is_image_src", "=", "False", ")", ":", "rewrite", "=", "self", ".", "img_src_rewrite", "if", "is_image_src", "else", "self", ".", "link_rewrite", "if", "rewrite", ":", "return", "rewrite", ".", "format", ...
This method is called to rewrite URLs. It uses either ``self.link_rewrite`` or ``self.img_src_rewrite`` depending on the value of ``is_image_src``. The URL is returned unchanged if the corresponding attribute is :obj:`None`.
[ "This", "method", "is", "called", "to", "rewrite", "URLs", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L367-L378
FSX/misaka
misaka/utils.py
args_to_int
def args_to_int(mapping, argument): """ Convert list of strings to an int using a mapping. """ if isinstance(argument, int): if argument == 0: return 0 deprecation('passing extensions and flags as constants is deprecated') return argument elif isinstance(argument,...
python
def args_to_int(mapping, argument): """ Convert list of strings to an int using a mapping. """ if isinstance(argument, int): if argument == 0: return 0 deprecation('passing extensions and flags as constants is deprecated') return argument elif isinstance(argument,...
[ "def", "args_to_int", "(", "mapping", ",", "argument", ")", ":", "if", "isinstance", "(", "argument", ",", "int", ")", ":", "if", "argument", "==", "0", ":", "return", "0", "deprecation", "(", "'passing extensions and flags as constants is deprecated'", ")", "re...
Convert list of strings to an int using a mapping.
[ "Convert", "list", "of", "strings", "to", "an", "int", "using", "a", "mapping", "." ]
train
https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/utils.py#L40-L51
vsergeev/u-msgpack-python
umsgpack.py
_pack3
def _pack3(obj, fp, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object fp: a .write()-supporting file-like object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable ...
python
def _pack3(obj, fp, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object fp: a .write()-supporting file-like object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable ...
[ "def", "_pack3", "(", "obj", ",", "fp", ",", "*", "*", "options", ")", ":", "global", "compatibility", "ext_handlers", "=", "options", ".", "get", "(", "\"ext_handlers\"", ")", "if", "obj", "is", "None", ":", "_pack_nil", "(", "obj", ",", "fp", ",", ...
Serialize a Python object into MessagePack bytes. Args: obj: a Python object fp: a .write()-supporting file-like object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type ...
[ "Serialize", "a", "Python", "object", "into", "MessagePack", "bytes", "." ]
train
https://github.com/vsergeev/u-msgpack-python/blob/e290b768ce63177ae04ed96402915b75a9741f38/umsgpack.py#L486-L555
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
_get_task_target
def _get_task_target(): """Get the default target for a pipeline task. Current version id format is: user_defined_version.minor_version_number Current module id is just the module's name. It could be "default" Returns: A complete target name is of format version.module. If module is the default module, ...
python
def _get_task_target(): """Get the default target for a pipeline task. Current version id format is: user_defined_version.minor_version_number Current module id is just the module's name. It could be "default" Returns: A complete target name is of format version.module. If module is the default module, ...
[ "def", "_get_task_target", "(", ")", ":", "# Break circular dependency.", "# pylint: disable=g-import-not-at-top", "import", "pipeline", "if", "pipeline", ".", "_TEST_MODE", ":", "return", "None", "# Further protect against test cases that doesn't set env vars", "# propertly.", "...
Get the default target for a pipeline task. Current version id format is: user_defined_version.minor_version_number Current module id is just the module's name. It could be "default" Returns: A complete target name is of format version.module. If module is the default module, just version. None if target ...
[ "Get", "the", "default", "target", "for", "a", "pipeline", "task", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L40-L66
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
for_name
def for_name(fq_name, recursive=False): """Find class/function/method specified by its fully qualified name. Fully qualified can be specified as: * <module_name>.<class_name> * <module_name>.<function_name> * <module_name>.<class_name>.<method_name> (an unbound method will be returned in this cas...
python
def for_name(fq_name, recursive=False): """Find class/function/method specified by its fully qualified name. Fully qualified can be specified as: * <module_name>.<class_name> * <module_name>.<function_name> * <module_name>.<class_name>.<method_name> (an unbound method will be returned in this cas...
[ "def", "for_name", "(", "fq_name", ",", "recursive", "=", "False", ")", ":", "fq_name", "=", "str", "(", "fq_name", ")", "module_name", "=", "__name__", "short_name", "=", "fq_name", "if", "fq_name", ".", "rfind", "(", "\".\"", ")", ">=", "0", ":", "("...
Find class/function/method specified by its fully qualified name. Fully qualified can be specified as: * <module_name>.<class_name> * <module_name>.<function_name> * <module_name>.<class_name>.<method_name> (an unbound method will be returned in this case). for_name works by doing __import__ for...
[ "Find", "class", "/", "function", "/", "method", "specified", "by", "its", "fully", "qualified", "name", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L69-L133
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
is_generator_function
def is_generator_function(obj): """Return true if the object is a user-defined generator function. Generator function objects provides same attributes as functions. See isfunction.__doc__ for attributes listing. Adapted from Python 2.6. Args: obj: an object to test. Returns: true if the object i...
python
def is_generator_function(obj): """Return true if the object is a user-defined generator function. Generator function objects provides same attributes as functions. See isfunction.__doc__ for attributes listing. Adapted from Python 2.6. Args: obj: an object to test. Returns: true if the object i...
[ "def", "is_generator_function", "(", "obj", ")", ":", "CO_GENERATOR", "=", "0x20", "return", "bool", "(", "(", "(", "inspect", ".", "isfunction", "(", "obj", ")", "or", "inspect", ".", "ismethod", "(", "obj", ")", ")", "and", "obj", ".", "func_code", "...
Return true if the object is a user-defined generator function. Generator function objects provides same attributes as functions. See isfunction.__doc__ for attributes listing. Adapted from Python 2.6. Args: obj: an object to test. Returns: true if the object is generator function.
[ "Return", "true", "if", "the", "object", "is", "a", "user", "-", "defined", "generator", "function", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L136-L152
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
_register_json_primitive
def _register_json_primitive(object_type, encoder, decoder): """Extend what Pipeline can serialize. Args: object_type: type of the object. encoder: a function that takes in an object and returns a dict of json primitives. decoder: inverse function of encoder. """ global _TYPE_TO_ENCODER glo...
python
def _register_json_primitive(object_type, encoder, decoder): """Extend what Pipeline can serialize. Args: object_type: type of the object. encoder: a function that takes in an object and returns a dict of json primitives. decoder: inverse function of encoder. """ global _TYPE_TO_ENCODER glo...
[ "def", "_register_json_primitive", "(", "object_type", ",", "encoder", ",", "decoder", ")", ":", "global", "_TYPE_TO_ENCODER", "global", "_TYPE_NAME_TO_DECODER", "if", "object_type", "not", "in", "_TYPE_TO_ENCODER", ":", "_TYPE_TO_ENCODER", "[", "object_type", "]", "=...
Extend what Pipeline can serialize. Args: object_type: type of the object. encoder: a function that takes in an object and returns a dict of json primitives. decoder: inverse function of encoder.
[ "Extend", "what", "Pipeline", "can", "serialize", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L211-L224
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
_JsonDecodeKey
def _JsonDecodeKey(d): """Json decode a ndb.Key object.""" k_c = d['key_string'] if isinstance(k_c, (list, tuple)): return ndb.Key(flat=k_c) return ndb.Key(urlsafe=d['key_string'])
python
def _JsonDecodeKey(d): """Json decode a ndb.Key object.""" k_c = d['key_string'] if isinstance(k_c, (list, tuple)): return ndb.Key(flat=k_c) return ndb.Key(urlsafe=d['key_string'])
[ "def", "_JsonDecodeKey", "(", "d", ")", ":", "k_c", "=", "d", "[", "'key_string'", "]", "if", "isinstance", "(", "k_c", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "ndb", ".", "Key", "(", "flat", "=", "k_c", ")", "return", "ndb", "."...
Json decode a ndb.Key object.
[ "Json", "decode", "a", "ndb", ".", "Key", "object", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L238-L243
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
JsonEncoder.default
def default(self, o): """Inherit docs.""" if type(o) in _TYPE_TO_ENCODER: encoder = _TYPE_TO_ENCODER[type(o)] json_struct = encoder(o) json_struct[self.TYPE_ID] = type(o).__name__ return json_struct return super(JsonEncoder, self).default(o)
python
def default(self, o): """Inherit docs.""" if type(o) in _TYPE_TO_ENCODER: encoder = _TYPE_TO_ENCODER[type(o)] json_struct = encoder(o) json_struct[self.TYPE_ID] = type(o).__name__ return json_struct return super(JsonEncoder, self).default(o)
[ "def", "default", "(", "self", ",", "o", ")", ":", "if", "type", "(", "o", ")", "in", "_TYPE_TO_ENCODER", ":", "encoder", "=", "_TYPE_TO_ENCODER", "[", "type", "(", "o", ")", "]", "json_struct", "=", "encoder", "(", "o", ")", "json_struct", "[", "sel...
Inherit docs.
[ "Inherit", "docs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L160-L167
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/util.py
JsonDecoder._dict_to_obj
def _dict_to_obj(self, d): """Converts a dictionary of json object to a Python object.""" if JsonEncoder.TYPE_ID not in d: return d type_name = d.pop(JsonEncoder.TYPE_ID) if type_name in _TYPE_NAME_TO_DECODER: decoder = _TYPE_NAME_TO_DECODER[type_name] return decoder(d) else: ...
python
def _dict_to_obj(self, d): """Converts a dictionary of json object to a Python object.""" if JsonEncoder.TYPE_ID not in d: return d type_name = d.pop(JsonEncoder.TYPE_ID) if type_name in _TYPE_NAME_TO_DECODER: decoder = _TYPE_NAME_TO_DECODER[type_name] return decoder(d) else: ...
[ "def", "_dict_to_obj", "(", "self", ",", "d", ")", ":", "if", "JsonEncoder", ".", "TYPE_ID", "not", "in", "d", ":", "return", "d", "type_name", "=", "d", ".", "pop", "(", "JsonEncoder", ".", "TYPE_ID", ")", "if", "type_name", "in", "_TYPE_NAME_TO_DECODER...
Converts a dictionary of json object to a Python object.
[ "Converts", "a", "dictionary", "of", "json", "object", "to", "a", "Python", "object", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/util.py#L178-L188
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_short_repr
def _short_repr(obj): """Helper function returns a truncated repr() of an object.""" stringified = pprint.saferepr(obj) if len(stringified) > 200: return '%s... (%d bytes)' % (stringified[:200], len(stringified)) return stringified
python
def _short_repr(obj): """Helper function returns a truncated repr() of an object.""" stringified = pprint.saferepr(obj) if len(stringified) > 200: return '%s... (%d bytes)' % (stringified[:200], len(stringified)) return stringified
[ "def", "_short_repr", "(", "obj", ")", ":", "stringified", "=", "pprint", ".", "saferepr", "(", "obj", ")", "if", "len", "(", "stringified", ")", ">", "200", ":", "return", "'%s... (%d bytes)'", "%", "(", "stringified", "[", ":", "200", "]", ",", "len"...
Helper function returns a truncated repr() of an object.
[ "Helper", "function", "returns", "a", "truncated", "repr", "()", "of", "an", "object", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1233-L1238
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_write_json_blob
def _write_json_blob(encoded_value, pipeline_id=None): """Writes a JSON encoded value to a Cloud Storage File. This function will store the blob in a GCS file in the default bucket under the appengine_pipeline directory. Optionally using another directory level specified by pipeline_id Args: encoded_valu...
python
def _write_json_blob(encoded_value, pipeline_id=None): """Writes a JSON encoded value to a Cloud Storage File. This function will store the blob in a GCS file in the default bucket under the appengine_pipeline directory. Optionally using another directory level specified by pipeline_id Args: encoded_valu...
[ "def", "_write_json_blob", "(", "encoded_value", ",", "pipeline_id", "=", "None", ")", ":", "default_bucket", "=", "app_identity", ".", "get_default_gcs_bucket_name", "(", ")", "if", "default_bucket", "is", "None", ":", "raise", "Exception", "(", "\"No default cloud...
Writes a JSON encoded value to a Cloud Storage File. This function will store the blob in a GCS file in the default bucket under the appengine_pipeline directory. Optionally using another directory level specified by pipeline_id Args: encoded_value: The encoded JSON string. pipeline_id: A pipeline id t...
[ "Writes", "a", "JSON", "encoded", "value", "to", "a", "Cloud", "Storage", "File", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1241-L1276
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_dereference_args
def _dereference_args(pipeline_name, args, kwargs): """Dereference a Pipeline's arguments that are slots, validating them. Each argument value passed in is assumed to be a dictionary with the format: {'type': 'value', 'value': 'serializable'} # A resolved value. {'type': 'slot', 'slot_key': 'str() on a db...
python
def _dereference_args(pipeline_name, args, kwargs): """Dereference a Pipeline's arguments that are slots, validating them. Each argument value passed in is assumed to be a dictionary with the format: {'type': 'value', 'value': 'serializable'} # A resolved value. {'type': 'slot', 'slot_key': 'str() on a db...
[ "def", "_dereference_args", "(", "pipeline_name", ",", "args", ",", "kwargs", ")", ":", "lookup_slots", "=", "set", "(", ")", "for", "arg", "in", "itertools", ".", "chain", "(", "args", ",", "kwargs", ".", "itervalues", "(", ")", ")", ":", "if", "arg",...
Dereference a Pipeline's arguments that are slots, validating them. Each argument value passed in is assumed to be a dictionary with the format: {'type': 'value', 'value': 'serializable'} # A resolved value. {'type': 'slot', 'slot_key': 'str() on a db.Key'} # A pending Slot. Args: pipeline_name: The...
[ "Dereference", "a", "Pipeline", "s", "arguments", "that", "are", "slots", "validating", "them", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1279-L1332
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_generate_args
def _generate_args(pipeline, future, queue_name, base_path): """Generate the params used to describe a Pipeline's depedencies. The arguments passed to this method may be normal values, Slot instances (for named outputs), or PipelineFuture instances (for referring to the default output slot). Args: pipel...
python
def _generate_args(pipeline, future, queue_name, base_path): """Generate the params used to describe a Pipeline's depedencies. The arguments passed to this method may be normal values, Slot instances (for named outputs), or PipelineFuture instances (for referring to the default output slot). Args: pipel...
[ "def", "_generate_args", "(", "pipeline", ",", "future", ",", "queue_name", ",", "base_path", ")", ":", "params", "=", "{", "'args'", ":", "[", "]", ",", "'kwargs'", ":", "{", "}", ",", "'after_all'", ":", "[", "]", ",", "'output_slots'", ":", "{", "...
Generate the params used to describe a Pipeline's depedencies. The arguments passed to this method may be normal values, Slot instances (for named outputs), or PipelineFuture instances (for referring to the default output slot). Args: pipeline: The Pipeline instance to generate args for. future: The P...
[ "Generate", "the", "params", "used", "to", "describe", "a", "Pipeline", "s", "depedencies", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1335-L1419
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_get_timestamp_ms
def _get_timestamp_ms(when): """Converts a datetime.datetime to integer milliseconds since the epoch. Requires special handling to preserve microseconds. Args: when: A datetime.datetime instance. Returns: Integer time since the epoch in milliseconds. If the supplied 'when' is None, the return val...
python
def _get_timestamp_ms(when): """Converts a datetime.datetime to integer milliseconds since the epoch. Requires special handling to preserve microseconds. Args: when: A datetime.datetime instance. Returns: Integer time since the epoch in milliseconds. If the supplied 'when' is None, the return val...
[ "def", "_get_timestamp_ms", "(", "when", ")", ":", "if", "when", "is", "None", ":", "return", "None", "ms_since_epoch", "=", "float", "(", "time", ".", "mktime", "(", "when", ".", "utctimetuple", "(", ")", ")", "*", "1000.0", ")", "ms_since_epoch", "+=",...
Converts a datetime.datetime to integer milliseconds since the epoch. Requires special handling to preserve microseconds. Args: when: A datetime.datetime instance. Returns: Integer time since the epoch in milliseconds. If the supplied 'when' is None, the return value will be None.
[ "Converts", "a", "datetime", ".", "datetime", "to", "integer", "milliseconds", "since", "the", "epoch", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2872-L2888
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_get_internal_status
def _get_internal_status(pipeline_key=None, pipeline_dict=None, slot_dict=None, barrier_dict=None, status_dict=None): """Gets the UI dictionary of a pipeline from a set of status dictionaries. Args: pipeline_key...
python
def _get_internal_status(pipeline_key=None, pipeline_dict=None, slot_dict=None, barrier_dict=None, status_dict=None): """Gets the UI dictionary of a pipeline from a set of status dictionaries. Args: pipeline_key...
[ "def", "_get_internal_status", "(", "pipeline_key", "=", "None", ",", "pipeline_dict", "=", "None", ",", "slot_dict", "=", "None", ",", "barrier_dict", "=", "None", ",", "status_dict", "=", "None", ")", ":", "if", "pipeline_dict", "is", "None", ":", "pipelin...
Gets the UI dictionary of a pipeline from a set of status dictionaries. Args: pipeline_key: The key of the pipeline to lookup. pipeline_dict: Dictionary mapping pipeline db.Key to _PipelineRecord. Default is an empty dictionary. slot_dict: Dictionary mapping slot db.Key to _SlotRecord. Defaul...
[ "Gets", "the", "UI", "dictionary", "of", "a", "pipeline", "from", "a", "set", "of", "status", "dictionaries", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2891-L3056
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_get_internal_slot
def _get_internal_slot(slot_key=None, filler_pipeline_key=None, slot_dict=None): """Gets information about a _SlotRecord for display in UI. Args: slot_key: The db.Key of the slot to fetch. filler_pipeline_key: In the case the slot has not yet been filled, assum...
python
def _get_internal_slot(slot_key=None, filler_pipeline_key=None, slot_dict=None): """Gets information about a _SlotRecord for display in UI. Args: slot_key: The db.Key of the slot to fetch. filler_pipeline_key: In the case the slot has not yet been filled, assum...
[ "def", "_get_internal_slot", "(", "slot_key", "=", "None", ",", "filler_pipeline_key", "=", "None", ",", "slot_dict", "=", "None", ")", ":", "if", "slot_dict", "is", "None", ":", "slot_dict", "=", "{", "}", "slot_record", "=", "slot_dict", ".", "get", "(",...
Gets information about a _SlotRecord for display in UI. Args: slot_key: The db.Key of the slot to fetch. filler_pipeline_key: In the case the slot has not yet been filled, assume that the given db.Key (for a _PipelineRecord) will be the filler of the slot in the future. slot_dict: The slot JS...
[ "Gets", "information", "about", "a", "_SlotRecord", "for", "display", "in", "UI", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L3059-L3103
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
get_status_tree
def get_status_tree(root_pipeline_id): """Gets the full status tree of a pipeline. Args: root_pipeline_id: The pipeline ID to get status for. Returns: Dictionary with the keys: rootPipelineId: The ID of the root pipeline. slots: Mapping of slot IDs to result of from _get_internal_slot. ...
python
def get_status_tree(root_pipeline_id): """Gets the full status tree of a pipeline. Args: root_pipeline_id: The pipeline ID to get status for. Returns: Dictionary with the keys: rootPipelineId: The ID of the root pipeline. slots: Mapping of slot IDs to result of from _get_internal_slot. ...
[ "def", "get_status_tree", "(", "root_pipeline_id", ")", ":", "root_pipeline_key", "=", "db", ".", "Key", ".", "from_path", "(", "_PipelineRecord", ".", "kind", "(", ")", ",", "root_pipeline_id", ")", "root_pipeline_record", "=", "db", ".", "get", "(", "root_pi...
Gets the full status tree of a pipeline. Args: root_pipeline_id: The pipeline ID to get status for. Returns: Dictionary with the keys: rootPipelineId: The ID of the root pipeline. slots: Mapping of slot IDs to result of from _get_internal_slot. pipelines: Mapping of pipeline IDs to resul...
[ "Gets", "the", "full", "status", "tree", "of", "a", "pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L3106-L3203
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
get_pipeline_names
def get_pipeline_names(): """Returns the class paths of all Pipelines defined in alphabetical order.""" class_path_set = set() for cls in _PipelineMeta._all_classes: if cls.class_path is not None: class_path_set.add(cls.class_path) return sorted(class_path_set)
python
def get_pipeline_names(): """Returns the class paths of all Pipelines defined in alphabetical order.""" class_path_set = set() for cls in _PipelineMeta._all_classes: if cls.class_path is not None: class_path_set.add(cls.class_path) return sorted(class_path_set)
[ "def", "get_pipeline_names", "(", ")", ":", "class_path_set", "=", "set", "(", ")", "for", "cls", "in", "_PipelineMeta", ".", "_all_classes", ":", "if", "cls", ".", "class_path", "is", "not", "None", ":", "class_path_set", ".", "add", "(", "cls", ".", "c...
Returns the class paths of all Pipelines defined in alphabetical order.
[ "Returns", "the", "class", "paths", "of", "all", "Pipelines", "defined", "in", "alphabetical", "order", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L3206-L3212
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
get_root_list
def get_root_list(class_path=None, cursor=None, count=50): """Gets a list root Pipelines. Args: class_path: Optional. If supplied, only return root Pipelines with the given class_path. By default all root pipelines are returned. cursor: Optional. When supplied, the cursor returned from the last call ...
python
def get_root_list(class_path=None, cursor=None, count=50): """Gets a list root Pipelines. Args: class_path: Optional. If supplied, only return root Pipelines with the given class_path. By default all root pipelines are returned. cursor: Optional. When supplied, the cursor returned from the last call ...
[ "def", "get_root_list", "(", "class_path", "=", "None", ",", "cursor", "=", "None", ",", "count", "=", "50", ")", ":", "query", "=", "_PipelineRecord", ".", "all", "(", "cursor", "=", "cursor", ")", "if", "class_path", ":", "query", ".", "filter", "(",...
Gets a list root Pipelines. Args: class_path: Optional. If supplied, only return root Pipelines with the given class_path. By default all root pipelines are returned. cursor: Optional. When supplied, the cursor returned from the last call to get_root_list which indicates where to pick up. cou...
[ "Gets", "a", "list", "root", "Pipelines", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L3215-L3287
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
create_handlers_map
def create_handlers_map(prefix='.*'): """Create new handlers map. Args: prefix: url prefix to use. Returns: list of (regexp, handler) pairs for WSGIApplication constructor. """ return [ (prefix + '/output', _BarrierHandler), (prefix + '/run', _PipelineHandler), (prefix + '/finalize...
python
def create_handlers_map(prefix='.*'): """Create new handlers map. Args: prefix: url prefix to use. Returns: list of (regexp, handler) pairs for WSGIApplication constructor. """ return [ (prefix + '/output', _BarrierHandler), (prefix + '/run', _PipelineHandler), (prefix + '/finalize...
[ "def", "create_handlers_map", "(", "prefix", "=", "'.*'", ")", ":", "return", "[", "(", "prefix", "+", "'/output'", ",", "_BarrierHandler", ")", ",", "(", "prefix", "+", "'/run'", ",", "_PipelineHandler", ")", ",", "(", "prefix", "+", "'/finalized'", ",", ...
Create new handlers map. Args: prefix: url prefix to use. Returns: list of (regexp, handler) pairs for WSGIApplication constructor.
[ "Create", "new", "handlers", "map", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L3303-L3325
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Slot.value
def value(self): """Returns the current value of this slot. Returns: The value of the slot (a serializable Python type). Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled....
python
def value(self): """Returns the current value of this slot. Returns: The value of the slot (a serializable Python type). Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled....
[ "def", "value", "(", "self", ")", ":", "if", "not", "self", ".", "filled", ":", "raise", "SlotNotFilledError", "(", "'Slot with name \"%s\", key \"%s\" not yet filled.'", "%", "(", "self", ".", "name", ",", "self", ".", "key", ")", ")", "return", "self", "."...
Returns the current value of this slot. Returns: The value of the slot (a serializable Python type). Raises: SlotNotFilledError if the value hasn't been filled yet.
[ "Returns", "the", "current", "value", "of", "this", "slot", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L203-L215
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Slot.filler
def filler(self): """Returns the pipeline ID that filled this slot's value. Returns: A string that is the pipeline ID. Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.' ...
python
def filler(self): """Returns the pipeline ID that filled this slot's value. Returns: A string that is the pipeline ID. Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.' ...
[ "def", "filler", "(", "self", ")", ":", "if", "not", "self", ".", "filled", ":", "raise", "SlotNotFilledError", "(", "'Slot with name \"%s\", key \"%s\" not yet filled.'", "%", "(", "self", ".", "name", ",", "self", ".", "key", ")", ")", "return", "self", "....
Returns the pipeline ID that filled this slot's value. Returns: A string that is the pipeline ID. Raises: SlotNotFilledError if the value hasn't been filled yet.
[ "Returns", "the", "pipeline", "ID", "that", "filled", "this", "slot", "s", "value", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L218-L230
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Slot.fill_datetime
def fill_datetime(self): """Returns when the slot was filled. Returns: A datetime.datetime. Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.' ...
python
def fill_datetime(self): """Returns when the slot was filled. Returns: A datetime.datetime. Raises: SlotNotFilledError if the value hasn't been filled yet. """ if not self.filled: raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.' ...
[ "def", "fill_datetime", "(", "self", ")", ":", "if", "not", "self", ".", "filled", ":", "raise", "SlotNotFilledError", "(", "'Slot with name \"%s\", key \"%s\" not yet filled.'", "%", "(", "self", ".", "name", ",", "self", ".", "key", ")", ")", "return", "self...
Returns when the slot was filled. Returns: A datetime.datetime. Raises: SlotNotFilledError if the value hasn't been filled yet.
[ "Returns", "when", "the", "slot", "was", "filled", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L233-L245
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Slot._set_value
def _set_value(self, slot_record): """Sets the value of this slot based on its corresponding _SlotRecord. Does nothing if the slot has not yet been filled. Args: slot_record: The _SlotRecord containing this Slot's value. """ if slot_record.status == _SlotRecord.FILLED: self.filled = Tr...
python
def _set_value(self, slot_record): """Sets the value of this slot based on its corresponding _SlotRecord. Does nothing if the slot has not yet been filled. Args: slot_record: The _SlotRecord containing this Slot's value. """ if slot_record.status == _SlotRecord.FILLED: self.filled = Tr...
[ "def", "_set_value", "(", "self", ",", "slot_record", ")", ":", "if", "slot_record", ".", "status", "==", "_SlotRecord", ".", "FILLED", ":", "self", ".", "filled", "=", "True", "self", ".", "_filler_pipeline_key", "=", "_SlotRecord", ".", "filler", ".", "g...
Sets the value of this slot based on its corresponding _SlotRecord. Does nothing if the slot has not yet been filled. Args: slot_record: The _SlotRecord containing this Slot's value.
[ "Sets", "the", "value", "of", "this", "slot", "based", "on", "its", "corresponding", "_SlotRecord", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L247-L260
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
PipelineFuture._inherit_outputs
def _inherit_outputs(self, pipeline_name, already_defined, resolve_outputs=False): """Inherits outputs from a calling Pipeline. Args: pipeline_name: The Pipeline class name (used for debugging). already_defined: Maps output name t...
python
def _inherit_outputs(self, pipeline_name, already_defined, resolve_outputs=False): """Inherits outputs from a calling Pipeline. Args: pipeline_name: The Pipeline class name (used for debugging). already_defined: Maps output name t...
[ "def", "_inherit_outputs", "(", "self", ",", "pipeline_name", ",", "already_defined", ",", "resolve_outputs", "=", "False", ")", ":", "for", "name", ",", "slot_key", "in", "already_defined", ".", "iteritems", "(", ")", ":", "if", "not", "isinstance", "(", "s...
Inherits outputs from a calling Pipeline. Args: pipeline_name: The Pipeline class name (used for debugging). already_defined: Maps output name to stringified db.Key (of _SlotRecords) of any exiting output slots to be inherited by this future. resolve_outputs: When True, this method will d...
[ "Inherits", "outputs", "from", "a", "calling", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L314-L358
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.from_id
def from_id(cls, pipeline_id, resolve_outputs=True, _pipeline_record=None): """Returns an instance corresponding to an existing Pipeline. The returned object will have the same properties a Pipeline does while it's running synchronously (e.g., like what it's first allocated), allowing callers to inspec...
python
def from_id(cls, pipeline_id, resolve_outputs=True, _pipeline_record=None): """Returns an instance corresponding to an existing Pipeline. The returned object will have the same properties a Pipeline does while it's running synchronously (e.g., like what it's first allocated), allowing callers to inspec...
[ "def", "from_id", "(", "cls", ",", "pipeline_id", ",", "resolve_outputs", "=", "True", ",", "_pipeline_record", "=", "None", ")", ":", "pipeline_record", "=", "_pipeline_record", "# Support pipeline IDs and idempotence_keys that are not unicode.", "if", "not", "isinstance...
Returns an instance corresponding to an existing Pipeline. The returned object will have the same properties a Pipeline does while it's running synchronously (e.g., like what it's first allocated), allowing callers to inspect caller arguments, outputs, fill slots, complete the pipeline, abort, retry, e...
[ "Returns", "an", "instance", "corresponding", "to", "an", "existing", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L544-L609
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.start
def start(self, idempotence_key='', queue_name='default', base_path='/_ah/pipeline', return_task=False, countdown=None, eta=None): """Starts a new instance of this pipeline. Args: idempotence_key: The ID to use for this Pipeline and ...
python
def start(self, idempotence_key='', queue_name='default', base_path='/_ah/pipeline', return_task=False, countdown=None, eta=None): """Starts a new instance of this pipeline. Args: idempotence_key: The ID to use for this Pipeline and ...
[ "def", "start", "(", "self", ",", "idempotence_key", "=", "''", ",", "queue_name", "=", "'default'", ",", "base_path", "=", "'/_ah/pipeline'", ",", "return_task", "=", "False", ",", "countdown", "=", "None", ",", "eta", "=", "None", ")", ":", "if", "not"...
Starts a new instance of this pipeline. Args: idempotence_key: The ID to use for this Pipeline and throughout its asynchronous workflow to ensure the operations are idempotent. If empty a starting key will be automatically assigned. queue_name: What queue this Pipeline's workflow should...
[ "Starts", "a", "new", "instance", "of", "this", "pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L613-L673
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.retry
def retry(self, retry_message=''): """Forces a currently running asynchronous pipeline to retry. Note this may not be called by synchronous or generator pipelines. Those must instead raise the 'Retry' exception during execution. Args: retry_message: Optional message explaining why the retry happ...
python
def retry(self, retry_message=''): """Forces a currently running asynchronous pipeline to retry. Note this may not be called by synchronous or generator pipelines. Those must instead raise the 'Retry' exception during execution. Args: retry_message: Optional message explaining why the retry happ...
[ "def", "retry", "(", "self", ",", "retry_message", "=", "''", ")", ":", "if", "not", "self", ".", "async", ":", "raise", "UnexpectedPipelineError", "(", "'May only call retry() method for asynchronous pipelines.'", ")", "if", "self", ".", "try_cancel", "(", ")", ...
Forces a currently running asynchronous pipeline to retry. Note this may not be called by synchronous or generator pipelines. Those must instead raise the 'Retry' exception during execution. Args: retry_message: Optional message explaining why the retry happened. Returns: True if the Pipe...
[ "Forces", "a", "currently", "running", "asynchronous", "pipeline", "to", "retry", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L693-L713
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.abort
def abort(self, abort_message=''): """Mark the entire pipeline up to the root as aborted. Note this should only be called from *outside* the context of a running pipeline. Synchronous and generator pipelines should raise the 'Abort' exception to cause this behavior during execution. Args: ab...
python
def abort(self, abort_message=''): """Mark the entire pipeline up to the root as aborted. Note this should only be called from *outside* the context of a running pipeline. Synchronous and generator pipelines should raise the 'Abort' exception to cause this behavior during execution. Args: ab...
[ "def", "abort", "(", "self", ",", "abort_message", "=", "''", ")", ":", "# TODO: Use thread-local variable to enforce that this is not called", "# while a pipeline is executing in the current thread.", "if", "(", "self", ".", "async", "and", "self", ".", "_root_pipeline_key",...
Mark the entire pipeline up to the root as aborted. Note this should only be called from *outside* the context of a running pipeline. Synchronous and generator pipelines should raise the 'Abort' exception to cause this behavior during execution. Args: abort_message: Optional message explaining w...
[ "Mark", "the", "entire", "pipeline", "up", "to", "the", "root", "as", "aborted", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L715-L738
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.fill
def fill(self, name_or_slot, value): """Fills an output slot required by this Pipeline. Args: name_or_slot: The name of the slot (a string) or Slot record to fill. value: The serializable value to assign to this slot. Raises: UnexpectedPipelineError if the Slot no longer exists. SlotNotD...
python
def fill(self, name_or_slot, value): """Fills an output slot required by this Pipeline. Args: name_or_slot: The name of the slot (a string) or Slot record to fill. value: The serializable value to assign to this slot. Raises: UnexpectedPipelineError if the Slot no longer exists. SlotNotD...
[ "def", "fill", "(", "self", ",", "name_or_slot", ",", "value", ")", ":", "if", "isinstance", "(", "name_or_slot", ",", "basestring", ")", ":", "slot", "=", "getattr", "(", "self", ".", "outputs", ",", "name_or_slot", ")", "elif", "isinstance", "(", "name...
Fills an output slot required by this Pipeline. Args: name_or_slot: The name of the slot (a string) or Slot record to fill. value: The serializable value to assign to this slot. Raises: UnexpectedPipelineError if the Slot no longer exists. SlotNotDeclaredError if trying to output to a ...
[ "Fills", "an", "output", "slot", "required", "by", "this", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L741-L765
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.set_status
def set_status(self, message=None, console_url=None, status_links=None): """Sets the current status of this pipeline. This method is purposefully non-transactional. Updates are written to the datastore immediately and overwrite all existing statuses. Args: message: (optional) Overall status mess...
python
def set_status(self, message=None, console_url=None, status_links=None): """Sets the current status of this pipeline. This method is purposefully non-transactional. Updates are written to the datastore immediately and overwrite all existing statuses. Args: message: (optional) Overall status mess...
[ "def", "set_status", "(", "self", ",", "message", "=", "None", ",", "console_url", "=", "None", ",", "status_links", "=", "None", ")", ":", "if", "_TEST_MODE", ":", "logging", ".", "info", "(", "'New status for %s#%s: message=%r, console_url=%r, status_links=%r'", ...
Sets the current status of this pipeline. This method is purposefully non-transactional. Updates are written to the datastore immediately and overwrite all existing statuses. Args: message: (optional) Overall status message. console_url: (optional) Relative URL to use for the "console" of this...
[ "Sets", "the", "current", "status", "of", "this", "pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L767-L815
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.complete
def complete(self, default_output=None): """Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async...
python
def complete(self, default_output=None): """Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async...
[ "def", "complete", "(", "self", ",", "default_output", "=", "None", ")", ":", "# TODO: Enforce that all outputs expected by this async pipeline were", "# filled before this complete() function was called. May required all", "# async functions to declare their outputs upfront.", "if", "no...
Marks this asynchronous Pipeline as complete. Args: default_output: What value the 'default' output slot should be assigned. Raises: UnexpectedPipelineError if the slot no longer exists or this method was called for a pipeline that is not async.
[ "Marks", "this", "asynchronous", "Pipeline", "as", "complete", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L817-L834
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.get_callback_url
def get_callback_url(self, **kwargs): """Returns a relative URL for invoking this Pipeline's callback method. Args: kwargs: Dictionary mapping keyword argument names to single values that should be passed to the callback when it is invoked. Raises: UnexpectedPipelineError if this is in...
python
def get_callback_url(self, **kwargs): """Returns a relative URL for invoking this Pipeline's callback method. Args: kwargs: Dictionary mapping keyword argument names to single values that should be passed to the callback when it is invoked. Raises: UnexpectedPipelineError if this is in...
[ "def", "get_callback_url", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# TODO: Support positional parameters.", "if", "not", "self", ".", "async", ":", "raise", "UnexpectedPipelineError", "(", "'May only call get_callback_url() method for asynchronous pipelines.'", ")"...
Returns a relative URL for invoking this Pipeline's callback method. Args: kwargs: Dictionary mapping keyword argument names to single values that should be passed to the callback when it is invoked. Raises: UnexpectedPipelineError if this is invoked on pipeline that is not async.
[ "Returns", "a", "relative", "URL", "for", "invoking", "this", "Pipeline", "s", "callback", "method", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L836-L852
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.get_callback_task
def get_callback_task(self, *args, **kwargs): """Returns a task for calling back this Pipeline. Args: params: Keyword argument containing a dictionary of key/value pairs that will be passed to the callback when it is executed. args, kwargs: Passed to the taskqueue.Task constructor. Use thes...
python
def get_callback_task(self, *args, **kwargs): """Returns a task for calling back this Pipeline. Args: params: Keyword argument containing a dictionary of key/value pairs that will be passed to the callback when it is executed. args, kwargs: Passed to the taskqueue.Task constructor. Use thes...
[ "def", "get_callback_task", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "async", ":", "raise", "UnexpectedPipelineError", "(", "'May only call get_callback_task() method for asynchronous pipelines.'", ")", "params", "=...
Returns a task for calling back this Pipeline. Args: params: Keyword argument containing a dictionary of key/value pairs that will be passed to the callback when it is executed. args, kwargs: Passed to the taskqueue.Task constructor. Use these arguments to set the task name (for idempot...
[ "Returns", "a", "task", "for", "calling", "back", "this", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L854-L875
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.send_result_email
def send_result_email(self, sender=None): """Sends an email to admins indicating this Pipeline has completed. For developer convenience. Automatically called from finalized for root Pipelines that do not override the default action. Args: sender: (optional) Override the sender's email address. ...
python
def send_result_email(self, sender=None): """Sends an email to admins indicating this Pipeline has completed. For developer convenience. Automatically called from finalized for root Pipelines that do not override the default action. Args: sender: (optional) Override the sender's email address. ...
[ "def", "send_result_email", "(", "self", ",", "sender", "=", "None", ")", ":", "status", "=", "'successful'", "if", "self", ".", "was_aborted", ":", "status", "=", "'aborted'", "app_id", "=", "os", ".", "environ", "[", "'APPLICATION_ID'", "]", "shard_index",...
Sends an email to admins indicating this Pipeline has completed. For developer convenience. Automatically called from finalized for root Pipelines that do not override the default action. Args: sender: (optional) Override the sender's email address.
[ "Sends", "an", "email", "to", "admins", "indicating", "this", "Pipeline", "has", "completed", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L877-L935
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.cleanup
def cleanup(self): """Clean up this Pipeline and all Datastore records used for coordination. Only works when called on a root pipeline. Child pipelines will ignore calls to this method. After this method is called, Pipeline.from_id() and related status methods will return inconsistent or missing ...
python
def cleanup(self): """Clean up this Pipeline and all Datastore records used for coordination. Only works when called on a root pipeline. Child pipelines will ignore calls to this method. After this method is called, Pipeline.from_id() and related status methods will return inconsistent or missing ...
[ "def", "cleanup", "(", "self", ")", ":", "if", "self", ".", "_root_pipeline_key", "is", "None", ":", "raise", "UnexpectedPipelineError", "(", "'Could not cleanup Pipeline with unknown root pipeline ID.'", ")", "if", "not", "self", ".", "is_root", ":", "return", "tas...
Clean up this Pipeline and all Datastore records used for coordination. Only works when called on a root pipeline. Child pipelines will ignore calls to this method. After this method is called, Pipeline.from_id() and related status methods will return inconsistent or missing results. This method is ...
[ "Clean", "up", "this", "Pipeline", "and", "all", "Datastore", "records", "used", "for", "coordination", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L937-L956
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline.with_params
def with_params(self, **kwargs): """Modify various execution parameters of a Pipeline before it runs. This method has no effect in test mode. Args: kwargs: Attributes to modify on this Pipeline instance before it has been executed. Returns: This Pipeline instance, for easy chainin...
python
def with_params(self, **kwargs): """Modify various execution parameters of a Pipeline before it runs. This method has no effect in test mode. Args: kwargs: Attributes to modify on this Pipeline instance before it has been executed. Returns: This Pipeline instance, for easy chainin...
[ "def", "with_params", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "_TEST_MODE", ":", "logging", ".", "info", "(", "'Setting runtime parameters for %s#%s: %r'", ",", "self", ",", "self", ".", "pipeline_id", ",", "kwargs", ")", "return", "self", "if"...
Modify various execution parameters of a Pipeline before it runs. This method has no effect in test mode. Args: kwargs: Attributes to modify on this Pipeline instance before it has been executed. Returns: This Pipeline instance, for easy chaining.
[ "Modify", "various", "execution", "parameters", "of", "a", "Pipeline", "before", "it", "runs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L958-L986
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline._set_class_path
def _set_class_path(cls, module_dict=sys.modules): """Sets the absolute path to this class as a string. Used by the Pipeline API to reconstruct the Pipeline sub-class object at execution time instead of passing around a serialized function. Args: module_dict: Used for testing. """ # Do n...
python
def _set_class_path(cls, module_dict=sys.modules): """Sets the absolute path to this class as a string. Used by the Pipeline API to reconstruct the Pipeline sub-class object at execution time instead of passing around a serialized function. Args: module_dict: Used for testing. """ # Do n...
[ "def", "_set_class_path", "(", "cls", ",", "module_dict", "=", "sys", ".", "modules", ")", ":", "# Do not traverse the class hierarchy fetching the class path attribute.", "found", "=", "cls", ".", "__dict__", ".", "get", "(", "'_class_path'", ")", "if", "found", "i...
Sets the absolute path to this class as a string. Used by the Pipeline API to reconstruct the Pipeline sub-class object at execution time instead of passing around a serialized function. Args: module_dict: Used for testing.
[ "Sets", "the", "absolute", "path", "to", "this", "class", "as", "a", "string", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1035-L1068
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline._set_values_internal
def _set_values_internal(self, context, pipeline_key, root_pipeline_key, outputs, result_status): """Sets the user-visible values provided as an API by this class. Args: ...
python
def _set_values_internal(self, context, pipeline_key, root_pipeline_key, outputs, result_status): """Sets the user-visible values provided as an API by this class. Args: ...
[ "def", "_set_values_internal", "(", "self", ",", "context", ",", "pipeline_key", ",", "root_pipeline_key", ",", "outputs", ",", "result_status", ")", ":", "self", ".", "_context", "=", "context", "self", ".", "_pipeline_key", "=", "pipeline_key", "self", ".", ...
Sets the user-visible values provided as an API by this class. Args: context: The _PipelineContext used for this Pipeline. pipeline_key: The db.Key of this pipeline. root_pipeline_key: The db.Key of the root pipeline. outputs: The PipelineFuture for this pipeline. result_status: The r...
[ "Sets", "the", "user", "-", "visible", "values", "provided", "as", "an", "API", "by", "this", "class", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1070-L1089
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline._callback_internal
def _callback_internal(self, kwargs): """Used to execute callbacks on asynchronous pipelines.""" logging.debug('Callback %s(*%s, **%s)#%s with params: %r', self._class_path, _short_repr(self.args), _short_repr(self.kwargs), self._pipeline_key.name(), kwargs) return self.c...
python
def _callback_internal(self, kwargs): """Used to execute callbacks on asynchronous pipelines.""" logging.debug('Callback %s(*%s, **%s)#%s with params: %r', self._class_path, _short_repr(self.args), _short_repr(self.kwargs), self._pipeline_key.name(), kwargs) return self.c...
[ "def", "_callback_internal", "(", "self", ",", "kwargs", ")", ":", "logging", ".", "debug", "(", "'Callback %s(*%s, **%s)#%s with params: %r'", ",", "self", ".", "_class_path", ",", "_short_repr", "(", "self", ".", "args", ")", ",", "_short_repr", "(", "self", ...
Used to execute callbacks on asynchronous pipelines.
[ "Used", "to", "execute", "callbacks", "on", "asynchronous", "pipelines", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1091-L1096
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline._run_internal
def _run_internal(self, context, pipeline_key, root_pipeline_key, caller_output): """Used by the Pipeline evaluator to execute this Pipeline.""" self._set_values_internal( context, pipeline_key, root_pipeline_key, caller_out...
python
def _run_internal(self, context, pipeline_key, root_pipeline_key, caller_output): """Used by the Pipeline evaluator to execute this Pipeline.""" self._set_values_internal( context, pipeline_key, root_pipeline_key, caller_out...
[ "def", "_run_internal", "(", "self", ",", "context", ",", "pipeline_key", ",", "root_pipeline_key", ",", "caller_output", ")", ":", "self", ".", "_set_values_internal", "(", "context", ",", "pipeline_key", ",", "root_pipeline_key", ",", "caller_output", ",", "_Pip...
Used by the Pipeline evaluator to execute this Pipeline.
[ "Used", "by", "the", "Pipeline", "evaluator", "to", "execute", "this", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1098-L1110
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
Pipeline._finalized_internal
def _finalized_internal(self, context, pipeline_key, root_pipeline_key, caller_output, aborted): """Used by the Pipeline evaluator to finalize this Pipeline.""" result_status = _Pipe...
python
def _finalized_internal(self, context, pipeline_key, root_pipeline_key, caller_output, aborted): """Used by the Pipeline evaluator to finalize this Pipeline.""" result_status = _Pipe...
[ "def", "_finalized_internal", "(", "self", ",", "context", ",", "pipeline_key", ",", "root_pipeline_key", ",", "caller_output", ",", "aborted", ")", ":", "result_status", "=", "_PipelineRecord", ".", "RUN", "if", "aborted", ":", "result_status", "=", "_PipelineRec...
Used by the Pipeline evaluator to finalize this Pipeline.
[ "Used", "by", "the", "Pipeline", "evaluator", "to", "finalize", "this", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1112-L1131
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
InOrder._add_future
def _add_future(cls, future): """Adds a future to the list of in-order futures thus far. Args: future: The future to add to the list. """ if cls._local._activated: cls._local._in_order_futures.add(future)
python
def _add_future(cls, future): """Adds a future to the list of in-order futures thus far. Args: future: The future to add to the list. """ if cls._local._activated: cls._local._in_order_futures.add(future)
[ "def", "_add_future", "(", "cls", ",", "future", ")", ":", "if", "cls", ".", "_local", ".", "_activated", ":", "cls", ".", "_local", ".", "_in_order_futures", ".", "add", "(", "future", ")" ]
Adds a future to the list of in-order futures thus far. Args: future: The future to add to the list.
[ "Adds", "a", "future", "to", "the", "list", "of", "in", "-", "order", "futures", "thus", "far", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1190-L1197
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
InOrder._thread_init
def _thread_init(cls): """Ensure thread local is initialized.""" if not hasattr(cls._local, '_in_order_futures'): cls._local._in_order_futures = set() cls._local._activated = False
python
def _thread_init(cls): """Ensure thread local is initialized.""" if not hasattr(cls._local, '_in_order_futures'): cls._local._in_order_futures = set() cls._local._activated = False
[ "def", "_thread_init", "(", "cls", ")", ":", "if", "not", "hasattr", "(", "cls", ".", "_local", ",", "'_in_order_futures'", ")", ":", "cls", ".", "_local", ".", "_in_order_futures", "=", "set", "(", ")", "cls", ".", "_local", ".", "_activated", "=", "F...
Ensure thread local is initialized.
[ "Ensure", "thread", "local", "is", "initialized", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1224-L1228
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.from_environ
def from_environ(cls, environ=os.environ): """Constructs a _PipelineContext from the task queue environment.""" base_path, unused = (environ['PATH_INFO'].rsplit('/', 1) + [''])[:2] return cls( environ['HTTP_X_APPENGINE_TASKNAME'], environ['HTTP_X_APPENGINE_QUEUENAME'], base_path)
python
def from_environ(cls, environ=os.environ): """Constructs a _PipelineContext from the task queue environment.""" base_path, unused = (environ['PATH_INFO'].rsplit('/', 1) + [''])[:2] return cls( environ['HTTP_X_APPENGINE_TASKNAME'], environ['HTTP_X_APPENGINE_QUEUENAME'], base_path)
[ "def", "from_environ", "(", "cls", ",", "environ", "=", "os", ".", "environ", ")", ":", "base_path", ",", "unused", "=", "(", "environ", "[", "'PATH_INFO'", "]", ".", "rsplit", "(", "'/'", ",", "1", ")", "+", "[", "''", "]", ")", "[", ":", "2", ...
Constructs a _PipelineContext from the task queue environment.
[ "Constructs", "a", "_PipelineContext", "from", "the", "task", "queue", "environment", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1452-L1458
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.fill_slot
def fill_slot(self, filler_pipeline_key, slot, value): """Fills a slot, enqueueing a task to trigger pending barriers. Args: filler_pipeline_key: db.Key or stringified key of the _PipelineRecord that filled this slot. slot: The Slot instance to fill. value: The serializable value to a...
python
def fill_slot(self, filler_pipeline_key, slot, value): """Fills a slot, enqueueing a task to trigger pending barriers. Args: filler_pipeline_key: db.Key or stringified key of the _PipelineRecord that filled this slot. slot: The Slot instance to fill. value: The serializable value to a...
[ "def", "fill_slot", "(", "self", ",", "filler_pipeline_key", ",", "slot", ",", "value", ")", ":", "if", "not", "isinstance", "(", "filler_pipeline_key", ",", "db", ".", "Key", ")", ":", "filler_pipeline_key", "=", "db", ".", "Key", "(", "filler_pipeline_key"...
Fills a slot, enqueueing a task to trigger pending barriers. Args: filler_pipeline_key: db.Key or stringified key of the _PipelineRecord that filled this slot. slot: The Slot instance to fill. value: The serializable value to assign. Raises: UnexpectedPipelineError if the _Slot...
[ "Fills", "a", "slot", "enqueueing", "a", "task", "to", "trigger", "pending", "barriers", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1460-L1519
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.notify_barriers
def notify_barriers(self, slot_key, cursor, use_barrier_indexes, max_to_notify=_MAX_BARRIERS_TO_NOTIFY): """Searches for barriers affected by a slot and triggers completed ones. Args: slot_key: db.Key or stringified k...
python
def notify_barriers(self, slot_key, cursor, use_barrier_indexes, max_to_notify=_MAX_BARRIERS_TO_NOTIFY): """Searches for barriers affected by a slot and triggers completed ones. Args: slot_key: db.Key or stringified k...
[ "def", "notify_barriers", "(", "self", ",", "slot_key", ",", "cursor", ",", "use_barrier_indexes", ",", "max_to_notify", "=", "_MAX_BARRIERS_TO_NOTIFY", ")", ":", "if", "not", "isinstance", "(", "slot_key", ",", "db", ".", "Key", ")", ":", "slot_key", "=", "...
Searches for barriers affected by a slot and triggers completed ones. Args: slot_key: db.Key or stringified key of the _SlotRecord that was filled. cursor: Stringified Datastore cursor where the notification query should pick up. use_barrier_indexes: When True, use _BarrierIndex records t...
[ "Searches", "for", "barriers", "affected", "by", "a", "slot", "and", "triggers", "completed", "ones", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1521-L1665
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.begin_abort
def begin_abort(self, root_pipeline_key, abort_message): """Kicks off the abort process for a root pipeline and all its children. Args: root_pipeline_key: db.Key of the root pipeline to abort. abort_message: Message explaining why the abort happened, only saved into the root pipeline. ...
python
def begin_abort(self, root_pipeline_key, abort_message): """Kicks off the abort process for a root pipeline and all its children. Args: root_pipeline_key: db.Key of the root pipeline to abort. abort_message: Message explaining why the abort happened, only saved into the root pipeline. ...
[ "def", "begin_abort", "(", "self", ",", "root_pipeline_key", ",", "abort_message", ")", ":", "def", "txn", "(", ")", ":", "pipeline_record", "=", "db", ".", "get", "(", "root_pipeline_key", ")", "if", "pipeline_record", "is", "None", ":", "logging", ".", "...
Kicks off the abort process for a root pipeline and all its children. Args: root_pipeline_key: db.Key of the root pipeline to abort. abort_message: Message explaining why the abort happened, only saved into the root pipeline. Returns: True if the abort signal was sent successfully;...
[ "Kicks", "off", "the", "abort", "process", "for", "a", "root", "pipeline", "and", "all", "its", "children", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1667-L1706
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.continue_abort
def continue_abort(self, root_pipeline_key, cursor=None, max_to_notify=_MAX_ABORTS_TO_BEGIN): """Sends the abort signal to all children for a root pipeline. Args: root_pipeline_key: db.Key of the root pipeline to abort. cursor: The quer...
python
def continue_abort(self, root_pipeline_key, cursor=None, max_to_notify=_MAX_ABORTS_TO_BEGIN): """Sends the abort signal to all children for a root pipeline. Args: root_pipeline_key: db.Key of the root pipeline to abort. cursor: The quer...
[ "def", "continue_abort", "(", "self", ",", "root_pipeline_key", ",", "cursor", "=", "None", ",", "max_to_notify", "=", "_MAX_ABORTS_TO_BEGIN", ")", ":", "if", "not", "isinstance", "(", "root_pipeline_key", ",", "db", ".", "Key", ")", ":", "root_pipeline_key", ...
Sends the abort signal to all children for a root pipeline. Args: root_pipeline_key: db.Key of the root pipeline to abort. cursor: The query cursor for enumerating _PipelineRecords when inserting tasks to cause child pipelines to terminate. max_to_notify: Used for testing.
[ "Sends", "the", "abort", "signal", "to", "all", "children", "for", "a", "root", "pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1708-L1771
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.start
def start(self, pipeline, return_task=True, countdown=None, eta=None): """Starts a pipeline. Args: pipeline: Pipeline instance to run. return_task: When True, do not submit the task to start the pipeline but instead return it for someone else to enqueue. countdown: Time in seconds int...
python
def start(self, pipeline, return_task=True, countdown=None, eta=None): """Starts a pipeline. Args: pipeline: Pipeline instance to run. return_task: When True, do not submit the task to start the pipeline but instead return it for someone else to enqueue. countdown: Time in seconds int...
[ "def", "start", "(", "self", ",", "pipeline", ",", "return_task", "=", "True", ",", "countdown", "=", "None", ",", "eta", "=", "None", ")", ":", "# Adjust all pipeline output keys for this Pipeline to be children of", "# the _PipelineRecord, that way we can write them all a...
Starts a pipeline. Args: pipeline: Pipeline instance to run. return_task: When True, do not submit the task to start the pipeline but instead return it for someone else to enqueue. countdown: Time in seconds into the future that this Task should execute. Defaults to zero. et...
[ "Starts", "a", "pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1773-L1855
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.evaluate
def evaluate(self, pipeline_key, purpose=None, attempt=0): """Evaluates the given Pipeline and enqueues sub-stages for execution. Args: pipeline_key: The db.Key or stringified key of the _PipelineRecord to run. purpose: Why evaluate was called ('start', 'finalize', or 'abort'). attempt: The a...
python
def evaluate(self, pipeline_key, purpose=None, attempt=0): """Evaluates the given Pipeline and enqueues sub-stages for execution. Args: pipeline_key: The db.Key or stringified key of the _PipelineRecord to run. purpose: Why evaluate was called ('start', 'finalize', or 'abort'). attempt: The a...
[ "def", "evaluate", "(", "self", ",", "pipeline_key", ",", "purpose", "=", "None", ",", "attempt", "=", "0", ")", ":", "After", ".", "_thread_init", "(", ")", "InOrder", ".", "_thread_init", "(", ")", "InOrder", ".", "_local", ".", "_activated", "=", "F...
Evaluates the given Pipeline and enqueues sub-stages for execution. Args: pipeline_key: The db.Key or stringified key of the _PipelineRecord to run. purpose: Why evaluate was called ('start', 'finalize', or 'abort'). attempt: The attempt number that should be tried.
[ "Evaluates", "the", "given", "Pipeline", "and", "enqueues", "sub", "-", "stages", "for", "execution", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L1989-L2359
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext._create_barrier_entities
def _create_barrier_entities(root_pipeline_key, child_pipeline_key, purpose, blocking_slot_keys): """Creates all of the entities required for a _BarrierRecord. Args: root_pipeline_key: The root pipeline this is p...
python
def _create_barrier_entities(root_pipeline_key, child_pipeline_key, purpose, blocking_slot_keys): """Creates all of the entities required for a _BarrierRecord. Args: root_pipeline_key: The root pipeline this is p...
[ "def", "_create_barrier_entities", "(", "root_pipeline_key", ",", "child_pipeline_key", ",", "purpose", ",", "blocking_slot_keys", ")", ":", "result", "=", "[", "]", "blocking_slot_keys", "=", "list", "(", "blocking_slot_keys", ")", "barrier", "=", "_BarrierRecord", ...
Creates all of the entities required for a _BarrierRecord. Args: root_pipeline_key: The root pipeline this is part of. child_pipeline_key: The pipeline this barrier is for. purpose: _BarrierRecord.START or _BarrierRecord.FINALIZE. blocking_slot_keys: Set of db.Keys corresponding to _SlotRec...
[ "Creates", "all", "of", "the", "entities", "required", "for", "a", "_BarrierRecord", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2362-L2405
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.handle_run_exception
def handle_run_exception(self, pipeline_key, pipeline_func, e): """Handles an exception raised by a Pipeline's user code. Args: pipeline_key: The pipeline that raised the error. pipeline_func: The class path name of the Pipeline that was running. e: The exception that was raised. Returns...
python
def handle_run_exception(self, pipeline_key, pipeline_func, e): """Handles an exception raised by a Pipeline's user code. Args: pipeline_key: The pipeline that raised the error. pipeline_func: The class path name of the Pipeline that was running. e: The exception that was raised. Returns...
[ "def", "handle_run_exception", "(", "self", ",", "pipeline_key", ",", "pipeline_func", ",", "e", ")", ":", "if", "isinstance", "(", "e", ",", "Retry", ")", ":", "retry_message", "=", "str", "(", "e", ")", "logging", ".", "warning", "(", "'User forced retry...
Handles an exception raised by a Pipeline's user code. Args: pipeline_key: The pipeline that raised the error. pipeline_func: The class path name of the Pipeline that was running. e: The exception that was raised. Returns: True if the exception should be re-raised up through the callin...
[ "Handles", "an", "exception", "raised", "by", "a", "Pipeline", "s", "user", "code", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2407-L2435
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.transition_run
def transition_run(self, pipeline_key, blocking_slot_keys=None, fanned_out_pipelines=None, pipelines_to_run=None): """Marks an asynchronous or generator pipeline as running. Does nothing if the pipeline is no longer in a runnab...
python
def transition_run(self, pipeline_key, blocking_slot_keys=None, fanned_out_pipelines=None, pipelines_to_run=None): """Marks an asynchronous or generator pipeline as running. Does nothing if the pipeline is no longer in a runnab...
[ "def", "transition_run", "(", "self", ",", "pipeline_key", ",", "blocking_slot_keys", "=", "None", ",", "fanned_out_pipelines", "=", "None", ",", "pipelines_to_run", "=", "None", ")", ":", "def", "txn", "(", ")", ":", "pipeline_record", "=", "db", ".", "get"...
Marks an asynchronous or generator pipeline as running. Does nothing if the pipeline is no longer in a runnable state. Args: pipeline_key: The db.Key of the _PipelineRecord to update. blocking_slot_keys: List of db.Key instances that this pipeline's finalization barrier should wait on in a...
[ "Marks", "an", "asynchronous", "or", "generator", "pipeline", "as", "running", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2437-L2523
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.transition_complete
def transition_complete(self, pipeline_key): """Marks the given pipeline as complete. Does nothing if the pipeline is no longer in a state that can be completed. Args: pipeline_key: db.Key of the _PipelineRecord that has completed. """ def txn(): pipeline_record = db.get(pipeline_key) ...
python
def transition_complete(self, pipeline_key): """Marks the given pipeline as complete. Does nothing if the pipeline is no longer in a state that can be completed. Args: pipeline_key: db.Key of the _PipelineRecord that has completed. """ def txn(): pipeline_record = db.get(pipeline_key) ...
[ "def", "transition_complete", "(", "self", ",", "pipeline_key", ")", ":", "def", "txn", "(", ")", ":", "pipeline_record", "=", "db", ".", "get", "(", "pipeline_key", ")", "if", "pipeline_record", "is", "None", ":", "logging", ".", "warning", "(", "'Tried t...
Marks the given pipeline as complete. Does nothing if the pipeline is no longer in a state that can be completed. Args: pipeline_key: db.Key of the _PipelineRecord that has completed.
[ "Marks", "the", "given", "pipeline", "as", "complete", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2525-L2551
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_PipelineContext.transition_retry
def transition_retry(self, pipeline_key, retry_message): """Marks the given pipeline as requiring another retry. Does nothing if all attempts have been exceeded. Args: pipeline_key: db.Key of the _PipelineRecord that needs to be retried. retry_message: User-supplied message indicating the reas...
python
def transition_retry(self, pipeline_key, retry_message): """Marks the given pipeline as requiring another retry. Does nothing if all attempts have been exceeded. Args: pipeline_key: db.Key of the _PipelineRecord that needs to be retried. retry_message: User-supplied message indicating the reas...
[ "def", "transition_retry", "(", "self", ",", "pipeline_key", ",", "retry_message", ")", ":", "def", "txn", "(", ")", ":", "pipeline_record", "=", "db", ".", "get", "(", "pipeline_key", ")", "if", "pipeline_record", "is", "None", ":", "logging", ".", "warni...
Marks the given pipeline as requiring another retry. Does nothing if all attempts have been exceeded. Args: pipeline_key: db.Key of the _PipelineRecord that needs to be retried. retry_message: User-supplied message indicating the reason for the retry.
[ "Marks", "the", "given", "pipeline", "as", "requiring", "another", "retry", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2553-L2615
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/pipeline.py
_CallbackHandler.run_callback
def run_callback(self): """Runs the callback for the pipeline specified in the request. Raises: _CallbackTaskError if something was wrong with the request parameters. """ pipeline_id = self.request.get('pipeline_id') if not pipeline_id: raise _CallbackTaskError('"pipeline_id" parameter ...
python
def run_callback(self): """Runs the callback for the pipeline specified in the request. Raises: _CallbackTaskError if something was wrong with the request parameters. """ pipeline_id = self.request.get('pipeline_id') if not pipeline_id: raise _CallbackTaskError('"pipeline_id" parameter ...
[ "def", "run_callback", "(", "self", ")", ":", "pipeline_id", "=", "self", ".", "request", ".", "get", "(", "'pipeline_id'", ")", "if", "not", "pipeline_id", ":", "raise", "_CallbackTaskError", "(", "'\"pipeline_id\" parameter missing.'", ")", "pipeline_key", "=", ...
Runs the callback for the pipeline specified in the request. Raises: _CallbackTaskError if something was wrong with the request parameters.
[ "Runs", "the", "callback", "for", "the", "pipeline", "specified", "in", "the", "request", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/pipeline.py#L2803-L2867
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/__init__.py
_fix_path
def _fix_path(): """Finds the google_appengine directory and fixes Python imports to use it.""" import os import sys all_paths = os.environ.get('PYTHONPATH').split(os.pathsep) for path_dir in all_paths: dev_appserver_path = os.path.join(path_dir, 'dev_appserver.py') if os.path.exists(dev_appserver_pat...
python
def _fix_path(): """Finds the google_appengine directory and fixes Python imports to use it.""" import os import sys all_paths = os.environ.get('PYTHONPATH').split(os.pathsep) for path_dir in all_paths: dev_appserver_path = os.path.join(path_dir, 'dev_appserver.py') if os.path.exists(dev_appserver_pat...
[ "def", "_fix_path", "(", ")", ":", "import", "os", "import", "sys", "all_paths", "=", "os", ".", "environ", ".", "get", "(", "'PYTHONPATH'", ")", ".", "split", "(", "os", ".", "pathsep", ")", "for", "path_dir", "in", "all_paths", ":", "dev_appserver_path...
Finds the google_appengine directory and fixes Python imports to use it.
[ "Finds", "the", "google_appengine", "directory", "and", "fixes", "Python", "imports", "to", "use", "it", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/__init__.py#L22-L37
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/models.py
_PipelineRecord.params
def params(self): """Returns the dictionary of parameters for this Pipeline.""" if hasattr(self, '_params_decoded'): return self._params_decoded if self.params_blob is not None: value_encoded = self.params_blob.open().read() else: value_encoded = self.params_text value = json.loa...
python
def params(self): """Returns the dictionary of parameters for this Pipeline.""" if hasattr(self, '_params_decoded'): return self._params_decoded if self.params_blob is not None: value_encoded = self.params_blob.open().read() else: value_encoded = self.params_text value = json.loa...
[ "def", "params", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_params_decoded'", ")", ":", "return", "self", ".", "_params_decoded", "if", "self", ".", "params_blob", "is", "not", "None", ":", "value_encoded", "=", "self", ".", "params_blob"...
Returns the dictionary of parameters for this Pipeline.
[ "Returns", "the", "dictionary", "of", "parameters", "for", "this", "Pipeline", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/models.py#L96-L117
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/models.py
_SlotRecord.value
def value(self): """Returns the value of this Slot.""" if hasattr(self, '_value_decoded'): return self._value_decoded if self.value_blob is not None: encoded_value = self.value_blob.open().read() else: encoded_value = self.value_text self._value_decoded = json.loads(encoded_value...
python
def value(self): """Returns the value of this Slot.""" if hasattr(self, '_value_decoded'): return self._value_decoded if self.value_blob is not None: encoded_value = self.value_blob.open().read() else: encoded_value = self.value_text self._value_decoded = json.loads(encoded_value...
[ "def", "value", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_value_decoded'", ")", ":", "return", "self", ".", "_value_decoded", "if", "self", ".", "value_blob", "is", "not", "None", ":", "encoded_value", "=", "self", ".", "value_blob", "...
Returns the value of this Slot.
[ "Returns", "the", "value", "of", "this", "Slot", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/models.py#L156-L167
GoogleCloudPlatform/appengine-pipelines
python/src/pipeline/models.py
_BarrierIndex.to_barrier_key
def to_barrier_key(cls, barrier_index_key): """Converts a _BarrierIndex key to a _BarrierRecord key. Args: barrier_index_key: db.Key for a _BarrierIndex entity. Returns: db.Key for the corresponding _BarrierRecord entity. """ barrier_index_path = barrier_index_key.to_path() # Pick...
python
def to_barrier_key(cls, barrier_index_key): """Converts a _BarrierIndex key to a _BarrierRecord key. Args: barrier_index_key: db.Key for a _BarrierIndex entity. Returns: db.Key for the corresponding _BarrierRecord entity. """ barrier_index_path = barrier_index_key.to_path() # Pick...
[ "def", "to_barrier_key", "(", "cls", ",", "barrier_index_key", ")", ":", "barrier_index_path", "=", "barrier_index_key", ".", "to_path", "(", ")", "# Pick out the items from the _BarrierIndex key path that we need to", "# construct the _BarrierRecord key path.", "(", "pipeline_ki...
Converts a _BarrierIndex key to a _BarrierRecord key. Args: barrier_index_key: db.Key for a _BarrierIndex entity. Returns: db.Key for the corresponding _BarrierRecord entity.
[ "Converts", "a", "_BarrierIndex", "key", "to", "a", "_BarrierRecord", "key", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/models.py#L251-L271
bcbnz/pylabels
labels/sheet.py
Sheet.partial_page
def partial_page(self, page, used_labels): """Allows a page to be marked as already partially used so you can generate a PDF to print on the remaining labels. Parameters ---------- page: positive integer The page number to mark as partially used. The page must not ha...
python
def partial_page(self, page, used_labels): """Allows a page to be marked as already partially used so you can generate a PDF to print on the remaining labels. Parameters ---------- page: positive integer The page number to mark as partially used. The page must not ha...
[ "def", "partial_page", "(", "self", ",", "page", ",", "used_labels", ")", ":", "# Check the page number is valid.", "if", "page", "<=", "self", ".", "page_count", ":", "raise", "ValueError", "(", "\"Page {0:d} has already started, cannot mark used labels now.\"", ".", "...
Allows a page to be marked as already partially used so you can generate a PDF to print on the remaining labels. Parameters ---------- page: positive integer The page number to mark as partially used. The page must not have already been started, i.e., for page 1 ...
[ "Allows", "a", "page", "to", "be", "marked", "as", "already", "partially", "used", "so", "you", "can", "generate", "a", "PDF", "to", "print", "on", "the", "remaining", "labels", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L205-L239
bcbnz/pylabels
labels/sheet.py
Sheet._new_page
def _new_page(self): """Helper function to start a new page. Not intended for external use. """ self._current_page = Drawing(*self._pagesize) if self._bgimage: self._current_page.add(self._bgimage) self._pages.append(self._current_page) self.page_count += 1 ...
python
def _new_page(self): """Helper function to start a new page. Not intended for external use. """ self._current_page = Drawing(*self._pagesize) if self._bgimage: self._current_page.add(self._bgimage) self._pages.append(self._current_page) self.page_count += 1 ...
[ "def", "_new_page", "(", "self", ")", ":", "self", ".", "_current_page", "=", "Drawing", "(", "*", "self", ".", "_pagesize", ")", "if", "self", ".", "_bgimage", ":", "self", ".", "_current_page", ".", "add", "(", "self", ".", "_bgimage", ")", "self", ...
Helper function to start a new page. Not intended for external use.
[ "Helper", "function", "to", "start", "a", "new", "page", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L241-L250
bcbnz/pylabels
labels/sheet.py
Sheet._next_label
def _next_label(self): """Helper method to move to the next label. Not intended for external use. This does not increment the label_count attribute as the next label may not be usable (it may have been marked as missing through partial_pages). See _next_unused_label for generally more u...
python
def _next_label(self): """Helper method to move to the next label. Not intended for external use. This does not increment the label_count attribute as the next label may not be usable (it may have been marked as missing through partial_pages). See _next_unused_label for generally more u...
[ "def", "_next_label", "(", "self", ")", ":", "# Special case for the very first label.", "if", "self", ".", "page_count", "==", "0", ":", "self", ".", "_new_page", "(", ")", "# Filled up a page.", "elif", "self", ".", "_position", "==", "self", ".", "_numlabels"...
Helper method to move to the next label. Not intended for external use. This does not increment the label_count attribute as the next label may not be usable (it may have been marked as missing through partial_pages). See _next_unused_label for generally more useful method.
[ "Helper", "method", "to", "move", "to", "the", "next", "label", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L252-L274
bcbnz/pylabels
labels/sheet.py
Sheet._next_unused_label
def _next_unused_label(self): """Helper method to move to the next unused label. Not intended for external use. This method will shade in any missing labels if desired, and will increment the label_count attribute once a suitable label position has been found. """ self....
python
def _next_unused_label(self): """Helper method to move to the next unused label. Not intended for external use. This method will shade in any missing labels if desired, and will increment the label_count attribute once a suitable label position has been found. """ self....
[ "def", "_next_unused_label", "(", "self", ")", ":", "self", ".", "_next_label", "(", ")", "# This label may be missing.", "if", "self", ".", "page_count", "in", "self", ".", "_used", ":", "# Keep try while the label is missing.", "missing", "=", "self", ".", "_use...
Helper method to move to the next unused label. Not intended for external use. This method will shade in any missing labels if desired, and will increment the label_count attribute once a suitable label position has been found.
[ "Helper", "method", "to", "move", "to", "the", "next", "unused", "label", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L276-L304
bcbnz/pylabels
labels/sheet.py
Sheet._calculate_edges
def _calculate_edges(self): """Calculate edges of the current label. Not intended for external use. """ # Calculate the left edge of the label. left = self.specs.left_margin left += (self.specs.label_width * (self._position[1] - 1)) if self.specs.column_gap: ...
python
def _calculate_edges(self): """Calculate edges of the current label. Not intended for external use. """ # Calculate the left edge of the label. left = self.specs.left_margin left += (self.specs.label_width * (self._position[1] - 1)) if self.specs.column_gap: ...
[ "def", "_calculate_edges", "(", "self", ")", ":", "# Calculate the left edge of the label.", "left", "=", "self", ".", "specs", ".", "left_margin", "left", "+=", "(", "self", ".", "specs", ".", "label_width", "*", "(", "self", ".", "_position", "[", "1", "]"...
Calculate edges of the current label. Not intended for external use.
[ "Calculate", "edges", "of", "the", "current", "label", ".", "Not", "intended", "for", "external", "use", "." ]
train
https://github.com/bcbnz/pylabels/blob/ecdb4ca48061d8f1dc0fcfe2d55ce2b89e0e5ec6/labels/sheet.py#L306-L326