nodes: 0, module; 1, function_definition; 2, function_name:get; 3, parameters; 4, block; 5, identifier:self; 6, identifier:slug; 7, expression_statement; 8, expression_statement; 9, comment:# check if is accessible from api; 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, return_statement; 22, comment:"""Get KnwKB.
  
          Url parameters:
              - from: filter "mappings from"
              - to: filter "mappings to"
              - page
              - per_page
              - match_type: s=substring, e=exact, sw=startswith
              - sortby: 'from' or 'to'
          """; 23, assignment; 24, call; 25, assignment; 26, call; 27, call; 28, call; 29, call; 30, call; 31, call; 32, assignment; 33, assignment; 34, assignment; 35, identifier:kb_dict; 36, identifier:kb; 37, call; 38, identifier:check_knowledge_access; 39, argument_list; 40, identifier:parser; 41, call; 42, attribute; 43, argument_list; 44, attribute; 45, argument_list; 46, attribute; 47, argument_list; 48, attribute; 49, argument_list; 50, attribute; 51, argument_list; 52, attribute; 53, argument_list; 54, identifier:args; 55, call; 56, identifier:kb_dict; 57, call; 58, subscript; 59, call; 60, attribute; 61, argument_list; 62, identifier:kb; 63, attribute; 64, argument_list; 65, identifier:parser; 66, identifier:add_argument; 67, string; 68, keyword_argument; 69, keyword_argument; 70, identifier:parser; 71, identifier:add_argument; 72, string; 73, keyword_argument; 74, keyword_argument; 75, identifier:parser; 76, identifier:add_argument; 77, string; 78, keyword_argument; 79, keyword_argument; 80, identifier:parser; 81, identifier:add_argument; 82, string; 83, keyword_argument; 84, keyword_argument; 85, identifier:parser; 86, identifier:add_argument; 87, string; 88, keyword_argument; 89, keyword_argument; 90, identifier:parser; 91, identifier:add_argument; 92, string; 93, keyword_argument; 94, keyword_argument; 95, attribute; 96, argument_list; 97, attribute; 98, argument_list; 99, identifier:kb_dict; 100, string; 101, attribute; 102, argument_list; 103, identifier:api; 104, identifier:get_kb_by_slug; 105, identifier:slug; 106, identifier:reqparse; 107, identifier:RequestParser; 108, string_content:from; 109, identifier:type; 110, identifier:str; 111, identifier:help; 112, string:"Return only entries where key matches this."; 113, string_content:to; 114, identifier:type; 115, identifier:str; 116, identifier:help; 117, string:"Return only entries where value matches this."; 118, string_content:page; 119, identifier:type; 120, identifier:int; 121, identifier:help; 122, string:"Require a specific page"; 123, string_content:per_page; 124, identifier:type; 125, identifier:int; 126, identifier:help; 127, string:"Set how much result per page"; 128, string_content:match_type; 129, identifier:type; 130, identifier:str; 131, identifier:help; 132, string:"s=substring, e=exact, sw=startswith"; 133, string_content:sortby; 134, identifier:type; 135, identifier:str; 136, identifier:help; 137, string:"the sorting criteria ('from' or 'to')"; 138, identifier:parser; 139, identifier:parse_args; 140, identifier:kb; 141, identifier:to_dict; 142, string_content:mappings; 143, identifier:KnwKBMappingsResource; 144, line_continuation:\; 145, identifier:search_mappings; 146, keyword_argument; 147, keyword_argument; 148, keyword_argument; 149, keyword_argument; 150, keyword_argument; 151, keyword_argument; 152, keyword_argument; 153, identifier:kb; 154, identifier:kb; 155, identifier:key; 156, subscript; 157, identifier:value; 158, subscript; 159, identifier:match_type; 160, subscript; 161, identifier:sortby; 162, subscript; 163, identifier:page; 164, subscript; 165, identifier:per_page; 166, subscript; 167, identifier:args; 168, string; 169, identifier:args; 170, string; 171, identifier:args; 172, string; 173, identifier:args; 174, string; 175, identifier:args; 176, string; 177, identifier:args; 178, string; 179, string_content:from; 180, string_content:to; 181, string_content:match_type; 182, string_content:sortby; 183, string_content:page; 184, string_content:per_page
code: def get(self, slug):
          """Get KnwKB.
  
          Url parameters:
              - from: filter "mappings from"
              - to: filter "mappings to"
              - page
              - per_page
              - match_type: s=substring, e=exact, sw=startswith
              - sortby: 'from' or 'to'
          """
          kb = api.get_kb_by_slug(slug)
  
          # check if is accessible from api
          check_knowledge_access(kb)
  
          parser = reqparse.RequestParser()
          parser.add_argument(
              'from', type=str,
              help="Return only entries where key matches this.")
          parser.add_argument(
              'to', type=str,
              help="Return only entries where value matches this.")
          parser.add_argument('page', type=int,
                              help="Require a specific page")
          parser.add_argument('per_page', type=int,
                              help="Set how much result per page")
          parser.add_argument('match_type', type=str,
                              help="s=substring, e=exact, sw=startswith")
          parser.add_argument('sortby', type=str,
                              help="the sorting criteria ('from' or 'to')")
          args = parser.parse_args()
          kb_dict = kb.to_dict()
          kb_dict['mappings'] = KnwKBMappingsResource \
              .search_mappings(kb=kb, key=args['from'], value=args['to'],
                               match_type=args['match_type'],
                               sortby=args['sortby'], page=args['page'],
                               per_page=args['per_page'])
          return kb_dict