query: Move 'ident' command to a function
This commit is contained in:
parent
64efb3d678
commit
2440d49731
3 changed files with 12 additions and 11 deletions
|
|
@ -46,7 +46,7 @@ class ApiIdentGetterResource:
|
|||
if version == 'latest':
|
||||
version = query.get_latest_tag()
|
||||
|
||||
symbol_definitions, symbol_references, symbol_doccomments = query.query('ident', version, ident, family)
|
||||
symbol_definitions, symbol_references, symbol_doccomments = query.search_ident(version, ident, family)
|
||||
|
||||
resp.status = falcon.HTTP_200
|
||||
resp.content_type = falcon.MEDIA_JSON
|
||||
|
|
|
|||
|
|
@ -238,22 +238,23 @@ class Query:
|
|||
return []
|
||||
|
||||
elif cmd == 'ident':
|
||||
|
||||
# Returns identifier search results
|
||||
|
||||
version = args[0]
|
||||
ident = args[1]
|
||||
family = args[2]
|
||||
|
||||
return self.search_ident(version, ident, family)
|
||||
|
||||
else:
|
||||
return 'Unknown subcommand: ' + cmd + '\n'
|
||||
|
||||
# Returns identifier search results
|
||||
def search_ident(self, version, ident, family):
|
||||
# DT bindings compatible strings are handled differently
|
||||
if family == 'B':
|
||||
return self.get_idents_comps(version, ident)
|
||||
else:
|
||||
return self.get_idents_defs(version, ident, family)
|
||||
|
||||
else:
|
||||
return 'Unknown subcommand: ' + cmd + '\n'
|
||||
|
||||
# Returns the latest tag that is included in the database.
|
||||
# This excludes release candidates.
|
||||
def get_latest_tag(self):
|
||||
|
|
@ -405,7 +406,7 @@ class Query:
|
|||
|
||||
|
||||
def cmd_ident(q, version, ident, family, **kwargs):
|
||||
symbol_definitions, symbol_references, symbol_doccomments = q.query("ident", version, ident, family)
|
||||
symbol_definitions, symbol_references, symbol_doccomments = q.search_ident(version, ident, family)
|
||||
print("Symbol Definitions:")
|
||||
for symbol_definition in symbol_definitions:
|
||||
print(symbol_definition)
|
||||
|
|
|
|||
|
|
@ -687,7 +687,7 @@ def generate_ident_page(ctx: RequestContext, q: Query,
|
|||
|
||||
status = falcon.HTTP_OK
|
||||
source_base_url = get_source_base_url(project, version)
|
||||
symbol_definitions, symbol_references, symbol_doccomments = q.query('ident', version, ident, family)
|
||||
symbol_definitions, symbol_references, symbol_doccomments = q.search_ident(version, ident, family)
|
||||
symbol_sections = []
|
||||
|
||||
if len(symbol_definitions) or len(symbol_references):
|
||||
|
|
|
|||
Loading…
Reference in a new issue