partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
register_items_hook
Registers a hook callable to process tree items right before they are passed to templates. Callable should be able to: a) handle ``tree_items`` and ``tree_sender`` key params. ``tree_items`` will contain a list of extended TreeItem objects ready to pass to template. ``tree_sender``...
sitetree/sitetreeapp.py
def register_items_hook(func): """Registers a hook callable to process tree items right before they are passed to templates. Callable should be able to: a) handle ``tree_items`` and ``tree_sender`` key params. ``tree_items`` will contain a list of extended TreeItem objects ready to pass to...
def register_items_hook(func): """Registers a hook callable to process tree items right before they are passed to templates. Callable should be able to: a) handle ``tree_items`` and ``tree_sender`` key params. ``tree_items`` will contain a list of extended TreeItem objects ready to pass to...
[ "Registers", "a", "hook", "callable", "to", "process", "tree", "items", "right", "before", "they", "are", "passed", "to", "templates", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L86-L130
[ "def", "register_items_hook", "(", "func", ")", ":", "global", "_ITEMS_PROCESSOR", "global", "_ITEMS_PROCESSOR_ARGS_LEN", "_ITEMS_PROCESSOR", "=", "func", "if", "func", ":", "args_len", "=", "len", "(", "getargspec", "(", "func", ")", ".", "args", ")", "if", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
register_dynamic_trees
Registers dynamic trees to be available for `sitetree` runtime. Expects `trees` to be an iterable with structures created with `compose_dynamic_tree()`. Example:: register_dynamic_trees( # Get all the trees from `my_app`. compose_dynamic_tree('my_app'), # Get all ...
sitetree/sitetreeapp.py
def register_dynamic_trees(trees, *args, **kwargs): """Registers dynamic trees to be available for `sitetree` runtime. Expects `trees` to be an iterable with structures created with `compose_dynamic_tree()`. Example:: register_dynamic_trees( # Get all the trees from `my_app`. ...
def register_dynamic_trees(trees, *args, **kwargs): """Registers dynamic trees to be available for `sitetree` runtime. Expects `trees` to be an iterable with structures created with `compose_dynamic_tree()`. Example:: register_dynamic_trees( # Get all the trees from `my_app`. ...
[ "Registers", "dynamic", "trees", "to", "be", "available", "for", "sitetree", "runtime", ".", "Expects", "trees", "to", "be", "an", "iterable", "with", "structures", "created", "with", "compose_dynamic_tree", "()", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L162-L222
[ "def", "register_dynamic_trees", "(", "trees", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "_DYNAMIC_TREES", "if", "_IDX_ORPHAN_TREES", "not", "in", "_DYNAMIC_TREES", ":", "_DYNAMIC_TREES", "[", "_IDX_ORPHAN_TREES", "]", "=", "{", "}", "if",...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
compose_dynamic_tree
Returns a structure describing a dynamic sitetree.utils The structure can be built from various sources, :param str|iterable src: If a string is passed to `src`, it'll be treated as the name of an app, from where one want to import sitetrees definitions. `src` can be an iterable of tree definit...
sitetree/sitetreeapp.py
def compose_dynamic_tree(src, target_tree_alias=None, parent_tree_item_alias=None, include_trees=None): """Returns a structure describing a dynamic sitetree.utils The structure can be built from various sources, :param str|iterable src: If a string is passed to `src`, it'll be treated as the name of an app...
def compose_dynamic_tree(src, target_tree_alias=None, parent_tree_item_alias=None, include_trees=None): """Returns a structure describing a dynamic sitetree.utils The structure can be built from various sources, :param str|iterable src: If a string is passed to `src`, it'll be treated as the name of an app...
[ "Returns", "a", "structure", "describing", "a", "dynamic", "sitetree", ".", "utils", "The", "structure", "can", "be", "built", "from", "various", "sources" ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L230-L267
[ "def", "compose_dynamic_tree", "(", "src", ",", "target_tree_alias", "=", "None", ",", "parent_tree_item_alias", "=", "None", ",", "include_trees", "=", "None", ")", ":", "def", "result", "(", "sitetrees", "=", "src", ")", ":", "if", "include_trees", "is", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
Cache.init
Initializes local cache from Django cache.
sitetree/sitetreeapp.py
def init(self): """Initializes local cache from Django cache.""" # Drop cache flag set by .reset() method. cache.get('sitetrees_reset') and self.empty(init=False) self.cache = cache.get( 'sitetrees', {'sitetrees': {}, 'parents': {}, 'items_by_ids': {}, 'tree_aliases': {}})
def init(self): """Initializes local cache from Django cache.""" # Drop cache flag set by .reset() method. cache.get('sitetrees_reset') and self.empty(init=False) self.cache = cache.get( 'sitetrees', {'sitetrees': {}, 'parents': {}, 'items_by_ids': {}, 'tree_aliases': {}})
[ "Initializes", "local", "cache", "from", "Django", "cache", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L321-L328
[ "def", "init", "(", "self", ")", ":", "# Drop cache flag set by .reset() method.", "cache", ".", "get", "(", "'sitetrees_reset'", ")", "and", "self", ".", "empty", "(", "init", "=", "False", ")", "self", ".", "cache", "=", "cache", ".", "get", "(", "'sitet...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
Cache.empty
Empties cached sitetree data.
sitetree/sitetreeapp.py
def empty(self, **kwargs): """Empties cached sitetree data.""" cache.delete('sitetrees') cache.delete('sitetrees_reset') kwargs.get('init', True) and self.init()
def empty(self, **kwargs): """Empties cached sitetree data.""" cache.delete('sitetrees') cache.delete('sitetrees_reset') kwargs.get('init', True) and self.init()
[ "Empties", "cached", "sitetree", "data", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L334-L339
[ "def", "empty", "(", "self", ",", "*", "*", "kwargs", ")", ":", "cache", ".", "delete", "(", "'sitetrees'", ")", "cache", ".", "delete", "(", "'sitetrees_reset'", ")", "kwargs", ".", "get", "(", "'init'", ",", "True", ")", "and", "self", ".", "init",...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
Cache.get_entry
Returns cache entry parameter value by its name. :param str|unicode entry_name: :param key: :return:
sitetree/sitetreeapp.py
def get_entry(self, entry_name, key): """Returns cache entry parameter value by its name. :param str|unicode entry_name: :param key: :return: """ return self.cache[entry_name].get(key, False)
def get_entry(self, entry_name, key): """Returns cache entry parameter value by its name. :param str|unicode entry_name: :param key: :return: """ return self.cache[entry_name].get(key, False)
[ "Returns", "cache", "entry", "parameter", "value", "by", "its", "name", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L341-L348
[ "def", "get_entry", "(", "self", ",", "entry_name", ",", "key", ")", ":", "return", "self", ".", "cache", "[", "entry_name", "]", ".", "get", "(", "key", ",", "False", ")" ]
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
Cache.update_entry_value
Updates cache entry parameter with new data. :param str|unicode entry_name: :param key: :param value:
sitetree/sitetreeapp.py
def update_entry_value(self, entry_name, key, value): """Updates cache entry parameter with new data. :param str|unicode entry_name: :param key: :param value: """ if key not in self.cache[entry_name]: self.cache[entry_name][key] = {} self.cache[entry...
def update_entry_value(self, entry_name, key, value): """Updates cache entry parameter with new data. :param str|unicode entry_name: :param key: :param value: """ if key not in self.cache[entry_name]: self.cache[entry_name][key] = {} self.cache[entry...
[ "Updates", "cache", "entry", "parameter", "with", "new", "data", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L350-L360
[ "def", "update_entry_value", "(", "self", ",", "entry_name", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "self", ".", "cache", "[", "entry_name", "]", ":", "self", ".", "cache", "[", "entry_name", "]", "[", "key", "]", "=", "{", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
Cache.set_entry
Replaces entire cache entry parameter data by its name with new data. :param str|unicode entry_name: :param key: :param value:
sitetree/sitetreeapp.py
def set_entry(self, entry_name, key, value): """Replaces entire cache entry parameter data by its name with new data. :param str|unicode entry_name: :param key: :param value: """ self.cache[entry_name][key] = value
def set_entry(self, entry_name, key, value): """Replaces entire cache entry parameter data by its name with new data. :param str|unicode entry_name: :param key: :param value: """ self.cache[entry_name][key] = value
[ "Replaces", "entire", "cache", "entry", "parameter", "data", "by", "its", "name", "with", "new", "data", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L362-L369
[ "def", "set_entry", "(", "self", ",", "entry_name", ",", "key", ",", "value", ")", ":", "self", ".", "cache", "[", "entry_name", "]", "[", "key", "]", "=", "value" ]
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.init
Initializes sitetree to handle new request. :param Context|None context:
sitetree/sitetreeapp.py
def init(self, context): """Initializes sitetree to handle new request. :param Context|None context: """ self.cache = Cache() self.current_page_context = context self.current_request = context.get('request', None) if context else None self.current_lang = get_lang...
def init(self, context): """Initializes sitetree to handle new request. :param Context|None context: """ self.cache = Cache() self.current_page_context = context self.current_request = context.get('request', None) if context else None self.current_lang = get_lang...
[ "Initializes", "sitetree", "to", "handle", "new", "request", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L378-L391
[ "def", "init", "(", "self", ",", "context", ")", ":", "self", ".", "cache", "=", "Cache", "(", ")", "self", ".", "current_page_context", "=", "context", "self", ".", "current_request", "=", "context", ".", "get", "(", "'request'", ",", "None", ")", "if...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.resolve_tree_i18n_alias
Resolves internationalized tree alias. Verifies whether a separate sitetree is available for currently active language. If so, returns i18n alias. If not, returns the initial alias. :param str|unicode alias: :rtype: str|unicode
sitetree/sitetreeapp.py
def resolve_tree_i18n_alias(self, alias): """Resolves internationalized tree alias. Verifies whether a separate sitetree is available for currently active language. If so, returns i18n alias. If not, returns the initial alias. :param str|unicode alias: :rtype: str|unicode ...
def resolve_tree_i18n_alias(self, alias): """Resolves internationalized tree alias. Verifies whether a separate sitetree is available for currently active language. If so, returns i18n alias. If not, returns the initial alias. :param str|unicode alias: :rtype: str|unicode ...
[ "Resolves", "internationalized", "tree", "alias", ".", "Verifies", "whether", "a", "separate", "sitetree", "is", "available", "for", "currently", "active", "language", ".", "If", "so", "returns", "i18n", "alias", ".", "If", "not", "returns", "the", "initial", ...
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L393-L415
[ "def", "resolve_tree_i18n_alias", "(", "self", ",", "alias", ")", ":", "if", "alias", "not", "in", "_I18N_TREES", ":", "return", "alias", "current_language_code", "=", "self", ".", "current_lang", "i18n_tree_alias", "=", "'%s_%s'", "%", "(", "alias", ",", "cur...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.attach_dynamic_tree_items
Attaches dynamic sitetrees items registered with `register_dynamic_trees()` to an initial (source) items list. :param str|unicode tree_alias: :param list src_tree_items: :rtype: list
sitetree/sitetreeapp.py
def attach_dynamic_tree_items(tree_alias, src_tree_items): """Attaches dynamic sitetrees items registered with `register_dynamic_trees()` to an initial (source) items list. :param str|unicode tree_alias: :param list src_tree_items: :rtype: list """ if not _DYNAMI...
def attach_dynamic_tree_items(tree_alias, src_tree_items): """Attaches dynamic sitetrees items registered with `register_dynamic_trees()` to an initial (source) items list. :param str|unicode tree_alias: :param list src_tree_items: :rtype: list """ if not _DYNAMI...
[ "Attaches", "dynamic", "sitetrees", "items", "registered", "with", "register_dynamic_trees", "()", "to", "an", "initial", "(", "source", ")", "items", "list", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L418-L470
[ "def", "attach_dynamic_tree_items", "(", "tree_alias", ",", "src_tree_items", ")", ":", "if", "not", "_DYNAMIC_TREES", ":", "return", "src_tree_items", "# This guarantees that a dynamic source stays intact,", "# no matter how dynamic sitetrees are attached.", "trees", "=", "deepc...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.current_app_is_admin
Returns boolean whether current application is Admin contrib. :rtype: bool
sitetree/sitetreeapp.py
def current_app_is_admin(self): """Returns boolean whether current application is Admin contrib. :rtype: bool """ is_admin = self._current_app_is_admin if is_admin is None: context = self.current_page_context current_app = getattr( # Try ...
def current_app_is_admin(self): """Returns boolean whether current application is Admin contrib. :rtype: bool """ is_admin = self._current_app_is_admin if is_admin is None: context = self.current_page_context current_app = getattr( # Try ...
[ "Returns", "boolean", "whether", "current", "application", "is", "Admin", "contrib", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L472-L493
[ "def", "current_app_is_admin", "(", "self", ")", ":", "is_admin", "=", "self", ".", "_current_app_is_admin", "if", "is_admin", "is", "None", ":", "context", "=", "self", ".", "current_page_context", "current_app", "=", "getattr", "(", "# Try from request.resolver_ma...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_sitetree
Gets site tree items from the given site tree. Caches result to dictionary. Returns (tree alias, tree items) tuple. :param str|unicode alias: :rtype: tuple
sitetree/sitetreeapp.py
def get_sitetree(self, alias): """Gets site tree items from the given site tree. Caches result to dictionary. Returns (tree alias, tree items) tuple. :param str|unicode alias: :rtype: tuple """ cache_ = self.cache get_cache_entry = cache_.get_entry ...
def get_sitetree(self, alias): """Gets site tree items from the given site tree. Caches result to dictionary. Returns (tree alias, tree items) tuple. :param str|unicode alias: :rtype: tuple """ cache_ = self.cache get_cache_entry = cache_.get_entry ...
[ "Gets", "site", "tree", "items", "from", "the", "given", "site", "tree", ".", "Caches", "result", "to", "dictionary", ".", "Returns", "(", "tree", "alias", "tree", "items", ")", "tuple", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L495-L579
[ "def", "get_sitetree", "(", "self", ",", "alias", ")", ":", "cache_", "=", "self", ".", "cache", "get_cache_entry", "=", "cache_", ".", "get_entry", "set_cache_entry", "=", "cache_", ".", "set_entry", "caching_required", "=", "False", "if", "not", "self", "....
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.calculate_item_depth
Calculates depth of the item in the tree. :param str|unicode tree_alias: :param int item_id: :param int depth: :rtype: int
sitetree/sitetreeapp.py
def calculate_item_depth(self, tree_alias, item_id, depth=0): """Calculates depth of the item in the tree. :param str|unicode tree_alias: :param int item_id: :param int depth: :rtype: int """ item = self.get_item_by_id(tree_alias, item_id) if hasattr(ite...
def calculate_item_depth(self, tree_alias, item_id, depth=0): """Calculates depth of the item in the tree. :param str|unicode tree_alias: :param int item_id: :param int depth: :rtype: int """ item = self.get_item_by_id(tree_alias, item_id) if hasattr(ite...
[ "Calculates", "depth", "of", "the", "item", "in", "the", "tree", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L581-L597
[ "def", "calculate_item_depth", "(", "self", ",", "tree_alias", ",", "item_id", ",", "depth", "=", "0", ")", ":", "item", "=", "self", ".", "get_item_by_id", "(", "tree_alias", ",", "item_id", ")", "if", "hasattr", "(", "item", ",", "'depth'", ")", ":", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_tree_current_item
Resolves current tree item of 'tree_alias' tree matching current request path against URL of given tree item. :param str|unicode tree_alias: :rtype: TreeItemBase
sitetree/sitetreeapp.py
def get_tree_current_item(self, tree_alias): """Resolves current tree item of 'tree_alias' tree matching current request path against URL of given tree item. :param str|unicode tree_alias: :rtype: TreeItemBase """ current_item = self._current_items.get(tree_alias, _UNSET...
def get_tree_current_item(self, tree_alias): """Resolves current tree item of 'tree_alias' tree matching current request path against URL of given tree item. :param str|unicode tree_alias: :rtype: TreeItemBase """ current_item = self._current_items.get(tree_alias, _UNSET...
[ "Resolves", "current", "tree", "item", "of", "tree_alias", "tree", "matching", "current", "request", "path", "against", "URL", "of", "given", "tree", "item", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L608-L649
[ "def", "get_tree_current_item", "(", "self", ",", "tree_alias", ")", ":", "current_item", "=", "self", ".", "_current_items", ".", "get", "(", "tree_alias", ",", "_UNSET", ")", "if", "current_item", "is", "not", "_UNSET", ":", "if", "current_item", "is", "no...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.url
Resolves item's URL. :param TreeItemBase sitetree_item: TreeItemBase heir object, 'url' property of which is processed as URL pattern or simple URL. :param Context context: :rtype: str|unicode
sitetree/sitetreeapp.py
def url(self, sitetree_item, context=None): """Resolves item's URL. :param TreeItemBase sitetree_item: TreeItemBase heir object, 'url' property of which is processed as URL pattern or simple URL. :param Context context: :rtype: str|unicode """ context = con...
def url(self, sitetree_item, context=None): """Resolves item's URL. :param TreeItemBase sitetree_item: TreeItemBase heir object, 'url' property of which is processed as URL pattern or simple URL. :param Context context: :rtype: str|unicode """ context = con...
[ "Resolves", "item", "s", "URL", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L651-L707
[ "def", "url", "(", "self", ",", "sitetree_item", ",", "context", "=", "None", ")", ":", "context", "=", "context", "or", "self", ".", "current_page_context", "resolve_var", "=", "self", ".", "resolve_var", "if", "not", "isinstance", "(", "sitetree_item", ","...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.init_tree
Initializes sitetree in memory. Returns tuple with resolved tree alias and items on success. On fail returns (None, None). :param str|unicode tree_alias: :param Context context: :rtype: tuple
sitetree/sitetreeapp.py
def init_tree(self, tree_alias, context): """Initializes sitetree in memory. Returns tuple with resolved tree alias and items on success. On fail returns (None, None). :param str|unicode tree_alias: :param Context context: :rtype: tuple """ request = co...
def init_tree(self, tree_alias, context): """Initializes sitetree in memory. Returns tuple with resolved tree alias and items on success. On fail returns (None, None). :param str|unicode tree_alias: :param Context context: :rtype: tuple """ request = co...
[ "Initializes", "sitetree", "in", "memory", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L709-L737
[ "def", "init_tree", "(", "self", ",", "tree_alias", ",", "context", ")", ":", "request", "=", "context", ".", "get", "(", "'request'", ",", "None", ")", "if", "request", "is", "None", ":", "raise", "SiteTreeError", "(", "'Sitetree requires \"django.core.contex...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_current_page_attr
Returns an arbitrary attribute of a sitetree item resolved as current for current page. :param str|unicode attr_name: :param str|unicode tree_alias: :param Context context: :rtype: str|unicode
sitetree/sitetreeapp.py
def get_current_page_attr(self, attr_name, tree_alias, context): """Returns an arbitrary attribute of a sitetree item resolved as current for current page. :param str|unicode attr_name: :param str|unicode tree_alias: :param Context context: :rtype: str|unicode """ ...
def get_current_page_attr(self, attr_name, tree_alias, context): """Returns an arbitrary attribute of a sitetree item resolved as current for current page. :param str|unicode attr_name: :param str|unicode tree_alias: :param Context context: :rtype: str|unicode """ ...
[ "Returns", "an", "arbitrary", "attribute", "of", "a", "sitetree", "item", "resolved", "as", "current", "for", "current", "page", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L748-L767
[ "def", "get_current_page_attr", "(", "self", ",", "attr_name", ",", "tree_alias", ",", "context", ")", ":", "tree_alias", ",", "sitetree_items", "=", "self", ".", "init_tree", "(", "tree_alias", ",", "context", ")", "current_item", "=", "self", ".", "get_tree_...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_ancestor_level
Returns ancestor of level `deep` recursively :param TreeItemBase current_item: :param int depth: :rtype: TreeItemBase
sitetree/sitetreeapp.py
def get_ancestor_level(self, current_item, depth=1): """Returns ancestor of level `deep` recursively :param TreeItemBase current_item: :param int depth: :rtype: TreeItemBase """ if current_item.parent is None: return current_item if depth <= 1: ...
def get_ancestor_level(self, current_item, depth=1): """Returns ancestor of level `deep` recursively :param TreeItemBase current_item: :param int depth: :rtype: TreeItemBase """ if current_item.parent is None: return current_item if depth <= 1: ...
[ "Returns", "ancestor", "of", "level", "deep", "recursively" ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L769-L782
[ "def", "get_ancestor_level", "(", "self", ",", "current_item", ",", "depth", "=", "1", ")", ":", "if", "current_item", ".", "parent", "is", "None", ":", "return", "current_item", "if", "depth", "<=", "1", ":", "return", "current_item", ".", "parent", "retu...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.menu
Builds and returns menu structure for 'sitetree_menu' tag. :param str|unicode tree_alias: :param str|unicode tree_branches: :param Context context: :rtype: list|str
sitetree/sitetreeapp.py
def menu(self, tree_alias, tree_branches, context): """Builds and returns menu structure for 'sitetree_menu' tag. :param str|unicode tree_alias: :param str|unicode tree_branches: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_...
def menu(self, tree_alias, tree_branches, context): """Builds and returns menu structure for 'sitetree_menu' tag. :param str|unicode tree_alias: :param str|unicode tree_branches: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_...
[ "Builds", "and", "returns", "menu", "structure", "for", "sitetree_menu", "tag", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L784-L849
[ "def", "menu", "(", "self", ",", "tree_alias", ",", "tree_branches", ",", "context", ")", ":", "tree_alias", ",", "sitetree_items", "=", "self", ".", "init_tree", "(", "tree_alias", ",", "context", ")", "if", "not", "sitetree_items", ":", "return", "''", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.apply_hook
Applies item processing hook, registered with ``register_item_hook()`` to items supplied, and returns processed list. Returns initial items list if no hook is registered. :param list items: :param str|unicode sender: menu, breadcrumbs, sitetree, {type}.children, {type}.has_children ...
sitetree/sitetreeapp.py
def apply_hook(self, items, sender): """Applies item processing hook, registered with ``register_item_hook()`` to items supplied, and returns processed list. Returns initial items list if no hook is registered. :param list items: :param str|unicode sender: menu, breadcrumbs, si...
def apply_hook(self, items, sender): """Applies item processing hook, registered with ``register_item_hook()`` to items supplied, and returns processed list. Returns initial items list if no hook is registered. :param list items: :param str|unicode sender: menu, breadcrumbs, si...
[ "Applies", "item", "processing", "hook", "registered", "with", "register_item_hook", "()", "to", "items", "supplied", "and", "returns", "processed", "list", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L851-L869
[ "def", "apply_hook", "(", "self", ",", "items", ",", "sender", ")", ":", "processor", "=", "_ITEMS_PROCESSOR", "if", "processor", "is", "None", ":", "return", "items", "if", "_ITEMS_PROCESSOR_ARGS_LEN", "==", "2", ":", "return", "processor", "(", "tree_items",...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.check_access
Checks whether a current user has an access to a certain item. :param TreeItemBase item: :param Context context: :rtype: bool
sitetree/sitetreeapp.py
def check_access(self, item, context): """Checks whether a current user has an access to a certain item. :param TreeItemBase item: :param Context context: :rtype: bool """ if hasattr(self.current_request.user.is_authenticated, '__call__'): authenticated = sel...
def check_access(self, item, context): """Checks whether a current user has an access to a certain item. :param TreeItemBase item: :param Context context: :rtype: bool """ if hasattr(self.current_request.user.is_authenticated, '__call__'): authenticated = sel...
[ "Checks", "whether", "a", "current", "user", "has", "an", "access", "to", "a", "certain", "item", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L871-L903
[ "def", "check_access", "(", "self", ",", "item", ",", "context", ")", ":", "if", "hasattr", "(", "self", ".", "current_request", ".", "user", ".", "is_authenticated", ",", "'__call__'", ")", ":", "authenticated", "=", "self", ".", "current_request", ".", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.breadcrumbs
Builds and returns breadcrumb trail structure for 'sitetree_breadcrumbs' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str
sitetree/sitetreeapp.py
def breadcrumbs(self, tree_alias, context): """Builds and returns breadcrumb trail structure for 'sitetree_breadcrumbs' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_tree(tree_alias, context) ...
def breadcrumbs(self, tree_alias, context): """Builds and returns breadcrumb trail structure for 'sitetree_breadcrumbs' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_tree(tree_alias, context) ...
[ "Builds", "and", "returns", "breadcrumb", "trail", "structure", "for", "sitetree_breadcrumbs", "tag", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L905-L944
[ "def", "breadcrumbs", "(", "self", ",", "tree_alias", ",", "context", ")", ":", "tree_alias", ",", "sitetree_items", "=", "self", ".", "init_tree", "(", "tree_alias", ",", "context", ")", "if", "not", "sitetree_items", ":", "return", "''", "current_item", "=...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.tree
Builds and returns tree structure for 'sitetree_tree' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str
sitetree/sitetreeapp.py
def tree(self, tree_alias, context): """Builds and returns tree structure for 'sitetree_tree' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_tree(tree_alias, context) if not sitetree_items:...
def tree(self, tree_alias, context): """Builds and returns tree structure for 'sitetree_tree' tag. :param str|unicode tree_alias: :param Context context: :rtype: list|str """ tree_alias, sitetree_items = self.init_tree(tree_alias, context) if not sitetree_items:...
[ "Builds", "and", "returns", "tree", "structure", "for", "sitetree_tree", "tag", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L946-L962
[ "def", "tree", "(", "self", ",", "tree_alias", ",", "context", ")", ":", "tree_alias", ",", "sitetree_items", "=", "self", ".", "init_tree", "(", "tree_alias", ",", "context", ")", "if", "not", "sitetree_items", ":", "return", "''", "tree_items", "=", "sel...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.children
Builds and returns site tree item children structure for 'sitetree_children' tag. :param TreeItemBase parent_item: :param str|unicode navigation_type: menu, sitetree :param str|unicode use_template: :param Context context: :rtype: list
sitetree/sitetreeapp.py
def children(self, parent_item, navigation_type, use_template, context): """Builds and returns site tree item children structure for 'sitetree_children' tag. :param TreeItemBase parent_item: :param str|unicode navigation_type: menu, sitetree :param str|unicode use_template: :par...
def children(self, parent_item, navigation_type, use_template, context): """Builds and returns site tree item children structure for 'sitetree_children' tag. :param TreeItemBase parent_item: :param str|unicode navigation_type: menu, sitetree :param str|unicode use_template: :par...
[ "Builds", "and", "returns", "site", "tree", "item", "children", "structure", "for", "sitetree_children", "tag", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L964-L992
[ "def", "children", "(", "self", ",", "parent_item", ",", "navigation_type", ",", "use_template", ",", "context", ")", ":", "# Resolve parent item and current tree alias.", "parent_item", "=", "self", ".", "resolve_var", "(", "parent_item", ",", "context", ")", "tree...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_children
Returns item's children. :param str|unicode tree_alias: :param TreeItemBase|None item: :rtype: list
sitetree/sitetreeapp.py
def get_children(self, tree_alias, item): """Returns item's children. :param str|unicode tree_alias: :param TreeItemBase|None item: :rtype: list """ if not self.current_app_is_admin(): # We do not need i18n for a tree rendered in Admin dropdown. t...
def get_children(self, tree_alias, item): """Returns item's children. :param str|unicode tree_alias: :param TreeItemBase|None item: :rtype: list """ if not self.current_app_is_admin(): # We do not need i18n for a tree rendered in Admin dropdown. t...
[ "Returns", "item", "s", "children", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L994-L1005
[ "def", "get_children", "(", "self", ",", "tree_alias", ",", "item", ")", ":", "if", "not", "self", ".", "current_app_is_admin", "(", ")", ":", "# We do not need i18n for a tree rendered in Admin dropdown.", "tree_alias", "=", "self", ".", "resolve_tree_i18n_alias", "(...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.update_has_children
Updates 'has_children' attribute for tree items inplace. :param str|unicode tree_alias: :param list tree_items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu
sitetree/sitetreeapp.py
def update_has_children(self, tree_alias, tree_items, navigation_type): """Updates 'has_children' attribute for tree items inplace. :param str|unicode tree_alias: :param list tree_items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu """ get_children = s...
def update_has_children(self, tree_alias, tree_items, navigation_type): """Updates 'has_children' attribute for tree items inplace. :param str|unicode tree_alias: :param list tree_items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu """ get_children = s...
[ "Updates", "has_children", "attribute", "for", "tree", "items", "inplace", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1007-L1022
[ "def", "update_has_children", "(", "self", ",", "tree_alias", ",", "tree_items", ",", "navigation_type", ")", ":", "get_children", "=", "self", ".", "get_children", "filter_items", "=", "self", ".", "filter_items", "apply_hook", "=", "self", ".", "apply_hook", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.filter_items
Filters sitetree item's children if hidden and by navigation type. NB: We do not apply any filters to sitetree in admin app. :param list items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu :rtype: list
sitetree/sitetreeapp.py
def filter_items(self, items, navigation_type=None): """Filters sitetree item's children if hidden and by navigation type. NB: We do not apply any filters to sitetree in admin app. :param list items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu :rtype: list ...
def filter_items(self, items, navigation_type=None): """Filters sitetree item's children if hidden and by navigation type. NB: We do not apply any filters to sitetree in admin app. :param list items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu :rtype: list ...
[ "Filters", "sitetree", "item", "s", "children", "if", "hidden", "and", "by", "navigation", "type", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1024-L1053
[ "def", "filter_items", "(", "self", ",", "items", ",", "navigation_type", "=", "None", ")", ":", "if", "self", ".", "current_app_is_admin", "(", ")", ":", "return", "items", "items_filtered", "=", "[", "]", "context", "=", "self", ".", "current_page_context"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.get_ancestor_item
Climbs up the site tree to resolve root item for chosen one. :param str|unicode tree_alias: :param TreeItemBase base_item: :rtype: TreeItemBase
sitetree/sitetreeapp.py
def get_ancestor_item(self, tree_alias, base_item): """Climbs up the site tree to resolve root item for chosen one. :param str|unicode tree_alias: :param TreeItemBase base_item: :rtype: TreeItemBase """ parent = None if hasattr(base_item, 'parent') and base_item...
def get_ancestor_item(self, tree_alias, base_item): """Climbs up the site tree to resolve root item for chosen one. :param str|unicode tree_alias: :param TreeItemBase base_item: :rtype: TreeItemBase """ parent = None if hasattr(base_item, 'parent') and base_item...
[ "Climbs", "up", "the", "site", "tree", "to", "resolve", "root", "item", "for", "chosen", "one", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1055-L1070
[ "def", "get_ancestor_item", "(", "self", ",", "tree_alias", ",", "base_item", ")", ":", "parent", "=", "None", "if", "hasattr", "(", "base_item", ",", "'parent'", ")", "and", "base_item", ".", "parent", "is", "not", "None", ":", "parent", "=", "self", "....
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.tree_climber
Climbs up the site tree to mark items of current branch. :param str|unicode tree_alias: :param TreeItemBase base_item:
sitetree/sitetreeapp.py
def tree_climber(self, tree_alias, base_item): """Climbs up the site tree to mark items of current branch. :param str|unicode tree_alias: :param TreeItemBase base_item: """ if base_item is not None: base_item.in_current_branch = True if hasattr(base_item,...
def tree_climber(self, tree_alias, base_item): """Climbs up the site tree to mark items of current branch. :param str|unicode tree_alias: :param TreeItemBase base_item: """ if base_item is not None: base_item.in_current_branch = True if hasattr(base_item,...
[ "Climbs", "up", "the", "site", "tree", "to", "mark", "items", "of", "current", "branch", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1072-L1081
[ "def", "tree_climber", "(", "self", ",", "tree_alias", ",", "base_item", ")", ":", "if", "base_item", "is", "not", "None", ":", "base_item", ".", "in_current_branch", "=", "True", "if", "hasattr", "(", "base_item", ",", "'parent'", ")", "and", "base_item", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SiteTree.resolve_var
Resolves name as a variable in a given context. If no context specified page context' is considered as context. :param str|unicode varname: :param Context context: :return:
sitetree/sitetreeapp.py
def resolve_var(self, varname, context=None): """Resolves name as a variable in a given context. If no context specified page context' is considered as context. :param str|unicode varname: :param Context context: :return: """ context = context or self.current_pa...
def resolve_var(self, varname, context=None): """Resolves name as a variable in a given context. If no context specified page context' is considered as context. :param str|unicode varname: :param Context context: :return: """ context = context or self.current_pa...
[ "Resolves", "name", "as", "a", "variable", "in", "a", "given", "context", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1083-L1104
[ "def", "resolve_var", "(", "self", ",", "varname", ",", "context", "=", "None", ")", ":", "context", "=", "context", "or", "self", ".", "current_page_context", "if", "isinstance", "(", "varname", ",", "FilterExpression", ")", ":", "varname", "=", "varname", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
sitetree_tree
Parses sitetree tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_tree from "mytree" %} Used to render tree for "mytree" site tree. 2. Four arguments: {% sitetree_tree from "mytree" template "sitetree/mytree.html" %} Used to ...
sitetree/templatetags/sitetree.py
def sitetree_tree(parser, token): """Parses sitetree tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_tree from "mytree" %} Used to render tree for "mytree" site tree. 2. Four arguments: {% sitetree_tree from "mytree" template "sit...
def sitetree_tree(parser, token): """Parses sitetree tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_tree from "mytree" %} Used to render tree for "mytree" site tree. 2. Four arguments: {% sitetree_tree from "mytree" template "sit...
[ "Parses", "sitetree", "tag", "parameters", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L12-L35
[ "def", "sitetree_tree", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "use_template", "=", "detect_clause", "(", "parser", ",", "'template'", ",", "tokens", ")", "tokens_num", "=", "len", "(", "tokens", ")"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
sitetree_children
Parses sitetree_children tag parameters. Six arguments: {% sitetree_children of someitem for menu template "sitetree/mychildren.html" %} Used to render child items of specific site tree 'someitem' using template "sitetree/mychildren.html" for menu navigation. Basical...
sitetree/templatetags/sitetree.py
def sitetree_children(parser, token): """Parses sitetree_children tag parameters. Six arguments: {% sitetree_children of someitem for menu template "sitetree/mychildren.html" %} Used to render child items of specific site tree 'someitem' using template "sitetree/mychildren.h...
def sitetree_children(parser, token): """Parses sitetree_children tag parameters. Six arguments: {% sitetree_children of someitem for menu template "sitetree/mychildren.html" %} Used to render child items of specific site tree 'someitem' using template "sitetree/mychildren.h...
[ "Parses", "sitetree_children", "tag", "parameters", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L39-L66
[ "def", "sitetree_children", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "use_template", "=", "detect_clause", "(", "parser", ",", "'template'", ",", "tokens", ")", "tokens_num", "=", "len", "(", "tokens", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
sitetree_breadcrumbs
Parses sitetree_breadcrumbs tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_breadcrumbs from "mytree" %} Used to render breadcrumb path for "mytree" site tree. 2. Four arguments: {% sitetree_breadcrumbs from "mytree" template "sitetre...
sitetree/templatetags/sitetree.py
def sitetree_breadcrumbs(parser, token): """Parses sitetree_breadcrumbs tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_breadcrumbs from "mytree" %} Used to render breadcrumb path for "mytree" site tree. 2. Four arguments: {% site...
def sitetree_breadcrumbs(parser, token): """Parses sitetree_breadcrumbs tag parameters. Two notation types are possible: 1. Two arguments: {% sitetree_breadcrumbs from "mytree" %} Used to render breadcrumb path for "mytree" site tree. 2. Four arguments: {% site...
[ "Parses", "sitetree_breadcrumbs", "tag", "parameters", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L70-L93
[ "def", "sitetree_breadcrumbs", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "use_template", "=", "detect_clause", "(", "parser", ",", "'template'", ",", "tokens", ")", "tokens_num", "=", "len", "(", "tokens"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
sitetree_menu
Parses sitetree_menu tag parameters. {% sitetree_menu from "mytree" include "trunk,1,level3" %} Used to render trunk, branch with id 1 and branch aliased 'level3' elements from "mytree" site tree as a menu. These are reserved aliases: * 'trunk' - items without parents ...
sitetree/templatetags/sitetree.py
def sitetree_menu(parser, token): """Parses sitetree_menu tag parameters. {% sitetree_menu from "mytree" include "trunk,1,level3" %} Used to render trunk, branch with id 1 and branch aliased 'level3' elements from "mytree" site tree as a menu. These are reserved aliases: ...
def sitetree_menu(parser, token): """Parses sitetree_menu tag parameters. {% sitetree_menu from "mytree" include "trunk,1,level3" %} Used to render trunk, branch with id 1 and branch aliased 'level3' elements from "mytree" site tree as a menu. These are reserved aliases: ...
[ "Parses", "sitetree_menu", "tag", "parameters", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L97-L126
[ "def", "sitetree_menu", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "use_template", "=", "detect_clause", "(", "parser", ",", "'template'", ",", "tokens", ")", "tokens_num", "=", "len", "(", "tokens", ")"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
render
Render helper is used by template node functions to render given template with given tree items in context.
sitetree/templatetags/sitetree.py
def render(context, tree_items, use_template): """Render helper is used by template node functions to render given template with given tree items in context. """ context.push() context['sitetree_items'] = tree_items if isinstance(use_template, FilterExpression): use_template = use_temp...
def render(context, tree_items, use_template): """Render helper is used by template node functions to render given template with given tree items in context. """ context.push() context['sitetree_items'] = tree_items if isinstance(use_template, FilterExpression): use_template = use_temp...
[ "Render", "helper", "is", "used", "by", "template", "node", "functions", "to", "render", "given", "template", "with", "given", "tree", "items", "in", "context", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L293-L307
[ "def", "render", "(", "context", ",", "tree_items", ",", "use_template", ")", ":", "context", ".", "push", "(", ")", "context", "[", "'sitetree_items'", "]", "=", "tree_items", "if", "isinstance", "(", "use_template", ",", "FilterExpression", ")", ":", "use_...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
SimpleNode.for_tag
Node constructor to be used in tags.
sitetree/templatetags/sitetree.py
def for_tag(cls, parser, token, preposition, error_hint): """Node constructor to be used in tags.""" tokens = token.split_contents() if len(tokens) >= 3 and tokens[1] == preposition: as_var = cls.get_as_var(tokens) tree_alias = parser.compile_filter(tokens[2]) ...
def for_tag(cls, parser, token, preposition, error_hint): """Node constructor to be used in tags.""" tokens = token.split_contents() if len(tokens) >= 3 and tokens[1] == preposition: as_var = cls.get_as_var(tokens) tree_alias = parser.compile_filter(tokens[2]) ...
[ "Node", "constructor", "to", "be", "used", "in", "tags", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/templatetags/sitetree.py#L209-L219
[ "def", "for_tag", "(", "cls", ",", "parser", ",", "token", ",", "preposition", ",", "error_hint", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "tokens", ")", ">=", "3", "and", "tokens", "[", "1", "]", "==", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
get_model_url_name
Returns a URL for a given Tree admin page type.
sitetree/admin.py
def get_model_url_name(model_nfo, page, with_namespace=False): """Returns a URL for a given Tree admin page type.""" prefix = '' if with_namespace: prefix = 'admin:' return ('%s%s_%s' % (prefix, '%s_%s' % model_nfo, page)).lower()
def get_model_url_name(model_nfo, page, with_namespace=False): """Returns a URL for a given Tree admin page type.""" prefix = '' if with_namespace: prefix = 'admin:' return ('%s%s_%s' % (prefix, '%s_%s' % model_nfo, page)).lower()
[ "Returns", "a", "URL", "for", "a", "given", "Tree", "admin", "page", "type", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L34-L39
[ "def", "get_model_url_name", "(", "model_nfo", ",", "page", ",", "with_namespace", "=", "False", ")", ":", "prefix", "=", "''", "if", "with_namespace", ":", "prefix", "=", "'admin:'", "return", "(", "'%s%s_%s'", "%", "(", "prefix", ",", "'%s_%s'", "%", "mo...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
_reregister_tree_admin
Forces unregistration of tree admin class with following re-registration.
sitetree/admin.py
def _reregister_tree_admin(): """Forces unregistration of tree admin class with following re-registration.""" try: admin.site.unregister(MODEL_TREE_CLASS) except NotRegistered: pass admin.site.register(MODEL_TREE_CLASS, _TREE_ADMIN())
def _reregister_tree_admin(): """Forces unregistration of tree admin class with following re-registration.""" try: admin.site.unregister(MODEL_TREE_CLASS) except NotRegistered: pass admin.site.register(MODEL_TREE_CLASS, _TREE_ADMIN())
[ "Forces", "unregistration", "of", "tree", "admin", "class", "with", "following", "re", "-", "registration", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L60-L66
[ "def", "_reregister_tree_admin", "(", ")", ":", "try", ":", "admin", ".", "site", ".", "unregister", "(", "MODEL_TREE_CLASS", ")", "except", "NotRegistered", ":", "pass", "admin", ".", "site", ".", "register", "(", "MODEL_TREE_CLASS", ",", "_TREE_ADMIN", "(", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
redirects_handler
Fixes Admin contrib redirects compatibility problems introduced in Django 1.4 by url handling changes.
sitetree/admin.py
def redirects_handler(*args, **kwargs): """Fixes Admin contrib redirects compatibility problems introduced in Django 1.4 by url handling changes. """ path = args[0].path shift = '../' if 'delete' in path: # Weird enough 'delete' is not handled by TreeItemAdmin::response_change(). ...
def redirects_handler(*args, **kwargs): """Fixes Admin contrib redirects compatibility problems introduced in Django 1.4 by url handling changes. """ path = args[0].path shift = '../' if 'delete' in path: # Weird enough 'delete' is not handled by TreeItemAdmin::response_change(). ...
[ "Fixes", "Admin", "contrib", "redirects", "compatibility", "problems", "introduced", "in", "Django", "1", ".", "4", "by", "url", "handling", "changes", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L279-L295
[ "def", "redirects_handler", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "path", "=", "args", "[", "0", "]", ".", "path", "shift", "=", "'../'", "if", "'delete'", "in", "path", ":", "# Weird enough 'delete' is not handled by TreeItemAdmin::response_chang...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin._redirect
Generic redirect for item editor.
sitetree/admin.py
def _redirect(self, request, response): """Generic redirect for item editor.""" if '_addanother' in request.POST: return HttpResponseRedirect('../item_add/') elif '_save' in request.POST: return HttpResponseRedirect('../') elif '_continue' in request.POST: ...
def _redirect(self, request, response): """Generic redirect for item editor.""" if '_addanother' in request.POST: return HttpResponseRedirect('../item_add/') elif '_save' in request.POST: return HttpResponseRedirect('../') elif '_continue' in request.POST: ...
[ "Generic", "redirect", "for", "item", "editor", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L127-L139
[ "def", "_redirect", "(", "self", ",", "request", ",", "response", ")", ":", "if", "'_addanother'", "in", "request", ".", "POST", ":", "return", "HttpResponseRedirect", "(", "'../item_add/'", ")", "elif", "'_save'", "in", "request", ".", "POST", ":", "return"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.response_add
Redirects to the appropriate items' 'continue' page on item add. As we administer tree items within tree itself, we should make some changes to redirection process.
sitetree/admin.py
def response_add(self, request, obj, post_url_continue=None, **kwargs): """Redirects to the appropriate items' 'continue' page on item add. As we administer tree items within tree itself, we should make some changes to redirection process. """ if post_url_continue is None: ...
def response_add(self, request, obj, post_url_continue=None, **kwargs): """Redirects to the appropriate items' 'continue' page on item add. As we administer tree items within tree itself, we should make some changes to redirection process. """ if post_url_continue is None: ...
[ "Redirects", "to", "the", "appropriate", "items", "continue", "page", "on", "item", "add", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L141-L151
[ "def", "response_add", "(", "self", ",", "request", ",", "obj", ",", "post_url_continue", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "post_url_continue", "is", "None", ":", "post_url_continue", "=", "'../item_%s/'", "%", "obj", ".", "pk", "retur...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.response_change
Redirects to the appropriate items' 'add' page on item change. As we administer tree items within tree itself, we should make some changes to redirection process.
sitetree/admin.py
def response_change(self, request, obj, **kwargs): """Redirects to the appropriate items' 'add' page on item change. As we administer tree items within tree itself, we should make some changes to redirection process. """ return self._redirect(request, super(TreeItemAdmin, self)...
def response_change(self, request, obj, **kwargs): """Redirects to the appropriate items' 'add' page on item change. As we administer tree items within tree itself, we should make some changes to redirection process. """ return self._redirect(request, super(TreeItemAdmin, self)...
[ "Redirects", "to", "the", "appropriate", "items", "add", "page", "on", "item", "change", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L153-L160
[ "def", "response_change", "(", "self", ",", "request", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_redirect", "(", "request", ",", "super", "(", "TreeItemAdmin", ",", "self", ")", ".", "response_change", "(", "request", ",", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.get_form
Returns modified form for TreeItem model. 'Parent' field choices are built by sitetree itself.
sitetree/admin.py
def get_form(self, request, obj=None, **kwargs): """Returns modified form for TreeItem model. 'Parent' field choices are built by sitetree itself. """ if obj is not None and obj.parent is not None: self.previous_parent = obj.parent previous_parent_id = self.previ...
def get_form(self, request, obj=None, **kwargs): """Returns modified form for TreeItem model. 'Parent' field choices are built by sitetree itself. """ if obj is not None and obj.parent is not None: self.previous_parent = obj.parent previous_parent_id = self.previ...
[ "Returns", "modified", "form", "for", "TreeItem", "model", ".", "Parent", "field", "choices", "are", "built", "by", "sitetree", "itself", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L162-L197
[ "def", "get_form", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "obj", "is", "not", "None", "and", "obj", ".", "parent", "is", "not", "None", ":", "self", ".", "previous_parent", "=", "obj", ".", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.get_tree
Fetches Tree for current or given TreeItem.
sitetree/admin.py
def get_tree(self, request, tree_id, item_id=None): """Fetches Tree for current or given TreeItem.""" if tree_id is None: tree_id = self.get_object(request, item_id).tree_id self.tree = MODEL_TREE_CLASS._default_manager.get(pk=tree_id) self.tree.verbose_name_plural = self.tre...
def get_tree(self, request, tree_id, item_id=None): """Fetches Tree for current or given TreeItem.""" if tree_id is None: tree_id = self.get_object(request, item_id).tree_id self.tree = MODEL_TREE_CLASS._default_manager.get(pk=tree_id) self.tree.verbose_name_plural = self.tre...
[ "Fetches", "Tree", "for", "current", "or", "given", "TreeItem", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L207-L214
[ "def", "get_tree", "(", "self", ",", "request", ",", "tree_id", ",", "item_id", "=", "None", ")", ":", "if", "tree_id", "is", "None", ":", "tree_id", "=", "self", ".", "get_object", "(", "request", ",", "item_id", ")", ".", "tree_id", "self", ".", "t...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.item_move
Moves item up or down by swapping 'sort_order' field values of neighboring items.
sitetree/admin.py
def item_move(self, request, tree_id, item_id, direction): """Moves item up or down by swapping 'sort_order' field values of neighboring items.""" current_item = MODEL_TREE_ITEM_CLASS._default_manager.get(pk=item_id) if direction == 'up': sort_order = 'sort_order' else: ...
def item_move(self, request, tree_id, item_id, direction): """Moves item up or down by swapping 'sort_order' field values of neighboring items.""" current_item = MODEL_TREE_ITEM_CLASS._default_manager.get(pk=item_id) if direction == 'up': sort_order = 'sort_order' else: ...
[ "Moves", "item", "up", "or", "down", "by", "swapping", "sort_order", "field", "values", "of", "neighboring", "items", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L232-L262
[ "def", "item_move", "(", "self", ",", "request", ",", "tree_id", ",", "item_id", ",", "direction", ")", ":", "current_item", "=", "MODEL_TREE_ITEM_CLASS", ".", "_default_manager", ".", "get", "(", "pk", "=", "item_id", ")", "if", "direction", "==", "'up'", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeItemAdmin.save_model
Saves TreeItem model under certain Tree. Handles item's parent assignment exception.
sitetree/admin.py
def save_model(self, request, obj, form, change): """Saves TreeItem model under certain Tree. Handles item's parent assignment exception. """ if change: # No, you're not allowed to make item parent of itself if obj.parent is not None and obj.parent.id == obj.id: ...
def save_model(self, request, obj, form, change): """Saves TreeItem model under certain Tree. Handles item's parent assignment exception. """ if change: # No, you're not allowed to make item parent of itself if obj.parent is not None and obj.parent.id == obj.id: ...
[ "Saves", "TreeItem", "model", "under", "certain", "Tree", ".", "Handles", "item", "s", "parent", "assignment", "exception", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L264-L276
[ "def", "save_model", "(", "self", ",", "request", ",", "obj", ",", "form", ",", "change", ")", ":", "if", "change", ":", "# No, you're not allowed to make item parent of itself", "if", "obj", ".", "parent", "is", "not", "None", "and", "obj", ".", "parent", "...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeAdmin.get_urls
Manages not only TreeAdmin URLs but also TreeItemAdmin URLs.
sitetree/admin.py
def get_urls(self): """Manages not only TreeAdmin URLs but also TreeItemAdmin URLs.""" urls = super(TreeAdmin, self).get_urls() prefix_change = 'change/' if DJANGO_POST_19 else '' sitetree_urls = [ url(r'^change/$', redirects_handler, name=get_tree_item_url_name('changelist...
def get_urls(self): """Manages not only TreeAdmin URLs but also TreeItemAdmin URLs.""" urls = super(TreeAdmin, self).get_urls() prefix_change = 'change/' if DJANGO_POST_19 else '' sitetree_urls = [ url(r'^change/$', redirects_handler, name=get_tree_item_url_name('changelist...
[ "Manages", "not", "only", "TreeAdmin", "URLs", "but", "also", "TreeItemAdmin", "URLs", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L320-L354
[ "def", "get_urls", "(", "self", ")", ":", "urls", "=", "super", "(", "TreeAdmin", ",", "self", ")", ".", "get_urls", "(", ")", "prefix_change", "=", "'change/'", "if", "DJANGO_POST_19", "else", "''", "sitetree_urls", "=", "[", "url", "(", "r'^change/$'", ...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
TreeAdmin.dump_view
Dumps sitetrees with items using django-smuggler. :param request: :return:
sitetree/admin.py
def dump_view(cls, request): """Dumps sitetrees with items using django-smuggler. :param request: :return: """ from smuggler.views import dump_to_response return dump_to_response(request, [MODEL_TREE, MODEL_TREE_ITEM], filename_prefix='sitetrees')
def dump_view(cls, request): """Dumps sitetrees with items using django-smuggler. :param request: :return: """ from smuggler.views import dump_to_response return dump_to_response(request, [MODEL_TREE, MODEL_TREE_ITEM], filename_prefix='sitetrees')
[ "Dumps", "sitetrees", "with", "items", "using", "django", "-", "smuggler", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/admin.py#L357-L364
[ "def", "dump_view", "(", "cls", ",", "request", ")", ":", "from", "smuggler", ".", "views", "import", "dump_to_response", "return", "dump_to_response", "(", "request", ",", "[", "MODEL_TREE", ",", "MODEL_TREE_ITEM", "]", ",", "filename_prefix", "=", "'sitetrees'...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
tree
Dynamically creates and returns a sitetree. :param str|unicode alias: :param str|unicode title: :param iterable items: dynamic sitetree items objects created by `item` function. :param kwargs: Additional arguments to pass to tree item initializer. :rtype: TreeBase
sitetree/utils.py
def tree(alias, title='', items=None, **kwargs): """Dynamically creates and returns a sitetree. :param str|unicode alias: :param str|unicode title: :param iterable items: dynamic sitetree items objects created by `item` function. :param kwargs: Additional arguments to pass to tree item initializer....
def tree(alias, title='', items=None, **kwargs): """Dynamically creates and returns a sitetree. :param str|unicode alias: :param str|unicode title: :param iterable items: dynamic sitetree items objects created by `item` function. :param kwargs: Additional arguments to pass to tree item initializer....
[ "Dynamically", "creates", "and", "returns", "a", "sitetree", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L19-L43
[ "def", "tree", "(", "alias", ",", "title", "=", "''", ",", "items", "=", "None", ",", "*", "*", "kwargs", ")", ":", "tree_obj", "=", "get_tree_model", "(", ")", "(", "alias", "=", "alias", ",", "title", "=", "title", ",", "*", "*", "kwargs", ")",...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
item
Dynamically creates and returns a sitetree item object. :param str|unicode title: :param str|unicode url: :param list, set children: a list of children for tree item. Children should also be created by `item` function. :param bool url_as_pattern: consider URL as a name of a named URL :param str...
sitetree/utils.py
def item( title, url, children=None, url_as_pattern=True, hint='', alias='', description='', in_menu=True, in_breadcrumbs=True, in_sitetree=True, access_loggedin=False, access_guest=False, access_by_perms=None, perms_mode_all=True, **kwargs): """Dynamically creates and returns a sitetree item object...
def item( title, url, children=None, url_as_pattern=True, hint='', alias='', description='', in_menu=True, in_breadcrumbs=True, in_sitetree=True, access_loggedin=False, access_guest=False, access_by_perms=None, perms_mode_all=True, **kwargs): """Dynamically creates and returns a sitetree item object...
[ "Dynamically", "creates", "and", "returns", "a", "sitetree", "item", "object", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L46-L140
[ "def", "item", "(", "title", ",", "url", ",", "children", "=", "None", ",", "url_as_pattern", "=", "True", ",", "hint", "=", "''", ",", "alias", "=", "''", ",", "description", "=", "''", ",", "in_menu", "=", "True", ",", "in_breadcrumbs", "=", "True"...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
import_app_sitetree_module
Imports sitetree module from a given app. :param str|unicode app: Application name :return: module|None
sitetree/utils.py
def import_app_sitetree_module(app): """Imports sitetree module from a given app. :param str|unicode app: Application name :return: module|None """ module_name = settings.APP_MODULE_NAME module = import_module(app) try: sub_module = import_module('%s.%s' % (app, module_name)) ...
def import_app_sitetree_module(app): """Imports sitetree module from a given app. :param str|unicode app: Application name :return: module|None """ module_name = settings.APP_MODULE_NAME module = import_module(app) try: sub_module = import_module('%s.%s' % (app, module_name)) ...
[ "Imports", "sitetree", "module", "from", "a", "given", "app", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L143-L157
[ "def", "import_app_sitetree_module", "(", "app", ")", ":", "module_name", "=", "settings", ".", "APP_MODULE_NAME", "module", "=", "import_module", "(", "app", ")", "try", ":", "sub_module", "=", "import_module", "(", "'%s.%s'", "%", "(", "app", ",", "module_na...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
import_project_sitetree_modules
Imports sitetrees modules from packages (apps). Returns a list of submodules. :rtype: list
sitetree/utils.py
def import_project_sitetree_modules(): """Imports sitetrees modules from packages (apps). Returns a list of submodules. :rtype: list """ from django.conf import settings as django_settings submodules = [] for app in django_settings.INSTALLED_APPS: module = import_app_sitetree_module...
def import_project_sitetree_modules(): """Imports sitetrees modules from packages (apps). Returns a list of submodules. :rtype: list """ from django.conf import settings as django_settings submodules = [] for app in django_settings.INSTALLED_APPS: module = import_app_sitetree_module...
[ "Imports", "sitetrees", "modules", "from", "packages", "(", "apps", ")", ".", "Returns", "a", "list", "of", "submodules", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L160-L172
[ "def", "import_project_sitetree_modules", "(", ")", ":", "from", "django", ".", "conf", "import", "settings", "as", "django_settings", "submodules", "=", "[", "]", "for", "app", "in", "django_settings", ".", "INSTALLED_APPS", ":", "module", "=", "import_app_sitetr...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
get_app_n_model
Returns tuple with application and tree[item] model class names. :param str|unicode settings_entry_name: :rtype: tuple
sitetree/utils.py
def get_app_n_model(settings_entry_name): """Returns tuple with application and tree[item] model class names. :param str|unicode settings_entry_name: :rtype: tuple """ try: app_name, model_name = getattr(settings, settings_entry_name).split('.') except ValueError: raise Improper...
def get_app_n_model(settings_entry_name): """Returns tuple with application and tree[item] model class names. :param str|unicode settings_entry_name: :rtype: tuple """ try: app_name, model_name = getattr(settings, settings_entry_name).split('.') except ValueError: raise Improper...
[ "Returns", "tuple", "with", "application", "and", "tree", "[", "item", "]", "model", "class", "names", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L175-L186
[ "def", "get_app_n_model", "(", "settings_entry_name", ")", ":", "try", ":", "app_name", ",", "model_name", "=", "getattr", "(", "settings", ",", "settings_entry_name", ")", ".", "split", "(", "'.'", ")", "except", "ValueError", ":", "raise", "ImproperlyConfigure...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
get_model_class
Returns a certain sitetree model as defined in the project settings. :param str|unicode settings_entry_name: :rtype: TreeItemBase|TreeBase
sitetree/utils.py
def get_model_class(settings_entry_name): """Returns a certain sitetree model as defined in the project settings. :param str|unicode settings_entry_name: :rtype: TreeItemBase|TreeBase """ app_name, model_name = get_app_n_model(settings_entry_name) try: model = apps_get_model(app_name, ...
def get_model_class(settings_entry_name): """Returns a certain sitetree model as defined in the project settings. :param str|unicode settings_entry_name: :rtype: TreeItemBase|TreeBase """ app_name, model_name = get_app_n_model(settings_entry_name) try: model = apps_get_model(app_name, ...
[ "Returns", "a", "certain", "sitetree", "model", "as", "defined", "in", "the", "project", "settings", "." ]
idlesign/django-sitetree
python
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L189-L206
[ "def", "get_model_class", "(", "settings_entry_name", ")", ":", "app_name", ",", "model_name", "=", "get_app_n_model", "(", "settings_entry_name", ")", "try", ":", "model", "=", "apps_get_model", "(", "app_name", ",", "model_name", ")", "except", "(", "LookupError...
61de4608e6e415247c75fe8691027d7c4ed0d1e7
test
H11Mixin.asgi_send
Called by the ASGI instance to send a message.
hypercorn/asgi/h11.py
async def asgi_send(self, message: dict) -> None: """Called by the ASGI instance to send a message.""" if message["type"] == "http.response.start" and self.state == ASGIHTTPState.REQUEST: self.response = message elif message["type"] == "http.response.body" and self.state in { ...
async def asgi_send(self, message: dict) -> None: """Called by the ASGI instance to send a message.""" if message["type"] == "http.response.start" and self.state == ASGIHTTPState.REQUEST: self.response = message elif message["type"] == "http.response.body" and self.state in { ...
[ "Called", "by", "the", "ASGI", "instance", "to", "send", "a", "message", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/asgi/h11.py#L123-L151
[ "async", "def", "asgi_send", "(", "self", ",", "message", ":", "dict", ")", "->", "None", ":", "if", "message", "[", "\"type\"", "]", "==", "\"http.response.start\"", "and", "self", ".", "state", "==", "ASGIHTTPState", ".", "REQUEST", ":", "self", ".", "...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
WebsocketMixin.asgi_send
Called by the ASGI instance to send a message.
hypercorn/asgi/wsproto.py
async def asgi_send(self, message: dict) -> None: """Called by the ASGI instance to send a message.""" if message["type"] == "websocket.accept" and self.state == ASGIWebsocketState.HANDSHAKE: headers = build_and_validate_headers(message.get("headers", [])) raise_if_subprotocol_pr...
async def asgi_send(self, message: dict) -> None: """Called by the ASGI instance to send a message.""" if message["type"] == "websocket.accept" and self.state == ASGIWebsocketState.HANDSHAKE: headers = build_and_validate_headers(message.get("headers", [])) raise_if_subprotocol_pr...
[ "Called", "by", "the", "ASGI", "instance", "to", "send", "a", "message", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/asgi/wsproto.py#L108-L151
[ "async", "def", "asgi_send", "(", "self", ",", "message", ":", "dict", ")", "->", "None", ":", "if", "message", "[", "\"type\"", "]", "==", "\"websocket.accept\"", "and", "self", ".", "state", "==", "ASGIWebsocketState", ".", "HANDSHAKE", ":", "headers", "...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
serve
Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: python asyncio.run(serve(app, config)) It is assumed that the event-loop is configured before calling this function, therefore configuration va...
hypercorn/asyncio/__init__.py
async def serve(app: ASGIFramework, config: Config) -> None: """Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: python asyncio.run(serve(app, config)) It is assumed that the event-loop is con...
async def serve(app: ASGIFramework, config: Config) -> None: """Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: python asyncio.run(serve(app, config)) It is assumed that the event-loop is con...
[ "Serve", "an", "ASGI", "framework", "app", "given", "the", "config", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/asyncio/__init__.py#L8-L30
[ "async", "def", "serve", "(", "app", ":", "ASGIFramework", ",", "config", ":", "Config", ")", "->", "None", ":", "if", "config", ".", "debug", ":", "warnings", ".", "warn", "(", "\"The config `debug` has no affect when using serve\"", ",", "Warning", ")", "if"...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
serve
Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: python trio.run(partial(serve, app, config)) It is assumed that the event-loop is configured before calling this function, therefore configurat...
hypercorn/trio/__init__.py
async def serve( app: ASGIFramework, config: Config, *, task_status: trio._core._run._TaskStatus = trio.TASK_STATUS_IGNORED, ) -> None: """Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: py...
async def serve( app: ASGIFramework, config: Config, *, task_status: trio._core._run._TaskStatus = trio.TASK_STATUS_IGNORED, ) -> None: """Serve an ASGI framework app given the config. This allows for a programmatic way to serve an ASGI framework, it can be used via, .. code-block:: py...
[ "Serve", "an", "ASGI", "framework", "app", "given", "the", "config", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/trio/__init__.py#L10-L37
[ "async", "def", "serve", "(", "app", ":", "ASGIFramework", ",", "config", ":", "Config", ",", "*", ",", "task_status", ":", "trio", ".", "_core", ".", "_run", ".", "_TaskStatus", "=", "trio", ".", "TASK_STATUS_IGNORED", ",", ")", "->", "None", ":", "if...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
Config.from_mapping
Create a configuration from a mapping. This allows either a mapping to be directly passed or as keyword arguments, for example, .. code-block:: python config = {'keep_alive_timeout': 10} Config.from_mapping(config) Config.form_mapping(keep_alive_timeout=10)...
hypercorn/config.py
def from_mapping( cls: Type["Config"], mapping: Optional[Mapping[str, Any]] = None, **kwargs: Any ) -> "Config": """Create a configuration from a mapping. This allows either a mapping to be directly passed or as keyword arguments, for example, .. code-block:: python ...
def from_mapping( cls: Type["Config"], mapping: Optional[Mapping[str, Any]] = None, **kwargs: Any ) -> "Config": """Create a configuration from a mapping. This allows either a mapping to be directly passed or as keyword arguments, for example, .. code-block:: python ...
[ "Create", "a", "configuration", "from", "a", "mapping", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/config.py#L206-L236
[ "def", "from_mapping", "(", "cls", ":", "Type", "[", "\"Config\"", "]", ",", "mapping", ":", "Optional", "[", "Mapping", "[", "str", ",", "Any", "]", "]", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Config\"", ":", "mappings", "...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
Config.from_pyfile
Create a configuration from a Python file. .. code-block:: python Config.from_pyfile('hypercorn_config.py') Arguments: filename: The filename which gives the path to the file.
hypercorn/config.py
def from_pyfile(cls: Type["Config"], filename: FilePath) -> "Config": """Create a configuration from a Python file. .. code-block:: python Config.from_pyfile('hypercorn_config.py') Arguments: filename: The filename which gives the path to the file. """ ...
def from_pyfile(cls: Type["Config"], filename: FilePath) -> "Config": """Create a configuration from a Python file. .. code-block:: python Config.from_pyfile('hypercorn_config.py') Arguments: filename: The filename which gives the path to the file. """ ...
[ "Create", "a", "configuration", "from", "a", "Python", "file", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/config.py#L239-L253
[ "def", "from_pyfile", "(", "cls", ":", "Type", "[", "\"Config\"", "]", ",", "filename", ":", "FilePath", ")", "->", "\"Config\"", ":", "file_path", "=", "os", ".", "fspath", "(", "filename", ")", "spec", "=", "importlib", ".", "util", ".", "spec_from_fil...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
Config.from_toml
Load the configuration values from a TOML formatted file. This allows configuration to be loaded as so .. code-block:: python Config.from_toml('config.toml') Arguments: filename: The filename which gives the path to the file.
hypercorn/config.py
def from_toml(cls: Type["Config"], filename: FilePath) -> "Config": """Load the configuration values from a TOML formatted file. This allows configuration to be loaded as so .. code-block:: python Config.from_toml('config.toml') Arguments: filename: The filena...
def from_toml(cls: Type["Config"], filename: FilePath) -> "Config": """Load the configuration values from a TOML formatted file. This allows configuration to be loaded as so .. code-block:: python Config.from_toml('config.toml') Arguments: filename: The filena...
[ "Load", "the", "configuration", "values", "from", "a", "TOML", "formatted", "file", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/config.py#L256-L271
[ "def", "from_toml", "(", "cls", ":", "Type", "[", "\"Config\"", "]", ",", "filename", ":", "FilePath", ")", "->", "\"Config\"", ":", "file_path", "=", "os", ".", "fspath", "(", "filename", ")", "with", "open", "(", "file_path", ")", "as", "file_", ":",...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
Config.from_object
Create a configuration from a Python object. This can be used to reference modules or objects within modules for example, .. code-block:: python Config.from_object('module') Config.from_object('module.instance') from module import instance Confi...
hypercorn/config.py
def from_object(cls: Type["Config"], instance: Union[object, str]) -> "Config": """Create a configuration from a Python object. This can be used to reference modules or objects within modules for example, .. code-block:: python Config.from_object('module') Conf...
def from_object(cls: Type["Config"], instance: Union[object, str]) -> "Config": """Create a configuration from a Python object. This can be used to reference modules or objects within modules for example, .. code-block:: python Config.from_object('module') Conf...
[ "Create", "a", "configuration", "from", "a", "Python", "object", "." ]
pgjones/hypercorn
python
https://github.com/pgjones/hypercorn/blob/ef93d741fe246846a127f9318b54505ac65f1ae7/hypercorn/config.py#L274-L309
[ "def", "from_object", "(", "cls", ":", "Type", "[", "\"Config\"", "]", ",", "instance", ":", "Union", "[", "object", ",", "str", "]", ")", "->", "\"Config\"", ":", "if", "isinstance", "(", "instance", ",", "str", ")", ":", "try", ":", "path", ",", ...
ef93d741fe246846a127f9318b54505ac65f1ae7
test
ZipkinLoggingContext.emit_spans
Main function to log all the annotations stored during the entire request. This is done if the request is sampled and the response was a success. It also logs the service (`ss` and `sr`) or the client ('cs' and 'cr') annotations.
py_zipkin/logging_helper.py
def emit_spans(self): """Main function to log all the annotations stored during the entire request. This is done if the request is sampled and the response was a success. It also logs the service (`ss` and `sr`) or the client ('cs' and 'cr') annotations. """ # FIXME: Sho...
def emit_spans(self): """Main function to log all the annotations stored during the entire request. This is done if the request is sampled and the response was a success. It also logs the service (`ss` and `sr`) or the client ('cs' and 'cr') annotations. """ # FIXME: Sho...
[ "Main", "function", "to", "log", "all", "the", "annotations", "stored", "during", "the", "entire", "request", ".", "This", "is", "done", "if", "the", "request", "is", "sampled", "and", "the", "response", "was", "a", "success", ".", "It", "also", "logs", ...
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/logging_helper.py#L71-L96
[ "def", "emit_spans", "(", "self", ")", ":", "# FIXME: Should have a single aggregate handler", "if", "self", ".", "firehose_handler", ":", "# FIXME: We need to allow different batching settings per handler", "self", ".", "_emit_spans_with_span_sender", "(", "ZipkinBatchSender", "...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_attrs_for_span
Creates a set of zipkin attributes for a span. :param sample_rate: Float between 0.0 and 100.0 to determine sampling rate :type sample_rate: float :param trace_id: Optional 16-character hex string representing a trace_id. If this is None, a random trace_id will be generated. :type t...
py_zipkin/zipkin.py
def create_attrs_for_span( sample_rate=100.0, trace_id=None, span_id=None, use_128bit_trace_id=False, ): """Creates a set of zipkin attributes for a span. :param sample_rate: Float between 0.0 and 100.0 to determine sampling rate :type sample_rate: float :param trace_id: Optional 16-cha...
def create_attrs_for_span( sample_rate=100.0, trace_id=None, span_id=None, use_128bit_trace_id=False, ): """Creates a set of zipkin attributes for a span. :param sample_rate: Float between 0.0 and 100.0 to determine sampling rate :type sample_rate: float :param trace_id: Optional 16-cha...
[ "Creates", "a", "set", "of", "zipkin", "attributes", "for", "a", "span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L642-L680
[ "def", "create_attrs_for_span", "(", "sample_rate", "=", "100.0", ",", "trace_id", "=", "None", ",", "span_id", "=", "None", ",", "use_128bit_trace_id", "=", "False", ",", ")", ":", "# Calculate if this trace is sampled based on the sample rate", "if", "trace_id", "is...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_http_headers_for_new_span
Generate the headers for a new zipkin span. .. note:: If the method is not called from within a zipkin_trace context, empty dict will be returned back. :returns: dict containing (X-B3-TraceId, X-B3-SpanId, X-B3-ParentSpanId, X-B3-Flags and X-B3-Sampled) keys OR an empty dict.
py_zipkin/zipkin.py
def create_http_headers_for_new_span(context_stack=None, tracer=None): """ Generate the headers for a new zipkin span. .. note:: If the method is not called from within a zipkin_trace context, empty dict will be returned back. :returns: dict containing (X-B3-TraceId, X-B3-SpanId, X-B3...
def create_http_headers_for_new_span(context_stack=None, tracer=None): """ Generate the headers for a new zipkin span. .. note:: If the method is not called from within a zipkin_trace context, empty dict will be returned back. :returns: dict containing (X-B3-TraceId, X-B3-SpanId, X-B3...
[ "Generate", "the", "headers", "for", "a", "new", "zipkin", "span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L683-L711
[ "def", "create_http_headers_for_new_span", "(", "context_stack", "=", "None", ",", "tracer", "=", "None", ")", ":", "if", "tracer", ":", "zipkin_attrs", "=", "tracer", ".", "get_zipkin_attrs", "(", ")", "elif", "context_stack", ":", "zipkin_attrs", "=", "context...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span._get_current_context
Returns the current ZipkinAttrs and generates new ones if needed. :returns: (report_root_timestamp, zipkin_attrs) :rtype: (bool, ZipkinAttrs)
py_zipkin/zipkin.py
def _get_current_context(self): """Returns the current ZipkinAttrs and generates new ones if needed. :returns: (report_root_timestamp, zipkin_attrs) :rtype: (bool, ZipkinAttrs) """ # This check is technically not necessary since only root spans will have # sample_rate, z...
def _get_current_context(self): """Returns the current ZipkinAttrs and generates new ones if needed. :returns: (report_root_timestamp, zipkin_attrs) :rtype: (bool, ZipkinAttrs) """ # This check is technically not necessary since only root spans will have # sample_rate, z...
[ "Returns", "the", "current", "ZipkinAttrs", "and", "generates", "new", "ones", "if", "needed", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L338-L406
[ "def", "_get_current_context", "(", "self", ")", ":", "# This check is technically not necessary since only root spans will have", "# sample_rate, zipkin_attrs or a transport set. But it helps making the", "# code clearer by separating the logic for a root span from the one for a", "# child span."...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span.start
Enter the new span context. All annotations logged inside this context will be attributed to this span. All new spans generated inside this context will have this span as their parent. In the unsampled case, this context still generates new span IDs and pushes them onto the threadlocal ...
py_zipkin/zipkin.py
def start(self): """Enter the new span context. All annotations logged inside this context will be attributed to this span. All new spans generated inside this context will have this span as their parent. In the unsampled case, this context still generates new span IDs and pushe...
def start(self): """Enter the new span context. All annotations logged inside this context will be attributed to this span. All new spans generated inside this context will have this span as their parent. In the unsampled case, this context still generates new span IDs and pushe...
[ "Enter", "the", "new", "span", "context", ".", "All", "annotations", "logged", "inside", "this", "context", "will", "be", "attributed", "to", "this", "span", ".", "All", "new", "spans", "generated", "inside", "this", "context", "will", "have", "this", "span"...
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L408-L464
[ "def", "start", "(", "self", ")", ":", "self", ".", "do_pop_attrs", "=", "False", "report_root_timestamp", ",", "self", ".", "zipkin_attrs", "=", "self", ".", "_get_current_context", "(", ")", "# If zipkin_attrs are not set up by now, that means this span is not", "# co...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span.stop
Exit the span context. Zipkin attrs are pushed onto the threadlocal stack regardless of sampling, so they always need to be popped off. The actual logging of spans depends on sampling and that the logging was correctly set up.
py_zipkin/zipkin.py
def stop(self, _exc_type=None, _exc_value=None, _exc_traceback=None): """Exit the span context. Zipkin attrs are pushed onto the threadlocal stack regardless of sampling, so they always need to be popped off. The actual logging of spans depends on sampling and that the logging was correc...
def stop(self, _exc_type=None, _exc_value=None, _exc_traceback=None): """Exit the span context. Zipkin attrs are pushed onto the threadlocal stack regardless of sampling, so they always need to be popped off. The actual logging of spans depends on sampling and that the logging was correc...
[ "Exit", "the", "span", "context", ".", "Zipkin", "attrs", "are", "pushed", "onto", "the", "threadlocal", "stack", "regardless", "of", "sampling", "so", "they", "always", "need", "to", "be", "popped", "off", ".", "The", "actual", "logging", "of", "spans", "...
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L469-L532
[ "def", "stop", "(", "self", ",", "_exc_type", "=", "None", ",", "_exc_value", "=", "None", ",", "_exc_traceback", "=", "None", ")", ":", "if", "self", ".", "do_pop_attrs", ":", "self", ".", "get_tracer", "(", ")", ".", "pop_zipkin_attrs", "(", ")", "# ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span.update_binary_annotations
Updates the binary annotations for the current span.
py_zipkin/zipkin.py
def update_binary_annotations(self, extra_annotations): """Updates the binary annotations for the current span.""" if not self.logging_context: # This is not the root span, so binary annotations will be added # to the log handler when this span context exits. self.bin...
def update_binary_annotations(self, extra_annotations): """Updates the binary annotations for the current span.""" if not self.logging_context: # This is not the root span, so binary annotations will be added # to the log handler when this span context exits. self.bin...
[ "Updates", "the", "binary", "annotations", "for", "the", "current", "span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L534-L543
[ "def", "update_binary_annotations", "(", "self", ",", "extra_annotations", ")", ":", "if", "not", "self", ".", "logging_context", ":", "# This is not the root span, so binary annotations will be added", "# to the log handler when this span context exits.", "self", ".", "binary_an...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span.add_sa_binary_annotation
Adds a 'sa' binary annotation to the current span. 'sa' binary annotations are useful for situations where you need to log where a request is going but the destination doesn't support zipkin. Note that the span must have 'cs'/'cr' annotations. :param port: The port number of the desti...
py_zipkin/zipkin.py
def add_sa_binary_annotation( self, port=0, service_name='unknown', host='127.0.0.1', ): """Adds a 'sa' binary annotation to the current span. 'sa' binary annotations are useful for situations where you need to log where a request is going but the destination...
def add_sa_binary_annotation( self, port=0, service_name='unknown', host='127.0.0.1', ): """Adds a 'sa' binary annotation to the current span. 'sa' binary annotations are useful for situations where you need to log where a request is going but the destination...
[ "Adds", "a", "sa", "binary", "annotation", "to", "the", "current", "span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L545-L582
[ "def", "add_sa_binary_annotation", "(", "self", ",", "port", "=", "0", ",", "service_name", "=", "'unknown'", ",", "host", "=", "'127.0.0.1'", ",", ")", ":", "if", "self", ".", "kind", "!=", "Kind", ".", "CLIENT", ":", "# TODO: trying to set a sa binary annota...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
zipkin_span.override_span_name
Overrides the current span name. This is useful if you don't know the span name yet when you create the zipkin_span object. i.e. pyramid_zipkin doesn't know which route the request matched until the function wrapped by the context manager completes. :param name: New span name ...
py_zipkin/zipkin.py
def override_span_name(self, name): """Overrides the current span name. This is useful if you don't know the span name yet when you create the zipkin_span object. i.e. pyramid_zipkin doesn't know which route the request matched until the function wrapped by the context manager c...
def override_span_name(self, name): """Overrides the current span name. This is useful if you don't know the span name yet when you create the zipkin_span object. i.e. pyramid_zipkin doesn't know which route the request matched until the function wrapped by the context manager c...
[ "Overrides", "the", "current", "span", "name", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/zipkin.py#L584-L597
[ "def", "override_span_name", "(", "self", ",", "name", ")", ":", "self", ".", "span_name", "=", "name", "if", "self", ".", "logging_context", ":", "self", ".", "logging_context", ".", "span_name", "=", "name" ]
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_endpoint
Creates a new Endpoint object. :param port: TCP/UDP port. Defaults to 0. :type port: int :param service_name: service name as a str. Defaults to 'unknown'. :type service_name: str :param host: ipv4 or ipv6 address of the host. Defaults to the current host ip. :type host: str :param use_...
py_zipkin/encoding/_helpers.py
def create_endpoint(port=None, service_name=None, host=None, use_defaults=True): """Creates a new Endpoint object. :param port: TCP/UDP port. Defaults to 0. :type port: int :param service_name: service name as a str. Defaults to 'unknown'. :type service_name: str :param host: ipv4 or ipv6 addre...
def create_endpoint(port=None, service_name=None, host=None, use_defaults=True): """Creates a new Endpoint object. :param port: TCP/UDP port. Defaults to 0. :type port: int :param service_name: service name as a str. Defaults to 'unknown'. :type service_name: str :param host: ipv4 or ipv6 addre...
[ "Creates", "a", "new", "Endpoint", "object", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_helpers.py#L156-L203
[ "def", "create_endpoint", "(", "port", "=", "None", ",", "service_name", "=", "None", ",", "host", "=", "None", ",", "use_defaults", "=", "True", ")", ":", "if", "use_defaults", ":", "if", "port", "is", "None", ":", "port", "=", "0", "if", "service_nam...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
copy_endpoint_with_new_service_name
Creates a copy of a given endpoint with a new service name. :param endpoint: existing Endpoint object :type endpoint: Endpoint :param new_service_name: new service name :type new_service_name: str :returns: zipkin new Endpoint object
py_zipkin/encoding/_helpers.py
def copy_endpoint_with_new_service_name(endpoint, new_service_name): """Creates a copy of a given endpoint with a new service name. :param endpoint: existing Endpoint object :type endpoint: Endpoint :param new_service_name: new service name :type new_service_name: str :returns: zipkin new Endpo...
def copy_endpoint_with_new_service_name(endpoint, new_service_name): """Creates a copy of a given endpoint with a new service name. :param endpoint: existing Endpoint object :type endpoint: Endpoint :param new_service_name: new service name :type new_service_name: str :returns: zipkin new Endpo...
[ "Creates", "a", "copy", "of", "a", "given", "endpoint", "with", "a", "new", "service", "name", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_helpers.py#L206-L220
[ "def", "copy_endpoint_with_new_service_name", "(", "endpoint", ",", "new_service_name", ")", ":", "return", "Endpoint", "(", "service_name", "=", "new_service_name", ",", "ipv4", "=", "endpoint", ".", "ipv4", ",", "ipv6", "=", "endpoint", ".", "ipv6", ",", "port...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
Span.build_v1_span
Builds and returns a V1 Span. :return: newly generated _V1Span :rtype: _V1Span
py_zipkin/encoding/_helpers.py
def build_v1_span(self): """Builds and returns a V1 Span. :return: newly generated _V1Span :rtype: _V1Span """ # We are simulating a full two-part span locally, so set cs=sr and ss=cr full_annotations = OrderedDict([ ('cs', self.timestamp), ('sr',...
def build_v1_span(self): """Builds and returns a V1 Span. :return: newly generated _V1Span :rtype: _V1Span """ # We are simulating a full two-part span locally, so set cs=sr and ss=cr full_annotations = OrderedDict([ ('cs', self.timestamp), ('sr',...
[ "Builds", "and", "returns", "a", "V1", "Span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_helpers.py#L117-L153
[ "def", "build_v1_span", "(", "self", ")", ":", "# We are simulating a full two-part span locally, so set cs=sr and ss=cr", "full_annotations", "=", "OrderedDict", "(", "[", "(", "'cs'", ",", "self", ".", "timestamp", ")", ",", "(", "'sr'", ",", "self", ".", "timesta...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
encode_pb_list
Encode list of protobuf Spans to binary. :param pb_spans: list of protobuf Spans. :type pb_spans: list of zipkin_pb2.Span :return: encoded list. :rtype: bytes
py_zipkin/encoding/protobuf/__init__.py
def encode_pb_list(pb_spans): """Encode list of protobuf Spans to binary. :param pb_spans: list of protobuf Spans. :type pb_spans: list of zipkin_pb2.Span :return: encoded list. :rtype: bytes """ pb_list = zipkin_pb2.ListOfSpans() pb_list.spans.extend(pb_spans) return pb_list.Serial...
def encode_pb_list(pb_spans): """Encode list of protobuf Spans to binary. :param pb_spans: list of protobuf Spans. :type pb_spans: list of zipkin_pb2.Span :return: encoded list. :rtype: bytes """ pb_list = zipkin_pb2.ListOfSpans() pb_list.spans.extend(pb_spans) return pb_list.Serial...
[ "Encode", "list", "of", "protobuf", "Spans", "to", "binary", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L22-L32
[ "def", "encode_pb_list", "(", "pb_spans", ")", ":", "pb_list", "=", "zipkin_pb2", ".", "ListOfSpans", "(", ")", "pb_list", ".", "spans", ".", "extend", "(", "pb_spans", ")", "return", "pb_list", ".", "SerializeToString", "(", ")" ]
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_protobuf_span
Converts a py_zipkin Span in a protobuf Span. :param span: py_zipkin Span to convert. :type span: py_zipkin.encoding.Span :return: protobuf's Span :rtype: zipkin_pb2.Span
py_zipkin/encoding/protobuf/__init__.py
def create_protobuf_span(span): """Converts a py_zipkin Span in a protobuf Span. :param span: py_zipkin Span to convert. :type span: py_zipkin.encoding.Span :return: protobuf's Span :rtype: zipkin_pb2.Span """ # Protobuf's composite types (i.e. Span's local_endpoint) are immutable. # S...
def create_protobuf_span(span): """Converts a py_zipkin Span in a protobuf Span. :param span: py_zipkin Span to convert. :type span: py_zipkin.encoding.Span :return: protobuf's Span :rtype: zipkin_pb2.Span """ # Protobuf's composite types (i.e. Span's local_endpoint) are immutable. # S...
[ "Converts", "a", "py_zipkin", "Span", "in", "a", "protobuf", "Span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L35-L86
[ "def", "create_protobuf_span", "(", "span", ")", ":", "# Protobuf's composite types (i.e. Span's local_endpoint) are immutable.", "# So we can't create a zipkin_pb2.Span here and then set the appropriate", "# fields since `pb_span.local_endpoint = zipkin_pb2.Endpoint` fails.", "# Instead we just c...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_hex_to_bytes
Encodes to hexadecimal ids to big-endian binary. :param hex_id: hexadecimal id to encode. :type hex_id: str :return: binary representation. :type: bytes
py_zipkin/encoding/protobuf/__init__.py
def _hex_to_bytes(hex_id): """Encodes to hexadecimal ids to big-endian binary. :param hex_id: hexadecimal id to encode. :type hex_id: str :return: binary representation. :type: bytes """ if len(hex_id) <= 16: int_id = unsigned_hex_to_signed_int(hex_id) return struct.pack('>q...
def _hex_to_bytes(hex_id): """Encodes to hexadecimal ids to big-endian binary. :param hex_id: hexadecimal id to encode. :type hex_id: str :return: binary representation. :type: bytes """ if len(hex_id) <= 16: int_id = unsigned_hex_to_signed_int(hex_id) return struct.pack('>q...
[ "Encodes", "to", "hexadecimal", "ids", "to", "big", "-", "endian", "binary", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L89-L112
[ "def", "_hex_to_bytes", "(", "hex_id", ")", ":", "if", "len", "(", "hex_id", ")", "<=", "16", ":", "int_id", "=", "unsigned_hex_to_signed_int", "(", "hex_id", ")", "return", "struct", ".", "pack", "(", "'>q'", ",", "int_id", ")", "else", ":", "# There's ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_get_protobuf_kind
Converts py_zipkin's Kind to Protobuf's Kind. :param kind: py_zipkin's Kind. :type kind: py_zipkin.Kind :return: correcponding protobuf's kind value. :rtype: zipkin_pb2.Span.Kind
py_zipkin/encoding/protobuf/__init__.py
def _get_protobuf_kind(kind): """Converts py_zipkin's Kind to Protobuf's Kind. :param kind: py_zipkin's Kind. :type kind: py_zipkin.Kind :return: correcponding protobuf's kind value. :rtype: zipkin_pb2.Span.Kind """ if kind == Kind.CLIENT: return zipkin_pb2.Span.CLIENT elif kind...
def _get_protobuf_kind(kind): """Converts py_zipkin's Kind to Protobuf's Kind. :param kind: py_zipkin's Kind. :type kind: py_zipkin.Kind :return: correcponding protobuf's kind value. :rtype: zipkin_pb2.Span.Kind """ if kind == Kind.CLIENT: return zipkin_pb2.Span.CLIENT elif kind...
[ "Converts", "py_zipkin", "s", "Kind", "to", "Protobuf", "s", "Kind", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L115-L131
[ "def", "_get_protobuf_kind", "(", "kind", ")", ":", "if", "kind", "==", "Kind", ".", "CLIENT", ":", "return", "zipkin_pb2", ".", "Span", ".", "CLIENT", "elif", "kind", "==", "Kind", ".", "SERVER", ":", "return", "zipkin_pb2", ".", "Span", ".", "SERVER", ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_convert_endpoint
Converts py_zipkin's Endpoint to Protobuf's Endpoint. :param endpoint: py_zipkins' endpoint to convert. :type endpoint: py_zipkin.encoding.Endpoint :return: corresponding protobuf's endpoint. :rtype: zipkin_pb2.Endpoint
py_zipkin/encoding/protobuf/__init__.py
def _convert_endpoint(endpoint): """Converts py_zipkin's Endpoint to Protobuf's Endpoint. :param endpoint: py_zipkins' endpoint to convert. :type endpoint: py_zipkin.encoding.Endpoint :return: corresponding protobuf's endpoint. :rtype: zipkin_pb2.Endpoint """ pb_endpoint = zipkin_pb2.Endpoi...
def _convert_endpoint(endpoint): """Converts py_zipkin's Endpoint to Protobuf's Endpoint. :param endpoint: py_zipkins' endpoint to convert. :type endpoint: py_zipkin.encoding.Endpoint :return: corresponding protobuf's endpoint. :rtype: zipkin_pb2.Endpoint """ pb_endpoint = zipkin_pb2.Endpoi...
[ "Converts", "py_zipkin", "s", "Endpoint", "to", "Protobuf", "s", "Endpoint", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L134-L153
[ "def", "_convert_endpoint", "(", "endpoint", ")", ":", "pb_endpoint", "=", "zipkin_pb2", ".", "Endpoint", "(", ")", "if", "endpoint", ".", "service_name", ":", "pb_endpoint", ".", "service_name", "=", "endpoint", ".", "service_name", "if", "endpoint", ".", "po...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_convert_annotations
Converts py_zipkin's annotations dict to protobuf. :param annotations: annotations dict. :type annotations: dict :return: corresponding protobuf's list of annotations. :rtype: list
py_zipkin/encoding/protobuf/__init__.py
def _convert_annotations(annotations): """Converts py_zipkin's annotations dict to protobuf. :param annotations: annotations dict. :type annotations: dict :return: corresponding protobuf's list of annotations. :rtype: list """ pb_annotations = [] for value, ts in annotations.items(): ...
def _convert_annotations(annotations): """Converts py_zipkin's annotations dict to protobuf. :param annotations: annotations dict. :type annotations: dict :return: corresponding protobuf's list of annotations. :rtype: list """ pb_annotations = [] for value, ts in annotations.items(): ...
[ "Converts", "py_zipkin", "s", "annotations", "dict", "to", "protobuf", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/protobuf/__init__.py#L156-L170
[ "def", "_convert_annotations", "(", "annotations", ")", ":", "pb_annotations", "=", "[", "]", "for", "value", ",", "ts", "in", "annotations", ".", "items", "(", ")", ":", "pb_annotations", ".", "append", "(", "zipkin_pb2", ".", "Annotation", "(", "timestamp"...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_annotation
Create a zipkin annotation object :param timestamp: timestamp of when the annotation occured in microseconds :param value: name of the annotation, such as 'sr' :param host: zipkin endpoint object :returns: zipkin annotation object
py_zipkin/thrift/__init__.py
def create_annotation(timestamp, value, host): """ Create a zipkin annotation object :param timestamp: timestamp of when the annotation occured in microseconds :param value: name of the annotation, such as 'sr' :param host: zipkin endpoint object :returns: zipkin annotation object """ ...
def create_annotation(timestamp, value, host): """ Create a zipkin annotation object :param timestamp: timestamp of when the annotation occured in microseconds :param value: name of the annotation, such as 'sr' :param host: zipkin endpoint object :returns: zipkin annotation object """ ...
[ "Create", "a", "zipkin", "annotation", "object" ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L24-L34
[ "def", "create_annotation", "(", "timestamp", ",", "value", ",", "host", ")", ":", "return", "zipkin_core", ".", "Annotation", "(", "timestamp", "=", "timestamp", ",", "value", "=", "value", ",", "host", "=", "host", ")" ]
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_binary_annotation
Create a zipkin binary annotation object :param key: name of the annotation, such as 'http.uri' :param value: value of the annotation, such as a URI :param annotation_type: type of annotation, such as AnnotationType.I32 :param host: zipkin endpoint object :returns: zipkin binary annotation object
py_zipkin/thrift/__init__.py
def create_binary_annotation(key, value, annotation_type, host): """ Create a zipkin binary annotation object :param key: name of the annotation, such as 'http.uri' :param value: value of the annotation, such as a URI :param annotation_type: type of annotation, such as AnnotationType.I32 :param...
def create_binary_annotation(key, value, annotation_type, host): """ Create a zipkin binary annotation object :param key: name of the annotation, such as 'http.uri' :param value: value of the annotation, such as a URI :param annotation_type: type of annotation, such as AnnotationType.I32 :param...
[ "Create", "a", "zipkin", "binary", "annotation", "object" ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L37-L53
[ "def", "create_binary_annotation", "(", "key", ",", "value", ",", "annotation_type", ",", "host", ")", ":", "return", "zipkin_core", ".", "BinaryAnnotation", "(", "key", "=", "key", ",", "value", "=", "value", ",", "annotation_type", "=", "annotation_type", ",...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_endpoint
Create a zipkin Endpoint object. An Endpoint object holds information about the network context of a span. :param port: int value of the port. Defaults to 0 :param service_name: service name as a str. Defaults to 'unknown' :param ipv4: ipv4 host address :param ipv6: ipv6 host address :returns:...
py_zipkin/thrift/__init__.py
def create_endpoint(port=0, service_name='unknown', ipv4=None, ipv6=None): """Create a zipkin Endpoint object. An Endpoint object holds information about the network context of a span. :param port: int value of the port. Defaults to 0 :param service_name: service name as a str. Defaults to 'unknown' ...
def create_endpoint(port=0, service_name='unknown', ipv4=None, ipv6=None): """Create a zipkin Endpoint object. An Endpoint object holds information about the network context of a span. :param port: int value of the port. Defaults to 0 :param service_name: service name as a str. Defaults to 'unknown' ...
[ "Create", "a", "zipkin", "Endpoint", "object", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L56-L85
[ "def", "create_endpoint", "(", "port", "=", "0", ",", "service_name", "=", "'unknown'", ",", "ipv4", "=", "None", ",", "ipv6", "=", "None", ")", ":", "ipv4_int", "=", "0", "ipv6_binary", "=", "None", "# Convert ip address to network byte order", "if", "ipv4", ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
copy_endpoint_with_new_service_name
Copies a copy of a given endpoint with a new service name. This should be very fast, on the order of several microseconds. :param endpoint: existing zipkin_core.Endpoint object :param service_name: str of new service name :returns: zipkin Endpoint object
py_zipkin/thrift/__init__.py
def copy_endpoint_with_new_service_name(endpoint, service_name): """Copies a copy of a given endpoint with a new service name. This should be very fast, on the order of several microseconds. :param endpoint: existing zipkin_core.Endpoint object :param service_name: str of new service name :returns:...
def copy_endpoint_with_new_service_name(endpoint, service_name): """Copies a copy of a given endpoint with a new service name. This should be very fast, on the order of several microseconds. :param endpoint: existing zipkin_core.Endpoint object :param service_name: str of new service name :returns:...
[ "Copies", "a", "copy", "of", "a", "given", "endpoint", "with", "a", "new", "service", "name", ".", "This", "should", "be", "very", "fast", "on", "the", "order", "of", "several", "microseconds", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L88-L100
[ "def", "copy_endpoint_with_new_service_name", "(", "endpoint", ",", "service_name", ")", ":", "return", "zipkin_core", ".", "Endpoint", "(", "ipv4", "=", "endpoint", ".", "ipv4", ",", "port", "=", "endpoint", ".", "port", ",", "service_name", "=", "service_name"...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
annotation_list_builder
Reformat annotations dict to return list of corresponding zipkin_core objects. :param annotations: dict containing key as annotation name, value being timestamp in seconds(float). :type host: :class:`zipkin_core.Endpoint` :returns: a list of annotation zipkin_core objects :rtype...
py_zipkin/thrift/__init__.py
def annotation_list_builder(annotations, host): """ Reformat annotations dict to return list of corresponding zipkin_core objects. :param annotations: dict containing key as annotation name, value being timestamp in seconds(float). :type host: :class:`zipkin_core.Endpoint` :...
def annotation_list_builder(annotations, host): """ Reformat annotations dict to return list of corresponding zipkin_core objects. :param annotations: dict containing key as annotation name, value being timestamp in seconds(float). :type host: :class:`zipkin_core.Endpoint` :...
[ "Reformat", "annotations", "dict", "to", "return", "list", "of", "corresponding", "zipkin_core", "objects", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L103-L116
[ "def", "annotation_list_builder", "(", "annotations", ",", "host", ")", ":", "return", "[", "create_annotation", "(", "int", "(", "timestamp", "*", "1000000", ")", ",", "key", ",", "host", ")", "for", "key", ",", "timestamp", "in", "annotations", ".", "ite...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
binary_annotation_list_builder
Reformat binary annotations dict to return list of zipkin_core objects. The value of the binary annotations MUST be in string format. :param binary_annotations: dict with key, value being the name and value of the binary annotation being logged. :type host: :class:`zipkin_cor...
py_zipkin/thrift/__init__.py
def binary_annotation_list_builder(binary_annotations, host): """ Reformat binary annotations dict to return list of zipkin_core objects. The value of the binary annotations MUST be in string format. :param binary_annotations: dict with key, value being the name and value ...
def binary_annotation_list_builder(binary_annotations, host): """ Reformat binary annotations dict to return list of zipkin_core objects. The value of the binary annotations MUST be in string format. :param binary_annotations: dict with key, value being the name and value ...
[ "Reformat", "binary", "annotations", "dict", "to", "return", "list", "of", "zipkin_core", "objects", ".", "The", "value", "of", "the", "binary", "annotations", "MUST", "be", "in", "string", "format", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L119-L135
[ "def", "binary_annotation_list_builder", "(", "binary_annotations", ",", "host", ")", ":", "# TODO: Remove the type hard-coding of STRING to take it as a param option.", "ann_type", "=", "zipkin_core", ".", "AnnotationType", ".", "STRING", "return", "[", "create_binary_annotation...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
create_span
Takes a bunch of span attributes and returns a thriftpy2 representation of the span. Timestamps passed in are in seconds, they're converted to microseconds before thrift encoding.
py_zipkin/thrift/__init__.py
def create_span( span_id, parent_span_id, trace_id, span_name, annotations, binary_annotations, timestamp_s, duration_s, ): """Takes a bunch of span attributes and returns a thriftpy2 representation of the span. Timestamps passed in are in seconds, they're converted to micros...
def create_span( span_id, parent_span_id, trace_id, span_name, annotations, binary_annotations, timestamp_s, duration_s, ): """Takes a bunch of span attributes and returns a thriftpy2 representation of the span. Timestamps passed in are in seconds, they're converted to micros...
[ "Takes", "a", "bunch", "of", "span", "attributes", "and", "returns", "a", "thriftpy2", "representation", "of", "the", "span", ".", "Timestamps", "passed", "in", "are", "in", "seconds", "they", "re", "converted", "to", "microseconds", "before", "thrift", "encod...
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L138-L174
[ "def", "create_span", "(", "span_id", ",", "parent_span_id", ",", "trace_id", ",", "span_name", ",", "annotations", ",", "binary_annotations", ",", "timestamp_s", ",", "duration_s", ",", ")", ":", "# Check if trace_id is 128-bit. If so, record trace_id_high separately.", ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
span_to_bytes
Returns a TBinaryProtocol encoded Thrift span. :param thrift_span: thrift object to encode. :returns: thrift object in TBinaryProtocol format bytes.
py_zipkin/thrift/__init__.py
def span_to_bytes(thrift_span): """ Returns a TBinaryProtocol encoded Thrift span. :param thrift_span: thrift object to encode. :returns: thrift object in TBinaryProtocol format bytes. """ transport = TMemoryBuffer() protocol = TBinaryProtocol(transport) thrift_span.write(protocol) ...
def span_to_bytes(thrift_span): """ Returns a TBinaryProtocol encoded Thrift span. :param thrift_span: thrift object to encode. :returns: thrift object in TBinaryProtocol format bytes. """ transport = TMemoryBuffer() protocol = TBinaryProtocol(transport) thrift_span.write(protocol) ...
[ "Returns", "a", "TBinaryProtocol", "encoded", "Thrift", "span", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L177-L188
[ "def", "span_to_bytes", "(", "thrift_span", ")", ":", "transport", "=", "TMemoryBuffer", "(", ")", "protocol", "=", "TBinaryProtocol", "(", "transport", ")", "thrift_span", ".", "write", "(", "protocol", ")", "return", "bytes", "(", "transport", ".", "getvalue...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
encode_bytes_list
Returns a TBinaryProtocol encoded list of Thrift objects. :param binary_thrift_obj_list: list of TBinaryProtocol objects to encode. :returns: bynary object representing the encoded list.
py_zipkin/thrift/__init__.py
def encode_bytes_list(binary_thrift_obj_list): # pragma: no cover """ Returns a TBinaryProtocol encoded list of Thrift objects. :param binary_thrift_obj_list: list of TBinaryProtocol objects to encode. :returns: bynary object representing the encoded list. """ transport = TMemoryBuffer() w...
def encode_bytes_list(binary_thrift_obj_list): # pragma: no cover """ Returns a TBinaryProtocol encoded list of Thrift objects. :param binary_thrift_obj_list: list of TBinaryProtocol objects to encode. :returns: bynary object representing the encoded list. """ transport = TMemoryBuffer() w...
[ "Returns", "a", "TBinaryProtocol", "encoded", "list", "of", "Thrift", "objects", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thrift/__init__.py#L191-L203
[ "def", "encode_bytes_list", "(", "binary_thrift_obj_list", ")", ":", "# pragma: no cover", "transport", "=", "TMemoryBuffer", "(", ")", "write_list_begin", "(", "transport", ",", "TType", ".", "STRUCT", ",", "len", "(", "binary_thrift_obj_list", ")", ")", "for", "...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
detect_span_version_and_encoding
Returns the span type and encoding for the message provided. The logic in this function is a Python port of https://github.com/openzipkin/zipkin/blob/master/zipkin/src/main/java/zipkin/internal/DetectingSpanDecoder.java :param message: span to perform operations on. :type message: byte array :retu...
py_zipkin/encoding/__init__.py
def detect_span_version_and_encoding(message): """Returns the span type and encoding for the message provided. The logic in this function is a Python port of https://github.com/openzipkin/zipkin/blob/master/zipkin/src/main/java/zipkin/internal/DetectingSpanDecoder.java :param message: span to perform ...
def detect_span_version_and_encoding(message): """Returns the span type and encoding for the message provided. The logic in this function is a Python port of https://github.com/openzipkin/zipkin/blob/master/zipkin/src/main/java/zipkin/internal/DetectingSpanDecoder.java :param message: span to perform ...
[ "Returns", "the", "span", "type", "and", "encoding", "for", "the", "message", "provided", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/__init__.py#L16-L69
[ "def", "detect_span_version_and_encoding", "(", "message", ")", ":", "# In case message is sent in as non-bytearray format,", "# safeguard convert to bytearray before handling", "if", "isinstance", "(", "message", ",", "six", ".", "string_types", ")", ":", "# Even six.b is not en...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
convert_spans
Converts encoded spans to a different encoding. param spans: encoded input spans. type spans: byte array param output_encoding: desired output encoding. type output_encoding: Encoding param input_encoding: optional input encoding. If this is not specified, it'll try to understand the encodi...
py_zipkin/encoding/__init__.py
def convert_spans(spans, output_encoding, input_encoding=None): """Converts encoded spans to a different encoding. param spans: encoded input spans. type spans: byte array param output_encoding: desired output encoding. type output_encoding: Encoding param input_encoding: optional input encodin...
def convert_spans(spans, output_encoding, input_encoding=None): """Converts encoded spans to a different encoding. param spans: encoded input spans. type spans: byte array param output_encoding: desired output encoding. type output_encoding: Encoding param input_encoding: optional input encodin...
[ "Converts", "encoded", "spans", "to", "a", "different", "encoding", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/__init__.py#L72-L101
[ "def", "convert_spans", "(", "spans", ",", "output_encoding", ",", "input_encoding", "=", "None", ")", ":", "if", "not", "isinstance", "(", "input_encoding", ",", "Encoding", ")", ":", "input_encoding", "=", "detect_span_version_and_encoding", "(", "message", "=",...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
push_zipkin_attrs
Stores the zipkin attributes to thread local. .. deprecated:: Use the Tracer interface which offers better multi-threading support. push_zipkin_attrs will be removed in version 1.0. :param zipkin_attr: tuple containing zipkin related attrs :type zipkin_attr: :class:`zipkin.ZipkinAttrs`
py_zipkin/thread_local.py
def push_zipkin_attrs(zipkin_attr): """Stores the zipkin attributes to thread local. .. deprecated:: Use the Tracer interface which offers better multi-threading support. push_zipkin_attrs will be removed in version 1.0. :param zipkin_attr: tuple containing zipkin related attrs :type zip...
def push_zipkin_attrs(zipkin_attr): """Stores the zipkin attributes to thread local. .. deprecated:: Use the Tracer interface which offers better multi-threading support. push_zipkin_attrs will be removed in version 1.0. :param zipkin_attr: tuple containing zipkin related attrs :type zip...
[ "Stores", "the", "zipkin", "attributes", "to", "thread", "local", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/thread_local.py#L78-L91
[ "def", "push_zipkin_attrs", "(", "zipkin_attr", ")", ":", "from", "py_zipkin", ".", "storage", "import", "ThreadLocalStack", "log", ".", "warning", "(", "'push_zipkin_attrs is deprecated. See DEPRECATIONS.rst for'", "'details on how to migrate to using Tracer.'", ")", "return",...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
generate_random_128bit_string
Returns a 128 bit UTF-8 encoded string. Follows the same conventions as generate_random_64bit_string(). The upper 32 bits are the current time in epoch seconds, and the lower 96 bits are random. This allows for AWS X-Ray `interop <https://github.com/openzipkin/zipkin/issues/1754>`_ :returns: 32-ch...
py_zipkin/util.py
def generate_random_128bit_string(): """Returns a 128 bit UTF-8 encoded string. Follows the same conventions as generate_random_64bit_string(). The upper 32 bits are the current time in epoch seconds, and the lower 96 bits are random. This allows for AWS X-Ray `interop <https://github.com/openzipki...
def generate_random_128bit_string(): """Returns a 128 bit UTF-8 encoded string. Follows the same conventions as generate_random_64bit_string(). The upper 32 bits are the current time in epoch seconds, and the lower 96 bits are random. This allows for AWS X-Ray `interop <https://github.com/openzipki...
[ "Returns", "a", "128", "bit", "UTF", "-", "8", "encoded", "string", ".", "Follows", "the", "same", "conventions", "as", "generate_random_64bit_string", "()", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/util.py#L17-L29
[ "def", "generate_random_128bit_string", "(", ")", ":", "t", "=", "int", "(", "time", ".", "time", "(", ")", ")", "lower_96", "=", "random", ".", "getrandbits", "(", "96", ")", "return", "'{:032x}'", ".", "format", "(", "(", "t", "<<", "96", ")", "|",...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
get_encoder
Creates encoder object for the given encoding. :param encoding: desired output encoding protocol. :type encoding: Encoding :return: corresponding IEncoder object :rtype: IEncoder
py_zipkin/encoding/_encoders.py
def get_encoder(encoding): """Creates encoder object for the given encoding. :param encoding: desired output encoding protocol. :type encoding: Encoding :return: corresponding IEncoder object :rtype: IEncoder """ if encoding == Encoding.V1_THRIFT: return _V1ThriftEncoder() if en...
def get_encoder(encoding): """Creates encoder object for the given encoding. :param encoding: desired output encoding protocol. :type encoding: Encoding :return: corresponding IEncoder object :rtype: IEncoder """ if encoding == Encoding.V1_THRIFT: return _V1ThriftEncoder() if en...
[ "Creates", "encoder", "object", "for", "the", "given", "encoding", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L11-L27
[ "def", "get_encoder", "(", "encoding", ")", ":", "if", "encoding", "==", "Encoding", ".", "V1_THRIFT", ":", "return", "_V1ThriftEncoder", "(", ")", "if", "encoding", "==", "Encoding", ".", "V1_JSON", ":", "return", "_V1JSONEncoder", "(", ")", "if", "encoding...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_V1ThriftEncoder.fits
Checks if the new span fits in the max payload size. Thrift lists have a fixed-size header and no delimiters between elements so it's easy to compute the list size.
py_zipkin/encoding/_encoders.py
def fits(self, current_count, current_size, max_size, new_span): """Checks if the new span fits in the max payload size. Thrift lists have a fixed-size header and no delimiters between elements so it's easy to compute the list size. """ return thrift.LIST_HEADER_SIZE + current_s...
def fits(self, current_count, current_size, max_size, new_span): """Checks if the new span fits in the max payload size. Thrift lists have a fixed-size header and no delimiters between elements so it's easy to compute the list size. """ return thrift.LIST_HEADER_SIZE + current_s...
[ "Checks", "if", "the", "new", "span", "fits", "in", "the", "max", "payload", "size", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L73-L79
[ "def", "fits", "(", "self", ",", "current_count", ",", "current_size", ",", "max_size", ",", "new_span", ")", ":", "return", "thrift", ".", "LIST_HEADER_SIZE", "+", "current_size", "+", "len", "(", "new_span", ")", "<=", "max_size" ]
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_V1ThriftEncoder.encode_span
Encodes the current span to thrift.
py_zipkin/encoding/_encoders.py
def encode_span(self, v2_span): """Encodes the current span to thrift.""" span = v2_span.build_v1_span() thrift_endpoint = thrift.create_endpoint( span.endpoint.port, span.endpoint.service_name, span.endpoint.ipv4, span.endpoint.ipv6, ) ...
def encode_span(self, v2_span): """Encodes the current span to thrift.""" span = v2_span.build_v1_span() thrift_endpoint = thrift.create_endpoint( span.endpoint.port, span.endpoint.service_name, span.endpoint.ipv4, span.endpoint.ipv6, ) ...
[ "Encodes", "the", "current", "span", "to", "thrift", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L100-L141
[ "def", "encode_span", "(", "self", ",", "v2_span", ")", ":", "span", "=", "v2_span", ".", "build_v1_span", "(", ")", "thrift_endpoint", "=", "thrift", ".", "create_endpoint", "(", "span", ".", "endpoint", ".", "port", ",", "span", ".", "endpoint", ".", "...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_BaseJSONEncoder._create_json_endpoint
Converts an Endpoint to a JSON endpoint dict. :param endpoint: endpoint object to convert. :type endpoint: Endpoint :param is_v1: whether we're serializing a v1 span. This is needed since in v1 some fields default to an empty string rather than being dropped if they're n...
py_zipkin/encoding/_encoders.py
def _create_json_endpoint(self, endpoint, is_v1): """Converts an Endpoint to a JSON endpoint dict. :param endpoint: endpoint object to convert. :type endpoint: Endpoint :param is_v1: whether we're serializing a v1 span. This is needed since in v1 some fields default to an em...
def _create_json_endpoint(self, endpoint, is_v1): """Converts an Endpoint to a JSON endpoint dict. :param endpoint: endpoint object to convert. :type endpoint: Endpoint :param is_v1: whether we're serializing a v1 span. This is needed since in v1 some fields default to an em...
[ "Converts", "an", "Endpoint", "to", "a", "JSON", "endpoint", "dict", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L159-L185
[ "def", "_create_json_endpoint", "(", "self", ",", "endpoint", ",", "is_v1", ")", ":", "json_endpoint", "=", "{", "}", "if", "endpoint", ".", "service_name", ":", "json_endpoint", "[", "'serviceName'", "]", "=", "endpoint", ".", "service_name", "elif", "is_v1",...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_V1JSONEncoder.encode_span
Encodes a single span to JSON.
py_zipkin/encoding/_encoders.py
def encode_span(self, v2_span): """Encodes a single span to JSON.""" span = v2_span.build_v1_span() json_span = { 'traceId': span.trace_id, 'name': span.name, 'id': span.id, 'annotations': [], 'binaryAnnotations': [], } ...
def encode_span(self, v2_span): """Encodes a single span to JSON.""" span = v2_span.build_v1_span() json_span = { 'traceId': span.trace_id, 'name': span.name, 'id': span.id, 'annotations': [], 'binaryAnnotations': [], } ...
[ "Encodes", "a", "single", "span", "to", "JSON", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L208-L253
[ "def", "encode_span", "(", "self", ",", "v2_span", ")", ":", "span", "=", "v2_span", ".", "build_v1_span", "(", ")", "json_span", "=", "{", "'traceId'", ":", "span", ".", "trace_id", ",", "'name'", ":", "span", ".", "name", ",", "'id'", ":", "span", ...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba
test
_V2JSONEncoder.encode_span
Encodes a single span to JSON.
py_zipkin/encoding/_encoders.py
def encode_span(self, span): """Encodes a single span to JSON.""" json_span = { 'traceId': span.trace_id, 'id': span.span_id, } if span.name: json_span['name'] = span.name if span.parent_id: json_span['parentId'] = span.parent_id ...
def encode_span(self, span): """Encodes a single span to JSON.""" json_span = { 'traceId': span.trace_id, 'id': span.span_id, } if span.name: json_span['name'] = span.name if span.parent_id: json_span['parentId'] = span.parent_id ...
[ "Encodes", "a", "single", "span", "to", "JSON", "." ]
Yelp/py_zipkin
python
https://github.com/Yelp/py_zipkin/blob/0944d9a3fb1f1798dbb276694aeed99f2b4283ba/py_zipkin/encoding/_encoders.py#L259-L303
[ "def", "encode_span", "(", "self", ",", "span", ")", ":", "json_span", "=", "{", "'traceId'", ":", "span", ".", "trace_id", ",", "'id'", ":", "span", ".", "span_id", ",", "}", "if", "span", ".", "name", ":", "json_span", "[", "'name'", "]", "=", "s...
0944d9a3fb1f1798dbb276694aeed99f2b4283ba