repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ergoithz/browsepy
browsepy/compat.py
re_escape
def re_escape(pattern, chars=frozenset("()[]{}?*+|^$\\.-#")): ''' Escape all special regex characters in pattern. Logic taken from regex module. :param pattern: regex pattern to escape :type patterm: str :returns: escaped pattern :rtype: str ''' escape = '\\{}'.format return ''....
python
def re_escape(pattern, chars=frozenset("()[]{}?*+|^$\\.-#")): ''' Escape all special regex characters in pattern. Logic taken from regex module. :param pattern: regex pattern to escape :type patterm: str :returns: escaped pattern :rtype: str ''' escape = '\\{}'.format return ''....
[ "def", "re_escape", "(", "pattern", ",", "chars", "=", "frozenset", "(", "\"()[]{}?*+|^$\\\\.-#\"", ")", ")", ":", "escape", "=", "'\\\\{}'", ".", "format", "return", "''", ".", "join", "(", "escape", "(", "c", ")", "if", "c", "in", "chars", "or", "c",...
Escape all special regex characters in pattern. Logic taken from regex module. :param pattern: regex pattern to escape :type patterm: str :returns: escaped pattern :rtype: str
[ "Escape", "all", "special", "regex", "characters", "in", "pattern", ".", "Logic", "taken", "from", "regex", "module", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/compat.py#L297-L312
ergoithz/browsepy
browsepy/plugin/player/__init__.py
register_plugin
def register_plugin(manager): ''' Register blueprints and actions using given plugin manager. :param manager: plugin manager :type manager: browsepy.manager.PluginManager ''' manager.register_blueprint(player) manager.register_mimetype_function(detect_playable_mimetype) # add style tag...
python
def register_plugin(manager): ''' Register blueprints and actions using given plugin manager. :param manager: plugin manager :type manager: browsepy.manager.PluginManager ''' manager.register_blueprint(player) manager.register_mimetype_function(detect_playable_mimetype) # add style tag...
[ "def", "register_plugin", "(", "manager", ")", ":", "manager", ".", "register_blueprint", "(", "player", ")", "manager", ".", "register_mimetype_function", "(", "detect_playable_mimetype", ")", "# add style tag", "manager", ".", "register_widget", "(", "place", "=", ...
Register blueprints and actions using given plugin manager. :param manager: plugin manager :type manager: browsepy.manager.PluginManager
[ "Register", "blueprints", "and", "actions", "using", "given", "plugin", "manager", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/plugin/player/__init__.py#L93-L151
ergoithz/browsepy
browsepy/file.py
fmt_size
def fmt_size(size, binary=True): ''' Get size and unit. :param size: size in bytes :type size: int :param binary: whether use binary or standard units, defaults to True :type binary: bool :return: size and unit :rtype: tuple of int and unit as str ''' if binary: fmt_size...
python
def fmt_size(size, binary=True): ''' Get size and unit. :param size: size in bytes :type size: int :param binary: whether use binary or standard units, defaults to True :type binary: bool :return: size and unit :rtype: tuple of int and unit as str ''' if binary: fmt_size...
[ "def", "fmt_size", "(", "size", ",", "binary", "=", "True", ")", ":", "if", "binary", ":", "fmt_sizes", "=", "binary_units", "fmt_divider", "=", "1024.", "else", ":", "fmt_sizes", "=", "standard_units", "fmt_divider", "=", "1000.", "for", "fmt", "in", "fmt...
Get size and unit. :param size: size in bytes :type size: int :param binary: whether use binary or standard units, defaults to True :type binary: bool :return: size and unit :rtype: tuple of int and unit as str
[ "Get", "size", "and", "unit", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L721-L742
ergoithz/browsepy
browsepy/file.py
relativize_path
def relativize_path(path, base, os_sep=os.sep): ''' Make absolute path relative to an absolute base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path component separator, defaults to current OS separator :type os_sep: str ...
python
def relativize_path(path, base, os_sep=os.sep): ''' Make absolute path relative to an absolute base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path component separator, defaults to current OS separator :type os_sep: str ...
[ "def", "relativize_path", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "if", "not", "check_base", "(", "path", ",", "base", ",", "os_sep", ")", ":", "raise", "OutsideDirectoryBase", "(", "\"%r is not under %r\"", "%", "(", "p...
Make absolute path relative to an absolute base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path component separator, defaults to current OS separator :type os_sep: str :return: relative path :rtype: str or unicode :rais...
[ "Make", "absolute", "path", "relative", "to", "an", "absolute", "base", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L745-L764
ergoithz/browsepy
browsepy/file.py
abspath_to_urlpath
def abspath_to_urlpath(path, base, os_sep=os.sep): ''' Make filesystem absolute path uri relative using given absolute base path. :param path: absolute path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: relative uri :rtype...
python
def abspath_to_urlpath(path, base, os_sep=os.sep): ''' Make filesystem absolute path uri relative using given absolute base path. :param path: absolute path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: relative uri :rtype...
[ "def", "abspath_to_urlpath", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "return", "relativize_path", "(", "path", ",", "base", ",", "os_sep", ")", ".", "replace", "(", "os_sep", ",", "'/'", ")" ]
Make filesystem absolute path uri relative using given absolute base path. :param path: absolute path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: relative uri :rtype: str or unicode :raises OutsideDirectoryBase: if resulting...
[ "Make", "filesystem", "absolute", "path", "uri", "relative", "using", "given", "absolute", "base", "path", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L767-L778
ergoithz/browsepy
browsepy/file.py
urlpath_to_abspath
def urlpath_to_abspath(path, base, os_sep=os.sep): ''' Make uri relative path fs absolute using a given absolute base path. :param path: relative path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: absolute path :rtype: str...
python
def urlpath_to_abspath(path, base, os_sep=os.sep): ''' Make uri relative path fs absolute using a given absolute base path. :param path: relative path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: absolute path :rtype: str...
[ "def", "urlpath_to_abspath", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "prefix", "=", "base", "if", "base", ".", "endswith", "(", "os_sep", ")", "else", "base", "+", "os_sep", "realpath", "=", "os", ".", "path", ".", ...
Make uri relative path fs absolute using a given absolute base path. :param path: relative path :param base: absolute base path :param os_sep: path component separator, defaults to current OS separator :return: absolute path :rtype: str or unicode :raises OutsideDirectoryBase: if resulting path...
[ "Make", "uri", "relative", "path", "fs", "absolute", "using", "a", "given", "absolute", "base", "path", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L781-L796
ergoithz/browsepy
browsepy/file.py
generic_filename
def generic_filename(path): ''' Extract filename of given path os-indepently, taking care of known path separators. :param path: path :return: filename :rtype: str or unicode (depending on given path) ''' for sep in common_path_separators: if sep in path: _, path = ...
python
def generic_filename(path): ''' Extract filename of given path os-indepently, taking care of known path separators. :param path: path :return: filename :rtype: str or unicode (depending on given path) ''' for sep in common_path_separators: if sep in path: _, path = ...
[ "def", "generic_filename", "(", "path", ")", ":", "for", "sep", "in", "common_path_separators", ":", "if", "sep", "in", "path", ":", "_", ",", "path", "=", "path", ".", "rsplit", "(", "sep", ",", "1", ")", "return", "path" ]
Extract filename of given path os-indepently, taking care of known path separators. :param path: path :return: filename :rtype: str or unicode (depending on given path)
[ "Extract", "filename", "of", "given", "path", "os", "-", "indepently", "taking", "care", "of", "known", "path", "separators", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L799-L812
ergoithz/browsepy
browsepy/file.py
clean_restricted_chars
def clean_restricted_chars(path, restricted_chars=restricted_chars): ''' Get path without restricted characters. :param path: path :return: path without restricted characters :rtype: str or unicode (depending on given path) ''' for character in restricted_chars: path = path.replace(...
python
def clean_restricted_chars(path, restricted_chars=restricted_chars): ''' Get path without restricted characters. :param path: path :return: path without restricted characters :rtype: str or unicode (depending on given path) ''' for character in restricted_chars: path = path.replace(...
[ "def", "clean_restricted_chars", "(", "path", ",", "restricted_chars", "=", "restricted_chars", ")", ":", "for", "character", "in", "restricted_chars", ":", "path", "=", "path", ".", "replace", "(", "character", ",", "'_'", ")", "return", "path" ]
Get path without restricted characters. :param path: path :return: path without restricted characters :rtype: str or unicode (depending on given path)
[ "Get", "path", "without", "restricted", "characters", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L815-L825
ergoithz/browsepy
browsepy/file.py
check_forbidden_filename
def check_forbidden_filename(filename, destiny_os=os.name, restricted_names=restricted_names): ''' Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_en...
python
def check_forbidden_filename(filename, destiny_os=os.name, restricted_names=restricted_names): ''' Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_en...
[ "def", "check_forbidden_filename", "(", "filename", ",", "destiny_os", "=", "os", ".", "name", ",", "restricted_names", "=", "restricted_names", ")", ":", "return", "(", "filename", "in", "restricted_names", "or", "destiny_os", "==", "'nt'", "and", "filename", "...
Get if given filename is forbidden for current OS or filesystem. :param filename: :param destiny_os: destination operative system :param fs_encoding: destination filesystem filename encoding :return: wether is forbidden on given OS (or filesystem) or not :rtype: bool
[ "Get", "if", "given", "filename", "is", "forbidden", "for", "current", "OS", "or", "filesystem", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L828-L844
ergoithz/browsepy
browsepy/file.py
check_path
def check_path(path, base, os_sep=os.sep): ''' Check if both given paths are equal. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :type base: str :return: wether two path are equal or not ...
python
def check_path(path, base, os_sep=os.sep): ''' Check if both given paths are equal. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :type base: str :return: wether two path are equal or not ...
[ "def", "check_path", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "base", "=", "base", "[", ":", "-", "len", "(", "os_sep", ")", "]", "if", "base", ".", "endswith", "(", "os_sep", ")", "else", "base", "return", "os", ...
Check if both given paths are equal. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :type base: str :return: wether two path are equal or not :rtype: bool
[ "Check", "if", "both", "given", "paths", "are", "equal", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L847-L861
ergoithz/browsepy
browsepy/file.py
check_base
def check_base(path, base, os_sep=os.sep): ''' Check if given absolute path is under or given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether path is under given base or no...
python
def check_base(path, base, os_sep=os.sep): ''' Check if given absolute path is under or given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether path is under given base or no...
[ "def", "check_base", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "return", "(", "check_path", "(", "path", ",", "base", ",", "os_sep", ")", "or", "check_under_base", "(", "path", ",", "base", ",", "os_sep", ")", ")" ]
Check if given absolute path is under or given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether path is under given base or not :rtype: bool
[ "Check", "if", "given", "absolute", "path", "is", "under", "or", "given", "base", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L864-L879
ergoithz/browsepy
browsepy/file.py
check_under_base
def check_under_base(path, base, os_sep=os.sep): ''' Check if given absolute path is under given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether file is under given base or...
python
def check_under_base(path, base, os_sep=os.sep): ''' Check if given absolute path is under given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether file is under given base or...
[ "def", "check_under_base", "(", "path", ",", "base", ",", "os_sep", "=", "os", ".", "sep", ")", ":", "prefix", "=", "base", "if", "base", ".", "endswith", "(", "os_sep", ")", "else", "base", "+", "os_sep", "return", "os", ".", "path", ".", "normcase"...
Check if given absolute path is under given base. :param path: absolute path :type path: str :param base: absolute base path :type base: str :param os_sep: path separator, defaults to os.sep :return: wether file is under given base or not :rtype: bool
[ "Check", "if", "given", "absolute", "path", "is", "under", "given", "base", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L882-L895
ergoithz/browsepy
browsepy/file.py
secure_filename
def secure_filename(path, destiny_os=os.name, fs_encoding=compat.FS_ENCODING): ''' Get rid of parent path components and special filenames. If path is invalid or protected, return empty string. :param path: unsafe path, only basename will be used :type: str :param destiny_os: destination opera...
python
def secure_filename(path, destiny_os=os.name, fs_encoding=compat.FS_ENCODING): ''' Get rid of parent path components and special filenames. If path is invalid or protected, return empty string. :param path: unsafe path, only basename will be used :type: str :param destiny_os: destination opera...
[ "def", "secure_filename", "(", "path", ",", "destiny_os", "=", "os", ".", "name", ",", "fs_encoding", "=", "compat", ".", "FS_ENCODING", ")", ":", "path", "=", "generic_filename", "(", "path", ")", "path", "=", "clean_restricted_chars", "(", "path", ",", "...
Get rid of parent path components and special filenames. If path is invalid or protected, return empty string. :param path: unsafe path, only basename will be used :type: str :param destiny_os: destination operative system (defaults to os.name) :type destiny_os: str :param fs_encoding: fs path...
[ "Get", "rid", "of", "parent", "path", "components", "and", "special", "filenames", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L898-L938
ergoithz/browsepy
browsepy/file.py
alternative_filename
def alternative_filename(filename, attempt=None): ''' Generates an alternative version of given filename. If an number attempt parameter is given, will be used on the alternative name, a random value will be used otherwise. :param filename: original filename :param attempt: optional attempt nu...
python
def alternative_filename(filename, attempt=None): ''' Generates an alternative version of given filename. If an number attempt parameter is given, will be used on the alternative name, a random value will be used otherwise. :param filename: original filename :param attempt: optional attempt nu...
[ "def", "alternative_filename", "(", "filename", ",", "attempt", "=", "None", ")", ":", "filename_parts", "=", "filename", ".", "rsplit", "(", "u'.'", ",", "2", ")", "name", "=", "filename_parts", "[", "0", "]", "ext", "=", "''", ".", "join", "(", "u'.%...
Generates an alternative version of given filename. If an number attempt parameter is given, will be used on the alternative name, a random value will be used otherwise. :param filename: original filename :param attempt: optional attempt number, defaults to null :return: new filename :rtype: s...
[ "Generates", "an", "alternative", "version", "of", "given", "filename", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L941-L961
ergoithz/browsepy
browsepy/file.py
scandir
def scandir(path, app=None): ''' Config-aware scandir. Currently, only aware of ``exclude_fnc``. :param path: absolute path :type path: str :param app: flask application :type app: flask.Flask or None :returns: filtered scandir entries :rtype: iterator ''' exclude = app and app....
python
def scandir(path, app=None): ''' Config-aware scandir. Currently, only aware of ``exclude_fnc``. :param path: absolute path :type path: str :param app: flask application :type app: flask.Flask or None :returns: filtered scandir entries :rtype: iterator ''' exclude = app and app....
[ "def", "scandir", "(", "path", ",", "app", "=", "None", ")", ":", "exclude", "=", "app", "and", "app", ".", "config", ".", "get", "(", "'exclude_fnc'", ")", "if", "exclude", ":", "return", "(", "item", "for", "item", "in", "compat", ".", "scandir", ...
Config-aware scandir. Currently, only aware of ``exclude_fnc``. :param path: absolute path :type path: str :param app: flask application :type app: flask.Flask or None :returns: filtered scandir entries :rtype: iterator
[ "Config", "-", "aware", "scandir", ".", "Currently", "only", "aware", "of", "exclude_fnc", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L964-L982
ergoithz/browsepy
browsepy/file.py
Node.is_excluded
def is_excluded(self): ''' Get if current node shouldn't be shown, using :attt:`app` config's exclude_fnc. :returns: True if excluded, False otherwise ''' exclude = self.app and self.app.config['exclude_fnc'] return exclude and exclude(self.path)
python
def is_excluded(self): ''' Get if current node shouldn't be shown, using :attt:`app` config's exclude_fnc. :returns: True if excluded, False otherwise ''' exclude = self.app and self.app.config['exclude_fnc'] return exclude and exclude(self.path)
[ "def", "is_excluded", "(", "self", ")", ":", "exclude", "=", "self", ".", "app", "and", "self", ".", "app", ".", "config", "[", "'exclude_fnc'", "]", "return", "exclude", "and", "exclude", "(", "self", ".", "path", ")" ]
Get if current node shouldn't be shown, using :attt:`app` config's exclude_fnc. :returns: True if excluded, False otherwise
[ "Get", "if", "current", "node", "shouldn", "t", "be", "shown", "using", ":", "attt", ":", "app", "config", "s", "exclude_fnc", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L68-L76
ergoithz/browsepy
browsepy/file.py
Node.widgets
def widgets(self): ''' List widgets with filter return True for this node (or without filter). Remove button is prepended if :property:can_remove returns true. :returns: list of widgets :rtype: list of namedtuple instances ''' widgets = [] if self.can_re...
python
def widgets(self): ''' List widgets with filter return True for this node (or without filter). Remove button is prepended if :property:can_remove returns true. :returns: list of widgets :rtype: list of namedtuple instances ''' widgets = [] if self.can_re...
[ "def", "widgets", "(", "self", ")", ":", "widgets", "=", "[", "]", "if", "self", ".", "can_remove", ":", "widgets", ".", "append", "(", "self", ".", "plugin_manager", ".", "create_widget", "(", "'entry-actions'", ",", "'button'", ",", "file", "=", "self"...
List widgets with filter return True for this node (or without filter). Remove button is prepended if :property:can_remove returns true. :returns: list of widgets :rtype: list of namedtuple instances
[ "List", "widgets", "with", "filter", "return", "True", "for", "this", "node", "(", "or", "without", "filter", ")", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L88-L108
ergoithz/browsepy
browsepy/file.py
Node.link
def link(self): ''' Get last widget with place "entry-link". :returns: widget on entry-link (ideally a link one) :rtype: namedtuple instance ''' link = None for widget in self.widgets: if widget.place == 'entry-link': link = widget ...
python
def link(self): ''' Get last widget with place "entry-link". :returns: widget on entry-link (ideally a link one) :rtype: namedtuple instance ''' link = None for widget in self.widgets: if widget.place == 'entry-link': link = widget ...
[ "def", "link", "(", "self", ")", ":", "link", "=", "None", "for", "widget", "in", "self", ".", "widgets", ":", "if", "widget", ".", "place", "==", "'entry-link'", ":", "link", "=", "widget", "return", "link" ]
Get last widget with place "entry-link". :returns: widget on entry-link (ideally a link one) :rtype: namedtuple instance
[ "Get", "last", "widget", "with", "place", "entry", "-", "link", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L111-L122
ergoithz/browsepy
browsepy/file.py
Node.can_remove
def can_remove(self): ''' Get if current node can be removed based on app config's directory_remove. :returns: True if current node can be removed, False otherwise. :rtype: bool ''' dirbase = self.app.config["directory_remove"] return bool(dirbase and che...
python
def can_remove(self): ''' Get if current node can be removed based on app config's directory_remove. :returns: True if current node can be removed, False otherwise. :rtype: bool ''' dirbase = self.app.config["directory_remove"] return bool(dirbase and che...
[ "def", "can_remove", "(", "self", ")", ":", "dirbase", "=", "self", ".", "app", ".", "config", "[", "\"directory_remove\"", "]", "return", "bool", "(", "dirbase", "and", "check_under_base", "(", "self", ".", "path", ",", "dirbase", ")", ")" ]
Get if current node can be removed based on app config's directory_remove. :returns: True if current node can be removed, False otherwise. :rtype: bool
[ "Get", "if", "current", "node", "can", "be", "removed", "based", "on", "app", "config", "s", "directory_remove", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L125-L134
ergoithz/browsepy
browsepy/file.py
Node.parent
def parent(self): ''' Get parent node if available based on app config's directory_base. :returns: parent object if available :rtype: Node instance or None ''' if check_path(self.path, self.app.config['directory_base']): return None parent = os.path.d...
python
def parent(self): ''' Get parent node if available based on app config's directory_base. :returns: parent object if available :rtype: Node instance or None ''' if check_path(self.path, self.app.config['directory_base']): return None parent = os.path.d...
[ "def", "parent", "(", "self", ")", ":", "if", "check_path", "(", "self", ".", "path", ",", "self", ".", "app", ".", "config", "[", "'directory_base'", "]", ")", ":", "return", "None", "parent", "=", "os", ".", "path", ".", "dirname", "(", "self", "...
Get parent node if available based on app config's directory_base. :returns: parent object if available :rtype: Node instance or None
[ "Get", "parent", "node", "if", "available", "based", "on", "app", "config", "s", "directory_base", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L158-L168
ergoithz/browsepy
browsepy/file.py
Node.ancestors
def ancestors(self): ''' Get list of ancestors until app config's directory_base is reached. :returns: list of ancestors starting from nearest. :rtype: list of Node objects ''' ancestors = [] parent = self.parent while parent: ancestors.append...
python
def ancestors(self): ''' Get list of ancestors until app config's directory_base is reached. :returns: list of ancestors starting from nearest. :rtype: list of Node objects ''' ancestors = [] parent = self.parent while parent: ancestors.append...
[ "def", "ancestors", "(", "self", ")", ":", "ancestors", "=", "[", "]", "parent", "=", "self", ".", "parent", "while", "parent", ":", "ancestors", ".", "append", "(", "parent", ")", "parent", "=", "parent", ".", "parent", "return", "ancestors" ]
Get list of ancestors until app config's directory_base is reached. :returns: list of ancestors starting from nearest. :rtype: list of Node objects
[ "Get", "list", "of", "ancestors", "until", "app", "config", "s", "directory_base", "is", "reached", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L171-L183
ergoithz/browsepy
browsepy/file.py
Node.modified
def modified(self): ''' Get human-readable last modification date-time. :returns: iso9008-like date-time string (without timezone) :rtype: str ''' try: dt = datetime.datetime.fromtimestamp(self.stats.st_mtime) return dt.strftime('%Y.%m.%d %H:%M:%S...
python
def modified(self): ''' Get human-readable last modification date-time. :returns: iso9008-like date-time string (without timezone) :rtype: str ''' try: dt = datetime.datetime.fromtimestamp(self.stats.st_mtime) return dt.strftime('%Y.%m.%d %H:%M:%S...
[ "def", "modified", "(", "self", ")", ":", "try", ":", "dt", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "self", ".", "stats", ".", "st_mtime", ")", "return", "dt", ".", "strftime", "(", "'%Y.%m.%d %H:%M:%S'", ")", "except", "OSError", ":...
Get human-readable last modification date-time. :returns: iso9008-like date-time string (without timezone) :rtype: str
[ "Get", "human", "-", "readable", "last", "modification", "date", "-", "time", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L186-L197
ergoithz/browsepy
browsepy/file.py
Node.from_urlpath
def from_urlpath(cls, path, app=None): ''' Alternative constructor which accepts a path as taken from URL and uses the given app or the current app config to get the real path. If class has attribute `generic` set to True, `directory_class` or `file_class` will be used as type. ...
python
def from_urlpath(cls, path, app=None): ''' Alternative constructor which accepts a path as taken from URL and uses the given app or the current app config to get the real path. If class has attribute `generic` set to True, `directory_class` or `file_class` will be used as type. ...
[ "def", "from_urlpath", "(", "cls", ",", "path", ",", "app", "=", "None", ")", ":", "app", "=", "app", "or", "current_app", "base", "=", "app", ".", "config", "[", "'directory_base'", "]", "path", "=", "urlpath_to_abspath", "(", "path", ",", "base", ")"...
Alternative constructor which accepts a path as taken from URL and uses the given app or the current app config to get the real path. If class has attribute `generic` set to True, `directory_class` or `file_class` will be used as type. :param path: relative path as from URL :pa...
[ "Alternative", "constructor", "which", "accepts", "a", "path", "as", "taken", "from", "URL", "and", "uses", "the", "given", "app", "or", "the", "current", "app", "config", "to", "get", "the", "real", "path", "." ]
train
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/file.py#L274-L296
brutasse/graphite-api
graphite_api/finders/whisper.py
WhisperFinder._find_paths
def _find_paths(self, current_dir, patterns): """Recursively generates absolute paths whose components underneath current_dir match the corresponding pattern in patterns""" pattern = patterns[0] patterns = patterns[1:] has_wildcard = is_pattern(pattern) using_glob...
python
def _find_paths(self, current_dir, patterns): """Recursively generates absolute paths whose components underneath current_dir match the corresponding pattern in patterns""" pattern = patterns[0] patterns = patterns[1:] has_wildcard = is_pattern(pattern) using_glob...
[ "def", "_find_paths", "(", "self", ",", "current_dir", ",", "patterns", ")", ":", "pattern", "=", "patterns", "[", "0", "]", "patterns", "=", "patterns", "[", "1", ":", "]", "has_wildcard", "=", "is_pattern", "(", "pattern", ")", "using_globstar", "=", "...
Recursively generates absolute paths whose components underneath current_dir match the corresponding pattern in patterns
[ "Recursively", "generates", "absolute", "paths", "whose", "components", "underneath", "current_dir", "match", "the", "corresponding", "pattern", "in", "patterns" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/finders/whisper.py#L73-L113
brutasse/graphite-api
graphite_api/intervals.py
union_overlapping
def union_overlapping(intervals): """Union any overlapping intervals in the given set.""" disjoint_intervals = [] for interval in intervals: if disjoint_intervals and disjoint_intervals[-1].overlaps(interval): disjoint_intervals[-1] = disjoint_intervals[-1].union(interval) else:...
python
def union_overlapping(intervals): """Union any overlapping intervals in the given set.""" disjoint_intervals = [] for interval in intervals: if disjoint_intervals and disjoint_intervals[-1].overlaps(interval): disjoint_intervals[-1] = disjoint_intervals[-1].union(interval) else:...
[ "def", "union_overlapping", "(", "intervals", ")", ":", "disjoint_intervals", "=", "[", "]", "for", "interval", "in", "intervals", ":", "if", "disjoint_intervals", "and", "disjoint_intervals", "[", "-", "1", "]", ".", "overlaps", "(", "interval", ")", ":", "...
Union any overlapping intervals in the given set.
[ "Union", "any", "overlapping", "intervals", "in", "the", "given", "set", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/intervals.py#L128-L138
brutasse/graphite-api
graphite_api/app.py
recurse
def recurse(query, index): """ Recursively walk across paths, adding leaves to the index as they're found. """ for node in app.store.find(query): if node.is_leaf: index.add(node.path) else: recurse('{0}.*'.format(node.path), index)
python
def recurse(query, index): """ Recursively walk across paths, adding leaves to the index as they're found. """ for node in app.store.find(query): if node.is_leaf: index.add(node.path) else: recurse('{0}.*'.format(node.path), index)
[ "def", "recurse", "(", "query", ",", "index", ")", ":", "for", "node", "in", "app", ".", "store", ".", "find", "(", "query", ")", ":", "if", "node", ".", "is_leaf", ":", "index", ".", "add", "(", "node", ".", "path", ")", "else", ":", "recurse", ...
Recursively walk across paths, adding leaves to the index as they're found.
[ "Recursively", "walk", "across", "paths", "adding", "leaves", "to", "the", "index", "as", "they", "re", "found", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/app.py#L204-L212
brutasse/graphite-api
graphite_api/_vendor/whisper.py
setAggregationMethod
def setAggregationMethod(path, aggregationMethod, xFilesFactor=None): """setAggregationMethod(path,aggregationMethod,xFilesFactor=None) path is a string aggregationMethod specifies the method to use when propagating data (see ``whisper.aggregationMethods``) xFilesFactor specifies the fraction of data points in a pro...
python
def setAggregationMethod(path, aggregationMethod, xFilesFactor=None): """setAggregationMethod(path,aggregationMethod,xFilesFactor=None) path is a string aggregationMethod specifies the method to use when propagating data (see ``whisper.aggregationMethods``) xFilesFactor specifies the fraction of data points in a pro...
[ "def", "setAggregationMethod", "(", "path", ",", "aggregationMethod", ",", "xFilesFactor", "=", "None", ")", ":", "fh", "=", "None", "try", ":", "fh", "=", "open", "(", "path", ",", "'r+b'", ")", "if", "LOCK", ":", "fcntl", ".", "flock", "(", "fh", "...
setAggregationMethod(path,aggregationMethod,xFilesFactor=None) path is a string aggregationMethod specifies the method to use when propagating data (see ``whisper.aggregationMethods``) xFilesFactor specifies the fraction of data points in a propagation interval that must have known values for a propagation to occur. ...
[ "setAggregationMethod", "(", "path", "aggregationMethod", "xFilesFactor", "=", "None", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L265-L319
brutasse/graphite-api
graphite_api/_vendor/whisper.py
validateArchiveList
def validateArchiveList(archiveList): """ Validates an archiveList. An ArchiveList must: 1. Have at least one archive config. Example: (60, 86400) 2. No archive may be a duplicate of another. 3. Higher precision archives' precision must evenly divide all lower precision archives' precision. 4. Lower precisi...
python
def validateArchiveList(archiveList): """ Validates an archiveList. An ArchiveList must: 1. Have at least one archive config. Example: (60, 86400) 2. No archive may be a duplicate of another. 3. Higher precision archives' precision must evenly divide all lower precision archives' precision. 4. Lower precisi...
[ "def", "validateArchiveList", "(", "archiveList", ")", ":", "if", "not", "archiveList", ":", "raise", "InvalidConfiguration", "(", "\"You must specify at least one archive configuration!\"", ")", "archiveList", "=", "sorted", "(", "archiveList", ",", "key", "=", "lambda...
Validates an archiveList. An ArchiveList must: 1. Have at least one archive config. Example: (60, 86400) 2. No archive may be a duplicate of another. 3. Higher precision archives' precision must evenly divide all lower precision archives' precision. 4. Lower precision archives must cover larger time intervals...
[ "Validates", "an", "archiveList", ".", "An", "ArchiveList", "must", ":", "1", ".", "Have", "at", "least", "one", "archive", "config", ".", "Example", ":", "(", "60", "86400", ")", "2", ".", "No", "archive", "may", "be", "a", "duplicate", "of", "another...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L322-L370
brutasse/graphite-api
graphite_api/_vendor/whisper.py
create
def create(path,archiveList,xFilesFactor=None,aggregationMethod=None,sparse=False,useFallocate=False): """create(path,archiveList,xFilesFactor=0.5,aggregationMethod='average') path is a string archiveList is a list of archives, each of which is of the form (secondsPerPoint,numberOfPoints) xFilesFactor specifies the ...
python
def create(path,archiveList,xFilesFactor=None,aggregationMethod=None,sparse=False,useFallocate=False): """create(path,archiveList,xFilesFactor=0.5,aggregationMethod='average') path is a string archiveList is a list of archives, each of which is of the form (secondsPerPoint,numberOfPoints) xFilesFactor specifies the ...
[ "def", "create", "(", "path", ",", "archiveList", ",", "xFilesFactor", "=", "None", ",", "aggregationMethod", "=", "None", ",", "sparse", "=", "False", ",", "useFallocate", "=", "False", ")", ":", "# Set default params", "if", "xFilesFactor", "is", "None", "...
create(path,archiveList,xFilesFactor=0.5,aggregationMethod='average') path is a string archiveList is a list of archives, each of which is of the form (secondsPerPoint,numberOfPoints) xFilesFactor specifies the fraction of data points in a propagation interval that must have known values for a propagation to occur agg...
[ "create", "(", "path", "archiveList", "xFilesFactor", "=", "0", ".", "5", "aggregationMethod", "=", "average", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L373-L436
brutasse/graphite-api
graphite_api/_vendor/whisper.py
update
def update(path,value,timestamp=None): """update(path,value,timestamp=None) path is a string value is a float timestamp is either an int or float """ value = float(value) fh = None try: fh = open(path,'r+b') return file_update(fh, value, timestamp) finally: if fh: fh.close()
python
def update(path,value,timestamp=None): """update(path,value,timestamp=None) path is a string value is a float timestamp is either an int or float """ value = float(value) fh = None try: fh = open(path,'r+b') return file_update(fh, value, timestamp) finally: if fh: fh.close()
[ "def", "update", "(", "path", ",", "value", ",", "timestamp", "=", "None", ")", ":", "value", "=", "float", "(", "value", ")", "fh", "=", "None", "try", ":", "fh", "=", "open", "(", "path", ",", "'r+b'", ")", "return", "file_update", "(", "fh", "...
update(path,value,timestamp=None) path is a string value is a float timestamp is either an int or float
[ "update", "(", "path", "value", "timestamp", "=", "None", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L535-L549
brutasse/graphite-api
graphite_api/_vendor/whisper.py
update_many
def update_many(path,points): """update_many(path,points) path is a string points is a list of (timestamp,value) points """ if not points: return points = [ (int(t),float(v)) for (t,v) in points] points.sort(key=lambda p: p[0],reverse=True) #order points by timestamp, newest first fh = None try: fh = o...
python
def update_many(path,points): """update_many(path,points) path is a string points is a list of (timestamp,value) points """ if not points: return points = [ (int(t),float(v)) for (t,v) in points] points.sort(key=lambda p: p[0],reverse=True) #order points by timestamp, newest first fh = None try: fh = o...
[ "def", "update_many", "(", "path", ",", "points", ")", ":", "if", "not", "points", ":", "return", "points", "=", "[", "(", "int", "(", "t", ")", ",", "float", "(", "v", ")", ")", "for", "(", "t", ",", "v", ")", "in", "points", "]", "points", ...
update_many(path,points) path is a string points is a list of (timestamp,value) points
[ "update_many", "(", "path", "points", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L603-L618
brutasse/graphite-api
graphite_api/_vendor/whisper.py
info
def info(path): """info(path) path is a string """ fh = None try: fh = open(path,'rb') return __readHeader(fh) finally: if fh: fh.close() return None
python
def info(path): """info(path) path is a string """ fh = None try: fh = open(path,'rb') return __readHeader(fh) finally: if fh: fh.close() return None
[ "def", "info", "(", "path", ")", ":", "fh", "=", "None", "try", ":", "fh", "=", "open", "(", "path", ",", "'rb'", ")", "return", "__readHeader", "(", "fh", ")", "finally", ":", "if", "fh", ":", "fh", ".", "close", "(", ")", "return", "None" ]
info(path) path is a string
[ "info", "(", "path", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L727-L739
brutasse/graphite-api
graphite_api/_vendor/whisper.py
fetch
def fetch(path,fromTime,untilTime=None,now=None): """fetch(path,fromTime,untilTime=None) path is a string fromTime is an epoch time untilTime is also an epoch time, but defaults to now. Returns a tuple of (timeInfo, valueList) where timeInfo is itself a tuple of (fromTime, untilTime, step) Returns None if no data ...
python
def fetch(path,fromTime,untilTime=None,now=None): """fetch(path,fromTime,untilTime=None) path is a string fromTime is an epoch time untilTime is also an epoch time, but defaults to now. Returns a tuple of (timeInfo, valueList) where timeInfo is itself a tuple of (fromTime, untilTime, step) Returns None if no data ...
[ "def", "fetch", "(", "path", ",", "fromTime", ",", "untilTime", "=", "None", ",", "now", "=", "None", ")", ":", "fh", "=", "None", "try", ":", "fh", "=", "open", "(", "path", ",", "'rb'", ")", "return", "file_fetch", "(", "fh", ",", "fromTime", "...
fetch(path,fromTime,untilTime=None) path is a string fromTime is an epoch time untilTime is also an epoch time, but defaults to now. Returns a tuple of (timeInfo, valueList) where timeInfo is itself a tuple of (fromTime, untilTime, step) Returns None if no data can be returned
[ "fetch", "(", "path", "fromTime", "untilTime", "=", "None", ")" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L741-L759
brutasse/graphite-api
graphite_api/_vendor/whisper.py
__archive_fetch
def __archive_fetch(fh, archive, fromTime, untilTime): """ Fetch data from a single archive. Note that checks for validity of the time period requested happen above this level so it's possible to wrap around the archive on a read and request data older than the archive's retention """ fromInterval = int( fromTime -...
python
def __archive_fetch(fh, archive, fromTime, untilTime): """ Fetch data from a single archive. Note that checks for validity of the time period requested happen above this level so it's possible to wrap around the archive on a read and request data older than the archive's retention """ fromInterval = int( fromTime -...
[ "def", "__archive_fetch", "(", "fh", ",", "archive", ",", "fromTime", ",", "untilTime", ")", ":", "fromInterval", "=", "int", "(", "fromTime", "-", "(", "fromTime", "%", "archive", "[", "'secondsPerPoint'", "]", ")", ")", "+", "archive", "[", "'secondsPerP...
Fetch data from a single archive. Note that checks for validity of the time period requested happen above this level so it's possible to wrap around the archive on a read and request data older than the archive's retention
[ "Fetch", "data", "from", "a", "single", "archive", ".", "Note", "that", "checks", "for", "validity", "of", "the", "time", "period", "requested", "happen", "above", "this", "level", "so", "it", "s", "possible", "to", "wrap", "around", "the", "archive", "on"...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L797-L860
brutasse/graphite-api
graphite_api/_vendor/whisper.py
merge
def merge(path_from, path_to): """ Merges the data from one whisper file into another. Each file must have the same archive configuration """ fh_from = open(path_from, 'rb') fh_to = open(path_to, 'rb+') return file_merge(fh_from, fh_to)
python
def merge(path_from, path_to): """ Merges the data from one whisper file into another. Each file must have the same archive configuration """ fh_from = open(path_from, 'rb') fh_to = open(path_to, 'rb+') return file_merge(fh_from, fh_to)
[ "def", "merge", "(", "path_from", ",", "path_to", ")", ":", "fh_from", "=", "open", "(", "path_from", ",", "'rb'", ")", "fh_to", "=", "open", "(", "path_to", ",", "'rb+'", ")", "return", "file_merge", "(", "fh_from", ",", "fh_to", ")" ]
Merges the data from one whisper file into another. Each file must have the same archive configuration
[ "Merges", "the", "data", "from", "one", "whisper", "file", "into", "another", ".", "Each", "file", "must", "have", "the", "same", "archive", "configuration" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L862-L868
brutasse/graphite-api
graphite_api/_vendor/whisper.py
diff
def diff(path_from, path_to, ignore_empty = False): """ Compare two whisper databases. Each file must have the same archive configuration """ fh_from = open(path_from, 'rb') fh_to = open(path_to, 'rb') diffs = file_diff(fh_from, fh_to, ignore_empty) fh_to.close() fh_from.close() return diffs
python
def diff(path_from, path_to, ignore_empty = False): """ Compare two whisper databases. Each file must have the same archive configuration """ fh_from = open(path_from, 'rb') fh_to = open(path_to, 'rb') diffs = file_diff(fh_from, fh_to, ignore_empty) fh_to.close() fh_from.close() return diffs
[ "def", "diff", "(", "path_from", ",", "path_to", ",", "ignore_empty", "=", "False", ")", ":", "fh_from", "=", "open", "(", "path_from", ",", "'rb'", ")", "fh_to", "=", "open", "(", "path_to", ",", "'rb'", ")", "diffs", "=", "file_diff", "(", "fh_from",...
Compare two whisper databases. Each file must have the same archive configuration
[ "Compare", "two", "whisper", "databases", ".", "Each", "file", "must", "have", "the", "same", "archive", "configuration" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L895-L902
brutasse/graphite-api
graphite_api/render/datalib.py
DataStore.add_data
def add_data(self, path, time_info, data, exprs): """ Stores data before it can be put into a time series """ # Dont add if empty if not nonempty(data): for d in self.data[path]: if nonempty(d['values']): return # Add data ...
python
def add_data(self, path, time_info, data, exprs): """ Stores data before it can be put into a time series """ # Dont add if empty if not nonempty(data): for d in self.data[path]: if nonempty(d['values']): return # Add data ...
[ "def", "add_data", "(", "self", ",", "path", ",", "time_info", ",", "data", ",", "exprs", ")", ":", "# Dont add if empty", "if", "not", "nonempty", "(", "data", ")", ":", "for", "d", "in", "self", ".", "data", "[", "path", "]", ":", "if", "nonempty",...
Stores data before it can be put into a time series
[ "Stores", "data", "before", "it", "can", "be", "put", "into", "a", "time", "series" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/datalib.py#L117-L133
brutasse/graphite-api
graphite_api/finders/__init__.py
extract_variants
def extract_variants(pattern): """Extract the pattern variants (ie. {foo,bar}baz = foobaz or barbaz).""" v1, v2 = pattern.find('{'), pattern.find('}') if v1 > -1 and v2 > v1: variations = pattern[v1+1:v2].split(',') variants = [pattern[:v1] + v + pattern[v2+1:] for v in variations] else:...
python
def extract_variants(pattern): """Extract the pattern variants (ie. {foo,bar}baz = foobaz or barbaz).""" v1, v2 = pattern.find('{'), pattern.find('}') if v1 > -1 and v2 > v1: variations = pattern[v1+1:v2].split(',') variants = [pattern[:v1] + v + pattern[v2+1:] for v in variations] else:...
[ "def", "extract_variants", "(", "pattern", ")", ":", "v1", ",", "v2", "=", "pattern", ".", "find", "(", "'{'", ")", ",", "pattern", ".", "find", "(", "'}'", ")", "if", "v1", ">", "-", "1", "and", "v2", ">", "v1", ":", "variations", "=", "pattern"...
Extract the pattern variants (ie. {foo,bar}baz = foobaz or barbaz).
[ "Extract", "the", "pattern", "variants", "(", "ie", ".", "{", "foo", "bar", "}", "baz", "=", "foobaz", "or", "barbaz", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/finders/__init__.py#L35-L43
brutasse/graphite-api
graphite_api/finders/__init__.py
match_entries
def match_entries(entries, pattern): """A drop-in replacement for fnmatch.filter that supports pattern variants (ie. {foo,bar}baz = foobaz or barbaz).""" matching = [] for variant in expand_braces(pattern): matching.extend(fnmatch.filter(entries, variant)) return list(_deduplicate(matching...
python
def match_entries(entries, pattern): """A drop-in replacement for fnmatch.filter that supports pattern variants (ie. {foo,bar}baz = foobaz or barbaz).""" matching = [] for variant in expand_braces(pattern): matching.extend(fnmatch.filter(entries, variant)) return list(_deduplicate(matching...
[ "def", "match_entries", "(", "entries", ",", "pattern", ")", ":", "matching", "=", "[", "]", "for", "variant", "in", "expand_braces", "(", "pattern", ")", ":", "matching", ".", "extend", "(", "fnmatch", ".", "filter", "(", "entries", ",", "variant", ")",...
A drop-in replacement for fnmatch.filter that supports pattern variants (ie. {foo,bar}baz = foobaz or barbaz).
[ "A", "drop", "-", "in", "replacement", "for", "fnmatch", ".", "filter", "that", "supports", "pattern", "variants", "(", "ie", ".", "{", "foo", "bar", "}", "baz", "=", "foobaz", "or", "barbaz", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/finders/__init__.py#L46-L54
brutasse/graphite-api
graphite_api/finders/__init__.py
expand_braces
def expand_braces(pattern): """Find the rightmost, innermost set of braces and, if it contains a comma-separated list, expand its contents recursively (any of its items may itself be a list enclosed in braces). Return the full list of expanded strings. """ res = set() # Used instead of s.s...
python
def expand_braces(pattern): """Find the rightmost, innermost set of braces and, if it contains a comma-separated list, expand its contents recursively (any of its items may itself be a list enclosed in braces). Return the full list of expanded strings. """ res = set() # Used instead of s.s...
[ "def", "expand_braces", "(", "pattern", ")", ":", "res", "=", "set", "(", ")", "# Used instead of s.strip('{}') because strip is greedy.", "# We want to remove only ONE leading { and ONE trailing }, if both exist", "def", "remove_outer_braces", "(", "s", ")", ":", "if", "s", ...
Find the rightmost, innermost set of braces and, if it contains a comma-separated list, expand its contents recursively (any of its items may itself be a list enclosed in braces). Return the full list of expanded strings.
[ "Find", "the", "rightmost", "innermost", "set", "of", "braces", "and", "if", "it", "contains", "a", "comma", "-", "separated", "list", "expand", "its", "contents", "recursively", "(", "any", "of", "its", "items", "may", "itself", "be", "a", "list", "enclos...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/finders/__init__.py#L57-L87
brutasse/graphite-api
graphite_api/carbonlink.py
CarbonLinkPool.select_host
def select_host(self, metric): """ Returns the carbon host that has data for the given metric. """ key = self.keyfunc(metric) nodes = [] servers = set() for node in self.hash_ring.get_nodes(key): server, instance = node if server in servers...
python
def select_host(self, metric): """ Returns the carbon host that has data for the given metric. """ key = self.keyfunc(metric) nodes = [] servers = set() for node in self.hash_ring.get_nodes(key): server, instance = node if server in servers...
[ "def", "select_host", "(", "self", ",", "metric", ")", ":", "key", "=", "self", ".", "keyfunc", "(", "metric", ")", "nodes", "=", "[", "]", "servers", "=", "set", "(", ")", "for", "node", "in", "self", ".", "hash_ring", ".", "get_nodes", "(", "key"...
Returns the carbon host that has data for the given metric.
[ "Returns", "the", "carbon", "host", "that", "has", "data", "for", "the", "given", "metric", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/carbonlink.py#L180-L196
brutasse/graphite-api
graphite_api/render/glyph.py
safeArgs
def safeArgs(args): """Iterate over valid, finite values in an iterable. Skip any items that are None, NaN, or infinite. """ return (arg for arg in args if arg is not None and not math.isnan(arg) and not math.isinf(arg))
python
def safeArgs(args): """Iterate over valid, finite values in an iterable. Skip any items that are None, NaN, or infinite. """ return (arg for arg in args if arg is not None and not math.isnan(arg) and not math.isinf(arg))
[ "def", "safeArgs", "(", "args", ")", ":", "return", "(", "arg", "for", "arg", "in", "args", "if", "arg", "is", "not", "None", "and", "not", "math", ".", "isnan", "(", "arg", ")", "and", "not", "math", ".", "isinf", "(", "arg", ")", ")" ]
Iterate over valid, finite values in an iterable. Skip any items that are None, NaN, or infinite.
[ "Iterate", "over", "valid", "finite", "values", "in", "an", "iterable", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L2147-L2153
brutasse/graphite-api
graphite_api/render/glyph.py
dataLimits
def dataLimits(data, drawNullAsZero=False, stacked=False): """Return the range of values in data as (yMinValue, yMaxValue). data is an array of TimeSeries objects. """ missingValues = any(None in series for series in data) finiteData = [series for series in data if not series.opti...
python
def dataLimits(data, drawNullAsZero=False, stacked=False): """Return the range of values in data as (yMinValue, yMaxValue). data is an array of TimeSeries objects. """ missingValues = any(None in series for series in data) finiteData = [series for series in data if not series.opti...
[ "def", "dataLimits", "(", "data", ",", "drawNullAsZero", "=", "False", ",", "stacked", "=", "False", ")", ":", "missingValues", "=", "any", "(", "None", "in", "series", "for", "series", "in", "data", ")", "finiteData", "=", "[", "series", "for", "series"...
Return the range of values in data as (yMinValue, yMaxValue). data is an array of TimeSeries objects.
[ "Return", "the", "range", "of", "values", "in", "data", "as", "(", "yMinValue", "yMaxValue", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L2172-L2203
brutasse/graphite-api
graphite_api/render/glyph.py
format_units
def format_units(v, step=None, system="si", units=None): """Format the given value in standardized units. ``system`` is either 'binary' or 'si' For more info, see: http://en.wikipedia.org/wiki/SI_prefix http://en.wikipedia.org/wiki/Binary_prefix """ if v is None: return 0, ...
python
def format_units(v, step=None, system="si", units=None): """Format the given value in standardized units. ``system`` is either 'binary' or 'si' For more info, see: http://en.wikipedia.org/wiki/SI_prefix http://en.wikipedia.org/wiki/Binary_prefix """ if v is None: return 0, ...
[ "def", "format_units", "(", "v", ",", "step", "=", "None", ",", "system", "=", "\"si\"", ",", "units", "=", "None", ")", ":", "if", "v", "is", "None", ":", "return", "0", ",", "''", "for", "prefix", ",", "size", "in", "UnitSystems", "[", "system", ...
Format the given value in standardized units. ``system`` is either 'binary' or 'si' For more info, see: http://en.wikipedia.org/wiki/SI_prefix http://en.wikipedia.org/wiki/Binary_prefix
[ "Format", "the", "given", "value", "in", "standardized", "units", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L2219-L2246
brutasse/graphite-api
graphite_api/render/glyph.py
_AxisTics.checkFinite
def checkFinite(value, name='value'): """Check that value is a finite number. If it is, return it. If not, raise GraphError describing the problem, using name in the error message. """ if math.isnan(value): raise GraphError('Encountered NaN %s' % (name,)) eli...
python
def checkFinite(value, name='value'): """Check that value is a finite number. If it is, return it. If not, raise GraphError describing the problem, using name in the error message. """ if math.isnan(value): raise GraphError('Encountered NaN %s' % (name,)) eli...
[ "def", "checkFinite", "(", "value", ",", "name", "=", "'value'", ")", ":", "if", "math", ".", "isnan", "(", "value", ")", ":", "raise", "GraphError", "(", "'Encountered NaN %s'", "%", "(", "name", ",", ")", ")", "elif", "math", ".", "isinf", "(", "va...
Check that value is a finite number. If it is, return it. If not, raise GraphError describing the problem, using name in the error message.
[ "Check", "that", "value", "is", "a", "finite", "number", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L347-L357
brutasse/graphite-api
graphite_api/render/glyph.py
_AxisTics.reconcileLimits
def reconcileLimits(self): """If self.minValue is not less than self.maxValue, fix the problem. If self.minValue is not less than self.maxValue, adjust self.minValue and/or self.maxValue (depending on which was not specified explicitly by the user) to make self.minValue < self.m...
python
def reconcileLimits(self): """If self.minValue is not less than self.maxValue, fix the problem. If self.minValue is not less than self.maxValue, adjust self.minValue and/or self.maxValue (depending on which was not specified explicitly by the user) to make self.minValue < self.m...
[ "def", "reconcileLimits", "(", "self", ")", ":", "if", "self", ".", "minValue", "<", "self", ".", "maxValue", ":", "# The limits are already OK.", "return", "minFixed", "=", "(", "self", ".", "minValueSource", "in", "[", "'min'", "]", ")", "maxFixed", "=", ...
If self.minValue is not less than self.maxValue, fix the problem. If self.minValue is not less than self.maxValue, adjust self.minValue and/or self.maxValue (depending on which was not specified explicitly by the user) to make self.minValue < self.maxValue. If the user specified both li...
[ "If", "self", ".", "minValue", "is", "not", "less", "than", "self", ".", "maxValue", "fix", "the", "problem", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L371-L399
brutasse/graphite-api
graphite_api/render/glyph.py
_AxisTics.applySettings
def applySettings(self, axisMin=None, axisMax=None, axisLimit=None): """Apply the specified settings to this axis. Set self.minValue, self.minValueSource, self.maxValue, self.maxValueSource, and self.axisLimit reasonably based on the parameters provided. Arguments: axi...
python
def applySettings(self, axisMin=None, axisMax=None, axisLimit=None): """Apply the specified settings to this axis. Set self.minValue, self.minValueSource, self.maxValue, self.maxValueSource, and self.axisLimit reasonably based on the parameters provided. Arguments: axi...
[ "def", "applySettings", "(", "self", ",", "axisMin", "=", "None", ",", "axisMax", "=", "None", ",", "axisLimit", "=", "None", ")", ":", "if", "axisMin", "is", "not", "None", "and", "not", "math", ".", "isnan", "(", "axisMin", ")", ":", "self", ".", ...
Apply the specified settings to this axis. Set self.minValue, self.minValueSource, self.maxValue, self.maxValueSource, and self.axisLimit reasonably based on the parameters provided. Arguments: axisMin -- a finite number, or None to choose a round minimum limit tha...
[ "Apply", "the", "specified", "settings", "to", "this", "axis", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L401-L446
brutasse/graphite-api
graphite_api/render/glyph.py
_AxisTics.makeLabel
def makeLabel(self, value): """Create a label for the specified value. Create a label string containing the value and its units (if any), based on the values of self.step, self.span, and self.unitSystem. """ value, prefix = format_units(value, self.step, ...
python
def makeLabel(self, value): """Create a label for the specified value. Create a label string containing the value and its units (if any), based on the values of self.step, self.span, and self.unitSystem. """ value, prefix = format_units(value, self.step, ...
[ "def", "makeLabel", "(", "self", ",", "value", ")", ":", "value", ",", "prefix", "=", "format_units", "(", "value", ",", "self", ".", "step", ",", "system", "=", "self", ".", "unitSystem", ")", "span", ",", "spanPrefix", "=", "format_units", "(", "self...
Create a label for the specified value. Create a label string containing the value and its units (if any), based on the values of self.step, self.span, and self.unitSystem.
[ "Create", "a", "label", "for", "the", "specified", "value", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L448-L474
brutasse/graphite-api
graphite_api/render/glyph.py
_LinearAxisTics.generateSteps
def generateSteps(self, minStep): """Generate allowed steps with step >= minStep in increasing order.""" self.checkFinite(minStep) if self.binary: base = 2.0 mantissas = [1.0] exponent = math.floor(math.log(minStep, 2) - EPSILON) else: bas...
python
def generateSteps(self, minStep): """Generate allowed steps with step >= minStep in increasing order.""" self.checkFinite(minStep) if self.binary: base = 2.0 mantissas = [1.0] exponent = math.floor(math.log(minStep, 2) - EPSILON) else: bas...
[ "def", "generateSteps", "(", "self", ",", "minStep", ")", ":", "self", ".", "checkFinite", "(", "minStep", ")", "if", "self", ".", "binary", ":", "base", "=", "2.0", "mantissas", "=", "[", "1.0", "]", "exponent", "=", "math", ".", "floor", "(", "math...
Generate allowed steps with step >= minStep in increasing order.
[ "Generate", "allowed", "steps", "with", "step", ">", "=", "minStep", "in", "increasing", "order", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L490-L509
brutasse/graphite-api
graphite_api/render/glyph.py
_LinearAxisTics.computeSlop
def computeSlop(self, step, divisor): """Compute the slop that would result from step and divisor. Return the slop, or None if this combination can't cover the full range. See chooseStep() for the definition of "slop". """ bottom = step * math.floor(self.minValue / float(step) ...
python
def computeSlop(self, step, divisor): """Compute the slop that would result from step and divisor. Return the slop, or None if this combination can't cover the full range. See chooseStep() for the definition of "slop". """ bottom = step * math.floor(self.minValue / float(step) ...
[ "def", "computeSlop", "(", "self", ",", "step", ",", "divisor", ")", ":", "bottom", "=", "step", "*", "math", ".", "floor", "(", "self", ".", "minValue", "/", "float", "(", "step", ")", "+", "EPSILON", ")", "top", "=", "bottom", "+", "step", "*", ...
Compute the slop that would result from step and divisor. Return the slop, or None if this combination can't cover the full range. See chooseStep() for the definition of "slop".
[ "Compute", "the", "slop", "that", "would", "result", "from", "step", "and", "divisor", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L511-L524
brutasse/graphite-api
graphite_api/render/glyph.py
_LinearAxisTics.chooseStep
def chooseStep(self, divisors=None, binary=False): """Choose a nice, pretty size for the steps between axis labels. Our main constraint is that the number of divisions must be taken from the divisors list. We pick a number of divisions and a step size that minimizes the amount of whites...
python
def chooseStep(self, divisors=None, binary=False): """Choose a nice, pretty size for the steps between axis labels. Our main constraint is that the number of divisions must be taken from the divisors list. We pick a number of divisions and a step size that minimizes the amount of whites...
[ "def", "chooseStep", "(", "self", ",", "divisors", "=", "None", ",", "binary", "=", "False", ")", ":", "self", ".", "binary", "=", "binary", "if", "divisors", "is", "None", ":", "divisors", "=", "[", "4", ",", "5", ",", "6", "]", "else", ":", "fo...
Choose a nice, pretty size for the steps between axis labels. Our main constraint is that the number of divisions must be taken from the divisors list. We pick a number of divisions and a step size that minimizes the amount of whitespace ("slop") that would need to be included outside o...
[ "Choose", "a", "nice", "pretty", "size", "for", "the", "steps", "between", "axis", "labels", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/render/glyph.py#L526-L604
brutasse/graphite-api
graphite_api/functions.py
formatPathExpressions
def formatPathExpressions(seriesList): """ Returns a comma-separated list of unique path expressions. """ pathExpressions = sorted(set([s.pathExpression for s in seriesList])) return ','.join(pathExpressions)
python
def formatPathExpressions(seriesList): """ Returns a comma-separated list of unique path expressions. """ pathExpressions = sorted(set([s.pathExpression for s in seriesList])) return ','.join(pathExpressions)
[ "def", "formatPathExpressions", "(", "seriesList", ")", ":", "pathExpressions", "=", "sorted", "(", "set", "(", "[", "s", ".", "pathExpression", "for", "s", "in", "seriesList", "]", ")", ")", "return", "','", ".", "join", "(", "pathExpressions", ")" ]
Returns a comma-separated list of unique path expressions.
[ "Returns", "a", "comma", "-", "separated", "list", "of", "unique", "path", "expressions", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L185-L190
brutasse/graphite-api
graphite_api/functions.py
sumSeries
def sumSeries(requestContext, *seriesLists): """ Short form: sum() This will add metrics together and return the sum at each datapoint. (See integral for a sum over time) Example:: &target=sum(company.server.application*.requestsHandled) This would show the sum of all requests handle...
python
def sumSeries(requestContext, *seriesLists): """ Short form: sum() This will add metrics together and return the sum at each datapoint. (See integral for a sum over time) Example:: &target=sum(company.server.application*.requestsHandled) This would show the sum of all requests handle...
[ "def", "sumSeries", "(", "requestContext", ",", "*", "seriesLists", ")", ":", "if", "not", "seriesLists", "or", "not", "any", "(", "seriesLists", ")", ":", "return", "[", "]", "seriesList", ",", "start", ",", "end", ",", "step", "=", "normalize", "(", ...
Short form: sum() This will add metrics together and return the sum at each datapoint. (See integral for a sum over time) Example:: &target=sum(company.server.application*.requestsHandled) This would show the sum of all requests handled per minute (provided requestsHandled are collected ...
[ "Short", "form", ":", "sum", "()" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L195-L220
brutasse/graphite-api
graphite_api/functions.py
sumSeriesWithWildcards
def sumSeriesWithWildcards(requestContext, seriesList, *positions): """ Call sumSeries after inserting wildcards at the given position(s). Example:: &target=sumSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of...
python
def sumSeriesWithWildcards(requestContext, seriesList, *positions): """ Call sumSeries after inserting wildcards at the given position(s). Example:: &target=sumSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of...
[ "def", "sumSeriesWithWildcards", "(", "requestContext", ",", "seriesList", ",", "*", "positions", ")", ":", "newSeries", "=", "{", "}", "newNames", "=", "list", "(", ")", "for", "series", "in", "seriesList", ":", "newname", "=", "'.'", ".", "join", "(", ...
Call sumSeries after inserting wildcards at the given position(s). Example:: &target=sumSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of:: &target=sumSeries(host.*.cpu-user.value)&target=sumSeries( ...
[ "Call", "sumSeries", "after", "inserting", "wildcards", "at", "the", "given", "position", "(", "s", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L223-L253
brutasse/graphite-api
graphite_api/functions.py
averageSeriesWithWildcards
def averageSeriesWithWildcards(requestContext, seriesList, *positions): """ Call averageSeries after inserting wildcards at the given position(s). Example:: &target=averageSeriesWithWildcards( host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of:: &t...
python
def averageSeriesWithWildcards(requestContext, seriesList, *positions): """ Call averageSeries after inserting wildcards at the given position(s). Example:: &target=averageSeriesWithWildcards( host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of:: &t...
[ "def", "averageSeriesWithWildcards", "(", "requestContext", ",", "seriesList", ",", "*", "positions", ")", ":", "matchedList", "=", "defaultdict", "(", "list", ")", "for", "series", "in", "seriesList", ":", "newname", "=", "'.'", ".", "join", "(", "map", "("...
Call averageSeries after inserting wildcards at the given position(s). Example:: &target=averageSeriesWithWildcards( host.cpu-[0-7].cpu-{user,system}.value, 1) This would be the equivalent of:: &target=averageSeries(host.*.cpu-user.value)&target=averageSeries( host.*....
[ "Call", "averageSeries", "after", "inserting", "wildcards", "at", "the", "given", "position", "(", "s", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L256-L282
brutasse/graphite-api
graphite_api/functions.py
multiplySeriesWithWildcards
def multiplySeriesWithWildcards(requestContext, seriesList, *position): """ Call multiplySeries after inserting wildcards at the given position(s). Example:: &target=multiplySeriesWithWildcards( web.host-[0-7].{avg-response,total-request}.value, 2) This would be the equivalent of:...
python
def multiplySeriesWithWildcards(requestContext, seriesList, *position): """ Call multiplySeries after inserting wildcards at the given position(s). Example:: &target=multiplySeriesWithWildcards( web.host-[0-7].{avg-response,total-request}.value, 2) This would be the equivalent of:...
[ "def", "multiplySeriesWithWildcards", "(", "requestContext", ",", "seriesList", ",", "*", "position", ")", ":", "positions", "=", "[", "position", "]", "if", "isinstance", "(", "position", ",", "int", ")", "else", "position", "newSeries", "=", "{", "}", "new...
Call multiplySeries after inserting wildcards at the given position(s). Example:: &target=multiplySeriesWithWildcards( web.host-[0-7].{avg-response,total-request}.value, 2) This would be the equivalent of:: &target=multiplySeries(web.host-0.{avg-response,total-request}.value) ...
[ "Call", "multiplySeries", "after", "inserting", "wildcards", "at", "the", "given", "position", "(", "s", ")", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L285-L318
brutasse/graphite-api
graphite_api/functions.py
rangeOfSeries
def rangeOfSeries(requestContext, *seriesLists): """ Takes a wildcard seriesList. Distills down a set of inputs into the range of the series Example:: &target=rangeOfSeries(Server*.connections.total) """ if not seriesLists or not any(seriesLists): return [] seriesList, sta...
python
def rangeOfSeries(requestContext, *seriesLists): """ Takes a wildcard seriesList. Distills down a set of inputs into the range of the series Example:: &target=rangeOfSeries(Server*.connections.total) """ if not seriesLists or not any(seriesLists): return [] seriesList, sta...
[ "def", "rangeOfSeries", "(", "requestContext", ",", "*", "seriesLists", ")", ":", "if", "not", "seriesLists", "or", "not", "any", "(", "seriesLists", ")", ":", "return", "[", "]", "seriesList", ",", "start", ",", "end", ",", "step", "=", "normalize", "("...
Takes a wildcard seriesList. Distills down a set of inputs into the range of the series Example:: &target=rangeOfSeries(Server*.connections.total)
[ "Takes", "a", "wildcard", "seriesList", ".", "Distills", "down", "a", "set", "of", "inputs", "into", "the", "range", "of", "the", "series" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L434-L452
brutasse/graphite-api
graphite_api/functions.py
percentileOfSeries
def percentileOfSeries(requestContext, seriesList, n, interpolate=False): """ percentileOfSeries returns a single series which is composed of the n-percentile values taken across a wildcard series at each point. Unless `interpolate` is set to True, percentile values are actual values contained in on...
python
def percentileOfSeries(requestContext, seriesList, n, interpolate=False): """ percentileOfSeries returns a single series which is composed of the n-percentile values taken across a wildcard series at each point. Unless `interpolate` is set to True, percentile values are actual values contained in on...
[ "def", "percentileOfSeries", "(", "requestContext", ",", "seriesList", ",", "n", ",", "interpolate", "=", "False", ")", ":", "if", "n", "<=", "0", ":", "raise", "ValueError", "(", "'The requested percent is required to be greater than 0'", ")", "if", "not", "serie...
percentileOfSeries returns a single series which is composed of the n-percentile values taken across a wildcard series at each point. Unless `interpolate` is set to True, percentile values are actual values contained in one of the supplied series.
[ "percentileOfSeries", "returns", "a", "single", "series", "which", "is", "composed", "of", "the", "n", "-", "percentile", "values", "taken", "across", "a", "wildcard", "series", "at", "each", "point", ".", "Unless", "interpolate", "is", "set", "to", "True", ...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L455-L474
brutasse/graphite-api
graphite_api/functions.py
keepLastValue
def keepLastValue(requestContext, seriesList, limit=INF): """ Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. ...
python
def keepLastValue(requestContext, seriesList, limit=INF): """ Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. ...
[ "def", "keepLastValue", "(", "requestContext", ",", "seriesList", ",", "limit", "=", "INF", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"keepLastValue(%s)\"", "%", "(", "series", ".", "name", ")", "series", ".", "pathE...
Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. Example:: &target=keepLastValue(Server01.connections.han...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "optionally", "a", "limit", "to", "the", "number", "of", "None", "values", "to", "skip", "over", ".", "Continues", "the", "line", "with", "the", "last", "received", "value", "when", "gap...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L477-L520
brutasse/graphite-api
graphite_api/functions.py
interpolate
def interpolate(requestContext, seriesList, limit=INF): """ Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. ...
python
def interpolate(requestContext, seriesList, limit=INF): """ Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. ...
[ "def", "interpolate", "(", "requestContext", ",", "seriesList", ",", "limit", "=", "INF", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"interpolate(%s)\"", "%", "(", "series", ".", "name", ")", "series", ".", "pathExpre...
Takes one metric or a wildcard seriesList, and optionally a limit to the number of 'None' values to skip over. Continues the line with the last received value when gaps ('None' values) appear in your data, rather than breaking your line. Example:: &target=interpolate(Server01.connections.handl...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "optionally", "a", "limit", "to", "the", "number", "of", "None", "values", "to", "skip", "over", ".", "Continues", "the", "line", "with", "the", "last", "received", "value", "when", "gap...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L523-L571
brutasse/graphite-api
graphite_api/functions.py
changed
def changed(requestContext, seriesList): """ Takes one metric or a wildcard seriesList. Output 1 when the value changed, 0 when null or the same Example:: &target=changed(Server01.connections.handled) """ for series in seriesList: series.name = series.pathExpression = 'changed(%...
python
def changed(requestContext, seriesList): """ Takes one metric or a wildcard seriesList. Output 1 when the value changed, 0 when null or the same Example:: &target=changed(Server01.connections.handled) """ for series in seriesList: series.name = series.pathExpression = 'changed(%...
[ "def", "changed", "(", "requestContext", ",", "seriesList", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "series", ".", "pathExpression", "=", "'changed(%s)'", "%", "series", ".", "name", "previous", "=", "None", "for", "...
Takes one metric or a wildcard seriesList. Output 1 when the value changed, 0 when null or the same Example:: &target=changed(Server01.connections.handled)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", ".", "Output", "1", "when", "the", "value", "changed", "0", "when", "null", "or", "the", "same", "Example", "::" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L574-L593
brutasse/graphite-api
graphite_api/functions.py
divideSeriesLists
def divideSeriesLists(requestContext, dividendSeriesList, divisorSeriesList): """ Iterates over a two lists and divides list1[0] by list2[0], list1[1] by list2[1] and so on. The lists need to be the same length """ if len(dividendSeriesList) != len(divisorSeriesList): raise ValueError("divi...
python
def divideSeriesLists(requestContext, dividendSeriesList, divisorSeriesList): """ Iterates over a two lists and divides list1[0] by list2[0], list1[1] by list2[1] and so on. The lists need to be the same length """ if len(dividendSeriesList) != len(divisorSeriesList): raise ValueError("divi...
[ "def", "divideSeriesLists", "(", "requestContext", ",", "dividendSeriesList", ",", "divisorSeriesList", ")", ":", "if", "len", "(", "dividendSeriesList", ")", "!=", "len", "(", "divisorSeriesList", ")", ":", "raise", "ValueError", "(", "\"dividendSeriesList and diviso...
Iterates over a two lists and divides list1[0] by list2[0], list1[1] by list2[1] and so on. The lists need to be the same length
[ "Iterates", "over", "a", "two", "lists", "and", "divides", "list1", "[", "0", "]", "by", "list2", "[", "0", "]", "list1", "[", "1", "]", "by", "list2", "[", "1", "]", "and", "so", "on", ".", "The", "lists", "need", "to", "be", "the", "same", "l...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L664-L695
brutasse/graphite-api
graphite_api/functions.py
divideSeries
def divideSeries(requestContext, dividendSeriesList, divisorSeriesList): """ Takes a dividend metric and a divisor metric and draws the division result. A constant may *not* be passed. To divide by a constant, use the scale() function (which is essentially a multiplication operation) and use the inv...
python
def divideSeries(requestContext, dividendSeriesList, divisorSeriesList): """ Takes a dividend metric and a divisor metric and draws the division result. A constant may *not* be passed. To divide by a constant, use the scale() function (which is essentially a multiplication operation) and use the inv...
[ "def", "divideSeries", "(", "requestContext", ",", "dividendSeriesList", ",", "divisorSeriesList", ")", ":", "if", "len", "(", "divisorSeriesList", ")", "==", "0", ":", "for", "series", "in", "dividendSeriesList", ":", "series", ".", "name", "=", "\"divideSeries...
Takes a dividend metric and a divisor metric and draws the division result. A constant may *not* be passed. To divide by a constant, use the scale() function (which is essentially a multiplication operation) and use the inverse of the dividend. (Division by 8 = multiplication by 1/8 or 0.125) Example::...
[ "Takes", "a", "dividend", "metric", "and", "a", "divisor", "metric", "and", "draws", "the", "division", "result", ".", "A", "constant", "may", "*", "not", "*", "be", "passed", ".", "To", "divide", "by", "a", "constant", "use", "the", "scale", "()", "fu...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L698-L745
brutasse/graphite-api
graphite_api/functions.py
multiplySeries
def multiplySeries(requestContext, *seriesLists): """ Takes two or more series and multiplies their points. A constant may not be used. To multiply by a constant, use the scale() function. Example:: &target=multiplySeries(Series.dividends,Series.divisors) """ if not seriesLists or no...
python
def multiplySeries(requestContext, *seriesLists): """ Takes two or more series and multiplies their points. A constant may not be used. To multiply by a constant, use the scale() function. Example:: &target=multiplySeries(Series.dividends,Series.divisors) """ if not seriesLists or no...
[ "def", "multiplySeries", "(", "requestContext", ",", "*", "seriesLists", ")", ":", "if", "not", "seriesLists", "or", "not", "any", "(", "seriesLists", ")", ":", "return", "[", "]", "seriesList", ",", "start", ",", "end", ",", "step", "=", "normalize", "(...
Takes two or more series and multiplies their points. A constant may not be used. To multiply by a constant, use the scale() function. Example:: &target=multiplySeries(Series.dividends,Series.divisors)
[ "Takes", "two", "or", "more", "series", "and", "multiplies", "their", "points", ".", "A", "constant", "may", "not", "be", "used", ".", "To", "multiply", "by", "a", "constant", "use", "the", "scale", "()", "function", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L748-L770
brutasse/graphite-api
graphite_api/functions.py
weightedAverage
def weightedAverage(requestContext, seriesListAvg, seriesListWeight, *nodes): """ Takes a series of average values and a series of weights and produces a weighted average for all values. The corresponding values should share one or more zero-indexed nodes. Example:: &target=weightedAverag...
python
def weightedAverage(requestContext, seriesListAvg, seriesListWeight, *nodes): """ Takes a series of average values and a series of weights and produces a weighted average for all values. The corresponding values should share one or more zero-indexed nodes. Example:: &target=weightedAverag...
[ "def", "weightedAverage", "(", "requestContext", ",", "seriesListAvg", ",", "seriesListWeight", ",", "*", "nodes", ")", ":", "if", "isinstance", "(", "nodes", ",", "int", ")", ":", "nodes", "=", "[", "nodes", "]", "sortedSeries", "=", "{", "}", "for", "s...
Takes a series of average values and a series of weights and produces a weighted average for all values. The corresponding values should share one or more zero-indexed nodes. Example:: &target=weightedAverage(*.transactions.mean,*.transactions.count,0) &target=weightedAverage(*.transactio...
[ "Takes", "a", "series", "of", "average", "values", "and", "a", "series", "of", "weights", "and", "produces", "a", "weighted", "average", "for", "all", "values", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L773-L843
brutasse/graphite-api
graphite_api/functions.py
exponentialMovingAverage
def exponentialMovingAverage(requestContext, seriesList, windowSize): """ Takes a series of values and a window size and produces an exponential moving average utilizing the following formula: ema(current) = constant * (Current Value) + (1 - constant) * ema(previous) The Constant is calculated as:...
python
def exponentialMovingAverage(requestContext, seriesList, windowSize): """ Takes a series of values and a window size and produces an exponential moving average utilizing the following formula: ema(current) = constant * (Current Value) + (1 - constant) * ema(previous) The Constant is calculated as:...
[ "def", "exponentialMovingAverage", "(", "requestContext", ",", "seriesList", ",", "windowSize", ")", ":", "# EMA = C * (current_value) + (1 - C) + EMA", "# C = 2 / (windowSize + 1)", "# The following was copied from movingAverage, and altered for ema", "if", "not", "seriesList", ":",...
Takes a series of values and a window size and produces an exponential moving average utilizing the following formula: ema(current) = constant * (Current Value) + (1 - constant) * ema(previous) The Constant is calculated as: constant = 2 / (windowSize + 1) The first period EMA uses a simple ...
[ "Takes", "a", "series", "of", "values", "and", "a", "window", "size", "and", "produces", "an", "exponential", "moving", "average", "utilizing", "the", "following", "formula", ":" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L846-L928
brutasse/graphite-api
graphite_api/functions.py
movingMedian
def movingMedian(requestContext, seriesList, windowSize): """ Graphs the moving median of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour...
python
def movingMedian(requestContext, seriesList, windowSize): """ Graphs the moving median of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour...
[ "def", "movingMedian", "(", "requestContext", ",", "seriesList", ",", "windowSize", ")", ":", "if", "not", "seriesList", ":", "return", "[", "]", "windowInterval", "=", "None", "if", "isinstance", "(", "windowSize", ",", "six", ".", "string_types", ")", ":",...
Graphs the moving median of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '5min' (See ``from / until`` in the render\_api_ for examples...
[ "Graphs", "the", "moving", "median", "of", "a", "metric", "(", "or", "metrics", ")", "over", "a", "fixed", "number", "of", "past", "points", "or", "a", "time", "interval", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L931-L991
brutasse/graphite-api
graphite_api/functions.py
scale
def scale(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and multiplies the datapoint by the constant provided at each point. Example:: &target=scale(Server.instance01.threads.busy,10) &target=scale(Server.instance*.threads.bu...
python
def scale(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and multiplies the datapoint by the constant provided at each point. Example:: &target=scale(Server.instance01.threads.busy,10) &target=scale(Server.instance*.threads.bu...
[ "def", "scale", "(", "requestContext", ",", "seriesList", ",", "factor", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"scale(%s,%g)\"", "%", "(", "series", ".", "name", ",", "float", "(", "factor", ")", ")", "series",...
Takes one metric or a wildcard seriesList followed by a constant, and multiplies the datapoint by the constant provided at each point. Example:: &target=scale(Server.instance01.threads.busy,10) &target=scale(Server.instance*.threads.busy,10)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "a", "constant", "and", "multiplies", "the", "datapoint", "by", "the", "constant", "provided", "at", "each", "point", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L994-L1010
brutasse/graphite-api
graphite_api/functions.py
scaleToSeconds
def scaleToSeconds(requestContext, seriesList, seconds): """ Takes one metric or a wildcard seriesList and returns "value per seconds" where seconds is a last argument to this functions. Useful in conjunction with derivative or integral function if you want to normalize its result to a known resolu...
python
def scaleToSeconds(requestContext, seriesList, seconds): """ Takes one metric or a wildcard seriesList and returns "value per seconds" where seconds is a last argument to this functions. Useful in conjunction with derivative or integral function if you want to normalize its result to a known resolu...
[ "def", "scaleToSeconds", "(", "requestContext", ",", "seriesList", ",", "seconds", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"scaleToSeconds(%s,%d)\"", "%", "(", "series", ".", "name", ",", "seconds", ")", "series", "....
Takes one metric or a wildcard seriesList and returns "value per seconds" where seconds is a last argument to this functions. Useful in conjunction with derivative or integral function if you want to normalize its result to a known resolution for arbitrary retentions
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "returns", "value", "per", "seconds", "where", "seconds", "is", "a", "last", "argument", "to", "this", "functions", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1013-L1028
brutasse/graphite-api
graphite_api/functions.py
pow
def pow(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and raises the datapoint by the power of the constant provided at each point. Example:: &target=pow(Server.instance01.threads.busy,10) &target=pow(Server.instance*.threads...
python
def pow(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and raises the datapoint by the power of the constant provided at each point. Example:: &target=pow(Server.instance01.threads.busy,10) &target=pow(Server.instance*.threads...
[ "def", "pow", "(", "requestContext", ",", "seriesList", ",", "factor", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"pow(%s,%g)\"", "%", "(", "series", ".", "name", ",", "float", "(", "factor", ")", ")", "series", "...
Takes one metric or a wildcard seriesList followed by a constant, and raises the datapoint by the power of the constant provided at each point. Example:: &target=pow(Server.instance01.threads.busy,10) &target=pow(Server.instance*.threads.busy,10)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "a", "constant", "and", "raises", "the", "datapoint", "by", "the", "power", "of", "the", "constant", "provided", "at", "each", "point", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1031-L1047
brutasse/graphite-api
graphite_api/functions.py
powSeries
def powSeries(requestContext, *seriesLists): """ Takes two or more series and pows their points. A constant line may be used. Example:: &target=powSeries(Server.instance01.app.requests, Server.instance01.app.replies) """ if not seriesLists or not any(seriesLi...
python
def powSeries(requestContext, *seriesLists): """ Takes two or more series and pows their points. A constant line may be used. Example:: &target=powSeries(Server.instance01.app.requests, Server.instance01.app.replies) """ if not seriesLists or not any(seriesLi...
[ "def", "powSeries", "(", "requestContext", ",", "*", "seriesLists", ")", ":", "if", "not", "seriesLists", "or", "not", "any", "(", "seriesLists", ")", ":", "return", "[", "]", "seriesList", ",", "start", ",", "end", ",", "step", "=", "normalize", "(", ...
Takes two or more series and pows their points. A constant line may be used. Example:: &target=powSeries(Server.instance01.app.requests, Server.instance01.app.replies)
[ "Takes", "two", "or", "more", "series", "and", "pows", "their", "points", ".", "A", "constant", "line", "may", "be", "used", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1050-L1079
brutasse/graphite-api
graphite_api/functions.py
squareRoot
def squareRoot(requestContext, seriesList): """ Takes one metric or a wildcard seriesList, and computes the square root of each datapoint. Example:: &target=squareRoot(Server.instance01.threads.busy) """ for series in seriesList: series.name = "squareRoot(%s)" % (series.name) ...
python
def squareRoot(requestContext, seriesList): """ Takes one metric or a wildcard seriesList, and computes the square root of each datapoint. Example:: &target=squareRoot(Server.instance01.threads.busy) """ for series in seriesList: series.name = "squareRoot(%s)" % (series.name) ...
[ "def", "squareRoot", "(", "requestContext", ",", "seriesList", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"squareRoot(%s)\"", "%", "(", "series", ".", "name", ")", "for", "i", ",", "value", "in", "enumerate", "(", "...
Takes one metric or a wildcard seriesList, and computes the square root of each datapoint. Example:: &target=squareRoot(Server.instance01.threads.busy)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "computes", "the", "square", "root", "of", "each", "datapoint", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1082-L1096
brutasse/graphite-api
graphite_api/functions.py
absolute
def absolute(requestContext, seriesList): """ Takes one metric or a wildcard seriesList and applies the mathematical abs function to each datapoint transforming it to its absolute value. Example:: &target=absolute(Server.instance01.threads.busy) &target=absolute(Server.instance*.thread...
python
def absolute(requestContext, seriesList): """ Takes one metric or a wildcard seriesList and applies the mathematical abs function to each datapoint transforming it to its absolute value. Example:: &target=absolute(Server.instance01.threads.busy) &target=absolute(Server.instance*.thread...
[ "def", "absolute", "(", "requestContext", ",", "seriesList", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"absolute(%s)\"", "%", "(", "series", ".", "name", ")", "series", ".", "pathExpression", "=", "series", ".", "nam...
Takes one metric or a wildcard seriesList and applies the mathematical abs function to each datapoint transforming it to its absolute value. Example:: &target=absolute(Server.instance01.threads.busy) &target=absolute(Server.instance*.threads.busy)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "applies", "the", "mathematical", "abs", "function", "to", "each", "datapoint", "transforming", "it", "to", "its", "absolute", "value", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1116-L1131
brutasse/graphite-api
graphite_api/functions.py
offset
def offset(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and adds the constant to each datapoint. Example:: &target=offset(Server.instance01.threads.busy,10) """ for series in seriesList: series.name = "offset(%s,%g)...
python
def offset(requestContext, seriesList, factor): """ Takes one metric or a wildcard seriesList followed by a constant, and adds the constant to each datapoint. Example:: &target=offset(Server.instance01.threads.busy,10) """ for series in seriesList: series.name = "offset(%s,%g)...
[ "def", "offset", "(", "requestContext", ",", "seriesList", ",", "factor", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"offset(%s,%g)\"", "%", "(", "series", ".", "name", ",", "float", "(", "factor", ")", ")", "series...
Takes one metric or a wildcard seriesList followed by a constant, and adds the constant to each datapoint. Example:: &target=offset(Server.instance01.threads.busy,10)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "a", "constant", "and", "adds", "the", "constant", "to", "each", "datapoint", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1134-L1150
brutasse/graphite-api
graphite_api/functions.py
offsetToZero
def offsetToZero(requestContext, seriesList): """ Offsets a metric or wildcard seriesList by subtracting the minimum value in the series from each datapoint. Useful to compare different series where the values in each series may be higher or lower on average but you're only interested in the re...
python
def offsetToZero(requestContext, seriesList): """ Offsets a metric or wildcard seriesList by subtracting the minimum value in the series from each datapoint. Useful to compare different series where the values in each series may be higher or lower on average but you're only interested in the re...
[ "def", "offsetToZero", "(", "requestContext", ",", "seriesList", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "\"offsetToZero(%s)\"", "%", "(", "series", ".", "name", ")", "minimum", "=", "safeMin", "(", "series", ")", "f...
Offsets a metric or wildcard seriesList by subtracting the minimum value in the series from each datapoint. Useful to compare different series where the values in each series may be higher or lower on average but you're only interested in the relative difference. An example use case is for compari...
[ "Offsets", "a", "metric", "or", "wildcard", "seriesList", "by", "subtracting", "the", "minimum", "value", "in", "the", "series", "from", "each", "datapoint", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1153-L1187
brutasse/graphite-api
graphite_api/functions.py
movingAverage
def movingAverage(requestContext, seriesList, windowSize): """ Graphs the moving average of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1ho...
python
def movingAverage(requestContext, seriesList, windowSize): """ Graphs the moving average of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1ho...
[ "def", "movingAverage", "(", "requestContext", ",", "seriesList", ",", "windowSize", ")", ":", "if", "not", "seriesList", ":", "return", "[", "]", "windowInterval", "=", "None", "if", "isinstance", "(", "windowSize", ",", "six", ".", "string_types", ")", ":"...
Graphs the moving average of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '5min' (See ``from / until`` in the render\_api_ for example...
[ "Graphs", "the", "moving", "average", "of", "a", "metric", "(", "or", "metrics", ")", "over", "a", "fixed", "number", "of", "past", "points", "or", "a", "time", "interval", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1190-L1254
brutasse/graphite-api
graphite_api/functions.py
movingSum
def movingSum(requestContext, seriesList, windowSize): """ Graphs the moving sum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '...
python
def movingSum(requestContext, seriesList, windowSize): """ Graphs the moving sum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '...
[ "def", "movingSum", "(", "requestContext", ",", "seriesList", ",", "windowSize", ")", ":", "if", "not", "seriesList", ":", "return", "[", "]", "windowInterval", "=", "None", "if", "isinstance", "(", "windowSize", ",", "six", ".", "string_types", ")", ":", ...
Graphs the moving sum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '5min' (See ``from / until`` in the render\_api_ for examples of...
[ "Graphs", "the", "moving", "sum", "of", "a", "metric", "(", "or", "metrics", ")", "over", "a", "fixed", "number", "of", "past", "points", "or", "a", "time", "interval", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1257-L1319
brutasse/graphite-api
graphite_api/functions.py
movingMax
def movingMax(requestContext, seriesList, windowSize): """ Graphs the moving maximum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' ...
python
def movingMax(requestContext, seriesList, windowSize): """ Graphs the moving maximum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' ...
[ "def", "movingMax", "(", "requestContext", ",", "seriesList", ",", "windowSize", ")", ":", "if", "not", "seriesList", ":", "return", "[", "]", "windowInterval", "=", "None", "if", "isinstance", "(", "windowSize", ",", "six", ".", "string_types", ")", ":", ...
Graphs the moving maximum of a metric (or metrics) over a fixed number of past points, or a time interval. Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like '1hour' or '5min' (See ``from / until`` in the render\_api_ for example...
[ "Graphs", "the", "moving", "maximum", "of", "a", "metric", "(", "or", "metrics", ")", "over", "a", "fixed", "number", "of", "past", "points", "or", "a", "time", "interval", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1382-L1439
brutasse/graphite-api
graphite_api/functions.py
consolidateBy
def consolidateBy(requestContext, seriesList, consolidationFunc): """ Takes one metric or a wildcard seriesList and a consolidation function name. Valid function names are 'sum', 'average', 'min', and 'max'. When a graph is drawn where width of the graph size in pixels is smaller than the numb...
python
def consolidateBy(requestContext, seriesList, consolidationFunc): """ Takes one metric or a wildcard seriesList and a consolidation function name. Valid function names are 'sum', 'average', 'min', and 'max'. When a graph is drawn where width of the graph size in pixels is smaller than the numb...
[ "def", "consolidateBy", "(", "requestContext", ",", "seriesList", ",", "consolidationFunc", ")", ":", "for", "series", "in", "seriesList", ":", "# datalib will throw an exception, so it's not necessary to validate", "# here", "series", ".", "consolidationFunc", "=", "consol...
Takes one metric or a wildcard seriesList and a consolidation function name. Valid function names are 'sum', 'average', 'min', and 'max'. When a graph is drawn where width of the graph size in pixels is smaller than the number of datapoints to be graphed, Graphite consolidates the values to to pre...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "a", "consolidation", "function", "name", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1464-L1492
brutasse/graphite-api
graphite_api/functions.py
delay
def delay(requestContext, seriesList, steps): """ This shifts all samples later by an integer number of steps. This can be used for custom derivative calculations, among other things. Note: this will pad the early end of the data with None for every step shifted. This complements other time-displac...
python
def delay(requestContext, seriesList, steps): """ This shifts all samples later by an integer number of steps. This can be used for custom derivative calculations, among other things. Note: this will pad the early end of the data with None for every step shifted. This complements other time-displac...
[ "def", "delay", "(", "requestContext", ",", "seriesList", ",", "steps", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "newValues", "=", "[", "]", "prev", "=", "[", "]", "for", "val", "in", "series", ":", "if", "len", ...
This shifts all samples later by an integer number of steps. This can be used for custom derivative calculations, among other things. Note: this will pad the early end of the data with None for every step shifted. This complements other time-displacement functions such as timeShift and timeSlice, in th...
[ "This", "shifts", "all", "samples", "later", "by", "an", "integer", "number", "of", "steps", ".", "This", "can", "be", "used", "for", "custom", "derivative", "calculations", "among", "other", "things", ".", "Note", ":", "this", "will", "pad", "the", "early...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1581-L1614
brutasse/graphite-api
graphite_api/functions.py
integral
def integral(requestContext, seriesList): """ This will show the sum over time, sort of like a continuous addition function. Useful for finding totals or trends in metrics that are collected per minute. Example:: &target=integral(company.sales.perMinute) This would start at zero on th...
python
def integral(requestContext, seriesList): """ This will show the sum over time, sort of like a continuous addition function. Useful for finding totals or trends in metrics that are collected per minute. Example:: &target=integral(company.sales.perMinute) This would start at zero on th...
[ "def", "integral", "(", "requestContext", ",", "seriesList", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "newValues", "=", "[", "]", "current", "=", "0.0", "for", "val", "in", "series", ":", "if", "val", "is", "None", ...
This will show the sum over time, sort of like a continuous addition function. Useful for finding totals or trends in metrics that are collected per minute. Example:: &target=integral(company.sales.perMinute) This would start at zero on the left side of the graph, adding the sales each mi...
[ "This", "will", "show", "the", "sum", "over", "time", "sort", "of", "like", "a", "continuous", "addition", "function", ".", "Useful", "for", "finding", "totals", "or", "trends", "in", "metrics", "that", "are", "collected", "per", "minute", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1617-L1646
brutasse/graphite-api
graphite_api/functions.py
integralByInterval
def integralByInterval(requestContext, seriesList, intervalUnit): """ This will do the same as integral() funcion, except resetting the total to 0 at the given time in the parameter "from" Useful for finding totals per hour/day/week/.. Example:: &target=integralByInterval(company.sales.per...
python
def integralByInterval(requestContext, seriesList, intervalUnit): """ This will do the same as integral() funcion, except resetting the total to 0 at the given time in the parameter "from" Useful for finding totals per hour/day/week/.. Example:: &target=integralByInterval(company.sales.per...
[ "def", "integralByInterval", "(", "requestContext", ",", "seriesList", ",", "intervalUnit", ")", ":", "intervalDuration", "=", "int", "(", "to_seconds", "(", "parseTimeOffset", "(", "intervalUnit", ")", ")", ")", "startTime", "=", "int", "(", "epoch", "(", "re...
This will do the same as integral() funcion, except resetting the total to 0 at the given time in the parameter "from" Useful for finding totals per hour/day/week/.. Example:: &target=integralByInterval(company.sales.perMinute, "1d")&from=midnight-10days Thi...
[ "This", "will", "do", "the", "same", "as", "integral", "()", "funcion", "except", "resetting", "the", "total", "to", "0", "at", "the", "given", "time", "in", "the", "parameter", "from", "Useful", "for", "finding", "totals", "per", "hour", "/", "day", "/"...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1649-L1694
brutasse/graphite-api
graphite_api/functions.py
nonNegativeDerivative
def nonNegativeDerivative(requestContext, seriesList, maxValue=None): """ Same as the derivative function above, but ignores datapoints that trend down. Useful for counters that increase for a long time, then wrap or reset. (Such as if a network interface is destroyed and recreated by unloading and ...
python
def nonNegativeDerivative(requestContext, seriesList, maxValue=None): """ Same as the derivative function above, but ignores datapoints that trend down. Useful for counters that increase for a long time, then wrap or reset. (Such as if a network interface is destroyed and recreated by unloading and ...
[ "def", "nonNegativeDerivative", "(", "requestContext", ",", "seriesList", ",", "maxValue", "=", "None", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "newValues", "=", "[", "]", "prev", "=", "None", "for", "val", "in", "se...
Same as the derivative function above, but ignores datapoints that trend down. Useful for counters that increase for a long time, then wrap or reset. (Such as if a network interface is destroyed and recreated by unloading and re-loading a kernel module, common with USB / WiFi cards. Example:: ...
[ "Same", "as", "the", "derivative", "function", "above", "but", "ignores", "datapoints", "that", "trend", "down", ".", "Useful", "for", "counters", "that", "increase", "for", "a", "long", "time", "then", "wrap", "or", "reset", ".", "(", "Such", "as", "if", ...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1697-L1738
brutasse/graphite-api
graphite_api/functions.py
stacked
def stacked(requestContext, seriesLists, stackName='__DEFAULT__'): """ Takes one metric or a wildcard seriesList and change them so they are stacked. This is a way of stacking just a couple of metrics without having to use the stacked area mode (that stacks everything). By means of this a mixed stac...
python
def stacked(requestContext, seriesLists, stackName='__DEFAULT__'): """ Takes one metric or a wildcard seriesList and change them so they are stacked. This is a way of stacking just a couple of metrics without having to use the stacked area mode (that stacks everything). By means of this a mixed stac...
[ "def", "stacked", "(", "requestContext", ",", "seriesLists", ",", "stackName", "=", "'__DEFAULT__'", ")", ":", "if", "'totalStack'", "in", "requestContext", ":", "totalStack", "=", "requestContext", "[", "'totalStack'", "]", ".", "get", "(", "stackName", ",", ...
Takes one metric or a wildcard seriesList and change them so they are stacked. This is a way of stacking just a couple of metrics without having to use the stacked area mode (that stacks everything). By means of this a mixed stacked and non stacked graph can be made It can also take an optional argumen...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "change", "them", "so", "they", "are", "stacked", ".", "This", "is", "a", "way", "of", "stacking", "just", "a", "couple", "of", "metrics", "without", "having", "to", "use", "the", "sta...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1741-L1786
brutasse/graphite-api
graphite_api/functions.py
areaBetween
def areaBetween(requestContext, *seriesLists): """ Draws the vertical area in between the two series in seriesList. Useful for visualizing a range such as the minimum and maximum latency for a service. areaBetween expects **exactly one argument** that results in exactly two series (see example belo...
python
def areaBetween(requestContext, *seriesLists): """ Draws the vertical area in between the two series in seriesList. Useful for visualizing a range such as the minimum and maximum latency for a service. areaBetween expects **exactly one argument** that results in exactly two series (see example belo...
[ "def", "areaBetween", "(", "requestContext", ",", "*", "seriesLists", ")", ":", "if", "len", "(", "seriesLists", ")", "==", "1", ":", "[", "seriesLists", "]", "=", "seriesLists", "assert", "len", "(", "seriesLists", ")", "==", "2", ",", "(", "\"areaBetwe...
Draws the vertical area in between the two series in seriesList. Useful for visualizing a range such as the minimum and maximum latency for a service. areaBetween expects **exactly one argument** that results in exactly two series (see example below). The order of the lower and higher values series doe...
[ "Draws", "the", "vertical", "area", "in", "between", "the", "two", "series", "in", "seriesList", ".", "Useful", "for", "visualizing", "a", "range", "such", "as", "the", "minimum", "and", "maximum", "latency", "for", "a", "service", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1789-L1828
brutasse/graphite-api
graphite_api/functions.py
aliasSub
def aliasSub(requestContext, seriesList, search, replace): """ Runs series names through a regex search/replace. Example:: &target=aliasSub(ip.*TCP*,"^.*TCP(\d+)","\\1") """ try: seriesList.name = re.sub(search, replace, seriesList.name) except AttributeError: for series...
python
def aliasSub(requestContext, seriesList, search, replace): """ Runs series names through a regex search/replace. Example:: &target=aliasSub(ip.*TCP*,"^.*TCP(\d+)","\\1") """ try: seriesList.name = re.sub(search, replace, seriesList.name) except AttributeError: for series...
[ "def", "aliasSub", "(", "requestContext", ",", "seriesList", ",", "search", ",", "replace", ")", ":", "try", ":", "seriesList", ".", "name", "=", "re", ".", "sub", "(", "search", ",", "replace", ",", "seriesList", ".", "name", ")", "except", "AttributeEr...
Runs series names through a regex search/replace. Example:: &target=aliasSub(ip.*TCP*,"^.*TCP(\d+)","\\1")
[ "Runs", "series", "names", "through", "a", "regex", "search", "/", "replace", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1831-L1844
brutasse/graphite-api
graphite_api/functions.py
alias
def alias(requestContext, seriesList, newName): """ Takes one metric or a wildcard seriesList and a string in quotes. Prints the string instead of the metric name in the legend. Example:: &target=alias(Sales.widgets.largeBlue,"Large Blue Widgets") """ try: seriesList.name = ne...
python
def alias(requestContext, seriesList, newName): """ Takes one metric or a wildcard seriesList and a string in quotes. Prints the string instead of the metric name in the legend. Example:: &target=alias(Sales.widgets.largeBlue,"Large Blue Widgets") """ try: seriesList.name = ne...
[ "def", "alias", "(", "requestContext", ",", "seriesList", ",", "newName", ")", ":", "try", ":", "seriesList", ".", "name", "=", "newName", "except", "AttributeError", ":", "for", "series", "in", "seriesList", ":", "series", ".", "name", "=", "newName", "re...
Takes one metric or a wildcard seriesList and a string in quotes. Prints the string instead of the metric name in the legend. Example:: &target=alias(Sales.widgets.largeBlue,"Large Blue Widgets")
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "a", "string", "in", "quotes", ".", "Prints", "the", "string", "instead", "of", "the", "metric", "name", "in", "the", "legend", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1847-L1862
brutasse/graphite-api
graphite_api/functions.py
cactiStyle
def cactiStyle(requestContext, seriesList, system=None, units=None): """ Takes a series list and modifies the aliases to provide column aligned output with Current, Max, and Min values in the style of cacti. Optionally takes a "system" value to apply unit formatting in the same style as the Y-axis, ...
python
def cactiStyle(requestContext, seriesList, system=None, units=None): """ Takes a series list and modifies the aliases to provide column aligned output with Current, Max, and Min values in the style of cacti. Optionally takes a "system" value to apply unit formatting in the same style as the Y-axis, ...
[ "def", "cactiStyle", "(", "requestContext", ",", "seriesList", ",", "system", "=", "None", ",", "units", "=", "None", ")", ":", "def", "fmt", "(", "x", ")", ":", "if", "system", ":", "if", "units", ":", "return", "\"%.2f %s\"", "%", "format_units", "("...
Takes a series list and modifies the aliases to provide column aligned output with Current, Max, and Min values in the style of cacti. Optionally takes a "system" value to apply unit formatting in the same style as the Y-axis, or a "unit" string to append an arbitrary unit suffix. NOTE: column alignment...
[ "Takes", "a", "series", "list", "and", "modifies", "the", "aliases", "to", "provide", "column", "aligned", "output", "with", "Current", "Max", "and", "Min", "values", "in", "the", "style", "of", "cacti", ".", "Optionally", "takes", "a", "system", "value", ...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1865-L1918
brutasse/graphite-api
graphite_api/functions.py
_getFirstPathExpression
def _getFirstPathExpression(name): """Returns the first metric path in an expression.""" tokens = grammar.parseString(name) pathExpression = None while pathExpression is None: if tokens.pathExpression: pathExpression = tokens.pathExpression elif tokens.expression: ...
python
def _getFirstPathExpression(name): """Returns the first metric path in an expression.""" tokens = grammar.parseString(name) pathExpression = None while pathExpression is None: if tokens.pathExpression: pathExpression = tokens.pathExpression elif tokens.expression: ...
[ "def", "_getFirstPathExpression", "(", "name", ")", ":", "tokens", "=", "grammar", ".", "parseString", "(", "name", ")", "pathExpression", "=", "None", "while", "pathExpression", "is", "None", ":", "if", "tokens", ".", "pathExpression", ":", "pathExpression", ...
Returns the first metric path in an expression.
[ "Returns", "the", "first", "metric", "path", "in", "an", "expression", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1921-L1934
brutasse/graphite-api
graphite_api/functions.py
aliasByNode
def aliasByNode(requestContext, seriesList, *nodes): """ Takes a seriesList and applies an alias derived from one or more "node" portion/s of the target name. Node indices are 0 indexed. Example:: &target=aliasByNode(ganglia.*.cpu.load5,1) """ for series in seriesList: pathExp...
python
def aliasByNode(requestContext, seriesList, *nodes): """ Takes a seriesList and applies an alias derived from one or more "node" portion/s of the target name. Node indices are 0 indexed. Example:: &target=aliasByNode(ganglia.*.cpu.load5,1) """ for series in seriesList: pathExp...
[ "def", "aliasByNode", "(", "requestContext", ",", "seriesList", ",", "*", "nodes", ")", ":", "for", "series", "in", "seriesList", ":", "pathExpression", "=", "_getFirstPathExpression", "(", "series", ".", "name", ")", "metric_pieces", "=", "pathExpression", ".",...
Takes a seriesList and applies an alias derived from one or more "node" portion/s of the target name. Node indices are 0 indexed. Example:: &target=aliasByNode(ganglia.*.cpu.load5,1)
[ "Takes", "a", "seriesList", "and", "applies", "an", "alias", "derived", "from", "one", "or", "more", "node", "portion", "/", "s", "of", "the", "target", "name", ".", "Node", "indices", "are", "0", "indexed", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1937-L1951
brutasse/graphite-api
graphite_api/functions.py
legendValue
def legendValue(requestContext, seriesList, *valueTypes): """ Takes one metric or a wildcard seriesList and a string in quotes. Appends a value to the metric name in the legend. Currently one or several of: `last`, `avg`, `total`, `min`, `max`. The last argument can be `si` (default) or `binary`, in...
python
def legendValue(requestContext, seriesList, *valueTypes): """ Takes one metric or a wildcard seriesList and a string in quotes. Appends a value to the metric name in the legend. Currently one or several of: `last`, `avg`, `total`, `min`, `max`. The last argument can be `si` (default) or `binary`, in...
[ "def", "legendValue", "(", "requestContext", ",", "seriesList", ",", "*", "valueTypes", ")", ":", "valueFuncs", "=", "{", "'avg'", ":", "lambda", "s", ":", "safeDiv", "(", "safeSum", "(", "s", ")", ",", "safeLen", "(", "s", ")", ")", ",", "'total'", ...
Takes one metric or a wildcard seriesList and a string in quotes. Appends a value to the metric name in the legend. Currently one or several of: `last`, `avg`, `total`, `min`, `max`. The last argument can be `si` (default) or `binary`, in that case values will be formatted in the corresponding system. ...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "and", "a", "string", "in", "quotes", ".", "Appends", "a", "value", "to", "the", "metric", "name", "in", "the", "legend", ".", "Currently", "one", "or", "several", "of", ":", "last", "avg", ...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1966-L2003
brutasse/graphite-api
graphite_api/functions.py
alpha
def alpha(requestContext, seriesList, alpha): """ Assigns the given alpha transparency setting to the series. Takes a float value between 0 and 1. """ for series in seriesList: series.options['alpha'] = alpha return seriesList
python
def alpha(requestContext, seriesList, alpha): """ Assigns the given alpha transparency setting to the series. Takes a float value between 0 and 1. """ for series in seriesList: series.options['alpha'] = alpha return seriesList
[ "def", "alpha", "(", "requestContext", ",", "seriesList", ",", "alpha", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "options", "[", "'alpha'", "]", "=", "alpha", "return", "seriesList" ]
Assigns the given alpha transparency setting to the series. Takes a float value between 0 and 1.
[ "Assigns", "the", "given", "alpha", "transparency", "setting", "to", "the", "series", ".", "Takes", "a", "float", "value", "between", "0", "and", "1", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2006-L2013
brutasse/graphite-api
graphite_api/functions.py
color
def color(requestContext, seriesList, theColor): """ Assigns the given color to the seriesList Example:: &target=color(collectd.hostname.cpu.0.user, 'green') &target=color(collectd.hostname.cpu.0.system, 'ff0000') &target=color(collectd.hostname.cpu.0.idle, 'gray') &target=...
python
def color(requestContext, seriesList, theColor): """ Assigns the given color to the seriesList Example:: &target=color(collectd.hostname.cpu.0.user, 'green') &target=color(collectd.hostname.cpu.0.system, 'ff0000') &target=color(collectd.hostname.cpu.0.idle, 'gray') &target=...
[ "def", "color", "(", "requestContext", ",", "seriesList", ",", "theColor", ")", ":", "for", "series", "in", "seriesList", ":", "series", ".", "color", "=", "theColor", "return", "seriesList" ]
Assigns the given color to the seriesList Example:: &target=color(collectd.hostname.cpu.0.user, 'green') &target=color(collectd.hostname.cpu.0.system, 'ff0000') &target=color(collectd.hostname.cpu.0.idle, 'gray') &target=color(collectd.hostname.cpu.0.idle, '6464ffaa')
[ "Assigns", "the", "given", "color", "to", "the", "seriesList" ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2016-L2030
brutasse/graphite-api
graphite_api/functions.py
substr
def substr(requestContext, seriesList, start=0, stop=0): """ Takes one metric or a wildcard seriesList followed by 1 or 2 integers. Assume that the metric name is a list or array, with each element separated by dots. Prints n - length elements of the array (if only one integer n is passed) or n - m ...
python
def substr(requestContext, seriesList, start=0, stop=0): """ Takes one metric or a wildcard seriesList followed by 1 or 2 integers. Assume that the metric name is a list or array, with each element separated by dots. Prints n - length elements of the array (if only one integer n is passed) or n - m ...
[ "def", "substr", "(", "requestContext", ",", "seriesList", ",", "start", "=", "0", ",", "stop", "=", "0", ")", ":", "for", "series", "in", "seriesList", ":", "left", "=", "series", ".", "name", ".", "rfind", "(", "'('", ")", "+", "1", "right", "=",...
Takes one metric or a wildcard seriesList followed by 1 or 2 integers. Assume that the metric name is a list or array, with each element separated by dots. Prints n - length elements of the array (if only one integer n is passed) or n - m elements of the array (if two integers n and m are passed). The l...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "1", "or", "2", "integers", ".", "Assume", "that", "the", "metric", "name", "is", "a", "list", "or", "array", "with", "each", "element", "separated", "by", "dots", ".", "Pri...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2033-L2062
brutasse/graphite-api
graphite_api/functions.py
logarithm
def logarithm(requestContext, seriesList, base=10): """ Takes one metric or a wildcard seriesList, a base, and draws the y-axis in logarithmic format. If base is omitted, the function defaults to base 10. Example:: &target=log(carbon.agents.hostname.avgUpdateTime,2) """ results = [] ...
python
def logarithm(requestContext, seriesList, base=10): """ Takes one metric or a wildcard seriesList, a base, and draws the y-axis in logarithmic format. If base is omitted, the function defaults to base 10. Example:: &target=log(carbon.agents.hostname.avgUpdateTime,2) """ results = [] ...
[ "def", "logarithm", "(", "requestContext", ",", "seriesList", ",", "base", "=", "10", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "newValues", "=", "[", "]", "for", "val", "in", "series", ":", "if", "val", "is", "Non...
Takes one metric or a wildcard seriesList, a base, and draws the y-axis in logarithmic format. If base is omitted, the function defaults to base 10. Example:: &target=log(carbon.agents.hostname.avgUpdateTime,2)
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "a", "base", "and", "draws", "the", "y", "-", "axis", "in", "logarithmic", "format", ".", "If", "base", "is", "omitted", "the", "function", "defaults", "to", "base", "10", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2065-L2090
brutasse/graphite-api
graphite_api/functions.py
maximumBelow
def maximumBelow(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a maximum value below n. Example:: &target=maximumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which alw...
python
def maximumBelow(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a maximum value below n. Example:: &target=maximumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which alw...
[ "def", "maximumBelow", "(", "requestContext", ",", "seriesList", ",", "n", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "val", "=", "safeMax", "(", "series", ")", "if", "val", "is", "None", "or", "val", "<=", "n", ":"...
Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a maximum value below n. Example:: &target=maximumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which always sent less than 1000 packets/min.
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "a", "constant", "n", ".", "Draws", "only", "the", "metrics", "with", "a", "maximum", "value", "below", "n", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2133-L2150
brutasse/graphite-api
graphite_api/functions.py
minimumBelow
def minimumBelow(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a minimum value below n. Example:: &target=minimumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which sen...
python
def minimumBelow(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a minimum value below n. Example:: &target=minimumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which sen...
[ "def", "minimumBelow", "(", "requestContext", ",", "seriesList", ",", "n", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "val", "=", "safeMin", "(", "series", ")", "if", "val", "is", "None", "or", "val", "<=", "n", ":"...
Takes one metric or a wildcard seriesList followed by a constant n. Draws only the metrics with a minimum value below n. Example:: &target=minimumBelow(system.interface.eth*.packetsSent,1000) This would only display interfaces which sent at one point less than 1000 packets/min.
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "a", "constant", "n", ".", "Draws", "only", "the", "metrics", "with", "a", "minimum", "value", "below", "n", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2153-L2170
brutasse/graphite-api
graphite_api/functions.py
highestMax
def highestMax(requestContext, seriesList, n=1): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the N metrics with the highest maximum value in the time period specified. Example:: &target=highestMax(server*.instance*.threads....
python
def highestMax(requestContext, seriesList, n=1): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the N metrics with the highest maximum value in the time period specified. Example:: &target=highestMax(server*.instance*.threads....
[ "def", "highestMax", "(", "requestContext", ",", "seriesList", ",", "n", "=", "1", ")", ":", "result_list", "=", "sorted", "(", "seriesList", ",", "key", "=", "lambda", "s", ":", "safeMax", "(", "s", ")", ")", "[", "-", "n", ":", "]", "return", "so...
Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the N metrics with the highest maximum value in the time period specified. Example:: &target=highestMax(server*.instance*.threads.busy,5) Draws the top 5 servers who have had the most bu...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "an", "integer", "N", "." ]
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2189-L2205
brutasse/graphite-api
graphite_api/functions.py
currentAbove
def currentAbove(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics whose value is above N at the end of the time period specified. Example:: &target=currentAbove(server*.instance*.thread...
python
def currentAbove(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics whose value is above N at the end of the time period specified. Example:: &target=currentAbove(server*.instance*.thread...
[ "def", "currentAbove", "(", "requestContext", ",", "seriesList", ",", "n", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "val", "=", "safeLast", "(", "series", ")", "if", "val", "is", "not", "None", "and", "val", ">=", ...
Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics whose value is above N at the end of the time period specified. Example:: &target=currentAbove(server*.instance*.threads.busy,50) Draws the servers with more than 50 busy thre...
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "an", "integer", "N", ".", "Out", "of", "all", "metrics", "passed", "draws", "only", "the", "metrics", "whose", "value", "is", "above", "N", "at", "the", "end", "of", "the",...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2224-L2242
brutasse/graphite-api
graphite_api/functions.py
averageAbove
def averageAbove(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics with an average value above N for the time period specified. Example:: &target=averageAbove(server*.instance*.threads.b...
python
def averageAbove(requestContext, seriesList, n): """ Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics with an average value above N for the time period specified. Example:: &target=averageAbove(server*.instance*.threads.b...
[ "def", "averageAbove", "(", "requestContext", ",", "seriesList", ",", "n", ")", ":", "results", "=", "[", "]", "for", "series", "in", "seriesList", ":", "val", "=", "safeAvg", "(", "series", ")", "if", "val", "is", "not", "None", "and", "val", ">=", ...
Takes one metric or a wildcard seriesList followed by an integer N. Out of all metrics passed, draws only the metrics with an average value above N for the time period specified. Example:: &target=averageAbove(server*.instance*.threads.busy,25) Draws the servers with average values above 25.
[ "Takes", "one", "metric", "or", "a", "wildcard", "seriesList", "followed", "by", "an", "integer", "N", ".", "Out", "of", "all", "metrics", "passed", "draws", "only", "the", "metrics", "with", "an", "average", "value", "above", "N", "for", "the", "time", ...
train
https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L2298-L2316