<gh_stars>0
import sys
import os
import subprocess
from codegen import *
from utilities import add_arguments, ArgSpec


info_prog = sys.argv[1]
initial_conditions = subprocess.check_output([info_prog, "incoming"]).strip()
initial_conditions = initial_conditions.split("\n")

target_path = os.path.join("branchedflowsim", "incoming")
if not os.path.exists(target_path):
    os.makedirs(target_path)

disclaimer = '''"""
This file was automatically generated by `incoming_codegen.py`. Do not edit manually!
"""
'''

for incoming in initial_conditions:
    target_file = open(os.path.join(target_path, incoming + ".py"), "w")  # type: file
    data = subprocess.check_output([info_prog, "incoming", "args", incoming])
    description = subprocess.check_output([info_prog, "incoming", "doc", incoming]).strip()
    result = eval(data)  # type: list[ArgSpec]

    obs_class = Class(incoming.title().replace("_", ""), "Incoming")
    obs_class.add_code("_ARGUMENTS_ = %s" % data)
    obs_class.add_code("_NAME_ = '%s'" % incoming)

    init = Function("__init__")
    obs_class.add_method(init)
    obs_class.docstring = description

    init.add_argument("self")
    add_arguments(result, obs_class, init)

    target_file.write(disclaimer)
    target_file.write("from ..cmdline_helpers import ArgSpec\n")
    target_file.write("from .incoming import Incoming\n\n\n")
    target_file.write(str(obs_class))
    target_file.close()


__init__file = open(os.path.join(target_path, "__init__.py"), "w")



for incoming in initial_conditions:
    __init__file.write("from .{} import {}\n".format(incoming, incoming.title().replace("_", "")))

import sys
import os
import subprocess
from codegen import *
from utilities import add_arguments, ArgSpec


info_prog = sys.argv[1]
initial_conditions = subprocess.check_output([info_prog, "incoming"]).strip()
initial_conditions = initial_conditions.split("\n")

target_path = os.path.join("branchedflowsim", "incoming")
if not os.path.exists(target_path):
    os.makedirs(target_path)

disclaimer = '''"""
This file was automatically generated by `incoming_codegen.py`. Do not edit manually!
"""
'''

for incoming in initial_conditions:
    target_file = open(os.path.join(target_path, incoming + ".py"), "w")  # type: file
    data = subprocess.check_output([info_prog, "incoming", "args", incoming])
    description = subprocess.check_output([info_prog, "incoming", "doc", incoming]).strip()
    result = eval(data)  # type: list[ArgSpec]

    obs_class = Class(incoming.title().replace("_", ""), "Incoming")
    obs_class.add_code("_ARGUMENTS_ = %s" % data)
    obs_class.add_code("_NAME_ = '%s'" % incoming)

    init = Function("__init__")
    obs_class.add_method(init)
    obs_class.docstring = description

    init.add_argument("self")
    add_arguments(result, obs_class, init)

    target_file.write(disclaimer)
    target_file.write("from ..cmdline_helpers import ArgSpec\n")
    target_file.write("from .incoming import Incoming\n\n\n")
    target_file.write(str(obs_class))
    target_file.close()


__init__file = open(os.path.join(target_path, "__init__.py"), "w")



for incoming in initial_conditions:
    __init__file.write("from .{} import {}\n".format(incoming, incoming.title().replace("_", "")))
""" This file was automatically generated by `incoming_codegen.py`. Do not edit manually! """ # type: file # type: list[ArgSpec]