# Path: eppy/useful_scripts/loopdiagram.py
# 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
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def dropnodes(edges):
#     """draw a graph without the nodes"""
#     newedges = []
#     added = False
#     for edge in edges:
#         if bothnodes(edge):
#             newtup = (edge[0][0], edge[1][0])
#             newedges.append(newtup)
#             added = True
#         elif firstisnode(edge):
#             for edge1 in edges:
#                 if edge[0] == edge1[1]:
#                     newtup = (edge1[0], edge[1])
#                     try:
#                         newedges.index(newtup)
#                     except ValueError as e:
#                         newedges.append(newtup)
#                     added = True
#         elif secondisnode(edge):
#             for edge1 in edges:
#                 if edge[1] == edge1[0]:
#                     newtup = (edge[0], edge1[1])
#                     try:
#                         newedges.index(newtup)
#                     except ValueError as e:
#                         newedges.append(newtup)
#                     added = True
#         # gets the hanging nodes - nodes with no connection
#         if not added:
#             if firstisnode(edge):
#                 newedges.append((edge[0][0], edge[1]))
#             if secondisnode(edge):
#                 newedges.append((edge[0], edge[1][0]))
#         added = False
#     return newedges
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def edges2nodes(edges):
#     """gather the nodes from the edges"""
#     nodes = []
#     for e1, e2 in edges:
#         nodes.append(e1)
#         nodes.append(e2)
#     nodedict = dict([(n, None) for n in nodes])
#     justnodes = list(nodedict.keys())
#     # justnodes.sort()
#     justnodes = sorted(justnodes, key=lambda x: str(x[0]))
#     return justnodes
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def process_idf(fname, iddfile):
#     data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)
#     print("constructing the loops")
#     edges = makeairplantloop(data, commdct)
#     print("cleaning edges")
#     edges = clean_edges(edges)
#     print("making the diagram")
# 
#     return makediagram(edges)
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def replace_colon(s, replacewith="__"):
#     """replace the colon with something"""
#     return s.replace(":", replacewith)
# 
# Path: eppy/pytest_helpers.py
# def do_integration_tests():
#     """
#     Check whether the 'EPPY_INTEGRATION' environment variable has been set to do
#     integration tests.
# 
#     Returns
#     -------
#     bool
# 
#     """
#     return os.getenv("EPPY_INTEGRATION", False)


import os
import pytest
from eppy.useful_scripts.loopdiagram import clean_edges
from eppy.useful_scripts.loopdiagram import dropnodes
from eppy.useful_scripts.loopdiagram import edges2nodes
from eppy.useful_scripts.loopdiagram import process_idf
from eppy.useful_scripts.loopdiagram import replace_colon
from eppy.pytest_helpers import do_integration_tests
    edges = [(a, b), (b, c), (c, d), (d, e), (e, f), (f, g), (g, h), (h, i)]
    theresult = [("a", "b"), ("b", "d"), ("d", "f"), ("f", "h"), ("h", "i")]
    result = dropnodes(edges)
    assert result == theresult
    # test 2
    (a, b, c, d, e, f, g, h, i, j) = (
        ("a", node),
        "b",
        ("c", node),
        ("d", node),
        "e",
        "f",
        ("g", node),
        ("h", node),
        "i",
        ("j", node),
    )
    edges = [
        (a, b),
        (b, c),
        (c, e),
        (e, g),
        (g, i),
        (i, j),
        (b, d),
        (d, f),
        (f, h),
        (h, i),
    ]
    theresult = [("a", "b"), ("b", "e"), ("e", "i"), ("i", "j"), ("b", "f"), ("f", "i")]

# Path: eppy/useful_scripts/loopdiagram.py
# 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
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def dropnodes(edges):
#     """draw a graph without the nodes"""
#     newedges = []
#     added = False
#     for edge in edges:
#         if bothnodes(edge):
#             newtup = (edge[0][0], edge[1][0])
#             newedges.append(newtup)
#             added = True
#         elif firstisnode(edge):
#             for edge1 in edges:
#                 if edge[0] == edge1[1]:
#                     newtup = (edge1[0], edge[1])
#                     try:
#                         newedges.index(newtup)
#                     except ValueError as e:
#                         newedges.append(newtup)
#                     added = True
#         elif secondisnode(edge):
#             for edge1 in edges:
#                 if edge[1] == edge1[0]:
#                     newtup = (edge[0], edge1[1])
#                     try:
#                         newedges.index(newtup)
#                     except ValueError as e:
#                         newedges.append(newtup)
#                     added = True
#         # gets the hanging nodes - nodes with no connection
#         if not added:
#             if firstisnode(edge):
#                 newedges.append((edge[0][0], edge[1]))
#             if secondisnode(edge):
#                 newedges.append((edge[0], edge[1][0]))
#         added = False
#     return newedges
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def edges2nodes(edges):
#     """gather the nodes from the edges"""
#     nodes = []
#     for e1, e2 in edges:
#         nodes.append(e1)
#         nodes.append(e2)
#     nodedict = dict([(n, None) for n in nodes])
#     justnodes = list(nodedict.keys())
#     # justnodes.sort()
#     justnodes = sorted(justnodes, key=lambda x: str(x[0]))
#     return justnodes
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def process_idf(fname, iddfile):
#     data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)
#     print("constructing the loops")
#     edges = makeairplantloop(data, commdct)
#     print("cleaning edges")
#     edges = clean_edges(edges)
#     print("making the diagram")
# 
#     return makediagram(edges)
# 
# Path: eppy/useful_scripts/loopdiagram.py
# def replace_colon(s, replacewith="__"):
#     """replace the colon with something"""
#     return s.replace(":", replacewith)
# 
# Path: eppy/pytest_helpers.py
# def do_integration_tests():
#     """
#     Check whether the 'EPPY_INTEGRATION' environment variable has been set to do
#     integration tests.
# 
#     Returns
#     -------
#     bool
# 
#     """
#     return os.getenv("EPPY_INTEGRATION", False)


# Path: tests/test_loopdiagram.py
import os
import pytest
from eppy.useful_scripts.loopdiagram import clean_edges
from eppy.useful_scripts.loopdiagram import dropnodes
from eppy.useful_scripts.loopdiagram import edges2nodes
from eppy.useful_scripts.loopdiagram import process_idf
from eppy.useful_scripts.loopdiagram import replace_colon
from eppy.pytest_helpers import do_integration_tests

    edges = [(a, b), (b, c), (c, d), (d, e), (e, f), (f, g), (g, h), (h, i)]
    theresult = [("a", "b"), ("b", "d"), ("d", "f"), ("f", "h"), ("h", "i")]
    result = dropnodes(edges)
    assert result == theresult
    # test 2
    (a, b, c, d, e, f, g, h, i, j) = (
        ("a", node),
        "b",
        ("c", node),
        ("d", node),
        "e",
        "f",
        ("g", node),
        ("h", node),
        "i",
        ("j", node),
    )
    edges = [
        (a, b),
        (b, c),
        (c, e),
        (e, g),
        (g, i),
        (i, j),
        (b, d),
        (d, f),
        (f, h),
        (h, i),
    ]
    theresult = [("a", "b"), ("b", "e"), ("e", "i"), ("i", "j"), ("b", "f"), ("f", "i")]

    result = dropnodes(edges)