# Path: scrypture/webapi.py
# class WebAPI(flask_wtf.Form):
# class PassHTTPAuthorizationHeader(requests.auth.AuthBase):
# def text_input(*args, **kwargs):
# def list_input(*args, **kwargs):
# def line_input(*args, **kwargs):
# def password_input(*args, **kwargs):
# def radio_field(*args, **kwargs):
# def submit_button(*args, **kwargs):
# def multiple_input(*args, **kwargs):
# def checkbox_field(*args, **kwargs):
# def file_field(*args, **kwargs):
#     def __init__(self, header):
#     def __call__(self, r):


import argparse
import sys
import re
import netaddr
from scrypture import webapi
#!/usr/bin/env python
# module_template.py
"""
Print out every IP from a list of subnets in CIDR notation
"""


def get_ips_from_cidr_subnets(ip_subnets):
    ipnets = [netaddr.IPNetwork(ip) for ip in ip_subnets]
    return [str(ip) for ipnet in ipnets
                    for ip in ipnet]


### CLI ###
def main():
    """"This main function implements the CLI"""
    parser = argparse.ArgumentParser(description='Do something awesome')
    parser.add_argument('input_list', nargs='+',
                        type=str, default=sys.stdin)
    parser.add_argument('-o', '--outfile', nargs='?',
                        type=argparse.FileType('w'), default=sys.stdout)
    args = parser.parse_args()

    input_list = args.input_list
    print '\n'.join(get_ips_from_cidr_subnets(input_list))

if __name__ == '__main__':
    main()

### WebAPI ###

# Path: scrypture/webapi.py
# class WebAPI(flask_wtf.Form):
# class PassHTTPAuthorizationHeader(requests.auth.AuthBase):
# def text_input(*args, **kwargs):
# def list_input(*args, **kwargs):
# def line_input(*args, **kwargs):
# def password_input(*args, **kwargs):
# def radio_field(*args, **kwargs):
# def submit_button(*args, **kwargs):
# def multiple_input(*args, **kwargs):
# def checkbox_field(*args, **kwargs):
# def file_field(*args, **kwargs):
#     def __init__(self, header):
#     def __call__(self, r):


# Path: scrypture/demo_scripts/Network/enumerate_ips.py
import argparse
import sys
import re
import netaddr
from scrypture import webapi

#!/usr/bin/env python
# module_template.py
"""
Print out every IP from a list of subnets in CIDR notation
"""


def get_ips_from_cidr_subnets(ip_subnets):
    ipnets = [netaddr.IPNetwork(ip) for ip in ip_subnets]
    return [str(ip) for ipnet in ipnets
                    for ip in ipnet]


### CLI ###
def main():
    """"This main function implements the CLI"""
    parser = argparse.ArgumentParser(description='Do something awesome')
    parser.add_argument('input_list', nargs='+',
                        type=str, default=sys.stdin)
    parser.add_argument('-o', '--outfile', nargs='?',
                        type=argparse.FileType('w'), default=sys.stdout)
    args = parser.parse_args()

    input_list = args.input_list
    print '\n'.join(get_ips_from_cidr_subnets(input_list))

if __name__ == '__main__':
    main()

### WebAPI ###

class WebAPI(webapi.WebAPI):