nodes
stringlengths
501
22.4k
edges
stringlengths
138
5.07k
code
stringlengths
108
19.3k
0, module; 1, function_definition; 2, function_name:title_from_rdf; 3, parameters; 4, block; 5, identifier:rdf; 6, identifier:url; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, with_statement; 14, string; 15, assignment; 16, identifier:title; 17, block; 18, identifier:url; 19, block; 20, assignment; 21, assignment; 22, with_clause; 23, block; 24, string_content:Try to extract a distribution title from a property. As it's not a mandatory property, it fallback on building a title from the URL then the format and in last ressort a generic resource name.; 25, identifier:title; 26, call; 27, return_statement; 28, expression_statement; 29, if_statement; 30, identifier:fmt; 31, call; 32, identifier:lang; 33, subscript; 34, with_item; 35, if_statement; 36, identifier:rdf_value; 37, argument_list; 38, identifier:title; 39, assignment; 40, boolean_operator; 41, block; 42, identifier:rdf_value; 43, argument_list; 44, attribute; 45, string; 46, call; 47, identifier:fmt; 48, block; 49, else_clause; 50, identifier:rdf; 51, attribute; 52, identifier:last_part; 53, subscript; 54, comparison_operator:'.' in last_part; 55, comparison_operator:'?' not in last_part; 56, return_statement; 57, identifier:rdf; 58, call; 59, identifier:current_app; 60, identifier:config; 61, string_content:DEFAULT_LANGUAGE; 62, attribute; 63, argument_list; 64, return_statement; 65, block; 66, identifier:DCT; 67, identifier:title; 68, call; 69, unary_operator; 70, string; 71, identifier:last_part; 72, string; 73, identifier:last_part; 74, identifier:last_part; 75, attribute; 76, argument_list; 77, identifier:i18n; 78, identifier:language; 79, identifier:lang; 80, call; 81, return_statement; 82, attribute; 83, argument_list; 84, integer:1; 85, string_content:.; 86, string_content:?; 87, identifier:DCT; 88, identifier:term; 89, string; 90, attribute; 91, argument_list; 92, call; 93, identifier:url; 94, identifier:split; 95, string; 96, string_content:format; 97, call; 98, identifier:format; 99, keyword_argument; 100, attribute; 101, argument_list; 102, string_content:/; 103, attribute; 104, argument_list; 105, identifier:format; 106, call; 107, identifier:i18n; 108, identifier:_; 109, string; 110, identifier:i18n; 111, identifier:_; 112, string; 113, attribute; 114, argument_list; 115, string_content:Nameless resource; 116, string_content:{format} resource; 117, identifier:fmt; 118, identifier:lower
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 9, 17; 10, 18; 10, 19; 11, 20; 12, 21; 13, 22; 13, 23; 14, 24; 15, 25; 15, 26; 17, 27; 19, 28; 19, 29; 20, 30; 20, 31; 21, 32; 21, 33; 22, 34; 23, 35; 26, 36; 26, 37; 27, 38; 28, 39; 29, 40; 29, 41; 31, 42; 31, 43; 33, 44; 33, 45; 34, 46; 35, 47; 35, 48; 35, 49; 37, 50; 37, 51; 39, 52; 39, 53; 40, 54; 40, 55; 41, 56; 43, 57; 43, 58; 44, 59; 44, 60; 45, 61; 46, 62; 46, 63; 48, 64; 49, 65; 51, 66; 51, 67; 53, 68; 53, 69; 54, 70; 54, 71; 55, 72; 55, 73; 56, 74; 58, 75; 58, 76; 62, 77; 62, 78; 63, 79; 64, 80; 65, 81; 68, 82; 68, 83; 69, 84; 70, 85; 72, 86; 75, 87; 75, 88; 76, 89; 80, 90; 80, 91; 81, 92; 82, 93; 82, 94; 83, 95; 89, 96; 90, 97; 90, 98; 91, 99; 92, 100; 92, 101; 95, 102; 97, 103; 97, 104; 99, 105; 99, 106; 100, 107; 100, 108; 101, 109; 103, 110; 103, 111; 104, 112; 106, 113; 106, 114; 109, 115; 112, 116; 113, 117; 113, 118
def title_from_rdf(rdf, url): ''' Try to extract a distribution title from a property. As it's not a mandatory property, it fallback on building a title from the URL then the format and in last ressort a generic resource name. ''' title = rdf_value(rdf, DCT.title) if title: return title if url: last_part = url.split('/')[-1] if '.' in last_part and '?' not in last_part: return last_part fmt = rdf_value(rdf, DCT.term('format')) lang = current_app.config['DEFAULT_LANGUAGE'] with i18n.language(lang): if fmt: return i18n._('{format} resource').format(format=fmt.lower()) else: return i18n._('Nameless resource')
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:by; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, identifier:desc; 13, False; 14, comment:"""Sorts by given property or function, ascending or descending order. Parameters ---------- by : str or callable If string, property by which to sort. If callable, it should receive a GeoFeature a return a value by which to sort. desc : bool, optional Descending sort, default to False (ascending). """; 15, call; 16, block; 17, else_clause; 18, assignment; 19, call; 20, identifier:callable; 21, argument_list; 22, expression_statement; 23, block; 24, identifier:sorted_features; 25, call; 26, attribute; 27, argument_list; 28, identifier:by; 29, assignment; 30, function_definition; 31, identifier:sorted; 32, argument_list; 33, identifier:self; 34, identifier:__class__; 35, identifier:sorted_features; 36, identifier:key; 37, identifier:by; 38, function_name:key; 39, parameters; 40, block; 41, call; 42, keyword_argument; 43, keyword_argument; 44, identifier:feature; 45, return_statement; 46, identifier:list; 47, argument_list; 48, identifier:reverse; 49, identifier:desc; 50, identifier:key; 51, identifier:key; 52, subscript; 53, identifier:self; 54, identifier:feature; 55, identifier:by
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 7, 13; 8, 14; 9, 15; 9, 16; 9, 17; 10, 18; 11, 19; 15, 20; 15, 21; 16, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 21, 28; 22, 29; 23, 30; 25, 31; 25, 32; 26, 33; 26, 34; 27, 35; 29, 36; 29, 37; 30, 38; 30, 39; 30, 40; 32, 41; 32, 42; 32, 43; 39, 44; 40, 45; 41, 46; 41, 47; 42, 48; 42, 49; 43, 50; 43, 51; 45, 52; 47, 53; 52, 54; 52, 55
def sort(self, by, desc=False): """Sorts by given property or function, ascending or descending order. Parameters ---------- by : str or callable If string, property by which to sort. If callable, it should receive a GeoFeature a return a value by which to sort. desc : bool, optional Descending sort, default to False (ascending). """ if callable(by): key = by else: def key(feature): return feature[by] sorted_features = sorted(list(self), reverse=desc, key=key) return self.__class__(sorted_features)
0, module; 1, function_definition; 2, function_name:shellc; 3, parameters; 4, comment:# This works! looks like this is a mutable 2d char array; 5, block; 6, identifier:ndim; 7, identifier:lenvals; 8, identifier:array; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, comment:""" Sort an array of character strings according to the ASCII collating sequence using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shellc_c.html :param ndim: Dimension of the array. :type ndim: int :param lenvals: String length. :type lenvals: int :param array: The array to be sorted. :type array: list of str. :return: The sorted array. :rtype: list of str. """; 16, assignment; 17, assignment; 18, assignment; 19, call; 20, call; 21, identifier:array; 22, call; 23, identifier:ndim; 24, call; 25, identifier:lenvals; 26, call; 27, attribute; 28, argument_list; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, attribute; 34, argument_list; 35, attribute; 36, argument_list; 37, identifier:libspice; 38, identifier:shellc_c; 39, identifier:ndim; 40, identifier:lenvals; 41, call; 42, identifier:stypes; 43, identifier:cVectorToPython; 44, identifier:array; 45, identifier:stypes; 46, identifier:listToCharArray; 47, identifier:array; 48, keyword_argument; 49, keyword_argument; 50, identifier:ctypes; 51, identifier:c_int; 52, identifier:ndim; 53, identifier:ctypes; 54, identifier:c_int; 55, identifier:lenvals; 56, attribute; 57, argument_list; 58, identifier:xLen; 59, identifier:lenvals; 60, identifier:yLen; 61, identifier:ndim; 62, identifier:ctypes; 63, identifier:byref; 64, identifier:array
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 9, 15; 10, 16; 11, 17; 12, 18; 13, 19; 14, 20; 16, 21; 16, 22; 17, 23; 17, 24; 18, 25; 18, 26; 19, 27; 19, 28; 20, 29; 20, 30; 22, 31; 22, 32; 24, 33; 24, 34; 26, 35; 26, 36; 27, 37; 27, 38; 28, 39; 28, 40; 28, 41; 29, 42; 29, 43; 30, 44; 31, 45; 31, 46; 32, 47; 32, 48; 32, 49; 33, 50; 33, 51; 34, 52; 35, 53; 35, 54; 36, 55; 41, 56; 41, 57; 48, 58; 48, 59; 49, 60; 49, 61; 56, 62; 56, 63; 57, 64
def shellc(ndim, lenvals, array): # This works! looks like this is a mutable 2d char array """ Sort an array of character strings according to the ASCII collating sequence using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shellc_c.html :param ndim: Dimension of the array. :type ndim: int :param lenvals: String length. :type lenvals: int :param array: The array to be sorted. :type array: list of str. :return: The sorted array. :rtype: list of str. """ array = stypes.listToCharArray(array, xLen=lenvals, yLen=ndim) ndim = ctypes.c_int(ndim) lenvals = ctypes.c_int(lenvals) libspice.shellc_c(ndim, lenvals, ctypes.byref(array)) return stypes.cVectorToPython(array)
0, module; 1, function_definition; 2, function_name:shelld; 3, parameters; 4, comment:# Works!, use this as example for "I/O" parameters; 5, block; 6, identifier:ndim; 7, identifier:array; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:""" Sort a double precision array using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shelld_c.html :param ndim: Dimension of the array. :type ndim: int :param array: The array to be sorted. :type array: Array of floats :return: The sorted array. :rtype: Array of floats """; 14, assignment; 15, assignment; 16, call; 17, call; 18, identifier:array; 19, call; 20, identifier:ndim; 21, call; 22, attribute; 23, argument_list; 24, attribute; 25, argument_list; 26, attribute; 27, argument_list; 28, attribute; 29, argument_list; 30, identifier:libspice; 31, identifier:shelld_c; 32, identifier:ndim; 33, call; 34, identifier:stypes; 35, identifier:cVectorToPython; 36, identifier:array; 37, identifier:stypes; 38, identifier:toDoubleVector; 39, identifier:array; 40, identifier:ctypes; 41, identifier:c_int; 42, identifier:ndim; 43, attribute; 44, argument_list; 45, identifier:ctypes; 46, identifier:cast; 47, identifier:array; 48, call; 49, attribute; 50, argument_list; 51, identifier:ctypes; 52, identifier:POINTER; 53, attribute; 54, identifier:ctypes; 55, identifier:c_double
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 8, 13; 9, 14; 10, 15; 11, 16; 12, 17; 14, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 19, 26; 19, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 26, 37; 26, 38; 27, 39; 28, 40; 28, 41; 29, 42; 33, 43; 33, 44; 43, 45; 43, 46; 44, 47; 44, 48; 48, 49; 48, 50; 49, 51; 49, 52; 50, 53; 53, 54; 53, 55
def shelld(ndim, array): # Works!, use this as example for "I/O" parameters """ Sort a double precision array using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shelld_c.html :param ndim: Dimension of the array. :type ndim: int :param array: The array to be sorted. :type array: Array of floats :return: The sorted array. :rtype: Array of floats """ array = stypes.toDoubleVector(array) ndim = ctypes.c_int(ndim) libspice.shelld_c(ndim, ctypes.cast(array, ctypes.POINTER(ctypes.c_double))) return stypes.cVectorToPython(array)
0, module; 1, function_definition; 2, function_name:shelli; 3, parameters; 4, comment:# Works!, use this as example for "I/O" parameters; 5, block; 6, identifier:ndim; 7, identifier:array; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:""" Sort an integer array using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shelli_c.html :param ndim: Dimension of the array. :type ndim: int :param array: The array to be sorted. :type array: Array of ints :return: The sorted array. :rtype: Array of ints """; 14, assignment; 15, assignment; 16, call; 17, call; 18, identifier:array; 19, call; 20, identifier:ndim; 21, call; 22, attribute; 23, argument_list; 24, attribute; 25, argument_list; 26, attribute; 27, argument_list; 28, attribute; 29, argument_list; 30, identifier:libspice; 31, identifier:shelli_c; 32, identifier:ndim; 33, call; 34, identifier:stypes; 35, identifier:cVectorToPython; 36, identifier:array; 37, identifier:stypes; 38, identifier:toIntVector; 39, identifier:array; 40, identifier:ctypes; 41, identifier:c_int; 42, identifier:ndim; 43, attribute; 44, argument_list; 45, identifier:ctypes; 46, identifier:cast; 47, identifier:array; 48, call; 49, attribute; 50, argument_list; 51, identifier:ctypes; 52, identifier:POINTER; 53, attribute; 54, identifier:ctypes; 55, identifier:c_int
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 8, 13; 9, 14; 10, 15; 11, 16; 12, 17; 14, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 17, 25; 19, 26; 19, 27; 21, 28; 21, 29; 22, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 26, 37; 26, 38; 27, 39; 28, 40; 28, 41; 29, 42; 33, 43; 33, 44; 43, 45; 43, 46; 44, 47; 44, 48; 48, 49; 48, 50; 49, 51; 49, 52; 50, 53; 53, 54; 53, 55
def shelli(ndim, array): # Works!, use this as example for "I/O" parameters """ Sort an integer array using the Shell Sort algorithm. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/shelli_c.html :param ndim: Dimension of the array. :type ndim: int :param array: The array to be sorted. :type array: Array of ints :return: The sorted array. :rtype: Array of ints """ array = stypes.toIntVector(array) ndim = ctypes.c_int(ndim) libspice.shelli_c(ndim, ctypes.cast(array, ctypes.POINTER(ctypes.c_int))) return stypes.cVectorToPython(array)
0, module; 1, function_definition; 2, function_name:make_retrieveParameters; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, return_statement; 11, identifier:offset; 12, integer:1; 13, identifier:count; 14, integer:100; 15, identifier:name; 16, string; 17, identifier:sort; 18, string; 19, comment:"""Create retrieve parameters dictionary to be used with APIs. :count: Number of records to display in the result. Cannot be less than 0 and cannot be greater than 100. If count is 0 then only the summary information will be returned. :offset: First record in results to return. Must be greater than zero :name: Name of the field to order by. Use a two-character abbreviation to specify the field ('AU': Author, 'CF': Conference Title, 'CG': Page, 'CW': Source, 'CV': Volume, 'LC': Local Times Cited, 'LD': Load Date, 'PG': Page, 'PY': Publication Year, 'RS': Relevance, 'SO': Source, 'TC': Times Cited, 'VL': Volume) :sort: Must be A (ascending) or D (descending). The sort parameter can only be D for Relevance and TimesCited. """; 20, call; 21, string_content:RS; 22, string_content:D; 23, identifier:_OrderedDict; 24, argument_list; 25, list; 26, tuple; 27, tuple; 28, tuple; 29, string; 30, identifier:offset; 31, string; 32, identifier:count; 33, string; 34, call; 35, string_content:firstRecord; 36, string_content:count; 37, string_content:sortField; 38, identifier:_OrderedDict; 39, argument_list; 40, list; 41, tuple; 42, tuple; 43, string; 44, identifier:name; 45, string; 46, identifier:sort; 47, string_content:name; 48, string_content:sort
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 5, 11; 5, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 16, 21; 18, 22; 20, 23; 20, 24; 24, 25; 25, 26; 25, 27; 25, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 31, 36; 33, 37; 34, 38; 34, 39; 39, 40; 40, 41; 40, 42; 41, 43; 41, 44; 42, 45; 42, 46; 43, 47; 45, 48
def make_retrieveParameters(offset=1, count=100, name='RS', sort='D'): """Create retrieve parameters dictionary to be used with APIs. :count: Number of records to display in the result. Cannot be less than 0 and cannot be greater than 100. If count is 0 then only the summary information will be returned. :offset: First record in results to return. Must be greater than zero :name: Name of the field to order by. Use a two-character abbreviation to specify the field ('AU': Author, 'CF': Conference Title, 'CG': Page, 'CW': Source, 'CV': Volume, 'LC': Local Times Cited, 'LD': Load Date, 'PG': Page, 'PY': Publication Year, 'RS': Relevance, 'SO': Source, 'TC': Times Cited, 'VL': Volume) :sort: Must be A (ascending) or D (descending). The sort parameter can only be D for Relevance and TimesCited. """ return _OrderedDict([ ('firstRecord', offset), ('count', count), ('sortField', _OrderedDict([('name', name), ('sort', sort)])) ])
0, module; 1, function_definition; 2, function_name:sorted_names; 3, parameters; 4, block; 5, identifier:names; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, comment:""" Sort a list of names but keep the word 'default' first if it's there. """; 14, assignment; 15, assignment; 16, comparison_operator:'default' in names; 17, block; 18, assignment; 19, identifier:have_default; 20, block; 21, identifier:sorted_names; 22, identifier:names; 23, call; 24, identifier:have_default; 25, False; 26, string; 27, identifier:names; 28, expression_statement; 29, expression_statement; 30, identifier:sorted_names; 31, call; 32, expression_statement; 33, identifier:list; 34, argument_list; 35, string_content:default; 36, call; 37, assignment; 38, identifier:sorted; 39, argument_list; 40, assignment; 41, identifier:names; 42, attribute; 43, argument_list; 44, identifier:have_default; 45, True; 46, identifier:names; 47, identifier:sorted_names; 48, binary_operator:['default'] + sorted_names; 49, identifier:names; 50, identifier:remove; 51, string; 52, list; 53, identifier:sorted_names; 54, string_content:default; 55, string; 56, string_content:default
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 7, 14; 8, 15; 9, 16; 9, 17; 10, 18; 11, 19; 11, 20; 12, 21; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 17, 29; 18, 30; 18, 31; 20, 32; 23, 33; 23, 34; 26, 35; 28, 36; 29, 37; 31, 38; 31, 39; 32, 40; 34, 41; 36, 42; 36, 43; 37, 44; 37, 45; 39, 46; 40, 47; 40, 48; 42, 49; 42, 50; 43, 51; 48, 52; 48, 53; 51, 54; 52, 55; 55, 56
def sorted_names(names): """ Sort a list of names but keep the word 'default' first if it's there. """ names = list(names) have_default = False if 'default' in names: names.remove('default') have_default = True sorted_names = sorted(names) if have_default: sorted_names = ['default'] + sorted_names return sorted_names
0, module; 1, function_definition; 2, function_name:getArticles; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, assert_statement; 13, assert_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:page; 18, integer:1; 19, identifier:count; 20, integer:100; 21, identifier:sortBy; 22, string:"rel"; 23, identifier:sortByAsc; 24, False; 25, identifier:returnInfo; 26, call; 27, comment:""" return a list of articles that match the topic page @param page: which page of the results to return (default: 1) @param count: number of articles to return (default: 100) @param sortBy: how are articles sorted. Options: id (internal id), date (publishing date), cosSim (closeness to the event centroid), rel (relevance to the query), sourceImportance (manually curated score of source importance - high value, high importance), sourceImportanceRank (reverse of sourceImportance), sourceAlexaGlobalRank (global rank of the news source), sourceAlexaCountryRank (country rank of the news source), socialScore (total shares on social media), facebookShares (shares on Facebook only) @param sortByAsc: should the results be sorted in ascending order (True) or descending (False) @param returnInfo: what details should be included in the returned information """; 28, comparison_operator:page >= 1; 29, comparison_operator:count <= 100; 30, assignment; 31, call; 32, call; 33, identifier:ReturnInfo; 34, argument_list; 35, identifier:page; 36, integer:1; 37, identifier:count; 38, integer:100; 39, identifier:params; 40, dictionary; 41, attribute; 42, argument_list; 43, attribute; 44, argument_list; 45, pair; 46, pair; 47, pair; 48, pair; 49, pair; 50, pair; 51, pair; 52, pair; 53, identifier:params; 54, identifier:update; 55, call; 56, attribute; 57, identifier:jsonRequest; 58, string:"/json/article"; 59, identifier:params; 60, string:"action"; 61, string:"getArticlesForTopicPage"; 62, string:"resultType"; 63, string:"articles"; 64, string:"dataType"; 65, subscript; 66, string:"articlesCount"; 67, identifier:count; 68, string:"articlesSortBy"; 69, identifier:sortBy; 70, string:"articlesSortByAsc"; 71, identifier:sortByAsc; 72, string:"page"; 73, identifier:page; 74, string:"topicPage"; 75, call; 76, attribute; 77, argument_list; 78, identifier:self; 79, identifier:eventRegistry; 80, attribute; 81, string:"dataType"; 82, attribute; 83, argument_list; 84, identifier:returnInfo; 85, identifier:getParams; 86, string:"articles"; 87, identifier:self; 88, identifier:topicPage; 89, identifier:json; 90, identifier:dumps; 91, attribute; 92, identifier:self; 93, identifier:topicPage
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 8, 22; 9, 23; 9, 24; 10, 25; 10, 26; 11, 27; 12, 28; 13, 29; 14, 30; 15, 31; 16, 32; 26, 33; 26, 34; 28, 35; 28, 36; 29, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 32, 43; 32, 44; 40, 45; 40, 46; 40, 47; 40, 48; 40, 49; 40, 50; 40, 51; 40, 52; 41, 53; 41, 54; 42, 55; 43, 56; 43, 57; 44, 58; 44, 59; 45, 60; 45, 61; 46, 62; 46, 63; 47, 64; 47, 65; 48, 66; 48, 67; 49, 68; 49, 69; 50, 70; 50, 71; 51, 72; 51, 73; 52, 74; 52, 75; 55, 76; 55, 77; 56, 78; 56, 79; 65, 80; 65, 81; 75, 82; 75, 83; 76, 84; 76, 85; 77, 86; 80, 87; 80, 88; 82, 89; 82, 90; 83, 91; 91, 92; 91, 93
def getArticles(self, page=1, count=100, sortBy = "rel", sortByAsc = False, returnInfo=ReturnInfo()): """ return a list of articles that match the topic page @param page: which page of the results to return (default: 1) @param count: number of articles to return (default: 100) @param sortBy: how are articles sorted. Options: id (internal id), date (publishing date), cosSim (closeness to the event centroid), rel (relevance to the query), sourceImportance (manually curated score of source importance - high value, high importance), sourceImportanceRank (reverse of sourceImportance), sourceAlexaGlobalRank (global rank of the news source), sourceAlexaCountryRank (country rank of the news source), socialScore (total shares on social media), facebookShares (shares on Facebook only) @param sortByAsc: should the results be sorted in ascending order (True) or descending (False) @param returnInfo: what details should be included in the returned information """ assert page >= 1 assert count <= 100 params = { "action": "getArticlesForTopicPage", "resultType": "articles", "dataType": self.topicPage["dataType"], "articlesCount": count, "articlesSortBy": sortBy, "articlesSortByAsc": sortByAsc, "page": page, "topicPage": json.dumps(self.topicPage) } params.update(returnInfo.getParams("articles")) return self.eventRegistry.jsonRequest("/json/article", params)
0, module; 1, function_definition; 2, function_name:pprint; 3, parameters; 4, block; 5, identifier:object; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, keyword_separator; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, if_statement; 21, identifier:stream; 22, identifier:_UNSET_SENTINEL; 23, identifier:indent; 24, identifier:_UNSET_SENTINEL; 25, identifier:width; 26, identifier:_UNSET_SENTINEL; 27, identifier:depth; 28, identifier:_UNSET_SENTINEL; 29, identifier:compact; 30, False; 31, identifier:ribbon_width; 32, identifier:_UNSET_SENTINEL; 33, identifier:max_seq_len; 34, identifier:_UNSET_SENTINEL; 35, identifier:sort_dict_keys; 36, identifier:_UNSET_SENTINEL; 37, identifier:end; 38, string; 39, comment:"""Pretty print a Python value ``object`` to ``stream``, which defaults to ``sys.stdout``. The output will not be colored. :param indent: number of spaces to add for each level of nesting. :param stream: the output stream, defaults to ``sys.stdout`` :param width: a soft maximum allowed number of columns in the output, which the layout algorithm attempts to stay under. :param depth: maximum depth to print nested structures :param ribbon_width: a soft maximum allowed number of columns in the output, after indenting the line :param max_seq_len: a maximum sequence length that applies to subclasses of lists, sets, frozensets, tuples and dicts. A trailing comment that indicates the number of truncated elements. Setting max_seq_len to ``None`` disables truncation. :param sort_dict_keys: a ``bool`` value indicating if dict keys should be sorted in the output. Defaults to ``False``, in which case the default order is used, which is the insertion order in CPython 3.6+. """; 40, assignment; 41, assignment; 42, call; 43, identifier:end; 44, block; 45, string_content; 46, identifier:sdocs; 47, call; 48, identifier:stream; 49, parenthesized_expression; 50, identifier:default_render_to_stream; 51, argument_list; 52, expression_statement; 53, escape_sequence:\n; 54, identifier:python_to_sdocs; 55, argument_list; 56, comment:# This is not in _default_config in case; 57, comment:# sys.stdout changes.; 58, conditional_expression:sys.stdout if stream is _UNSET_SENTINEL else stream; 59, identifier:stream; 60, identifier:sdocs; 61, call; 62, identifier:object; 63, dictionary_splat; 64, attribute; 65, comparison_operator:stream is _UNSET_SENTINEL; 66, identifier:stream; 67, attribute; 68, argument_list; 69, call; 70, identifier:sys; 71, identifier:stdout; 72, identifier:stream; 73, identifier:_UNSET_SENTINEL; 74, identifier:stream; 75, identifier:write; 76, identifier:end; 77, identifier:_merge_defaults; 78, argument_list; 79, keyword_argument; 80, keyword_argument; 81, keyword_argument; 82, keyword_argument; 83, keyword_argument; 84, keyword_argument; 85, identifier:indent; 86, identifier:indent; 87, identifier:width; 88, identifier:width; 89, identifier:depth; 90, identifier:depth; 91, identifier:ribbon_width; 92, identifier:ribbon_width; 93, identifier:max_seq_len; 94, identifier:max_seq_len; 95, identifier:sort_dict_keys; 96, identifier:sort_dict_keys
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 6, 21; 6, 22; 7, 23; 7, 24; 8, 25; 8, 26; 9, 27; 9, 28; 11, 29; 11, 30; 12, 31; 12, 32; 13, 33; 13, 34; 14, 35; 14, 36; 15, 37; 15, 38; 16, 39; 17, 40; 18, 41; 19, 42; 20, 43; 20, 44; 38, 45; 40, 46; 40, 47; 41, 48; 41, 49; 42, 50; 42, 51; 44, 52; 45, 53; 47, 54; 47, 55; 49, 56; 49, 57; 49, 58; 51, 59; 51, 60; 52, 61; 55, 62; 55, 63; 58, 64; 58, 65; 58, 66; 61, 67; 61, 68; 63, 69; 64, 70; 64, 71; 65, 72; 65, 73; 67, 74; 67, 75; 68, 76; 69, 77; 69, 78; 78, 79; 78, 80; 78, 81; 78, 82; 78, 83; 78, 84; 79, 85; 79, 86; 80, 87; 80, 88; 81, 89; 81, 90; 82, 91; 82, 92; 83, 93; 83, 94; 84, 95; 84, 96
def pprint( object, stream=_UNSET_SENTINEL, indent=_UNSET_SENTINEL, width=_UNSET_SENTINEL, depth=_UNSET_SENTINEL, *, compact=False, ribbon_width=_UNSET_SENTINEL, max_seq_len=_UNSET_SENTINEL, sort_dict_keys=_UNSET_SENTINEL, end='\n' ): """Pretty print a Python value ``object`` to ``stream``, which defaults to ``sys.stdout``. The output will not be colored. :param indent: number of spaces to add for each level of nesting. :param stream: the output stream, defaults to ``sys.stdout`` :param width: a soft maximum allowed number of columns in the output, which the layout algorithm attempts to stay under. :param depth: maximum depth to print nested structures :param ribbon_width: a soft maximum allowed number of columns in the output, after indenting the line :param max_seq_len: a maximum sequence length that applies to subclasses of lists, sets, frozensets, tuples and dicts. A trailing comment that indicates the number of truncated elements. Setting max_seq_len to ``None`` disables truncation. :param sort_dict_keys: a ``bool`` value indicating if dict keys should be sorted in the output. Defaults to ``False``, in which case the default order is used, which is the insertion order in CPython 3.6+. """ sdocs = python_to_sdocs( object, **_merge_defaults( indent=indent, width=width, depth=depth, ribbon_width=ribbon_width, max_seq_len=max_seq_len, sort_dict_keys=sort_dict_keys, ) ) stream = ( # This is not in _default_config in case # sys.stdout changes. sys.stdout if stream is _UNSET_SENTINEL else stream ) default_render_to_stream(stream, sdocs) if end: stream.write(end)
0, module; 1, function_definition; 2, function_name:cpprint; 3, parameters; 4, block; 5, identifier:object; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, keyword_separator; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, default_parameter; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, if_statement; 22, identifier:stream; 23, identifier:_UNSET_SENTINEL; 24, identifier:indent; 25, identifier:_UNSET_SENTINEL; 26, identifier:width; 27, identifier:_UNSET_SENTINEL; 28, identifier:depth; 29, identifier:_UNSET_SENTINEL; 30, identifier:compact; 31, False; 32, identifier:ribbon_width; 33, identifier:_UNSET_SENTINEL; 34, identifier:max_seq_len; 35, identifier:_UNSET_SENTINEL; 36, identifier:sort_dict_keys; 37, identifier:_UNSET_SENTINEL; 38, identifier:style; 39, None; 40, identifier:end; 41, string; 42, comment:"""Pretty print a Python value ``object`` to ``stream``, which defaults to sys.stdout. The output will be colored and syntax highlighted. :param indent: number of spaces to add for each level of nesting. :param stream: the output stream, defaults to sys.stdout :param width: a soft maximum allowed number of columns in the output, which the layout algorithm attempts to stay under. :param depth: maximum depth to print nested structures :param ribbon_width: a soft maximum allowed number of columns in the output, after indenting the line :param max_seq_len: a maximum sequence length that applies to subclasses of lists, sets, frozensets, tuples and dicts. A trailing comment that indicates the number of truncated elements. Setting max_seq_len to ``None`` disables truncation. :param sort_dict_keys: a ``bool`` value indicating if dict keys should be sorted in the output. Defaults to ``False``, in which case the default order is used, which is the insertion order in CPython 3.6+. :param style: one of ``'light'``, ``'dark'`` or a subclass of ``pygments.styles.Style``. If omitted, will use the default style. If the default style is not changed by the user with :func:`~prettyprinter.set_default_style`, the default is ``'dark'``. """; 43, assignment; 44, assignment; 45, call; 46, identifier:end; 47, block; 48, string_content; 49, identifier:sdocs; 50, call; 51, identifier:stream; 52, parenthesized_expression; 53, identifier:colored_render_to_stream; 54, argument_list; 55, expression_statement; 56, escape_sequence:\n; 57, identifier:python_to_sdocs; 58, argument_list; 59, comment:# This is not in _default_config in case; 60, comment:# sys.stdout changes.; 61, conditional_expression:sys.stdout if stream is _UNSET_SENTINEL else stream; 62, identifier:stream; 63, identifier:sdocs; 64, keyword_argument; 65, call; 66, identifier:object; 67, dictionary_splat; 68, attribute; 69, comparison_operator:stream is _UNSET_SENTINEL; 70, identifier:stream; 71, identifier:style; 72, identifier:style; 73, attribute; 74, argument_list; 75, call; 76, identifier:sys; 77, identifier:stdout; 78, identifier:stream; 79, identifier:_UNSET_SENTINEL; 80, identifier:stream; 81, identifier:write; 82, identifier:end; 83, identifier:_merge_defaults; 84, argument_list; 85, keyword_argument; 86, keyword_argument; 87, keyword_argument; 88, keyword_argument; 89, keyword_argument; 90, keyword_argument; 91, identifier:indent; 92, identifier:indent; 93, identifier:width; 94, identifier:width; 95, identifier:depth; 96, identifier:depth; 97, identifier:ribbon_width; 98, identifier:ribbon_width; 99, identifier:max_seq_len; 100, identifier:max_seq_len; 101, identifier:sort_dict_keys; 102, identifier:sort_dict_keys
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 6, 22; 6, 23; 7, 24; 7, 25; 8, 26; 8, 27; 9, 28; 9, 29; 11, 30; 11, 31; 12, 32; 12, 33; 13, 34; 13, 35; 14, 36; 14, 37; 15, 38; 15, 39; 16, 40; 16, 41; 17, 42; 18, 43; 19, 44; 20, 45; 21, 46; 21, 47; 41, 48; 43, 49; 43, 50; 44, 51; 44, 52; 45, 53; 45, 54; 47, 55; 48, 56; 50, 57; 50, 58; 52, 59; 52, 60; 52, 61; 54, 62; 54, 63; 54, 64; 55, 65; 58, 66; 58, 67; 61, 68; 61, 69; 61, 70; 64, 71; 64, 72; 65, 73; 65, 74; 67, 75; 68, 76; 68, 77; 69, 78; 69, 79; 73, 80; 73, 81; 74, 82; 75, 83; 75, 84; 84, 85; 84, 86; 84, 87; 84, 88; 84, 89; 84, 90; 85, 91; 85, 92; 86, 93; 86, 94; 87, 95; 87, 96; 88, 97; 88, 98; 89, 99; 89, 100; 90, 101; 90, 102
def cpprint( object, stream=_UNSET_SENTINEL, indent=_UNSET_SENTINEL, width=_UNSET_SENTINEL, depth=_UNSET_SENTINEL, *, compact=False, ribbon_width=_UNSET_SENTINEL, max_seq_len=_UNSET_SENTINEL, sort_dict_keys=_UNSET_SENTINEL, style=None, end='\n' ): """Pretty print a Python value ``object`` to ``stream``, which defaults to sys.stdout. The output will be colored and syntax highlighted. :param indent: number of spaces to add for each level of nesting. :param stream: the output stream, defaults to sys.stdout :param width: a soft maximum allowed number of columns in the output, which the layout algorithm attempts to stay under. :param depth: maximum depth to print nested structures :param ribbon_width: a soft maximum allowed number of columns in the output, after indenting the line :param max_seq_len: a maximum sequence length that applies to subclasses of lists, sets, frozensets, tuples and dicts. A trailing comment that indicates the number of truncated elements. Setting max_seq_len to ``None`` disables truncation. :param sort_dict_keys: a ``bool`` value indicating if dict keys should be sorted in the output. Defaults to ``False``, in which case the default order is used, which is the insertion order in CPython 3.6+. :param style: one of ``'light'``, ``'dark'`` or a subclass of ``pygments.styles.Style``. If omitted, will use the default style. If the default style is not changed by the user with :func:`~prettyprinter.set_default_style`, the default is ``'dark'``. """ sdocs = python_to_sdocs( object, **_merge_defaults( indent=indent, width=width, depth=depth, ribbon_width=ribbon_width, max_seq_len=max_seq_len, sort_dict_keys=sort_dict_keys, ) ) stream = ( # This is not in _default_config in case # sys.stdout changes. sys.stdout if stream is _UNSET_SENTINEL else stream ) colored_render_to_stream(stream, sdocs, style=style) if end: stream.write(end)
0, module; 1, function_definition; 2, function_name:_encrypted_data_keys_hash; 3, parameters; 4, block; 5, identifier:hasher; 6, identifier:encrypted_data_keys; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Generates the expected hash for the provided encrypted data keys. :param hasher: Existing hasher to use :type hasher: cryptography.hazmat.primitives.hashes.Hash :param iterable encrypted_data_keys: Encrypted data keys to hash :returns: Concatenated, sorted, list of all hashes :rtype: bytes """; 12, assignment; 13, identifier:edk; 14, identifier:encrypted_data_keys; 15, block; 16, call; 17, identifier:hashed_keys; 18, list; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, attribute; 24, argument_list; 25, assignment; 26, assignment; 27, call; 28, call; 29, string:b""; 30, identifier:join; 31, call; 32, identifier:serialized_edk; 33, call; 34, identifier:_hasher; 35, call; 36, attribute; 37, argument_list; 38, attribute; 39, argument_list; 40, identifier:sorted; 41, argument_list; 42, identifier:serialize_encrypted_data_key; 43, argument_list; 44, attribute; 45, argument_list; 46, identifier:_hasher; 47, identifier:update; 48, identifier:serialized_edk; 49, identifier:hashed_keys; 50, identifier:append; 51, call; 52, identifier:hashed_keys; 53, identifier:edk; 54, identifier:hasher; 55, identifier:copy; 56, attribute; 57, argument_list; 58, identifier:_hasher; 59, identifier:finalize
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 15, 19; 15, 20; 15, 21; 15, 22; 16, 23; 16, 24; 19, 25; 20, 26; 21, 27; 22, 28; 23, 29; 23, 30; 24, 31; 25, 32; 25, 33; 26, 34; 26, 35; 27, 36; 27, 37; 28, 38; 28, 39; 31, 40; 31, 41; 33, 42; 33, 43; 35, 44; 35, 45; 36, 46; 36, 47; 37, 48; 38, 49; 38, 50; 39, 51; 41, 52; 43, 53; 44, 54; 44, 55; 51, 56; 51, 57; 56, 58; 56, 59
def _encrypted_data_keys_hash(hasher, encrypted_data_keys): """Generates the expected hash for the provided encrypted data keys. :param hasher: Existing hasher to use :type hasher: cryptography.hazmat.primitives.hashes.Hash :param iterable encrypted_data_keys: Encrypted data keys to hash :returns: Concatenated, sorted, list of all hashes :rtype: bytes """ hashed_keys = [] for edk in encrypted_data_keys: serialized_edk = serialize_encrypted_data_key(edk) _hasher = hasher.copy() _hasher.update(serialized_edk) hashed_keys.append(_hasher.finalize()) return b"".join(sorted(hashed_keys))
0, module; 1, function_definition; 2, function_name:getOverlaySortOrder; 3, parameters; 4, block; 5, identifier:self; 6, identifier:ulOverlayHandle; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Gets the sort order of the overlay. See SetOverlaySortOrder for how this works."""; 13, assignment; 14, assignment; 15, assignment; 16, expression_list; 17, identifier:fn; 18, attribute; 19, identifier:punSortOrder; 20, call; 21, identifier:result; 22, call; 23, identifier:result; 24, attribute; 25, attribute; 26, identifier:getOverlaySortOrder; 27, identifier:c_uint32; 28, argument_list; 29, identifier:fn; 30, argument_list; 31, identifier:punSortOrder; 32, identifier:value; 33, identifier:self; 34, identifier:function_table; 35, identifier:ulOverlayHandle; 36, call; 37, identifier:byref; 38, argument_list; 39, identifier:punSortOrder
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 9, 14; 10, 15; 11, 16; 13, 17; 13, 18; 14, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 18, 25; 18, 26; 20, 27; 20, 28; 22, 29; 22, 30; 24, 31; 24, 32; 25, 33; 25, 34; 30, 35; 30, 36; 36, 37; 36, 38; 38, 39
def getOverlaySortOrder(self, ulOverlayHandle): """Gets the sort order of the overlay. See SetOverlaySortOrder for how this works.""" fn = self.function_table.getOverlaySortOrder punSortOrder = c_uint32() result = fn(ulOverlayHandle, byref(punSortOrder)) return result, punSortOrder.value
0, module; 1, function_definition; 2, function_name:naturalize_string; 3, parameters; 4, block; 5, identifier:key; 6, expression_statement; 7, return_statement; 8, comment:"""Analyzes string in a human way to enable natural sort :param nodename: The node name to analyze :returns: A structure that can be consumed by 'sorted' """; 9, list_comprehension; 10, conditional_expression:int(text) if text.isdigit() else text.lower(); 11, for_in_clause; 12, call; 13, call; 14, call; 15, identifier:text; 16, call; 17, identifier:int; 18, argument_list; 19, attribute; 20, argument_list; 21, attribute; 22, argument_list; 23, attribute; 24, argument_list; 25, identifier:text; 26, identifier:text; 27, identifier:isdigit; 28, identifier:text; 29, identifier:lower; 30, identifier:re; 31, identifier:split; 32, identifier:numregex; 33, identifier:key
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 10, 14; 11, 15; 11, 16; 12, 17; 12, 18; 13, 19; 13, 20; 14, 21; 14, 22; 16, 23; 16, 24; 18, 25; 19, 26; 19, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 24, 33
def naturalize_string(key): """Analyzes string in a human way to enable natural sort :param nodename: The node name to analyze :returns: A structure that can be consumed by 'sorted' """ return [int(text) if text.isdigit() else text.lower() for text in re.split(numregex, key)]
0, module; 1, function_definition; 2, function_name:_get_rows; 3, parameters; 4, block; 5, identifier:self; 6, identifier:options; 7, expression_statement; 8, if_statement; 9, comment:# Sort; 10, if_statement; 11, comment:# Slice if necessary; 12, if_statement; 13, return_statement; 14, comment:"""Return only those data rows that should be printed, based on slicing and sorting. Arguments: options - dictionary of option settings."""; 15, subscript; 16, block; 17, else_clause; 18, subscript; 19, block; 20, not_operator; 21, block; 22, identifier:rows; 23, identifier:options; 24, string:"oldsortslice"; 25, expression_statement; 26, block; 27, identifier:options; 28, string:"sortby"; 29, expression_statement; 30, comment:# Decorate; 31, expression_statement; 32, comment:# Sort; 33, expression_statement; 34, comment:# Undecorate; 35, expression_statement; 36, subscript; 37, expression_statement; 38, assignment; 39, expression_statement; 40, assignment; 41, assignment; 42, call; 43, assignment; 44, identifier:options; 45, string:"oldsortslice"; 46, assignment; 47, identifier:rows; 48, call; 49, assignment; 50, identifier:sortindex; 51, call; 52, identifier:rows; 53, list_comprehension; 54, attribute; 55, argument_list; 56, identifier:rows; 57, list_comprehension; 58, identifier:rows; 59, subscript; 60, attribute; 61, argument_list; 62, identifier:rows; 63, call; 64, attribute; 65, argument_list; 66, binary_operator:[row[sortindex]] + row; 67, for_in_clause; 68, identifier:rows; 69, identifier:sort; 70, keyword_argument; 71, keyword_argument; 72, subscript; 73, for_in_clause; 74, identifier:rows; 75, slice; 76, identifier:copy; 77, identifier:deepcopy; 78, subscript; 79, attribute; 80, argument_list; 81, attribute; 82, identifier:index; 83, subscript; 84, list; 85, identifier:row; 86, identifier:row; 87, identifier:rows; 88, identifier:reverse; 89, subscript; 90, identifier:key; 91, subscript; 92, identifier:row; 93, slice; 94, identifier:row; 95, identifier:rows; 96, subscript; 97, subscript; 98, attribute; 99, slice; 100, identifier:copy; 101, identifier:deepcopy; 102, attribute; 103, identifier:self; 104, identifier:_field_names; 105, identifier:options; 106, string:"sortby"; 107, subscript; 108, identifier:options; 109, string:"reversesort"; 110, identifier:options; 111, string:"sort_key"; 112, integer:1; 113, identifier:options; 114, string:"start"; 115, identifier:options; 116, string:"end"; 117, identifier:self; 118, identifier:_rows; 119, subscript; 120, subscript; 121, identifier:self; 122, identifier:_rows; 123, identifier:row; 124, identifier:sortindex; 125, identifier:options; 126, string:"start"; 127, identifier:options; 128, string:"end"
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 8, 16; 8, 17; 10, 18; 10, 19; 12, 20; 12, 21; 13, 22; 15, 23; 15, 24; 16, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 19, 31; 19, 32; 19, 33; 19, 34; 19, 35; 20, 36; 21, 37; 25, 38; 26, 39; 29, 40; 31, 41; 33, 42; 35, 43; 36, 44; 36, 45; 37, 46; 38, 47; 38, 48; 39, 49; 40, 50; 40, 51; 41, 52; 41, 53; 42, 54; 42, 55; 43, 56; 43, 57; 46, 58; 46, 59; 48, 60; 48, 61; 49, 62; 49, 63; 51, 64; 51, 65; 53, 66; 53, 67; 54, 68; 54, 69; 55, 70; 55, 71; 57, 72; 57, 73; 59, 74; 59, 75; 60, 76; 60, 77; 61, 78; 63, 79; 63, 80; 64, 81; 64, 82; 65, 83; 66, 84; 66, 85; 67, 86; 67, 87; 70, 88; 70, 89; 71, 90; 71, 91; 72, 92; 72, 93; 73, 94; 73, 95; 75, 96; 75, 97; 78, 98; 78, 99; 79, 100; 79, 101; 80, 102; 81, 103; 81, 104; 83, 105; 83, 106; 84, 107; 89, 108; 89, 109; 91, 110; 91, 111; 93, 112; 96, 113; 96, 114; 97, 115; 97, 116; 98, 117; 98, 118; 99, 119; 99, 120; 102, 121; 102, 122; 107, 123; 107, 124; 119, 125; 119, 126; 120, 127; 120, 128
def _get_rows(self, options): """Return only those data rows that should be printed, based on slicing and sorting. Arguments: options - dictionary of option settings.""" if options["oldsortslice"]: rows = copy.deepcopy(self._rows[options["start"]:options["end"]]) else: rows = copy.deepcopy(self._rows) # Sort if options["sortby"]: sortindex = self._field_names.index(options["sortby"]) # Decorate rows = [[row[sortindex]] + row for row in rows] # Sort rows.sort(reverse=options["reversesort"], key=options["sort_key"]) # Undecorate rows = [row[1:] for row in rows] # Slice if necessary if not options["oldsortslice"]: rows = rows[options["start"]:options["end"]] return rows
0, module; 1, function_definition; 2, function_name:_resolve_sort_by; 3, parameters; 4, block; 5, identifier:sort_by; 6, identifier:flag_radius_query; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:""" Result ``sort_by`` argument. :param sort_by: str, or sqlalchemy ORM attribute. :param flag_radius_query: :return: """; 11, comparison_operator:sort_by is None; 12, block; 13, elif_clause; 14, else_clause; 15, identifier:sort_by; 16, identifier:sort_by; 17, None; 18, if_statement; 19, call; 20, block; 21, block; 22, identifier:flag_radius_query; 23, block; 24, identifier:isinstance; 25, argument_list; 26, if_statement; 27, expression_statement; 28, expression_statement; 29, identifier:sort_by; 30, identifier:string_types; 31, comparison_operator:sort_by.lower() == SORT_BY_DIST; 32, block; 33, elif_clause; 34, assignment; 35, assignment; 36, call; 37, identifier:SORT_BY_DIST; 38, if_statement; 39, expression_statement; 40, comparison_operator:sort_by not in SimpleZipcode.__table__.columns; 41, block; 42, identifier:sort_by; 43, attribute; 44, identifier:sort_by; 45, identifier:SORT_BY_DIST; 46, attribute; 47, argument_list; 48, comparison_operator:flag_radius_query is False; 49, block; 50, assignment; 51, identifier:sort_by; 52, attribute; 53, expression_statement; 54, raise_statement; 55, identifier:sort_by; 56, identifier:name; 57, identifier:sort_by; 58, identifier:lower; 59, identifier:flag_radius_query; 60, False; 61, expression_statement; 62, raise_statement; 63, identifier:sort_by; 64, identifier:SORT_BY_DIST; 65, attribute; 66, identifier:columns; 67, assignment; 68, call; 69, assignment; 70, call; 71, identifier:SimpleZipcode; 72, identifier:__table__; 73, identifier:msg; 74, string:"`sort_by` arg has to be one of the Zipcode attribute or 'dist'!"; 75, identifier:ValueError; 76, argument_list; 77, identifier:msg; 78, string:"`sort_by` arg can be 'dist' only under distance based query!"; 79, identifier:ValueError; 80, argument_list; 81, identifier:msg; 82, identifier:msg
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 12, 18; 13, 19; 13, 20; 14, 21; 18, 22; 18, 23; 19, 24; 19, 25; 20, 26; 21, 27; 23, 28; 25, 29; 25, 30; 26, 31; 26, 32; 26, 33; 27, 34; 28, 35; 31, 36; 31, 37; 32, 38; 32, 39; 33, 40; 33, 41; 34, 42; 34, 43; 35, 44; 35, 45; 36, 46; 36, 47; 38, 48; 38, 49; 39, 50; 40, 51; 40, 52; 41, 53; 41, 54; 43, 55; 43, 56; 46, 57; 46, 58; 48, 59; 48, 60; 49, 61; 49, 62; 50, 63; 50, 64; 52, 65; 52, 66; 53, 67; 54, 68; 61, 69; 62, 70; 65, 71; 65, 72; 67, 73; 67, 74; 68, 75; 68, 76; 69, 77; 69, 78; 70, 79; 70, 80; 76, 81; 80, 82
def _resolve_sort_by(sort_by, flag_radius_query): """ Result ``sort_by`` argument. :param sort_by: str, or sqlalchemy ORM attribute. :param flag_radius_query: :return: """ if sort_by is None: if flag_radius_query: sort_by = SORT_BY_DIST elif isinstance(sort_by, string_types): if sort_by.lower() == SORT_BY_DIST: if flag_radius_query is False: msg = "`sort_by` arg can be 'dist' only under distance based query!" raise ValueError(msg) sort_by = SORT_BY_DIST elif sort_by not in SimpleZipcode.__table__.columns: msg = "`sort_by` arg has to be one of the Zipcode attribute or 'dist'!" raise ValueError(msg) else: sort_by = sort_by.name return sort_by
0, module; 1, function_definition; 2, function_name:getOPOrUserServices; 3, parameters; 4, block; 5, identifier:openid_services; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Extract OP Identifier services. If none found, return the rest, sorted with most preferred first according to OpenIDServiceEndpoint.openid_type_uris. openid_services is a list of OpenIDServiceEndpoint objects. Returns a list of OpenIDServiceEndpoint objects."""; 11, assignment; 12, assignment; 13, boolean_operator; 14, identifier:op_services; 15, call; 16, identifier:openid_services; 17, call; 18, identifier:op_services; 19, identifier:openid_services; 20, identifier:arrangeByType; 21, argument_list; 22, identifier:arrangeByType; 23, argument_list; 24, identifier:openid_services; 25, list; 26, identifier:openid_services; 27, attribute; 28, identifier:OPENID_IDP_2_0_TYPE; 29, identifier:OpenIDServiceEndpoint; 30, identifier:openid_type_uris
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 9, 13; 11, 14; 11, 15; 12, 16; 12, 17; 13, 18; 13, 19; 15, 20; 15, 21; 17, 22; 17, 23; 21, 24; 21, 25; 23, 26; 23, 27; 25, 28; 27, 29; 27, 30
def getOPOrUserServices(openid_services): """Extract OP Identifier services. If none found, return the rest, sorted with most preferred first according to OpenIDServiceEndpoint.openid_type_uris. openid_services is a list of OpenIDServiceEndpoint objects. Returns a list of OpenIDServiceEndpoint objects.""" op_services = arrangeByType(openid_services, [OPENID_IDP_2_0_TYPE]) openid_services = arrangeByType(openid_services, OpenIDServiceEndpoint.openid_type_uris) return op_services or openid_services
0, module; 1, function_definition; 2, function_name:AdvSearch; 3, parameters; 4, block; 5, identifier:document; 6, identifier:search; 7, default_parameter; 8, expression_statement; 9, comment:# Compile the search regexp; 10, expression_statement; 11, expression_statement; 12, comment:# Will match against searchels. Searchels is a list that contains last; 13, comment:# n text elements found in the document. 1 < n < bs; 14, expression_statement; 15, for_statement; 16, return_statement; 17, identifier:bs; 18, integer:3; 19, string; 20, assignment; 21, assignment; 22, assignment; 23, identifier:element; 24, call; 25, block; 26, call; 27, string_content:Return set of all regex matches This is an advanced version of python-docx.search() that takes into account blocks of <bs> elements at a time. What it does: It searches the entire document body for text blocks. Since the text to search could be spawned across multiple text blocks, we need to adopt some sort of algorithm to handle this situation. The smaller matching group of blocks (up to bs) is then adopted. If the matching group has more than one block, blocks other than first are cleared and all the replacement text is put on first block. Examples: original text blocks : [ 'Hel', 'lo,', ' world!' ] search : 'Hello,' output blocks : [ 'Hello,' ] original text blocks : [ 'Hel', 'lo', ' __', 'name', '__!' ] search : '(__[a-z]+__)' output blocks : [ '__name__' ] @param instance document: The original document @param str search: The text to search for (regexp) append, or a list of etree elements @param int bs: See above @return set All occurences of search string; 28, identifier:searchre; 29, call; 30, identifier:matches; 31, list; 32, identifier:searchels; 33, list; 34, attribute; 35, argument_list; 36, if_statement; 37, identifier:set; 38, argument_list; 39, attribute; 40, argument_list; 41, identifier:document; 42, identifier:iter; 43, comparison_operator:element.tag == '{%s}t' % nsprefixes['w']; 44, comment:# t (text) elements; 45, block; 46, identifier:matches; 47, identifier:re; 48, identifier:compile; 49, identifier:search; 50, attribute; 51, binary_operator:'{%s}t' % nsprefixes['w']; 52, if_statement; 53, identifier:element; 54, identifier:tag; 55, string; 56, subscript; 57, attribute; 58, comment:# Add this element to searchels; 59, block; 60, string_content:{%s}t; 61, identifier:nsprefixes; 62, string; 63, identifier:element; 64, identifier:text; 65, expression_statement; 66, if_statement; 67, comment:# Search all combinations, of searchels, starting from; 68, comment:# smaller up to bigger ones; 69, comment:# l = search lenght; 70, comment:# s = search start; 71, comment:# e = element IDs to merge; 72, expression_statement; 73, for_statement; 74, string_content:w; 75, call; 76, comparison_operator:len(searchels) > bs; 77, comment:# Is searchels is too long, remove first elements; 78, block; 79, assignment; 80, identifier:l; 81, call; 82, block; 83, attribute; 84, argument_list; 85, call; 86, identifier:bs; 87, expression_statement; 88, identifier:found; 89, False; 90, identifier:range; 91, argument_list; 92, if_statement; 93, for_statement; 94, identifier:searchels; 95, identifier:append; 96, identifier:element; 97, identifier:len; 98, argument_list; 99, call; 100, integer:1; 101, binary_operator:len(searchels)+1; 102, identifier:found; 103, block; 104, identifier:s; 105, call; 106, block; 107, identifier:searchels; 108, attribute; 109, argument_list; 110, call; 111, integer:1; 112, break_statement; 113, identifier:range; 114, argument_list; 115, if_statement; 116, if_statement; 117, identifier:searchels; 118, identifier:pop; 119, integer:0; 120, identifier:len; 121, argument_list; 122, call; 123, identifier:found; 124, block; 125, comparison_operator:s+l <= len(searchels); 126, block; 127, identifier:searchels; 128, identifier:len; 129, argument_list; 130, break_statement; 131, binary_operator:s+l; 132, call; 133, expression_statement; 134, expression_statement; 135, for_statement; 136, comment:# Searcs for the text in the whole txtsearch; 137, expression_statement; 138, if_statement; 139, identifier:searchels; 140, identifier:s; 141, identifier:l; 142, identifier:len; 143, argument_list; 144, assignment; 145, assignment; 146, identifier:k; 147, identifier:e; 148, block; 149, assignment; 150, identifier:match; 151, block; 152, identifier:searchels; 153, identifier:e; 154, call; 155, identifier:txtsearch; 156, string; 157, expression_statement; 158, identifier:match; 159, call; 160, expression_statement; 161, expression_statement; 162, identifier:range; 163, argument_list; 164, augmented_assignment; 165, attribute; 166, argument_list; 167, call; 168, assignment; 169, identifier:s; 170, binary_operator:s+l; 171, identifier:txtsearch; 172, attribute; 173, identifier:searchre; 174, identifier:search; 175, identifier:txtsearch; 176, attribute; 177, argument_list; 178, identifier:found; 179, True; 180, identifier:s; 181, identifier:l; 182, subscript; 183, identifier:text; 184, identifier:matches; 185, identifier:append; 186, call; 187, identifier:searchels; 188, identifier:k; 189, attribute; 190, argument_list; 191, identifier:match; 192, identifier:group
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 7, 17; 7, 18; 8, 19; 10, 20; 11, 21; 14, 22; 15, 23; 15, 24; 15, 25; 16, 26; 19, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 24, 34; 24, 35; 25, 36; 26, 37; 26, 38; 29, 39; 29, 40; 34, 41; 34, 42; 36, 43; 36, 44; 36, 45; 38, 46; 39, 47; 39, 48; 40, 49; 43, 50; 43, 51; 45, 52; 50, 53; 50, 54; 51, 55; 51, 56; 52, 57; 52, 58; 52, 59; 55, 60; 56, 61; 56, 62; 57, 63; 57, 64; 59, 65; 59, 66; 59, 67; 59, 68; 59, 69; 59, 70; 59, 71; 59, 72; 59, 73; 62, 74; 65, 75; 66, 76; 66, 77; 66, 78; 72, 79; 73, 80; 73, 81; 73, 82; 75, 83; 75, 84; 76, 85; 76, 86; 78, 87; 79, 88; 79, 89; 81, 90; 81, 91; 82, 92; 82, 93; 83, 94; 83, 95; 84, 96; 85, 97; 85, 98; 87, 99; 91, 100; 91, 101; 92, 102; 92, 103; 93, 104; 93, 105; 93, 106; 98, 107; 99, 108; 99, 109; 101, 110; 101, 111; 103, 112; 105, 113; 105, 114; 106, 115; 106, 116; 108, 117; 108, 118; 109, 119; 110, 120; 110, 121; 114, 122; 115, 123; 115, 124; 116, 125; 116, 126; 121, 127; 122, 128; 122, 129; 124, 130; 125, 131; 125, 132; 126, 133; 126, 134; 126, 135; 126, 136; 126, 137; 126, 138; 129, 139; 131, 140; 131, 141; 132, 142; 132, 143; 133, 144; 134, 145; 135, 146; 135, 147; 135, 148; 137, 149; 138, 150; 138, 151; 143, 152; 144, 153; 144, 154; 145, 155; 145, 156; 148, 157; 149, 158; 149, 159; 151, 160; 151, 161; 154, 162; 154, 163; 157, 164; 159, 165; 159, 166; 160, 167; 161, 168; 163, 169; 163, 170; 164, 171; 164, 172; 165, 173; 165, 174; 166, 175; 167, 176; 167, 177; 168, 178; 168, 179; 170, 180; 170, 181; 172, 182; 172, 183; 176, 184; 176, 185; 177, 186; 182, 187; 182, 188; 186, 189; 186, 190; 189, 191; 189, 192
def AdvSearch(document, search, bs=3): '''Return set of all regex matches This is an advanced version of python-docx.search() that takes into account blocks of <bs> elements at a time. What it does: It searches the entire document body for text blocks. Since the text to search could be spawned across multiple text blocks, we need to adopt some sort of algorithm to handle this situation. The smaller matching group of blocks (up to bs) is then adopted. If the matching group has more than one block, blocks other than first are cleared and all the replacement text is put on first block. Examples: original text blocks : [ 'Hel', 'lo,', ' world!' ] search : 'Hello,' output blocks : [ 'Hello,' ] original text blocks : [ 'Hel', 'lo', ' __', 'name', '__!' ] search : '(__[a-z]+__)' output blocks : [ '__name__' ] @param instance document: The original document @param str search: The text to search for (regexp) append, or a list of etree elements @param int bs: See above @return set All occurences of search string ''' # Compile the search regexp searchre = re.compile(search) matches = [] # Will match against searchels. Searchels is a list that contains last # n text elements found in the document. 1 < n < bs searchels = [] for element in document.iter(): if element.tag == '{%s}t' % nsprefixes['w']: # t (text) elements if element.text: # Add this element to searchels searchels.append(element) if len(searchels) > bs: # Is searchels is too long, remove first elements searchels.pop(0) # Search all combinations, of searchels, starting from # smaller up to bigger ones # l = search lenght # s = search start # e = element IDs to merge found = False for l in range(1, len(searchels)+1): if found: break for s in range(len(searchels)): if found: break if s+l <= len(searchels): e = range(s, s+l) txtsearch = '' for k in e: txtsearch += searchels[k].text # Searcs for the text in the whole txtsearch match = searchre.search(txtsearch) if match: matches.append(match.group()) found = True return set(matches)
0, module; 1, function_definition; 2, function_name:get_project_files; 3, parameters; 4, block; 5, expression_statement; 6, if_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""Retrieve a list of project files, ignoring hidden files. :return: sorted list of project files :rtype: :class:`list` """; 11, call; 12, block; 13, assignment; 14, pattern_list; 15, call; 16, block; 17, identifier:project_files; 18, identifier:is_git_project; 19, argument_list; 20, return_statement; 21, identifier:project_files; 22, list; 23, identifier:top; 24, identifier:subdirs; 25, identifier:files; 26, attribute; 27, argument_list; 28, for_statement; 29, for_statement; 30, call; 31, identifier:os; 32, identifier:walk; 33, string; 34, identifier:subdir; 35, identifier:subdirs; 36, block; 37, identifier:f; 38, identifier:files; 39, block; 40, identifier:get_git_project_files; 41, argument_list; 42, string_content:.; 43, if_statement; 44, if_statement; 45, expression_statement; 46, call; 47, block; 48, call; 49, block; 50, call; 51, attribute; 52, argument_list; 53, expression_statement; 54, attribute; 55, argument_list; 56, continue_statement; 57, attribute; 58, argument_list; 59, identifier:subdir; 60, identifier:startswith; 61, string; 62, call; 63, identifier:f; 64, identifier:startswith; 65, string; 66, identifier:project_files; 67, identifier:append; 68, call; 69, string_content:.; 70, attribute; 71, argument_list; 72, string_content:.; 73, attribute; 74, argument_list; 75, identifier:subdirs; 76, identifier:remove; 77, identifier:subdir; 78, attribute; 79, identifier:join; 80, identifier:top; 81, identifier:f; 82, identifier:os; 83, identifier:path
0, 1; 1, 2; 1, 3; 1, 4; 4, 5; 4, 6; 4, 7; 4, 8; 4, 9; 5, 10; 6, 11; 6, 12; 7, 13; 8, 14; 8, 15; 8, 16; 9, 17; 11, 18; 11, 19; 12, 20; 13, 21; 13, 22; 14, 23; 14, 24; 14, 25; 15, 26; 15, 27; 16, 28; 16, 29; 20, 30; 26, 31; 26, 32; 27, 33; 28, 34; 28, 35; 28, 36; 29, 37; 29, 38; 29, 39; 30, 40; 30, 41; 33, 42; 36, 43; 39, 44; 39, 45; 43, 46; 43, 47; 44, 48; 44, 49; 45, 50; 46, 51; 46, 52; 47, 53; 48, 54; 48, 55; 49, 56; 50, 57; 50, 58; 51, 59; 51, 60; 52, 61; 53, 62; 54, 63; 54, 64; 55, 65; 57, 66; 57, 67; 58, 68; 61, 69; 62, 70; 62, 71; 65, 72; 68, 73; 68, 74; 70, 75; 70, 76; 71, 77; 73, 78; 73, 79; 74, 80; 74, 81; 78, 82; 78, 83
def get_project_files(): """Retrieve a list of project files, ignoring hidden files. :return: sorted list of project files :rtype: :class:`list` """ if is_git_project(): return get_git_project_files() project_files = [] for top, subdirs, files in os.walk('.'): for subdir in subdirs: if subdir.startswith('.'): subdirs.remove(subdir) for f in files: if f.startswith('.'): continue project_files.append(os.path.join(top, f)) return project_files
0, module; 1, function_definition; 2, function_name:_validate_path; 3, parameters; 4, block; 5, identifier:path; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Sorts path values from largest to smallest. Will warn if path parameter was not already sorted. """; 12, comparison_operator:path is None; 13, block; 14, assignment; 15, comparison_operator:new_path[0] != path[0]; 16, block; 17, identifier:new_path; 18, identifier:path; 19, None; 20, return_statement; 21, identifier:new_path; 22, call; 23, subscript; 24, subscript; 25, expression_statement; 26, None; 27, attribute; 28, argument_list; 29, identifier:new_path; 30, integer:0; 31, identifier:path; 32, integer:0; 33, call; 34, identifier:np; 35, identifier:array; 36, call; 37, identifier:print; 38, argument_list; 39, identifier:sorted; 40, argument_list; 41, string:"Warning: Path must be sorted largest to smallest."; 42, call; 43, keyword_argument; 44, identifier:set; 45, argument_list; 46, identifier:reverse; 47, True; 48, identifier:path
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 7, 13; 8, 14; 9, 15; 9, 16; 10, 17; 12, 18; 12, 19; 13, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 20, 26; 22, 27; 22, 28; 23, 29; 23, 30; 24, 31; 24, 32; 25, 33; 27, 34; 27, 35; 28, 36; 33, 37; 33, 38; 36, 39; 36, 40; 38, 41; 40, 42; 40, 43; 42, 44; 42, 45; 43, 46; 43, 47; 45, 48
def _validate_path(path): """Sorts path values from largest to smallest. Will warn if path parameter was not already sorted. """ if path is None: return None new_path = np.array(sorted(set(path), reverse=True)) if new_path[0] != path[0]: print("Warning: Path must be sorted largest to smallest.") return new_path
0, module; 1, function_definition; 2, function_name:count; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:""" This method retrieve the total of records resulting from a given query. This attribute can be used compounded with query, filter, sort, order and facet methods. Examples: >>> from crossref.restful import Works >>> Works().query('zika').count() 3597 >>> Works().query('zika').filter(prefix='10.1590').count() 61 >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').count() 14 >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').query(author='Marli').count() 1 """; 13, assignment; 14, assignment; 15, assignment; 16, assignment; 17, call; 18, identifier:request_params; 19, call; 20, identifier:request_url; 21, call; 22, subscript; 23, integer:0; 24, identifier:result; 25, call; 26, identifier:int; 27, argument_list; 28, identifier:dict; 29, argument_list; 30, identifier:str; 31, argument_list; 32, identifier:request_params; 33, string; 34, attribute; 35, argument_list; 36, subscript; 37, attribute; 38, attribute; 39, string_content:rows; 40, call; 41, identifier:json; 42, subscript; 43, string; 44, identifier:self; 45, identifier:request_params; 46, identifier:self; 47, identifier:request_url; 48, attribute; 49, argument_list; 50, identifier:result; 51, string; 52, string_content:total-results; 53, identifier:self; 54, identifier:do_http_request; 55, string; 56, identifier:request_url; 57, keyword_argument; 58, keyword_argument; 59, string_content:message; 60, string_content:get; 61, identifier:data; 62, identifier:request_params; 63, identifier:custom_header; 64, call; 65, identifier:str; 66, argument_list; 67, attribute; 68, identifier:self; 69, identifier:etiquette
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 8, 14; 9, 15; 10, 16; 11, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 19, 28; 19, 29; 21, 30; 21, 31; 22, 32; 22, 33; 25, 34; 25, 35; 27, 36; 29, 37; 31, 38; 33, 39; 34, 40; 34, 41; 36, 42; 36, 43; 37, 44; 37, 45; 38, 46; 38, 47; 40, 48; 40, 49; 42, 50; 42, 51; 43, 52; 48, 53; 48, 54; 49, 55; 49, 56; 49, 57; 49, 58; 51, 59; 55, 60; 57, 61; 57, 62; 58, 63; 58, 64; 64, 65; 64, 66; 66, 67; 67, 68; 67, 69
def count(self): """ This method retrieve the total of records resulting from a given query. This attribute can be used compounded with query, filter, sort, order and facet methods. Examples: >>> from crossref.restful import Works >>> Works().query('zika').count() 3597 >>> Works().query('zika').filter(prefix='10.1590').count() 61 >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').count() 14 >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').query(author='Marli').count() 1 """ request_params = dict(self.request_params) request_url = str(self.request_url) request_params['rows'] = 0 result = self.do_http_request( 'get', request_url, data=request_params, custom_header=str(self.etiquette) ).json() return int(result['message']['total-results'])
0, module; 1, function_definition; 2, function_name:url; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:""" This attribute retrieve the url that will be used as a HTTP request to the Crossref API. This attribute can be used compounded with query, filter, sort, order and facet methods. Examples: >>> from crossref.restful import Works >>> Works().query('zika').url 'https://api.crossref.org/works?query=zika' >>> Works().query('zika').filter(prefix='10.1590').url 'https://api.crossref.org/works?query=zika&filter=prefix%3A10.1590' >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').url 'https://api.crossref.org/works?sort=published&order=desc&query=zika&filter=prefix%3A10.1590' >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').query(author='Marli').url 'https://api.crossref.org/works?sort=published&filter=prefix%3A10.1590%2Chas-abstract%3Atrue&query=zika&order=desc&query.author=Marli' """; 12, assignment; 13, assignment; 14, assignment; 15, attribute; 16, identifier:request_params; 17, call; 18, identifier:sorted_request_params; 19, call; 20, identifier:req; 21, call; 22, identifier:req; 23, identifier:url; 24, attribute; 25, argument_list; 26, identifier:sorted; 27, argument_list; 28, attribute; 29, argument_list; 30, identifier:self; 31, identifier:_escaped_pagging; 32, list_comprehension; 33, call; 34, identifier:prepare; 35, tuple; 36, for_in_clause; 37, attribute; 38, argument_list; 39, identifier:k; 40, identifier:v; 41, pattern_list; 42, call; 43, identifier:requests; 44, identifier:Request; 45, string; 46, attribute; 47, keyword_argument; 48, identifier:k; 49, identifier:v; 50, attribute; 51, argument_list; 52, string_content:get; 53, identifier:self; 54, identifier:request_url; 55, identifier:params; 56, identifier:sorted_request_params; 57, identifier:request_params; 58, identifier:items
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 9, 14; 10, 15; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 17, 24; 17, 25; 19, 26; 19, 27; 21, 28; 21, 29; 24, 30; 24, 31; 27, 32; 28, 33; 28, 34; 32, 35; 32, 36; 33, 37; 33, 38; 35, 39; 35, 40; 36, 41; 36, 42; 37, 43; 37, 44; 38, 45; 38, 46; 38, 47; 41, 48; 41, 49; 42, 50; 42, 51; 45, 52; 46, 53; 46, 54; 47, 55; 47, 56; 50, 57; 50, 58
def url(self): """ This attribute retrieve the url that will be used as a HTTP request to the Crossref API. This attribute can be used compounded with query, filter, sort, order and facet methods. Examples: >>> from crossref.restful import Works >>> Works().query('zika').url 'https://api.crossref.org/works?query=zika' >>> Works().query('zika').filter(prefix='10.1590').url 'https://api.crossref.org/works?query=zika&filter=prefix%3A10.1590' >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').url 'https://api.crossref.org/works?sort=published&order=desc&query=zika&filter=prefix%3A10.1590' >>> Works().query('zika').filter(prefix='10.1590').sort('published').order('desc').filter(has_abstract='true').query(author='Marli').url 'https://api.crossref.org/works?sort=published&filter=prefix%3A10.1590%2Chas-abstract%3Atrue&query=zika&order=desc&query.author=Marli' """ request_params = self._escaped_pagging() sorted_request_params = sorted([(k, v) for k, v in request_params.items()]) req = requests.Request( 'get', self.request_url, params=sorted_request_params).prepare() return req.url
0, module; 1, function_definition; 2, function_name:sortByNamespacePrefix; 3, parameters; 4, block; 5, identifier:urisList; 6, identifier:nsList; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, comment:# add remaining uris (if any); 12, for_statement; 13, return_statement; 14, comment:""" Given an ordered list of namespaces prefixes, order a list of uris based on that. Eg In [7]: ll Out[7]: [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef(u'printGenericTreeorg/2000/01/rdf-schema#comment'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass')] In [8]: sortByNamespacePrefix(ll, [OWL.OWLNS, RDFS]) Out[8]: [rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#comment'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')] """; 15, assignment; 16, assignment; 17, identifier:ns; 18, identifier:nsList; 19, block; 20, identifier:uri; 21, identifier:urisList; 22, block; 23, identifier:exit; 24, identifier:exit; 25, list; 26, identifier:urisList; 27, call; 28, expression_statement; 29, for_statement; 30, expression_statement; 31, if_statement; 32, identifier:sort_uri_list_by_name; 33, argument_list; 34, assignment; 35, identifier:uri; 36, identifier:urisList; 37, block; 38, augmented_assignment; 39, comparison_operator:uri not in exit; 40, block; 41, identifier:urisList; 42, identifier:innerexit; 43, list; 44, if_statement; 45, identifier:exit; 46, identifier:innerexit; 47, identifier:uri; 48, identifier:exit; 49, expression_statement; 50, call; 51, block; 52, augmented_assignment; 53, attribute; 54, argument_list; 55, expression_statement; 56, identifier:exit; 57, list; 58, call; 59, identifier:startswith; 60, call; 61, augmented_assignment; 62, identifier:uri; 63, identifier:str; 64, argument_list; 65, identifier:str; 66, argument_list; 67, identifier:innerexit; 68, list; 69, identifier:uri; 70, identifier:ns; 71, identifier:uri
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 12, 20; 12, 21; 12, 22; 13, 23; 15, 24; 15, 25; 16, 26; 16, 27; 19, 28; 19, 29; 19, 30; 22, 31; 27, 32; 27, 33; 28, 34; 29, 35; 29, 36; 29, 37; 30, 38; 31, 39; 31, 40; 33, 41; 34, 42; 34, 43; 37, 44; 38, 45; 38, 46; 39, 47; 39, 48; 40, 49; 44, 50; 44, 51; 49, 52; 50, 53; 50, 54; 51, 55; 52, 56; 52, 57; 53, 58; 53, 59; 54, 60; 55, 61; 57, 62; 58, 63; 58, 64; 60, 65; 60, 66; 61, 67; 61, 68; 64, 69; 66, 70; 68, 71
def sortByNamespacePrefix(urisList, nsList): """ Given an ordered list of namespaces prefixes, order a list of uris based on that. Eg In [7]: ll Out[7]: [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef(u'printGenericTreeorg/2000/01/rdf-schema#comment'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass')] In [8]: sortByNamespacePrefix(ll, [OWL.OWLNS, RDFS]) Out[8]: [rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#comment'), rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'), rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')] """ exit = [] urisList = sort_uri_list_by_name(urisList) for ns in nsList: innerexit = [] for uri in urisList: if str(uri).startswith(str(ns)): innerexit += [uri] exit += innerexit # add remaining uris (if any) for uri in urisList: if uri not in exit: exit += [uri] return exit
0, module; 1, function_definition; 2, function_name:sort_uri_list_by_name; 3, parameters; 4, block; 5, identifier:uri_list; 6, default_parameter; 7, expression_statement; 8, function_definition; 9, try_statement; 10, identifier:bypassNamespace; 11, False; 12, comment:""" Sorts a list of uris bypassNamespace: based on the last bit (usually the name after the namespace) of a uri It checks whether the last bit is specified using a # or just a /, eg: rdflib.URIRef('http://purl.org/ontology/mo/Vinyl'), rdflib.URIRef('http://purl.org/vocab/frbr/core#Work') """; 13, function_name:get_last_bit; 14, parameters; 15, block; 16, block; 17, except_clause; 18, identifier:uri_string; 19, try_statement; 20, return_statement; 21, if_statement; 22, comment:# TODO: do more testing.. maybe use a unicode-safe method instead of __str__; 23, block; 24, block; 25, except_clause; 26, identifier:x; 27, identifier:bypassNamespace; 28, block; 29, else_clause; 30, expression_statement; 31, return_statement; 32, expression_statement; 33, block; 34, return_statement; 35, block; 36, call; 37, identifier:uri_list; 38, assignment; 39, expression_statement; 40, call; 41, return_statement; 42, identifier:print; 43, argument_list; 44, identifier:x; 45, subscript; 46, assignment; 47, identifier:sorted; 48, argument_list; 49, call; 50, string:"Error in <sort_uri_list_by_name>: possibly a UnicodeEncodeError"; 51, call; 52, integer:1; 53, identifier:x; 54, subscript; 55, identifier:uri_list; 56, keyword_argument; 57, identifier:sorted; 58, argument_list; 59, attribute; 60, argument_list; 61, call; 62, unary_operator; 63, identifier:key; 64, lambda; 65, identifier:uri_list; 66, identifier:uri_string; 67, identifier:split; 68, string:"#"; 69, attribute; 70, argument_list; 71, integer:1; 72, lambda_parameters; 73, call; 74, identifier:uri_string; 75, identifier:split; 76, string:"/"; 77, identifier:x; 78, identifier:get_last_bit; 79, argument_list; 80, call; 81, attribute; 82, argument_list; 83, identifier:x; 84, identifier:__str__
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 6, 10; 6, 11; 7, 12; 8, 13; 8, 14; 8, 15; 9, 16; 9, 17; 14, 18; 15, 19; 15, 20; 16, 21; 17, 22; 17, 23; 19, 24; 19, 25; 20, 26; 21, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 25, 33; 28, 34; 29, 35; 30, 36; 31, 37; 32, 38; 33, 39; 34, 40; 35, 41; 36, 42; 36, 43; 38, 44; 38, 45; 39, 46; 40, 47; 40, 48; 41, 49; 43, 50; 45, 51; 45, 52; 46, 53; 46, 54; 48, 55; 48, 56; 49, 57; 49, 58; 51, 59; 51, 60; 54, 61; 54, 62; 56, 63; 56, 64; 58, 65; 59, 66; 59, 67; 60, 68; 61, 69; 61, 70; 62, 71; 64, 72; 64, 73; 69, 74; 69, 75; 70, 76; 72, 77; 73, 78; 73, 79; 79, 80; 80, 81; 80, 82; 81, 83; 81, 84
def sort_uri_list_by_name(uri_list, bypassNamespace=False): """ Sorts a list of uris bypassNamespace: based on the last bit (usually the name after the namespace) of a uri It checks whether the last bit is specified using a # or just a /, eg: rdflib.URIRef('http://purl.org/ontology/mo/Vinyl'), rdflib.URIRef('http://purl.org/vocab/frbr/core#Work') """ def get_last_bit(uri_string): try: x = uri_string.split("#")[1] except: x = uri_string.split("/")[-1] return x try: if bypassNamespace: return sorted(uri_list, key=lambda x: get_last_bit(x.__str__())) else: return sorted(uri_list) except: # TODO: do more testing.. maybe use a unicode-safe method instead of __str__ print( "Error in <sort_uri_list_by_name>: possibly a UnicodeEncodeError") return uri_list
0, module; 1, function_definition; 2, function_name:try_sort_fmt_opts; 3, parameters; 4, block; 5, identifier:rdf_format_opts_list; 6, identifier:uri; 7, expression_statement; 8, expression_statement; 9, comment:# print(filename, file_extension); 10, if_statement; 11, comment:"""reorder fmt options based on uri file type suffix - if available - so to test most likely serialization first when parsing some RDF NOTE this is not very nice as it is hardcoded and assumes the origin serializations to be this: ['turtle', 'xml', 'n3', 'nt', 'json-ld', 'rdfa'] """; 12, assignment; 13, boolean_operator; 14, block; 15, elif_clause; 16, elif_clause; 17, elif_clause; 18, elif_clause; 19, else_clause; 20, pattern_list; 21, call; 22, comparison_operator:file_extension == ".ttl"; 23, comparison_operator:file_extension == ".turtle"; 24, return_statement; 25, boolean_operator; 26, block; 27, boolean_operator; 28, block; 29, boolean_operator; 30, block; 31, comparison_operator:file_extension == ".rdfa"; 32, block; 33, block; 34, identifier:filename; 35, identifier:file_extension; 36, attribute; 37, argument_list; 38, identifier:file_extension; 39, string:".ttl"; 40, identifier:file_extension; 41, string:".turtle"; 42, list; 43, comparison_operator:file_extension == ".xml"; 44, comparison_operator:file_extension == ".rdf"; 45, return_statement; 46, comparison_operator:file_extension == ".nt"; 47, comparison_operator:file_extension == ".n3"; 48, return_statement; 49, comparison_operator:file_extension == ".json"; 50, comparison_operator:file_extension == ".jsonld"; 51, return_statement; 52, identifier:file_extension; 53, string:".rdfa"; 54, return_statement; 55, return_statement; 56, attribute; 57, identifier:splitext; 58, identifier:uri; 59, string; 60, string; 61, string; 62, string; 63, string; 64, string; 65, identifier:file_extension; 66, string:".xml"; 67, identifier:file_extension; 68, string:".rdf"; 69, list; 70, identifier:file_extension; 71, string:".nt"; 72, identifier:file_extension; 73, string:".n3"; 74, list; 75, identifier:file_extension; 76, string:".json"; 77, identifier:file_extension; 78, string:".jsonld"; 79, list; 80, list; 81, identifier:rdf_format_opts_list; 82, identifier:os; 83, identifier:path; 84, string_content:turtle; 85, string_content:n3; 86, string_content:nt; 87, string_content:json-ld; 88, string_content:rdfa; 89, string_content:xml; 90, string; 91, string; 92, string; 93, string; 94, string; 95, string; 96, string; 97, string; 98, string; 99, string; 100, string; 101, string; 102, string; 103, string; 104, string; 105, string; 106, string; 107, string; 108, string; 109, string; 110, string; 111, string; 112, string; 113, string; 114, string_content:xml; 115, string_content:turtle; 116, string_content:n3; 117, string_content:nt; 118, string_content:json-ld; 119, string_content:rdfa; 120, string_content:n3; 121, string_content:nt; 122, string_content:turtle; 123, string_content:xml; 124, string_content:json-ld; 125, string_content:rdfa; 126, string_content:json-ld; 127, string_content:rdfa; 128, string_content:n3; 129, string_content:nt; 130, string_content:turtle; 131, string_content:xml; 132, string_content:rdfa; 133, string_content:json-ld; 134, string_content:n3; 135, string_content:nt; 136, string_content:turtle; 137, string_content:xml
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 10, 13; 10, 14; 10, 15; 10, 16; 10, 17; 10, 18; 10, 19; 12, 20; 12, 21; 13, 22; 13, 23; 14, 24; 15, 25; 15, 26; 16, 27; 16, 28; 17, 29; 17, 30; 18, 31; 18, 32; 19, 33; 20, 34; 20, 35; 21, 36; 21, 37; 22, 38; 22, 39; 23, 40; 23, 41; 24, 42; 25, 43; 25, 44; 26, 45; 27, 46; 27, 47; 28, 48; 29, 49; 29, 50; 30, 51; 31, 52; 31, 53; 32, 54; 33, 55; 36, 56; 36, 57; 37, 58; 42, 59; 42, 60; 42, 61; 42, 62; 42, 63; 42, 64; 43, 65; 43, 66; 44, 67; 44, 68; 45, 69; 46, 70; 46, 71; 47, 72; 47, 73; 48, 74; 49, 75; 49, 76; 50, 77; 50, 78; 51, 79; 54, 80; 55, 81; 56, 82; 56, 83; 59, 84; 60, 85; 61, 86; 62, 87; 63, 88; 64, 89; 69, 90; 69, 91; 69, 92; 69, 93; 69, 94; 69, 95; 74, 96; 74, 97; 74, 98; 74, 99; 74, 100; 74, 101; 79, 102; 79, 103; 79, 104; 79, 105; 79, 106; 79, 107; 80, 108; 80, 109; 80, 110; 80, 111; 80, 112; 80, 113; 90, 114; 91, 115; 92, 116; 93, 117; 94, 118; 95, 119; 96, 120; 97, 121; 98, 122; 99, 123; 100, 124; 101, 125; 102, 126; 103, 127; 104, 128; 105, 129; 106, 130; 107, 131; 108, 132; 109, 133; 110, 134; 111, 135; 112, 136; 113, 137
def try_sort_fmt_opts(rdf_format_opts_list, uri): """reorder fmt options based on uri file type suffix - if available - so to test most likely serialization first when parsing some RDF NOTE this is not very nice as it is hardcoded and assumes the origin serializations to be this: ['turtle', 'xml', 'n3', 'nt', 'json-ld', 'rdfa'] """ filename, file_extension = os.path.splitext(uri) # print(filename, file_extension) if file_extension == ".ttl" or file_extension == ".turtle": return ['turtle', 'n3', 'nt', 'json-ld', 'rdfa', 'xml'] elif file_extension == ".xml" or file_extension == ".rdf": return ['xml', 'turtle', 'n3', 'nt', 'json-ld', 'rdfa'] elif file_extension == ".nt" or file_extension == ".n3": return ['n3', 'nt', 'turtle', 'xml', 'json-ld', 'rdfa'] elif file_extension == ".json" or file_extension == ".jsonld": return [ 'json-ld', 'rdfa', 'n3', 'nt', 'turtle', 'xml', ] elif file_extension == ".rdfa": return [ 'rdfa', 'json-ld', 'n3', 'nt', 'turtle', 'xml', ] else: return rdf_format_opts_list
0, module; 1, function_definition; 2, function_name:collect_results; 3, parameters; 4, block; 5, identifier:working_folder; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:""" Collect results in a working_folder. The output is nested dict[rec_name][sorter_name] of SortingExtrator. """; 13, assignment; 14, assignment; 15, assignment; 16, identifier:rec_name; 17, call; 18, block; 19, identifier:results; 20, identifier:results; 21, dictionary; 22, identifier:working_folder; 23, call; 24, identifier:output_folders; 25, binary_operator:working_folder/'output_folders'; 26, attribute; 27, argument_list; 28, if_statement; 29, comment:# print(rec_name); 30, expression_statement; 31, for_statement; 32, identifier:Path; 33, argument_list; 34, identifier:working_folder; 35, string; 36, identifier:os; 37, identifier:listdir; 38, identifier:output_folders; 39, not_operator; 40, block; 41, assignment; 42, identifier:sorter_name; 43, call; 44, comment:# print(' ', sorter_name); 45, block; 46, identifier:working_folder; 47, string_content:output_folders; 48, call; 49, continue_statement; 50, subscript; 51, dictionary; 52, attribute; 53, argument_list; 54, expression_statement; 55, comment:#~ print(output_folder); 56, if_statement; 57, expression_statement; 58, expression_statement; 59, attribute; 60, argument_list; 61, identifier:results; 62, identifier:rec_name; 63, identifier:os; 64, identifier:listdir; 65, binary_operator:output_folders / rec_name; 66, assignment; 67, not_operator; 68, block; 69, assignment; 70, assignment; 71, attribute; 72, identifier:isdir; 73, binary_operator:output_folders / rec_name; 74, identifier:output_folders; 75, identifier:rec_name; 76, identifier:output_folder; 77, binary_operator:output_folders / rec_name / sorter_name; 78, call; 79, continue_statement; 80, identifier:SorterClass; 81, subscript; 82, subscript; 83, call; 84, identifier:os; 85, identifier:path; 86, identifier:output_folders; 87, identifier:rec_name; 88, binary_operator:output_folders / rec_name; 89, identifier:sorter_name; 90, attribute; 91, argument_list; 92, identifier:sorter_dict; 93, identifier:sorter_name; 94, subscript; 95, identifier:sorter_name; 96, attribute; 97, argument_list; 98, identifier:output_folders; 99, identifier:rec_name; 100, attribute; 101, identifier:isdir; 102, identifier:output_folder; 103, identifier:results; 104, identifier:rec_name; 105, identifier:SorterClass; 106, identifier:get_result_from_folder; 107, identifier:output_folder; 108, identifier:os; 109, identifier:path
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 13, 20; 13, 21; 14, 22; 14, 23; 15, 24; 15, 25; 17, 26; 17, 27; 18, 28; 18, 29; 18, 30; 18, 31; 23, 32; 23, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 28, 39; 28, 40; 30, 41; 31, 42; 31, 43; 31, 44; 31, 45; 33, 46; 35, 47; 39, 48; 40, 49; 41, 50; 41, 51; 43, 52; 43, 53; 45, 54; 45, 55; 45, 56; 45, 57; 45, 58; 48, 59; 48, 60; 50, 61; 50, 62; 52, 63; 52, 64; 53, 65; 54, 66; 56, 67; 56, 68; 57, 69; 58, 70; 59, 71; 59, 72; 60, 73; 65, 74; 65, 75; 66, 76; 66, 77; 67, 78; 68, 79; 69, 80; 69, 81; 70, 82; 70, 83; 71, 84; 71, 85; 73, 86; 73, 87; 77, 88; 77, 89; 78, 90; 78, 91; 81, 92; 81, 93; 82, 94; 82, 95; 83, 96; 83, 97; 88, 98; 88, 99; 90, 100; 90, 101; 91, 102; 94, 103; 94, 104; 96, 105; 96, 106; 97, 107; 100, 108; 100, 109
def collect_results(working_folder): """ Collect results in a working_folder. The output is nested dict[rec_name][sorter_name] of SortingExtrator. """ results = {} working_folder = Path(working_folder) output_folders = working_folder/'output_folders' for rec_name in os.listdir(output_folders): if not os.path.isdir(output_folders / rec_name): continue # print(rec_name) results[rec_name] = {} for sorter_name in os.listdir(output_folders / rec_name): # print(' ', sorter_name) output_folder = output_folders / rec_name / sorter_name #~ print(output_folder) if not os.path.isdir(output_folder): continue SorterClass = sorter_dict[sorter_name] results[rec_name][sorter_name] = SorterClass.get_result_from_folder(output_folder) return results
0, module; 1, function_definition; 2, function_name:run_sorter; 3, parameters; 4, block; 5, identifier:sorter_name_or_class; 6, identifier:recording; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, dictionary_splat_pattern; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, return_statement; 20, identifier:output_folder; 21, None; 22, identifier:delete_output_folder; 23, False; 24, identifier:grouping_property; 25, None; 26, identifier:parallel; 27, False; 28, identifier:debug; 29, False; 30, identifier:params; 31, comment:""" Generic function to run a sorter via function approach. 2 Usage with name or class: by name: >>> sorting = run_sorter('tridesclous', recording) by class: >>> sorting = run_sorter(TridesclousSorter, recording) """; 32, call; 33, block; 34, elif_clause; 35, else_clause; 36, assignment; 37, call; 38, call; 39, assignment; 40, identifier:sortingextractor; 41, identifier:isinstance; 42, argument_list; 43, expression_statement; 44, comparison_operator:sorter_name_or_class in sorter_full_list; 45, block; 46, block; 47, identifier:sorter; 48, call; 49, attribute; 50, argument_list; 51, attribute; 52, argument_list; 53, identifier:sortingextractor; 54, call; 55, identifier:sorter_name_or_class; 56, identifier:str; 57, assignment; 58, identifier:sorter_name_or_class; 59, identifier:sorter_full_list; 60, expression_statement; 61, raise_statement; 62, identifier:SorterClass; 63, argument_list; 64, identifier:sorter; 65, identifier:set_params; 66, dictionary_splat; 67, identifier:sorter; 68, identifier:run; 69, attribute; 70, argument_list; 71, identifier:SorterClass; 72, subscript; 73, assignment; 74, parenthesized_expression; 75, keyword_argument; 76, keyword_argument; 77, keyword_argument; 78, keyword_argument; 79, keyword_argument; 80, keyword_argument; 81, identifier:params; 82, identifier:sorter; 83, identifier:get_result; 84, identifier:sorter_dict; 85, identifier:sorter_name_or_class; 86, identifier:SorterClass; 87, identifier:sorter_name_or_class; 88, call; 89, identifier:recording; 90, identifier:recording; 91, identifier:output_folder; 92, identifier:output_folder; 93, identifier:grouping_property; 94, identifier:grouping_property; 95, identifier:parallel; 96, identifier:parallel; 97, identifier:debug; 98, identifier:debug; 99, identifier:delete_output_folder; 100, identifier:delete_output_folder; 101, identifier:ValueError; 102, argument_list; 103, string; 104, string_content:Unknown sorter
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 10, 27; 11, 28; 11, 29; 12, 30; 13, 31; 14, 32; 14, 33; 14, 34; 14, 35; 15, 36; 16, 37; 17, 38; 18, 39; 19, 40; 32, 41; 32, 42; 33, 43; 34, 44; 34, 45; 35, 46; 36, 47; 36, 48; 37, 49; 37, 50; 38, 51; 38, 52; 39, 53; 39, 54; 42, 55; 42, 56; 43, 57; 44, 58; 44, 59; 45, 60; 46, 61; 48, 62; 48, 63; 49, 64; 49, 65; 50, 66; 51, 67; 51, 68; 54, 69; 54, 70; 57, 71; 57, 72; 60, 73; 61, 74; 63, 75; 63, 76; 63, 77; 63, 78; 63, 79; 63, 80; 66, 81; 69, 82; 69, 83; 72, 84; 72, 85; 73, 86; 73, 87; 74, 88; 75, 89; 75, 90; 76, 91; 76, 92; 77, 93; 77, 94; 78, 95; 78, 96; 79, 97; 79, 98; 80, 99; 80, 100; 88, 101; 88, 102; 102, 103; 103, 104
def run_sorter(sorter_name_or_class, recording, output_folder=None, delete_output_folder=False, grouping_property=None, parallel=False, debug=False, **params): """ Generic function to run a sorter via function approach. 2 Usage with name or class: by name: >>> sorting = run_sorter('tridesclous', recording) by class: >>> sorting = run_sorter(TridesclousSorter, recording) """ if isinstance(sorter_name_or_class, str): SorterClass = sorter_dict[sorter_name_or_class] elif sorter_name_or_class in sorter_full_list: SorterClass = sorter_name_or_class else: raise(ValueError('Unknown sorter')) sorter = SorterClass(recording=recording, output_folder=output_folder, grouping_property=grouping_property, parallel=parallel, debug=debug, delete_output_folder=delete_output_folder) sorter.set_params(**params) sorter.run() sortingextractor = sorter.get_result() return sortingextractor
0, module; 1, function_definition; 2, function_name:compute_performance; 3, parameters; 4, block; 5, identifier:SC; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, if_statement; 22, if_statement; 23, identifier:verbose; 24, True; 25, identifier:output; 26, string; 27, comment:""" Return some performance value for comparison. Parameters ------- SC: SortingComparison instance The SortingComparison verbose: bool Display on console or not output: dict or pandas Returns ---------- performance: dict or pandas.Serie depending output param """; 28, assignment; 29, assignment; 30, assignment; 31, assignment; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, assignment; 40, identifier:verbose; 41, block; 42, comparison_operator:output == 'dict'; 43, block; 44, elif_clause; 45, string_content:dict; 46, identifier:counts; 47, attribute; 48, identifier:tp_rate; 49, binary_operator:float(counts['TP']) / counts['TOT_ST1'] * 100; 50, identifier:cl_rate; 51, binary_operator:float(counts['CL']) / counts['TOT_ST1'] * 100; 52, identifier:fn_rate; 53, binary_operator:float(counts['FN']) / counts['TOT_ST1'] * 100; 54, identifier:fp_st1; 55, binary_operator:float(counts['FP']) / counts['TOT_ST1'] * 100; 56, identifier:fp_st2; 57, binary_operator:float(counts['FP']) / counts['TOT_ST2'] * 100; 58, identifier:accuracy; 59, binary_operator:tp_rate / (tp_rate + fn_rate + fp_st1) * 100; 60, identifier:sensitivity; 61, binary_operator:tp_rate / (tp_rate + fn_rate) * 100; 62, identifier:miss_rate; 63, binary_operator:fn_rate / (tp_rate + fn_rate) * 100; 64, identifier:precision; 65, binary_operator:tp_rate / (tp_rate + fp_st1) * 100; 66, identifier:false_discovery_rate; 67, binary_operator:fp_st1 / (tp_rate + fp_st1) * 100; 68, identifier:performance; 69, dictionary; 70, expression_statement; 71, expression_statement; 72, identifier:output; 73, string; 74, return_statement; 75, comparison_operator:output == 'pandas'; 76, block; 77, identifier:SC; 78, identifier:_counts; 79, binary_operator:float(counts['TP']) / counts['TOT_ST1']; 80, integer:100; 81, binary_operator:float(counts['CL']) / counts['TOT_ST1']; 82, integer:100; 83, binary_operator:float(counts['FN']) / counts['TOT_ST1']; 84, integer:100; 85, binary_operator:float(counts['FP']) / counts['TOT_ST1']; 86, integer:100; 87, binary_operator:float(counts['FP']) / counts['TOT_ST2']; 88, integer:100; 89, binary_operator:tp_rate / (tp_rate + fn_rate + fp_st1); 90, integer:100; 91, binary_operator:tp_rate / (tp_rate + fn_rate); 92, integer:100; 93, binary_operator:fn_rate / (tp_rate + fn_rate); 94, integer:100; 95, binary_operator:tp_rate / (tp_rate + fp_st1); 96, integer:100; 97, binary_operator:fp_st1 / (tp_rate + fp_st1); 98, integer:100; 99, pair; 100, pair; 101, pair; 102, pair; 103, pair; 104, pair; 105, pair; 106, pair; 107, pair; 108, pair; 109, assignment; 110, call; 111, string_content:dict; 112, identifier:performance; 113, identifier:output; 114, string; 115, return_statement; 116, call; 117, subscript; 118, call; 119, subscript; 120, call; 121, subscript; 122, call; 123, subscript; 124, call; 125, subscript; 126, identifier:tp_rate; 127, parenthesized_expression; 128, identifier:tp_rate; 129, parenthesized_expression; 130, identifier:fn_rate; 131, parenthesized_expression; 132, identifier:tp_rate; 133, parenthesized_expression; 134, identifier:fp_st1; 135, parenthesized_expression; 136, string; 137, identifier:tp_rate; 138, string; 139, identifier:cl_rate; 140, string; 141, identifier:fn_rate; 142, string; 143, identifier:fp_st1; 144, string; 145, identifier:fp_st2; 146, string; 147, identifier:accuracy; 148, string; 149, identifier:sensitivity; 150, string; 151, identifier:precision; 152, string; 153, identifier:miss_rate; 154, string; 155, identifier:false_discovery_rate; 156, identifier:txt; 157, call; 158, identifier:print; 159, argument_list; 160, string_content:pandas; 161, call; 162, identifier:float; 163, argument_list; 164, identifier:counts; 165, string; 166, identifier:float; 167, argument_list; 168, identifier:counts; 169, string; 170, identifier:float; 171, argument_list; 172, identifier:counts; 173, string; 174, identifier:float; 175, argument_list; 176, identifier:counts; 177, string; 178, identifier:float; 179, argument_list; 180, identifier:counts; 181, string; 182, binary_operator:tp_rate + fn_rate + fp_st1; 183, binary_operator:tp_rate + fn_rate; 184, binary_operator:tp_rate + fn_rate; 185, binary_operator:tp_rate + fp_st1; 186, binary_operator:tp_rate + fp_st1; 187, string_content:tp; 188, string_content:cl; 189, string_content:fn; 190, string_content:fp_st1; 191, string_content:fp_st2; 192, string_content:accuracy; 193, string_content:sensitivity; 194, string_content:precision; 195, string_content:miss_rate; 196, string_content:false_disc_rate; 197, attribute; 198, argument_list; 199, identifier:txt; 200, attribute; 201, argument_list; 202, subscript; 203, string_content:TOT_ST1; 204, subscript; 205, string_content:TOT_ST1; 206, subscript; 207, string_content:TOT_ST1; 208, subscript; 209, string_content:TOT_ST1; 210, subscript; 211, string_content:TOT_ST2; 212, binary_operator:tp_rate + fn_rate; 213, identifier:fp_st1; 214, identifier:tp_rate; 215, identifier:fn_rate; 216, identifier:tp_rate; 217, identifier:fn_rate; 218, identifier:tp_rate; 219, identifier:fp_st1; 220, identifier:tp_rate; 221, identifier:fp_st1; 222, identifier:_txt_performance; 223, identifier:format; 224, dictionary_splat; 225, identifier:pd; 226, identifier:Series; 227, identifier:performance; 228, identifier:counts; 229, string; 230, identifier:counts; 231, string; 232, identifier:counts; 233, string; 234, identifier:counts; 235, string; 236, identifier:counts; 237, string; 238, identifier:tp_rate; 239, identifier:fn_rate; 240, identifier:performance; 241, string_content:TP; 242, string_content:CL; 243, string_content:FN; 244, string_content:FP; 245, string_content:FP
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 6, 23; 6, 24; 7, 25; 7, 26; 8, 27; 9, 28; 10, 29; 11, 30; 12, 31; 13, 32; 14, 33; 15, 34; 16, 35; 17, 36; 18, 37; 19, 38; 20, 39; 21, 40; 21, 41; 22, 42; 22, 43; 22, 44; 26, 45; 28, 46; 28, 47; 29, 48; 29, 49; 30, 50; 30, 51; 31, 52; 31, 53; 32, 54; 32, 55; 33, 56; 33, 57; 34, 58; 34, 59; 35, 60; 35, 61; 36, 62; 36, 63; 37, 64; 37, 65; 38, 66; 38, 67; 39, 68; 39, 69; 41, 70; 41, 71; 42, 72; 42, 73; 43, 74; 44, 75; 44, 76; 47, 77; 47, 78; 49, 79; 49, 80; 51, 81; 51, 82; 53, 83; 53, 84; 55, 85; 55, 86; 57, 87; 57, 88; 59, 89; 59, 90; 61, 91; 61, 92; 63, 93; 63, 94; 65, 95; 65, 96; 67, 97; 67, 98; 69, 99; 69, 100; 69, 101; 69, 102; 69, 103; 69, 104; 69, 105; 69, 106; 69, 107; 69, 108; 70, 109; 71, 110; 73, 111; 74, 112; 75, 113; 75, 114; 76, 115; 79, 116; 79, 117; 81, 118; 81, 119; 83, 120; 83, 121; 85, 122; 85, 123; 87, 124; 87, 125; 89, 126; 89, 127; 91, 128; 91, 129; 93, 130; 93, 131; 95, 132; 95, 133; 97, 134; 97, 135; 99, 136; 99, 137; 100, 138; 100, 139; 101, 140; 101, 141; 102, 142; 102, 143; 103, 144; 103, 145; 104, 146; 104, 147; 105, 148; 105, 149; 106, 150; 106, 151; 107, 152; 107, 153; 108, 154; 108, 155; 109, 156; 109, 157; 110, 158; 110, 159; 114, 160; 115, 161; 116, 162; 116, 163; 117, 164; 117, 165; 118, 166; 118, 167; 119, 168; 119, 169; 120, 170; 120, 171; 121, 172; 121, 173; 122, 174; 122, 175; 123, 176; 123, 177; 124, 178; 124, 179; 125, 180; 125, 181; 127, 182; 129, 183; 131, 184; 133, 185; 135, 186; 136, 187; 138, 188; 140, 189; 142, 190; 144, 191; 146, 192; 148, 193; 150, 194; 152, 195; 154, 196; 157, 197; 157, 198; 159, 199; 161, 200; 161, 201; 163, 202; 165, 203; 167, 204; 169, 205; 171, 206; 173, 207; 175, 208; 177, 209; 179, 210; 181, 211; 182, 212; 182, 213; 183, 214; 183, 215; 184, 216; 184, 217; 185, 218; 185, 219; 186, 220; 186, 221; 197, 222; 197, 223; 198, 224; 200, 225; 200, 226; 201, 227; 202, 228; 202, 229; 204, 230; 204, 231; 206, 232; 206, 233; 208, 234; 208, 235; 210, 236; 210, 237; 212, 238; 212, 239; 224, 240; 229, 241; 231, 242; 233, 243; 235, 244; 237, 245
def compute_performance(SC, verbose=True, output='dict'): """ Return some performance value for comparison. Parameters ------- SC: SortingComparison instance The SortingComparison verbose: bool Display on console or not output: dict or pandas Returns ---------- performance: dict or pandas.Serie depending output param """ counts = SC._counts tp_rate = float(counts['TP']) / counts['TOT_ST1'] * 100 cl_rate = float(counts['CL']) / counts['TOT_ST1'] * 100 fn_rate = float(counts['FN']) / counts['TOT_ST1'] * 100 fp_st1 = float(counts['FP']) / counts['TOT_ST1'] * 100 fp_st2 = float(counts['FP']) / counts['TOT_ST2'] * 100 accuracy = tp_rate / (tp_rate + fn_rate + fp_st1) * 100 sensitivity = tp_rate / (tp_rate + fn_rate) * 100 miss_rate = fn_rate / (tp_rate + fn_rate) * 100 precision = tp_rate / (tp_rate + fp_st1) * 100 false_discovery_rate = fp_st1 / (tp_rate + fp_st1) * 100 performance = {'tp': tp_rate, 'cl': cl_rate, 'fn': fn_rate, 'fp_st1': fp_st1, 'fp_st2': fp_st2, 'accuracy': accuracy, 'sensitivity': sensitivity, 'precision': precision, 'miss_rate': miss_rate, 'false_disc_rate': false_discovery_rate} if verbose: txt = _txt_performance.format(**performance) print(txt) if output == 'dict': return performance elif output == 'pandas': return pd.Series(performance)
0, module; 1, function_definition; 2, function_name:add_color_stop_rgba; 3, parameters; 4, block; 5, identifier:self; 6, identifier:offset; 7, identifier:red; 8, identifier:green; 9, identifier:blue; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, identifier:alpha; 15, integer:1; 16, comment:"""Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle. If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added (stops added earlier before stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend. The color components and offset are in the range 0 to 1. If the values passed in are outside that range, they will be clamped. :param offset: Location along the gradient's control vector :param red: Red component of the color. :param green: Green component of the color. :param blue: Blue component of the color. :param alpha: Alpha component of the color. 1 (the default) is opaque, 0 fully transparent. :type offset: float :type red: float :type green: float :type blue: float :type alpha: float """; 17, call; 18, call; 19, attribute; 20, argument_list; 21, attribute; 22, argument_list; 23, identifier:cairo; 24, identifier:cairo_pattern_add_color_stop_rgba; 25, attribute; 26, identifier:offset; 27, identifier:red; 28, identifier:green; 29, identifier:blue; 30, identifier:alpha; 31, identifier:self; 32, identifier:_check_status; 33, identifier:self; 34, identifier:_pointer
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 10, 14; 10, 15; 11, 16; 12, 17; 13, 18; 17, 19; 17, 20; 18, 21; 18, 22; 19, 23; 19, 24; 20, 25; 20, 26; 20, 27; 20, 28; 20, 29; 20, 30; 21, 31; 21, 32; 25, 33; 25, 34
def add_color_stop_rgba(self, offset, red, green, blue, alpha=1): """Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle. If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added (stops added earlier before stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend. The color components and offset are in the range 0 to 1. If the values passed in are outside that range, they will be clamped. :param offset: Location along the gradient's control vector :param red: Red component of the color. :param green: Green component of the color. :param blue: Blue component of the color. :param alpha: Alpha component of the color. 1 (the default) is opaque, 0 fully transparent. :type offset: float :type red: float :type green: float :type blue: float :type alpha: float """ cairo.cairo_pattern_add_color_stop_rgba( self._pointer, offset, red, green, blue, alpha) self._check_status()
0, module; 1, function_definition; 2, function_name:get_all; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, return_statement; 15, identifier:start; 16, integer:0; 17, identifier:count; 18, unary_operator; 19, identifier:filter; 20, string; 21, identifier:fields; 22, string; 23, identifier:query; 24, string; 25, identifier:sort; 26, string; 27, identifier:view; 28, string; 29, comment:""" Gets a list of Deployment Servers based on optional sorting and filtering, and constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. fields: Specifies which fields should be returned in the result set. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Return a specific subset of the attributes of the resource or collection, by specifying the name of a predefined view. The default view is expand - show all attributes of the resource and all elements of collections of resources. Returns: list: Os Deployment Servers """; 30, call; 31, integer:1; 32, attribute; 33, argument_list; 34, attribute; 35, identifier:get_all; 36, identifier:start; 37, identifier:count; 38, keyword_argument; 39, keyword_argument; 40, keyword_argument; 41, keyword_argument; 42, keyword_argument; 43, identifier:self; 44, identifier:_client; 45, identifier:filter; 46, identifier:filter; 47, identifier:sort; 48, identifier:sort; 49, identifier:query; 50, identifier:query; 51, identifier:fields; 52, identifier:fields; 53, identifier:view; 54, identifier:view
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 6, 15; 6, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 11, 26; 12, 27; 12, 28; 13, 29; 14, 30; 18, 31; 30, 32; 30, 33; 32, 34; 32, 35; 33, 36; 33, 37; 33, 38; 33, 39; 33, 40; 33, 41; 33, 42; 34, 43; 34, 44; 38, 45; 38, 46; 39, 47; 39, 48; 40, 49; 40, 50; 41, 51; 41, 52; 42, 53; 42, 54
def get_all(self, start=0, count=-1, filter='', fields='', query='', sort='', view=''): """ Gets a list of Deployment Servers based on optional sorting and filtering, and constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. fields: Specifies which fields should be returned in the result set. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Return a specific subset of the attributes of the resource or collection, by specifying the name of a predefined view. The default view is expand - show all attributes of the resource and all elements of collections of resources. Returns: list: Os Deployment Servers """ return self._client.get_all(start, count, filter=filter, sort=sort, query=query, fields=fields, view=view)
0, module; 1, function_definition; 2, function_name:get_appliances; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, identifier:start; 17, integer:0; 18, identifier:count; 19, unary_operator; 20, identifier:filter; 21, string; 22, identifier:fields; 23, string; 24, identifier:query; 25, string; 26, identifier:sort; 27, string; 28, identifier:view; 29, string; 30, comment:""" Gets a list of all the Image Streamer resources based on optional sorting and filtering, and constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. fields: Specifies which fields should be returned in the result set. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Return a specific subset of the attributes of the resource or collection, by specifying the name of a predefined view. The default view is expand - show all attributes of the resource and all elements of collections of resources. Returns: list: Image Streamer resources associated with the Deployment Servers. """; 31, assignment; 32, call; 33, integer:1; 34, identifier:uri; 35, binary_operator:self.URI + '/image-streamer-appliances'; 36, attribute; 37, argument_list; 38, attribute; 39, string; 40, attribute; 41, identifier:get_all; 42, identifier:start; 43, identifier:count; 44, keyword_argument; 45, keyword_argument; 46, keyword_argument; 47, keyword_argument; 48, keyword_argument; 49, keyword_argument; 50, identifier:self; 51, identifier:URI; 52, string_content:/image-streamer-appliances; 53, identifier:self; 54, identifier:_client; 55, identifier:filter; 56, identifier:filter; 57, identifier:sort; 58, identifier:sort; 59, identifier:query; 60, identifier:query; 61, identifier:fields; 62, identifier:fields; 63, identifier:view; 64, identifier:view; 65, identifier:uri; 66, identifier:uri
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 10, 25; 11, 26; 11, 27; 12, 28; 12, 29; 13, 30; 14, 31; 15, 32; 19, 33; 31, 34; 31, 35; 32, 36; 32, 37; 35, 38; 35, 39; 36, 40; 36, 41; 37, 42; 37, 43; 37, 44; 37, 45; 37, 46; 37, 47; 37, 48; 37, 49; 38, 50; 38, 51; 39, 52; 40, 53; 40, 54; 44, 55; 44, 56; 45, 57; 45, 58; 46, 59; 46, 60; 47, 61; 47, 62; 48, 63; 48, 64; 49, 65; 49, 66
def get_appliances(self, start=0, count=-1, filter='', fields='', query='', sort='', view=''): """ Gets a list of all the Image Streamer resources based on optional sorting and filtering, and constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. fields: Specifies which fields should be returned in the result set. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Return a specific subset of the attributes of the resource or collection, by specifying the name of a predefined view. The default view is expand - show all attributes of the resource and all elements of collections of resources. Returns: list: Image Streamer resources associated with the Deployment Servers. """ uri = self.URI + '/image-streamer-appliances' return self._client.get_all(start, count, filter=filter, sort=sort, query=query, fields=fields, view=view, uri=uri)
0, module; 1, function_definition; 2, function_name:get_all; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, return_statement; 11, identifier:start; 12, integer:0; 13, identifier:count; 14, unary_operator; 15, identifier:sort; 16, string; 17, comment:""" Gets a list of logical interconnects based on optional sorting and filtering and is constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of logical interconnects. """; 18, call; 19, integer:1; 20, attribute; 21, argument_list; 22, attribute; 23, identifier:get_all; 24, identifier:start; 25, identifier:count; 26, keyword_argument; 27, identifier:self; 28, identifier:_helper; 29, identifier:sort; 30, identifier:sort
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 6, 11; 6, 12; 7, 13; 7, 14; 8, 15; 8, 16; 9, 17; 10, 18; 14, 19; 18, 20; 18, 21; 20, 22; 20, 23; 21, 24; 21, 25; 21, 26; 22, 27; 22, 28; 26, 29; 26, 30
def get_all(self, start=0, count=-1, sort=''): """ Gets a list of logical interconnects based on optional sorting and filtering and is constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of logical interconnects. """ return self._helper.get_all(start, count, sort=sort)
0, module; 1, function_definition; 2, function_name:get_endpoints; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:start; 14, integer:0; 15, identifier:count; 16, unary_operator; 17, identifier:filter; 18, string; 19, identifier:sort; 20, string; 21, comment:""" Gets a list of endpoints in a SAN. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of endpoints. """; 22, assignment; 23, call; 24, integer:1; 25, identifier:uri; 26, call; 27, attribute; 28, argument_list; 29, attribute; 30, argument_list; 31, attribute; 32, identifier:get_all; 33, identifier:start; 34, identifier:count; 35, keyword_argument; 36, keyword_argument; 37, keyword_argument; 38, string:"{}/endpoints/"; 39, identifier:format; 40, subscript; 41, identifier:self; 42, identifier:_helper; 43, identifier:filter; 44, identifier:filter; 45, identifier:sort; 46, identifier:sort; 47, identifier:uri; 48, identifier:uri; 49, attribute; 50, string:"uri"; 51, identifier:self; 52, identifier:data
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 11, 22; 12, 23; 16, 24; 22, 25; 22, 26; 23, 27; 23, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 28, 35; 28, 36; 28, 37; 29, 38; 29, 39; 30, 40; 31, 41; 31, 42; 35, 43; 35, 44; 36, 45; 36, 46; 37, 47; 37, 48; 40, 49; 40, 50; 49, 51; 49, 52
def get_endpoints(self, start=0, count=-1, filter='', sort=''): """ Gets a list of endpoints in a SAN. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of endpoints. """ uri = "{}/endpoints/".format(self.data["uri"]) return self._helper.get_all(start, count, filter=filter, sort=sort, uri=uri)
0, module; 1, function_definition; 2, function_name:__findFirstMissing; 3, parameters; 4, block; 5, identifier:self; 6, identifier:array; 7, identifier:start; 8, identifier:end; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, if_statement; 14, return_statement; 15, comment:""" Find the smallest elements missing in a sorted array. Returns: int: The smallest element missing. """; 16, parenthesized_expression; 17, block; 18, parenthesized_expression; 19, block; 20, assignment; 21, parenthesized_expression; 22, block; 23, call; 24, comparison_operator:start > end; 25, return_statement; 26, comparison_operator:start != array[start]; 27, return_statement; 28, identifier:mid; 29, call; 30, comparison_operator:array[mid] == mid; 31, return_statement; 32, attribute; 33, argument_list; 34, identifier:start; 35, identifier:end; 36, binary_operator:end + 1; 37, identifier:start; 38, subscript; 39, identifier:start; 40, identifier:int; 41, argument_list; 42, subscript; 43, identifier:mid; 44, call; 45, identifier:self; 46, identifier:__findFirstMissing; 47, identifier:array; 48, identifier:start; 49, identifier:mid; 50, identifier:end; 51, integer:1; 52, identifier:array; 53, identifier:start; 54, binary_operator:(start + end) / 2; 55, identifier:array; 56, identifier:mid; 57, attribute; 58, argument_list; 59, parenthesized_expression; 60, integer:2; 61, identifier:self; 62, identifier:__findFirstMissing; 63, identifier:array; 64, binary_operator:mid + 1; 65, identifier:end; 66, binary_operator:start + end; 67, identifier:mid; 68, integer:1; 69, identifier:start; 70, identifier:end
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 9, 15; 10, 16; 10, 17; 11, 18; 11, 19; 12, 20; 13, 21; 13, 22; 14, 23; 16, 24; 17, 25; 18, 26; 19, 27; 20, 28; 20, 29; 21, 30; 22, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 26, 37; 26, 38; 27, 39; 29, 40; 29, 41; 30, 42; 30, 43; 31, 44; 32, 45; 32, 46; 33, 47; 33, 48; 33, 49; 36, 50; 36, 51; 38, 52; 38, 53; 41, 54; 42, 55; 42, 56; 44, 57; 44, 58; 54, 59; 54, 60; 57, 61; 57, 62; 58, 63; 58, 64; 58, 65; 59, 66; 64, 67; 64, 68; 66, 69; 66, 70
def __findFirstMissing(self, array, start, end): """ Find the smallest elements missing in a sorted array. Returns: int: The smallest element missing. """ if (start > end): return end + 1 if (start != array[start]): return start mid = int((start + end) / 2) if (array[mid] == mid): return self.__findFirstMissing(array, mid + 1, end) return self.__findFirstMissing(array, start, mid)
0, module; 1, function_definition; 2, function_name:get_reachable_storage_pools; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, expression_statement; 15, expression_statement; 16, if_statement; 17, if_statement; 18, return_statement; 19, identifier:start; 20, integer:0; 21, identifier:count; 22, unary_operator; 23, identifier:filter; 24, string; 25, identifier:query; 26, string; 27, identifier:sort; 28, string; 29, identifier:networks; 30, None; 31, identifier:scope_exclusions; 32, None; 33, identifier:scope_uris; 34, string; 35, comment:""" Gets the storage pools that are connected on the specified networks based on the storage system port's expected network connectivity. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter: A general filter/query string to narrow the list of items returned. The default is no filter - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. networks: Specifies the comma-separated list of network URIs used by the reachable storage pools. scope_exclusions: Specifies the comma-separated list of storage-pools URIs that will be excluded from the scope validation checks. scope_uris: Specifies the comma-separated list of scope URIs used by the reachable storage pools. Returns: list: Reachable Storage Pools List. """; 36, assignment; 37, identifier:networks; 38, block; 39, identifier:scope_exclusions; 40, block; 41, call; 42, integer:1; 43, identifier:uri; 44, binary_operator:self.URI + "/reachable-storage-pools"; 45, expression_statement; 46, for_statement; 47, expression_statement; 48, expression_statement; 49, expression_statement; 50, expression_statement; 51, expression_statement; 52, attribute; 53, argument_list; 54, attribute; 55, string:"/reachable-storage-pools"; 56, assignment; 57, identifier:n; 58, identifier:networks; 59, block; 60, assignment; 61, assignment; 62, assignment; 63, assignment; 64, augmented_assignment; 65, attribute; 66, identifier:get; 67, call; 68, identifier:self; 69, identifier:URI; 70, identifier:elements; 71, string:"\'"; 72, expression_statement; 73, identifier:elements; 74, binary_operator:elements[:-1] + "\'"; 75, identifier:uri; 76, binary_operator:uri + "?networks=" + elements; 77, identifier:storage_pools_uris; 78, call; 79, identifier:uri; 80, conditional_expression:uri + "?" if "?" not in uri else uri + "&"; 81, identifier:uri; 82, call; 83, identifier:self; 84, identifier:_client; 85, attribute; 86, argument_list; 87, augmented_assignment; 88, subscript; 89, string:"\'"; 90, binary_operator:uri + "?networks="; 91, identifier:elements; 92, attribute; 93, argument_list; 94, binary_operator:uri + "?"; 95, comparison_operator:"?" not in uri; 96, binary_operator:uri + "&"; 97, attribute; 98, argument_list; 99, attribute; 100, identifier:build_query_uri; 101, keyword_argument; 102, keyword_argument; 103, keyword_argument; 104, keyword_argument; 105, keyword_argument; 106, keyword_argument; 107, keyword_argument; 108, identifier:elements; 109, binary_operator:n + ','; 110, identifier:elements; 111, slice; 112, identifier:uri; 113, string:"?networks="; 114, string:","; 115, identifier:join; 116, identifier:scope_exclusions; 117, identifier:uri; 118, string:"?"; 119, string:"?"; 120, identifier:uri; 121, identifier:uri; 122, string:"&"; 123, string:"scopeExclusions={}"; 124, identifier:format; 125, identifier:storage_pools_uris; 126, identifier:self; 127, identifier:_client; 128, identifier:start; 129, identifier:start; 130, identifier:count; 131, identifier:count; 132, identifier:filter; 133, identifier:filter; 134, identifier:query; 135, identifier:query; 136, identifier:sort; 137, identifier:sort; 138, identifier:uri; 139, identifier:uri; 140, identifier:scope_uris; 141, identifier:scope_uris; 142, identifier:n; 143, string; 144, unary_operator; 145, string_content:,; 146, integer:1
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 6, 19; 6, 20; 7, 21; 7, 22; 8, 23; 8, 24; 9, 25; 9, 26; 10, 27; 10, 28; 11, 29; 11, 30; 12, 31; 12, 32; 13, 33; 13, 34; 14, 35; 15, 36; 16, 37; 16, 38; 17, 39; 17, 40; 18, 41; 22, 42; 36, 43; 36, 44; 38, 45; 38, 46; 38, 47; 38, 48; 40, 49; 40, 50; 40, 51; 41, 52; 41, 53; 44, 54; 44, 55; 45, 56; 46, 57; 46, 58; 46, 59; 47, 60; 48, 61; 49, 62; 50, 63; 51, 64; 52, 65; 52, 66; 53, 67; 54, 68; 54, 69; 56, 70; 56, 71; 59, 72; 60, 73; 60, 74; 61, 75; 61, 76; 62, 77; 62, 78; 63, 79; 63, 80; 64, 81; 64, 82; 65, 83; 65, 84; 67, 85; 67, 86; 72, 87; 74, 88; 74, 89; 76, 90; 76, 91; 78, 92; 78, 93; 80, 94; 80, 95; 80, 96; 82, 97; 82, 98; 85, 99; 85, 100; 86, 101; 86, 102; 86, 103; 86, 104; 86, 105; 86, 106; 86, 107; 87, 108; 87, 109; 88, 110; 88, 111; 90, 112; 90, 113; 92, 114; 92, 115; 93, 116; 94, 117; 94, 118; 95, 119; 95, 120; 96, 121; 96, 122; 97, 123; 97, 124; 98, 125; 99, 126; 99, 127; 101, 128; 101, 129; 102, 130; 102, 131; 103, 132; 103, 133; 104, 134; 104, 135; 105, 136; 105, 137; 106, 138; 106, 139; 107, 140; 107, 141; 109, 142; 109, 143; 111, 144; 143, 145; 144, 146
def get_reachable_storage_pools(self, start=0, count=-1, filter='', query='', sort='', networks=None, scope_exclusions=None, scope_uris=''): """ Gets the storage pools that are connected on the specified networks based on the storage system port's expected network connectivity. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter: A general filter/query string to narrow the list of items returned. The default is no filter - all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. query: A general query string to narrow the list of resources returned. The default is no query - all resources are returned. networks: Specifies the comma-separated list of network URIs used by the reachable storage pools. scope_exclusions: Specifies the comma-separated list of storage-pools URIs that will be excluded from the scope validation checks. scope_uris: Specifies the comma-separated list of scope URIs used by the reachable storage pools. Returns: list: Reachable Storage Pools List. """ uri = self.URI + "/reachable-storage-pools" if networks: elements = "\'" for n in networks: elements += n + ',' elements = elements[:-1] + "\'" uri = uri + "?networks=" + elements if scope_exclusions: storage_pools_uris = ",".join(scope_exclusions) uri = uri + "?" if "?" not in uri else uri + "&" uri += "scopeExclusions={}".format(storage_pools_uris) return self._client.get(self._client.build_query_uri(start=start, count=count, filter=filter, query=query, sort=sort, uri=uri, scope_uris=scope_uris))
0, module; 1, function_definition; 2, function_name:get_snapshots; 3, parameters; 4, block; 5, identifier:self; 6, identifier:volume_id_or_uri; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:start; 15, integer:0; 16, identifier:count; 17, unary_operator; 18, identifier:filter; 19, string; 20, identifier:sort; 21, string; 22, comment:""" Gets all snapshots of a volume. Returns a list of snapshots based on optional sorting and filtering, and constrained by start and count parameters. Args: volume_id_or_uri: Can be either the volume id or the volume uri. start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of snapshots. """; 23, assignment; 24, call; 25, integer:1; 26, identifier:uri; 27, call; 28, attribute; 29, argument_list; 30, attribute; 31, argument_list; 32, attribute; 33, identifier:get_all; 34, identifier:start; 35, identifier:count; 36, keyword_argument; 37, keyword_argument; 38, keyword_argument; 39, identifier:self; 40, identifier:__build_volume_snapshot_uri; 41, identifier:volume_id_or_uri; 42, identifier:self; 43, identifier:_client; 44, identifier:filter; 45, identifier:filter; 46, identifier:sort; 47, identifier:sort; 48, identifier:uri; 49, identifier:uri
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 12, 23; 13, 24; 17, 25; 23, 26; 23, 27; 24, 28; 24, 29; 27, 30; 27, 31; 28, 32; 28, 33; 29, 34; 29, 35; 29, 36; 29, 37; 29, 38; 30, 39; 30, 40; 31, 41; 32, 42; 32, 43; 36, 44; 36, 45; 37, 46; 37, 47; 38, 48; 38, 49
def get_snapshots(self, volume_id_or_uri, start=0, count=-1, filter='', sort=''): """ Gets all snapshots of a volume. Returns a list of snapshots based on optional sorting and filtering, and constrained by start and count parameters. Args: volume_id_or_uri: Can be either the volume id or the volume uri. start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of snapshots. """ uri = self.__build_volume_snapshot_uri(volume_id_or_uri) return self._client.get_all(start, count, filter=filter, sort=sort, uri=uri)
0, module; 1, function_definition; 2, function_name:get_extra_managed_storage_volume_paths; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:start; 14, integer:0; 15, identifier:count; 16, unary_operator; 17, identifier:filter; 18, string; 19, identifier:sort; 20, string; 21, comment:""" Gets the list of extra managed storage volume paths. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of extra managed storage volume paths. """; 22, assignment; 23, call; 24, integer:1; 25, identifier:uri; 26, binary_operator:self.URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths'; 27, attribute; 28, argument_list; 29, attribute; 30, string; 31, attribute; 32, identifier:get_all; 33, identifier:start; 34, identifier:count; 35, keyword_argument; 36, keyword_argument; 37, keyword_argument; 38, identifier:self; 39, identifier:URI; 40, string_content:/repair?alertFixType=ExtraManagedStorageVolumePaths; 41, identifier:self; 42, identifier:_client; 43, identifier:filter; 44, identifier:filter; 45, identifier:sort; 46, identifier:sort; 47, identifier:uri; 48, identifier:uri
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 11, 22; 12, 23; 16, 24; 22, 25; 22, 26; 23, 27; 23, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 28, 35; 28, 36; 28, 37; 29, 38; 29, 39; 30, 40; 31, 41; 31, 42; 35, 43; 35, 44; 36, 45; 36, 46; 37, 47; 37, 48
def get_extra_managed_storage_volume_paths(self, start=0, count=-1, filter='', sort=''): """ Gets the list of extra managed storage volume paths. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: list: A list of extra managed storage volume paths. """ uri = self.URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths' return self._client.get_all(start, count, filter=filter, sort=sort, uri=uri)
0, module; 1, function_definition; 2, function_name:get_attachable_volumes; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, expression_statement; 15, if_statement; 16, return_statement; 17, identifier:start; 18, integer:0; 19, identifier:count; 20, unary_operator; 21, identifier:filter; 22, string; 23, identifier:query; 24, string; 25, identifier:sort; 26, string; 27, identifier:scope_uris; 28, string; 29, identifier:connections; 30, string; 31, comment:""" Gets the volumes that are connected on the specified networks based on the storage system port's expected network connectivity. A volume is attachable if it satisfies either of the following conditions: * The volume is shareable. * The volume not shareable and not attached. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A general query string to narrow the list of resources returned. The default is no query; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. connections: A list of dicts specifics the connections used by the attachable volumes. Needs network uri, initiatoer name and optional proxy name scope_uris: A list specifics the list of scope uris used by the attachable volumed. Returns: list: A list of attachable volumes that the appliance manages. """; 32, assignment; 33, identifier:connections; 34, block; 35, call; 36, integer:1; 37, identifier:uri; 38, binary_operator:self.URI + '/attachable-volumes'; 39, expression_statement; 40, attribute; 41, argument_list; 42, attribute; 43, string; 44, augmented_assignment; 45, attribute; 46, identifier:get_all; 47, identifier:start; 48, identifier:count; 49, keyword_argument; 50, keyword_argument; 51, keyword_argument; 52, keyword_argument; 53, keyword_argument; 54, identifier:self; 55, identifier:URI; 56, string_content:/attachable-volumes; 57, identifier:uri; 58, call; 59, identifier:self; 60, identifier:_client; 61, identifier:filter; 62, identifier:filter; 63, identifier:query; 64, identifier:query; 65, identifier:sort; 66, identifier:sort; 67, identifier:uri; 68, identifier:uri; 69, identifier:scope_uris; 70, identifier:scope_uris; 71, identifier:str; 72, argument_list; 73, binary_operator:'?' + 'connections=' + connections.__str__(); 74, binary_operator:'?' + 'connections='; 75, call; 76, string; 77, string; 78, attribute; 79, argument_list; 80, string_content:?; 81, string_content:connections=; 82, identifier:connections; 83, identifier:__str__
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 8, 22; 9, 23; 9, 24; 10, 25; 10, 26; 11, 27; 11, 28; 12, 29; 12, 30; 13, 31; 14, 32; 15, 33; 15, 34; 16, 35; 20, 36; 32, 37; 32, 38; 34, 39; 35, 40; 35, 41; 38, 42; 38, 43; 39, 44; 40, 45; 40, 46; 41, 47; 41, 48; 41, 49; 41, 50; 41, 51; 41, 52; 41, 53; 42, 54; 42, 55; 43, 56; 44, 57; 44, 58; 45, 59; 45, 60; 49, 61; 49, 62; 50, 63; 50, 64; 51, 65; 51, 66; 52, 67; 52, 68; 53, 69; 53, 70; 58, 71; 58, 72; 72, 73; 73, 74; 73, 75; 74, 76; 74, 77; 75, 78; 75, 79; 76, 80; 77, 81; 78, 82; 78, 83
def get_attachable_volumes(self, start=0, count=-1, filter='', query='', sort='', scope_uris='', connections=''): """ Gets the volumes that are connected on the specified networks based on the storage system port's expected network connectivity. A volume is attachable if it satisfies either of the following conditions: * The volume is shareable. * The volume not shareable and not attached. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A general query string to narrow the list of resources returned. The default is no query; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. connections: A list of dicts specifics the connections used by the attachable volumes. Needs network uri, initiatoer name and optional proxy name scope_uris: A list specifics the list of scope uris used by the attachable volumed. Returns: list: A list of attachable volumes that the appliance manages. """ uri = self.URI + '/attachable-volumes' if connections: uri += str('?' + 'connections=' + connections.__str__()) return self._client.get_all(start, count, filter=filter, query=query, sort=sort, uri=uri, scope_uris=scope_uris)
0, module; 1, function_definition; 2, function_name:get_available_storage_systems; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:start; 15, integer:0; 16, identifier:count; 17, unary_operator; 18, identifier:filter; 19, string; 20, identifier:sort; 21, string; 22, identifier:kwargs; 23, comment:""" Retrieves the list of the storage systems and their associated volumes available to the server profile based on the given server hardware type and enclosure group. Args: count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response may differ from the requested count if the sum of start and count exceed the total number of items. start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time, with the oldest entry first. enclosureGroupUri (str): The URI of the enclosure group associated with the resource. serverHardwareTypeUri (str): The URI of the server hardware type associated with the resource. Returns: list: Available storage systems. """; 24, assignment; 25, call; 26, integer:1; 27, identifier:uri; 28, call; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, attribute; 34, identifier:get_all; 35, keyword_argument; 36, keyword_argument; 37, keyword_argument; 38, keyword_argument; 39, keyword_argument; 40, attribute; 41, identifier:build_uri_with_query_string; 42, identifier:kwargs; 43, string; 44, identifier:self; 45, identifier:_helper; 46, identifier:start; 47, identifier:start; 48, identifier:count; 49, identifier:count; 50, identifier:filter; 51, identifier:filter; 52, identifier:sort; 53, identifier:sort; 54, identifier:uri; 55, identifier:uri; 56, identifier:self; 57, identifier:_helper; 58, string_content:/available-storage-systems
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 6, 14; 6, 15; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 9, 21; 10, 22; 11, 23; 12, 24; 13, 25; 17, 26; 24, 27; 24, 28; 25, 29; 25, 30; 28, 31; 28, 32; 29, 33; 29, 34; 30, 35; 30, 36; 30, 37; 30, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; 33, 44; 33, 45; 35, 46; 35, 47; 36, 48; 36, 49; 37, 50; 37, 51; 38, 52; 38, 53; 39, 54; 39, 55; 40, 56; 40, 57; 43, 58
def get_available_storage_systems(self, start=0, count=-1, filter='', sort='', **kwargs): """ Retrieves the list of the storage systems and their associated volumes available to the server profile based on the given server hardware type and enclosure group. Args: count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response may differ from the requested count if the sum of start and count exceed the total number of items. start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time, with the oldest entry first. enclosureGroupUri (str): The URI of the enclosure group associated with the resource. serverHardwareTypeUri (str): The URI of the server hardware type associated with the resource. Returns: list: Available storage systems. """ uri = self._helper.build_uri_with_query_string(kwargs, '/available-storage-systems') return self._helper.get_all(start=start, count=count, filter=filter, sort=sort, uri=uri)
0, module; 1, function_definition; 2, function_name:build_query_uri; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, expression_statement; 16, if_statement; 17, if_statement; 18, if_statement; 19, if_statement; 20, if_statement; 21, if_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, return_statement; 27, identifier:uri; 28, None; 29, identifier:start; 30, integer:0; 31, identifier:count; 32, unary_operator; 33, identifier:filter; 34, string; 35, identifier:query; 36, string; 37, identifier:sort; 38, string; 39, identifier:view; 40, string; 41, identifier:fields; 42, string; 43, identifier:scope_uris; 44, string; 45, comment:"""Builds the URI from given parameters. More than one request can be send to get the items, regardless the query parameter 'count', because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long. The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html Note: Single quote - "'" - inside a query parameter is not supported by OneView API. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items (default). filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources). fields: Name of the fields. uri: A specific URI (optional) scope_uris: An expression to restrict the resources returned according to the scopes to which they are assigned. Returns: uri: The complete uri """; 46, identifier:filter; 47, block; 48, identifier:query; 49, block; 50, identifier:sort; 51, block; 52, identifier:view; 53, block; 54, identifier:fields; 55, block; 56, identifier:scope_uris; 57, block; 58, assignment; 59, call; 60, assignment; 61, assignment; 62, identifier:uri; 63, integer:1; 64, expression_statement; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, expression_statement; 70, identifier:path; 71, conditional_expression:uri if uri else self._base_uri; 72, attribute; 73, argument_list; 74, identifier:symbol; 75, conditional_expression:'?' if '?' not in path else '&'; 76, identifier:uri; 77, call; 78, assignment; 79, assignment; 80, assignment; 81, assignment; 82, assignment; 83, assignment; 84, identifier:uri; 85, identifier:uri; 86, attribute; 87, identifier:self; 88, identifier:validate_resource_uri; 89, identifier:path; 90, string; 91, comparison_operator:'?' not in path; 92, string; 93, attribute; 94, argument_list; 95, identifier:filter; 96, call; 97, identifier:query; 98, binary_operator:"&query=" + quote(query); 99, identifier:sort; 100, binary_operator:"&sort=" + quote(sort); 101, identifier:view; 102, binary_operator:"&view=" + quote(view); 103, identifier:fields; 104, binary_operator:"&fields=" + quote(fields); 105, identifier:scope_uris; 106, binary_operator:"&scopeUris=" + quote(scope_uris); 107, identifier:self; 108, identifier:_base_uri; 109, string_content:?; 110, string; 111, identifier:path; 112, string_content:&; 113, string:"{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}"; 114, identifier:format; 115, identifier:path; 116, identifier:symbol; 117, identifier:start; 118, identifier:count; 119, identifier:filter; 120, identifier:query; 121, identifier:sort; 122, identifier:view; 123, identifier:fields; 124, identifier:scope_uris; 125, attribute; 126, argument_list; 127, string:"&query="; 128, call; 129, string:"&sort="; 130, call; 131, string:"&view="; 132, call; 133, string:"&fields="; 134, call; 135, string:"&scopeUris="; 136, call; 137, string_content:?; 138, identifier:self; 139, identifier:make_query_filter; 140, identifier:filter; 141, identifier:quote; 142, argument_list; 143, identifier:quote; 144, argument_list; 145, identifier:quote; 146, argument_list; 147, identifier:quote; 148, argument_list; 149, identifier:quote; 150, argument_list; 151, identifier:query; 152, identifier:sort; 153, identifier:view; 154, identifier:fields; 155, identifier:scope_uris
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 6, 27; 6, 28; 7, 29; 7, 30; 8, 31; 8, 32; 9, 33; 9, 34; 10, 35; 10, 36; 11, 37; 11, 38; 12, 39; 12, 40; 13, 41; 13, 42; 14, 43; 14, 44; 15, 45; 16, 46; 16, 47; 17, 48; 17, 49; 18, 50; 18, 51; 19, 52; 19, 53; 20, 54; 20, 55; 21, 56; 21, 57; 22, 58; 23, 59; 24, 60; 25, 61; 26, 62; 32, 63; 47, 64; 49, 65; 51, 66; 53, 67; 55, 68; 57, 69; 58, 70; 58, 71; 59, 72; 59, 73; 60, 74; 60, 75; 61, 76; 61, 77; 64, 78; 65, 79; 66, 80; 67, 81; 68, 82; 69, 83; 71, 84; 71, 85; 71, 86; 72, 87; 72, 88; 73, 89; 75, 90; 75, 91; 75, 92; 77, 93; 77, 94; 78, 95; 78, 96; 79, 97; 79, 98; 80, 99; 80, 100; 81, 101; 81, 102; 82, 103; 82, 104; 83, 105; 83, 106; 86, 107; 86, 108; 90, 109; 91, 110; 91, 111; 92, 112; 93, 113; 93, 114; 94, 115; 94, 116; 94, 117; 94, 118; 94, 119; 94, 120; 94, 121; 94, 122; 94, 123; 94, 124; 96, 125; 96, 126; 98, 127; 98, 128; 100, 129; 100, 130; 102, 131; 102, 132; 104, 133; 104, 134; 106, 135; 106, 136; 110, 137; 125, 138; 125, 139; 126, 140; 128, 141; 128, 142; 130, 143; 130, 144; 132, 145; 132, 146; 134, 147; 134, 148; 136, 149; 136, 150; 142, 151; 144, 152; 146, 153; 148, 154; 150, 155
def build_query_uri(self, uri=None, start=0, count=-1, filter='', query='', sort='', view='', fields='', scope_uris=''): """Builds the URI from given parameters. More than one request can be send to get the items, regardless the query parameter 'count', because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long. The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html Note: Single quote - "'" - inside a query parameter is not supported by OneView API. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items (default). filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources). fields: Name of the fields. uri: A specific URI (optional) scope_uris: An expression to restrict the resources returned according to the scopes to which they are assigned. Returns: uri: The complete uri """ if filter: filter = self.make_query_filter(filter) if query: query = "&query=" + quote(query) if sort: sort = "&sort=" + quote(sort) if view: view = "&view=" + quote(view) if fields: fields = "&fields=" + quote(fields) if scope_uris: scope_uris = "&scopeUris=" + quote(scope_uris) path = uri if uri else self._base_uri self.validate_resource_uri(path) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}".format(path, symbol, start, count, filter, query, sort, view, fields, scope_uris) return uri
0, module; 1, function_definition; 2, function_name:build_query_uri; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, expression_statement; 16, if_statement; 17, if_statement; 18, if_statement; 19, if_statement; 20, if_statement; 21, if_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, return_statement; 27, identifier:start; 28, integer:0; 29, identifier:count; 30, unary_operator; 31, identifier:filter; 32, string; 33, identifier:query; 34, string; 35, identifier:sort; 36, string; 37, identifier:view; 38, string; 39, identifier:fields; 40, string; 41, identifier:uri; 42, None; 43, identifier:scope_uris; 44, string; 45, comment:""" Builds the URI given the parameters. More than one request can be send to get the items, regardless the query parameter 'count', because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long. The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html Note: Single quote - "'" - inside a query parameter is not supported by OneView API. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items (default). filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources). fields: Name of the fields. uri: A specific URI (optional) scope_uris: An expression to restrict the resources returned according to the scopes to which they are assigned. Returns: uri: The complete uri """; 46, identifier:filter; 47, block; 48, identifier:query; 49, block; 50, identifier:sort; 51, block; 52, identifier:view; 53, block; 54, identifier:fields; 55, block; 56, identifier:scope_uris; 57, block; 58, assignment; 59, call; 60, assignment; 61, assignment; 62, identifier:uri; 63, integer:1; 64, expression_statement; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, expression_statement; 70, identifier:path; 71, conditional_expression:uri if uri else self._uri; 72, attribute; 73, argument_list; 74, identifier:symbol; 75, conditional_expression:'?' if '?' not in path else '&'; 76, identifier:uri; 77, call; 78, assignment; 79, assignment; 80, assignment; 81, assignment; 82, assignment; 83, assignment; 84, identifier:uri; 85, identifier:uri; 86, attribute; 87, identifier:self; 88, identifier:__validate_resource_uri; 89, identifier:path; 90, string; 91, comparison_operator:'?' not in path; 92, string; 93, attribute; 94, argument_list; 95, identifier:filter; 96, call; 97, identifier:query; 98, binary_operator:"&query=" + quote(query); 99, identifier:sort; 100, binary_operator:"&sort=" + quote(sort); 101, identifier:view; 102, binary_operator:"&view=" + quote(view); 103, identifier:fields; 104, binary_operator:"&fields=" + quote(fields); 105, identifier:scope_uris; 106, binary_operator:"&scopeUris=" + quote(scope_uris); 107, identifier:self; 108, identifier:_uri; 109, string_content:?; 110, string; 111, identifier:path; 112, string_content:&; 113, string:"{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}"; 114, identifier:format; 115, identifier:path; 116, identifier:symbol; 117, identifier:start; 118, identifier:count; 119, identifier:filter; 120, identifier:query; 121, identifier:sort; 122, identifier:view; 123, identifier:fields; 124, identifier:scope_uris; 125, attribute; 126, argument_list; 127, string:"&query="; 128, call; 129, string:"&sort="; 130, call; 131, string:"&view="; 132, call; 133, string:"&fields="; 134, call; 135, string:"&scopeUris="; 136, call; 137, string_content:?; 138, identifier:self; 139, identifier:__make_query_filter; 140, identifier:filter; 141, identifier:quote; 142, argument_list; 143, identifier:quote; 144, argument_list; 145, identifier:quote; 146, argument_list; 147, identifier:quote; 148, argument_list; 149, identifier:quote; 150, argument_list; 151, identifier:query; 152, identifier:sort; 153, identifier:view; 154, identifier:fields; 155, identifier:scope_uris
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 6, 27; 6, 28; 7, 29; 7, 30; 8, 31; 8, 32; 9, 33; 9, 34; 10, 35; 10, 36; 11, 37; 11, 38; 12, 39; 12, 40; 13, 41; 13, 42; 14, 43; 14, 44; 15, 45; 16, 46; 16, 47; 17, 48; 17, 49; 18, 50; 18, 51; 19, 52; 19, 53; 20, 54; 20, 55; 21, 56; 21, 57; 22, 58; 23, 59; 24, 60; 25, 61; 26, 62; 30, 63; 47, 64; 49, 65; 51, 66; 53, 67; 55, 68; 57, 69; 58, 70; 58, 71; 59, 72; 59, 73; 60, 74; 60, 75; 61, 76; 61, 77; 64, 78; 65, 79; 66, 80; 67, 81; 68, 82; 69, 83; 71, 84; 71, 85; 71, 86; 72, 87; 72, 88; 73, 89; 75, 90; 75, 91; 75, 92; 77, 93; 77, 94; 78, 95; 78, 96; 79, 97; 79, 98; 80, 99; 80, 100; 81, 101; 81, 102; 82, 103; 82, 104; 83, 105; 83, 106; 86, 107; 86, 108; 90, 109; 91, 110; 91, 111; 92, 112; 93, 113; 93, 114; 94, 115; 94, 116; 94, 117; 94, 118; 94, 119; 94, 120; 94, 121; 94, 122; 94, 123; 94, 124; 96, 125; 96, 126; 98, 127; 98, 128; 100, 129; 100, 130; 102, 131; 102, 132; 104, 133; 104, 134; 106, 135; 106, 136; 110, 137; 125, 138; 125, 139; 126, 140; 128, 141; 128, 142; 130, 143; 130, 144; 132, 145; 132, 146; 134, 147; 134, 148; 136, 149; 136, 150; 142, 151; 144, 152; 146, 153; 148, 154; 150, 155
def build_query_uri(self, start=0, count=-1, filter='', query='', sort='', view='', fields='', uri=None, scope_uris=''): """ Builds the URI given the parameters. More than one request can be send to get the items, regardless the query parameter 'count', because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long. The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html Note: Single quote - "'" - inside a query parameter is not supported by OneView API. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items (default). filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. query: A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. view: Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources). fields: Name of the fields. uri: A specific URI (optional) scope_uris: An expression to restrict the resources returned according to the scopes to which they are assigned. Returns: uri: The complete uri """ if filter: filter = self.__make_query_filter(filter) if query: query = "&query=" + quote(query) if sort: sort = "&sort=" + quote(sort) if view: view = "&view=" + quote(view) if fields: fields = "&fields=" + quote(fields) if scope_uris: scope_uris = "&scopeUris=" + quote(scope_uris) path = uri if uri else self._uri self.__validate_resource_uri(path) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}".format(path, symbol, start, count, filter, query, sort, view, fields, scope_uris) return uri
0, module; 1, function_definition; 2, function_name:get_all_without_ethernet; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:start; 14, integer:0; 15, identifier:count; 16, unary_operator; 17, identifier:filter; 18, string; 19, identifier:sort; 20, string; 21, comment:""" Gets a paginated collection of logical downlinks without ethernet. The collection is based on optional sorting and filtering and is constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: dict """; 22, assignment; 23, call; 24, integer:1; 25, identifier:without_ethernet_client; 26, call; 27, attribute; 28, argument_list; 29, identifier:ResourceClient; 30, argument_list; 31, identifier:without_ethernet_client; 32, identifier:get_all; 33, identifier:start; 34, identifier:count; 35, keyword_argument; 36, keyword_argument; 37, attribute; 38, string:"/rest/logical-downlinks/withoutEthernet"; 39, identifier:filter; 40, identifier:filter; 41, identifier:sort; 42, identifier:sort; 43, identifier:self; 44, identifier:_connection
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 11, 22; 12, 23; 16, 24; 22, 25; 22, 26; 23, 27; 23, 28; 26, 29; 26, 30; 27, 31; 27, 32; 28, 33; 28, 34; 28, 35; 28, 36; 30, 37; 30, 38; 35, 39; 35, 40; 36, 41; 36, 42; 37, 43; 37, 44
def get_all_without_ethernet(self, start=0, count=-1, filter='', sort=''): """ Gets a paginated collection of logical downlinks without ethernet. The collection is based on optional sorting and filtering and is constrained by start and count parameters. Args: start: The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item. count: The number of resources to return. A count of -1 requests all items. The actual number of items in the response might differ from the requested count if the sum of start and count exceeds the total number of items. filter (list or str): A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned. sort: The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first. Returns: dict """ without_ethernet_client = ResourceClient( self._connection, "/rest/logical-downlinks/withoutEthernet") return without_ethernet_client.get_all(start, count, filter=filter, sort=sort)
0, module; 1, function_definition; 2, function_name:reduce_sort; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, return_statement; 12, identifier:js_cmp; 13, None; 14, identifier:options; 15, None; 16, comment:""" Adds the Javascript built-in ``Riak.reduceSort`` to the query as a reduce phase. :param js_cmp: A Javascript comparator function as specified by Array.sort() :type js_cmp: string :param options: phase options, containing 'language', 'keep' flag, and/or 'arg'. :type options: dict """; 17, comparison_operator:options is None; 18, block; 19, identifier:js_cmp; 20, block; 21, call; 22, identifier:options; 23, None; 24, expression_statement; 25, expression_statement; 26, attribute; 27, argument_list; 28, assignment; 29, assignment; 30, identifier:self; 31, identifier:reduce; 32, string:"Riak.reduceSort"; 33, keyword_argument; 34, identifier:options; 35, call; 36, subscript; 37, identifier:js_cmp; 38, identifier:options; 39, identifier:options; 40, identifier:dict; 41, argument_list; 42, identifier:options; 43, string; 44, string_content:arg
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 9, 17; 9, 18; 10, 19; 10, 20; 11, 21; 17, 22; 17, 23; 18, 24; 20, 25; 21, 26; 21, 27; 24, 28; 25, 29; 26, 30; 26, 31; 27, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 33, 38; 33, 39; 35, 40; 35, 41; 36, 42; 36, 43; 43, 44
def reduce_sort(self, js_cmp=None, options=None): """ Adds the Javascript built-in ``Riak.reduceSort`` to the query as a reduce phase. :param js_cmp: A Javascript comparator function as specified by Array.sort() :type js_cmp: string :param options: phase options, containing 'language', 'keep' flag, and/or 'arg'. :type options: dict """ if options is None: options = dict() if js_cmp: options['arg'] = js_cmp return self.reduce("Riak.reduceSort", options=options)