# Path: inter/inter.py
# def cleanup_js(inter):
#   def _remove_constructor(item):
# def add_names(inter):
#   def generate_ints():
#   def _c(x):
# def get_meta(inter):
# def prepare_for_display(inter, filter_out):
#   def _sort(x1, x2):
#   def convert(x):
# def bounding_box(inter):
#   def oget(m, k, d):
#   def fget(m, k, d = 0.0):
#   def circle(shape):
#   def disc(shape):
#   def label(shape):
#   def vertex(shape):
#   def polygon(shape):
#   def octagon(shape):
#   def rect(shape):
#   def unknown(shape):
# def size(inter):
# def sort_by_type(inter):
#   def _sort(x1, x2):
# def _count_num_values(pads, param):
# def _equidistant(pads, direction):
# def _all_equal(pads, direction):
# def _sort_by_field(pads, field, reverse=False):
#   def _sort_by(a, b):
# def _clone_pad(pad_in, remove):
# def _make_mods(skip, pad, pads):
# def _check_single(orig_pads, horizontal):
# def _split_dual(pads, direction):
# def _one_by_one_equal(r1, r2, direction):
# def _check_dual_alt(r1, r2):
# def _check_dual(orig_pads, horizontal):
# def _split_quad(pads):
# def _check_quad(orig_pads):
# def _check_sequential(pads):
# def _find_pad_patterns(pads):
# def find_pad_patterns(inter):
# def import_footprint(importer, footprint_name):


from nose.tools import *
from functools import partial
from bs4 import BeautifulSoup
from inter import inter
import copy, shutil, os, time
import coffee.pycoffee as pycoffee
import coffee.generatesimple as generatesimple
import export.eagle
import export.kicad
import export.kicad_old
    importer = export.eagle.Import(eagle_lib)
    # trick to get our package xml into the empty eagle library
    package_soup = BeautifulSoup(eagle_package_xml, 'xml')
    package_soup.is_xml = False
    importer.soup.drawing.packages.append(package_soup)
    with open(eagle_lib, 'w+') as f:
      f.write(str(importer.soup))
    importer = export.eagle.Import(eagle_lib)
    interim = inter.import_footprint(importer, import_name) 
    assert interim != None
    coffee = generatesimple.generate_coffee(interim)
    # print coffee
    _assert_equal_no_meta(expected, coffee)
  finally:
    os.unlink(eagle_lib)

def _export_kicad_package(code, expected_name, expected):
  (error_txt, status_txt, interim) = pycoffee.compile_coffee(code)
  assert interim != None
  exporter = export.kicad.Export("dummy.kicad_mod")
  kicad_name = exporter.export_footprint(interim)
  assert kicad_name == expected_name
  assert_multi_line_equal(expected, exporter.get_string())

def _import_kicad_package(kicad_s, import_name, expected_coffee):
  try:
    kicad_lib = 'test/foo.kicad_mod'
    with open(kicad_lib, "w+") as f:
      f.write(kicad_s)
    importer = export.kicad.Import(kicad_lib)

# Path: inter/inter.py
# def cleanup_js(inter):
#   def _remove_constructor(item):
# def add_names(inter):
#   def generate_ints():
#   def _c(x):
# def get_meta(inter):
# def prepare_for_display(inter, filter_out):
#   def _sort(x1, x2):
#   def convert(x):
# def bounding_box(inter):
#   def oget(m, k, d):
#   def fget(m, k, d = 0.0):
#   def circle(shape):
#   def disc(shape):
#   def label(shape):
#   def vertex(shape):
#   def polygon(shape):
#   def octagon(shape):
#   def rect(shape):
#   def unknown(shape):
# def size(inter):
# def sort_by_type(inter):
#   def _sort(x1, x2):
# def _count_num_values(pads, param):
# def _equidistant(pads, direction):
# def _all_equal(pads, direction):
# def _sort_by_field(pads, field, reverse=False):
#   def _sort_by(a, b):
# def _clone_pad(pad_in, remove):
# def _make_mods(skip, pad, pads):
# def _check_single(orig_pads, horizontal):
# def _split_dual(pads, direction):
# def _one_by_one_equal(r1, r2, direction):
# def _check_dual_alt(r1, r2):
# def _check_dual(orig_pads, horizontal):
# def _split_quad(pads):
# def _check_quad(orig_pads):
# def _check_sequential(pads):
# def _find_pad_patterns(pads):
# def find_pad_patterns(inter):
# def import_footprint(importer, footprint_name):


# Path: test/madparts_test.py
from nose.tools import *
from functools import partial
from bs4 import BeautifulSoup
from inter import inter
import copy, shutil, os, time
import coffee.pycoffee as pycoffee
import coffee.generatesimple as generatesimple
import export.eagle
import export.kicad
import export.kicad_old

    importer = export.eagle.Import(eagle_lib)
    # trick to get our package xml into the empty eagle library
    package_soup = BeautifulSoup(eagle_package_xml, 'xml')
    package_soup.is_xml = False
    importer.soup.drawing.packages.append(package_soup)
    with open(eagle_lib, 'w+') as f:
      f.write(str(importer.soup))
    importer = export.eagle.Import(eagle_lib)
    interim = inter.import_footprint(importer, import_name) 
    assert interim != None
    coffee = generatesimple.generate_coffee(interim)
    # print coffee
    _assert_equal_no_meta(expected, coffee)
  finally:
    os.unlink(eagle_lib)

def _export_kicad_package(code, expected_name, expected):
  (error_txt, status_txt, interim) = pycoffee.compile_coffee(code)
  assert interim != None
  exporter = export.kicad.Export("dummy.kicad_mod")
  kicad_name = exporter.export_footprint(interim)
  assert kicad_name == expected_name
  assert_multi_line_equal(expected, exporter.get_string())

def _import_kicad_package(kicad_s, import_name, expected_coffee):
  try:
    kicad_lib = 'test/foo.kicad_mod'
    with open(kicad_lib, "w+") as f:
      f.write(kicad_s)
    importer = export.kicad.Import(kicad_lib)

    interim = inter.import_footprint(importer, import_name) 