<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from . . vendor import click <EOL> from . . util import get_result <EOL> from . import callbacks , types <EOL> DISPLAY_FIELDS = ( <EOL> ( '<STR_LIT:id>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:state>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> @ click . group ( ) <EOL> @ click . pass_context <EOL> def cli ( ctx ) : <EOL> """<STR_LIT>""" <EOL> @ cli . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> multiple = True , <EOL> callback = callbacks . transform_attributes , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> type = click . File ( '<STR_LIT:rb>' ) , <EOL> callback = callbacks . process_bulk_add , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT:-c>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> callback = callbacks . process_site_id , <EOL> ) <EOL> @ click . pass_context <EOL> def add ( ctx , attributes , bulk_add , cidr , state , site_id ) : <EOL> """<STR_LIT>""" <EOL> data = bulk_add or ctx . params <EOL> if bulk_add is None : <EOL> if cidr is None : <EOL> raise click . UsageError ( '<STR_LIT>' ) <EOL> if state is None : <EOL> data . pop ( '<STR_LIT:state>' , None ) <EOL> ctx . obj . add ( data ) <EOL> @ cli . group ( invoke_without_command = True ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> multiple = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT:-c>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = True , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = True , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = click . Choice ( [ '<STR_LIT:4>' , '<STR_LIT>' ] ) , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> callback = callbacks . process_site_id , <EOL> ) <EOL> @ click . pass_context <EOL> def list ( ctx , attributes , cidr , delimited , grep , id , include_ips , <EOL> include_networks , ip_version , limit , network_address , natural_key , <EOL> offset , prefix_length , query , root_only , state , site_id ) : <EOL> """<STR_LIT>""" <EOL> data = ctx . params <EOL> data . pop ( '<STR_LIT>' ) <EOL> if ctx . invoked_subcommand is None : <EOL> if query is not None : <EOL> results = ctx . obj . set_query ( data ) <EOL> networks = get_result ( results ) <EOL> networks = sorted ( <EOL> ( d [ '<STR_LIT>' ] , d [ '<STR_LIT>' ] ) for d in networks <EOL> ) <EOL> networks = [ '<STR_LIT>' % obj for obj in networks ] <EOL> joiner = '<STR_LIT:U+002C>' if delimited else '<STR_LIT:\n>' <EOL> click . echo ( joiner . join ( networks ) ) <EOL> else : <EOL> ctx . obj . list ( data , display_fields = DISPLAY_FIELDS ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . pass_context <EOL> def subnets ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . pass_context <EOL> def supernets ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def parent ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . pass_context <EOL> def ancestors ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def children ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def descendents ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def root ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> default = False , <EOL> show_default = True , <EOL> ) <EOL> @ click . pass_context <EOL> def siblings ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( <EOL> short_help = '<STR_LIT>' <EOL> ) <EOL> @ click . pass_context <EOL> def closest_parent ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> data = ctx . parent . params <EOL> obj_id = data . get ( '<STR_LIT:id>' ) <EOL> cidr = data . get ( '<STR_LIT>' ) <EOL> if obj_id is not None or cidr is None : <EOL> raise click . UsageError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> data [ '<STR_LIT:id>' ] = data [ '<STR_LIT>' ] <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> ASSIGNMENT_FIELDS = ( <EOL> ( '<STR_LIT:id>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def assignments ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = ASSIGNMENT_FIELDS , grep_name = '<STR_LIT>' <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . pass_context <EOL> def reserved ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> data = ctx . parent . params <EOL> data [ '<STR_LIT:id>' ] = <NUM_LIT:1> <EOL> callbacks . list_subcommand ( <EOL> ctx , display_fields = DISPLAY_FIELDS , grep_name = '<STR_LIT>' , <EOL> with_parent = False <EOL> ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> @ click . pass_context <EOL> def next_network ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> results = callbacks . list_subcommand ( ctx , return_results = True ) <EOL> click . echo ( '<STR_LIT:\n>' . join ( results ) ) <EOL> @ list . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> @ click . pass_context <EOL> def next_address ( ctx , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> results = callbacks . list_subcommand ( ctx , return_results = True ) <EOL> click . echo ( '<STR_LIT:\n>' . join ( results ) ) <EOL> @ cli . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT:-c>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = types . NETWORK_ID , <EOL> help = '<STR_LIT>' , <EOL> required = True , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> callback = callbacks . process_site_id , <EOL> ) <EOL> @ click . pass_context <EOL> def remove ( ctx , id , site_id ) : <EOL> """<STR_LIT>""" <EOL> data = ctx . params <EOL> ctx . obj . remove ( ** data ) <EOL> @ cli . command ( ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> multiple = True , <EOL> callback = callbacks . transform_attributes , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT:-c>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> callback = callbacks . process_site_id , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> flag_value = '<STR_LIT>' , <EOL> default = True , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> flag_value = '<STR_LIT>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> flag_value = '<STR_LIT:replace>' , <EOL> help = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> ) <EOL> @ click . option ( <EOL> '<STR_LIT>' , <EOL> is_flag = True , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> @ click . pass_context <EOL> def update ( ctx , attributes , cidr , id , state , site_id , attr_action , multi ) : <EOL> """<STR_LIT>""" <EOL> if not any ( [ attributes , state ] ) : <EOL> msg = '<STR_LIT>' <EOL> raise click . UsageError ( msg ) <EOL> if not id and not cidr : <EOL> raise click . UsageError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> data = ctx . params <EOL> ctx . obj . update ( data ) </s>
