# Path: eppy/EPlusInterfaceFunctions/readidf.py
# def readidf(idfname):
#     """read the idf file"""
#     # iddfile = sys.path[0] + '/EplusCode/Energy+.idd'
#     iddfile = "Energy+.idd"
#     # iddfile = './EPlusInterfaceFunctions/E1.idd' # TODO : can the path name be not hard coded
#     iddtxt = open(iddfile, "r").read()
#     block, commlst, commdct = parse_idd.extractidddata(iddfile)
# 
#     theidd = eplusdata.Idd(block, 2)
#     data = eplusdata.Eplusdata(theidd, idfname)
#     return data


import os
import sys
import argparse
import eppy
import eppy.EPlusInterfaceFunctions
import pydot
import eppy.loops as loops
from eppy.EPlusInterfaceFunctions import readidf
    return edges


def getedges(fname, iddfile):
    """return the edges of the idf file fname"""
    data, commdct, _idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
    edges = makeairplantloop(data, commdct)
    return edges


def replace_colon(s, replacewith="__"):
    """replace the colon with something"""
    return s.replace(":", replacewith)


def clean_edges(arg):
    if isinstance(arg, str):
        return replace_colon(arg)
    try:
        return tuple(clean_edges(x) for x in arg)
    except TypeError:  # catch when for loop fails
        return replace_colon(arg)  # not a sequence so just return repr


def make_and_save_diagram(fname, iddfile):
    g = process_idf(fname, iddfile)
    save_diagram(fname, g)


def process_idf(fname, iddfile):

# Path: eppy/EPlusInterfaceFunctions/readidf.py
# def readidf(idfname):
#     """read the idf file"""
#     # iddfile = sys.path[0] + '/EplusCode/Energy+.idd'
#     iddfile = "Energy+.idd"
#     # iddfile = './EPlusInterfaceFunctions/E1.idd' # TODO : can the path name be not hard coded
#     iddtxt = open(iddfile, "r").read()
#     block, commlst, commdct = parse_idd.extractidddata(iddfile)
# 
#     theidd = eplusdata.Idd(block, 2)
#     data = eplusdata.Eplusdata(theidd, idfname)
#     return data


# Path: eppy/useful_scripts/loopdiagram.py
import os
import sys
import argparse
import eppy
import eppy.EPlusInterfaceFunctions
import pydot
import eppy.loops as loops
from eppy.EPlusInterfaceFunctions import readidf

    return edges


def getedges(fname, iddfile):
    """return the edges of the idf file fname"""
    data, commdct, _idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
    edges = makeairplantloop(data, commdct)
    return edges


def replace_colon(s, replacewith="__"):
    """replace the colon with something"""
    return s.replace(":", replacewith)


def clean_edges(arg):
    if isinstance(arg, str):
        return replace_colon(arg)
    try:
        return tuple(clean_edges(x) for x in arg)
    except TypeError:  # catch when for loop fails
        return replace_colon(arg)  # not a sequence so just return repr


def make_and_save_diagram(fname, iddfile):
    g = process_idf(fname, iddfile)
    save_diagram(fname, g)


def process_idf(fname, iddfile):

    data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)