<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import argparse <EOL> import sys <EOL> import re <EOL> def nmap_to_csv ( nmap_output ) : <EOL> entries = re . split ( '<STR_LIT>' , nmap_output ) <EOL> csv_out = '<STR_LIT>' <EOL> for entry in entries [ <NUM_LIT:1> : ] : <EOL> entry_lines = entry . splitlines ( ) <EOL> ip_in_parens = re . findall ( '<STR_LIT>' , entry_lines [ <NUM_LIT:0> ] ) <EOL> if len ( ip_in_parens ) > <NUM_LIT:0> : <EOL> csv_out += ip_in_parens [ <NUM_LIT:0> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> csv_out += '<STR_LIT:U+002C>' <EOL> csv_out += entry_lines [ <NUM_LIT:0> ] <EOL> else : <EOL> csv_out += entry_lines [ <NUM_LIT:0> ] <EOL> csv_out += '<STR_LIT:U+002C>' <EOL> csv_out += '<STR_LIT>' <EOL> csv_out += '<STR_LIT:\n>' . join ( entry_lines [ <NUM_LIT:1> : ] ) <EOL> csv_out += '<STR_LIT>' <EOL> return csv_out <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = <NUM_LIT:1> , type = argparse . FileType ( '<STR_LIT:r>' ) , default = sys . stdin ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , nargs = <NUM_LIT:1> , type = argparse . FileType ( '<STR_LIT:w>' ) , default = sys . stdout ) <EOL> args = parser . parse_args ( ) <EOL> print ( nmap_to_csv ( args . nmap_input [ <NUM_LIT:0> ] . read ( ) ) , file = args . outfile ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) <EOL> from scrypture import webapi <EOL> class WebAPI ( webapi . WebAPI ) : <EOL> nmap_output = webapi . text_input ( '<STR_LIT>' ) <EOL> submit_button = webapi . submit_button ( '<STR_LIT>' ) <EOL> def run ( self , form_input ) : <EOL> nmap_output = form_input [ '<STR_LIT>' ] <EOL> output = nmap_to_csv ( nmap_output ) <EOL> return { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : output } </s>
