From: Michael Tremer Date: Thu, 1 Feb 2018 14:18:15 +0000 (+0000) Subject: location-query: Implement searching for an AS that matches a string X-Git-Tag: 0.9.0~70 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=da3e360e369c735bd5d09f8dd8f4545de15ceea7;ds=sidebyside location-query: Implement searching for an AS that matches a string Signed-off-by: Michael Tremer --- diff --git a/src/python/location-query.in b/src/python/location-query.in index 933024e..1f1d42a 100644 --- a/src/python/location-query.in +++ b/src/python/location-query.in @@ -65,6 +65,13 @@ class CLI(object): get_as.add_argument("asn", nargs="+") get_as.set_defaults(func=self.handle_get_as) + # Search for AS + search_as = subparsers.add_parser("search-as", + help=_("Search for Autonomous Systems that match the string"), + ) + search_as.add_argument("query", nargs=1) + search_as.set_defaults(func=self.handle_search_as) + return parser.parse_args() def run(self): @@ -148,6 +155,12 @@ class CLI(object): return ret + def handle_search_as(self, ns): + for query in ns.query: + # Print all matches ASes + for a in self.db.search_as(query): + print(a) + def main(): # Run the command line interface c = CLI()