Example #1
0
def output_lib(name):

    # Case insensitive to reduce mistakes
    for lib in output_libs:
        if name.lower() == lib.lower():
            return output_libs[lib]

    output_libs[name] = schlib.SchLib(os.path.join(dst_dir, name + '.lib'), create=real_mode)

    if not args.silent:
        print("Creating new library - '{n}'".format(n=name))

    return output_libs[name]
archive_files = []

# Iterate through each provided library
for lib_file in src_libs:
    lib_name = ''.join(os.path.basename(lib_file).split('.lib')[:-1])

    lib_path = os.path.dirname(lib_file)

    dcm_file = os.path.join(lib_path, lib_name + '.dcm')

    if args.verbose > 0:
        print("Encoding library '{l}'".format(l=lib_name))

    try:
        library = schlib.SchLib(lib_file)
    except:
        #TODO - Error message!
        continue

    if args.download:
        # Create an archive of this library...
        files = [lib_file, dcm_file]

        archive_dir = os.path.abspath(os.path.join(args.download, 'symbols'))

        if not os.path.exists(archive_dir):
            os.makedirs(archive_dir)

        archive_file = lib_name + '.7z'
import sch

logger = logging.getLogger('test')
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

paths = [
    "/home/jlewallen/conservify/kicad/conservify.lib",
    "/home/jlewallen/fieldkit/core/hardware/fk-core-cache.lib",
]

found = {}

merged = schlib.SchLib("conservify-new.lib", True)

for path in paths:
    lib = schlib.SchLib(path)
    logger.info(path)
    for c in lib.components:
        clean = c.name.replace("~", "")
        if clean not in found:
            found[clean] = c
            merged.components.append(c)

merged.save()

fps = {}
paths = [
    "/home/jlewallen/fieldkit/core/hardware/fk-core.sch"
Example #4
0
# Find the source libraries
src_libs = []
for lib in args.libs:
    src_libs += glob.glob(lib)

# Output libraries
output_libs = {}

# Find any libraries in the output directory
if os.path.exists(args.dest) and os.path.isdir(args.dest):
    op_libs = [x for x in os.listdir(args.dest) if x.endswith('.lib')]

    for op_lib in op_libs:
        lib_name = op_lib.split(os.path.sep)[-1].replace('.lib', '')
        lib = schlib.SchLib(op_lib)

        output_libs[lib_name] = lib
        print("Found existing library - '{l}'".format(l=lib_name))

allocated_symbols = 0
unallocated_symbols = []
overallocated_symbols = []

def output_lib(name):

    # Case insensitive to reduce mistakes
    for lib in output_libs:
        if name.lower() == lib.lower():
            return output_libs[lib]
Example #5
0
import argparse
import os
import sys
import logging
import shutil
import schlib
import sch

logger = logging.getLogger('test')
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

lib = schlib.SchLib("/home/jlewallen/conservify/kicad/conservify.lib")
for c in lib.components:
    clean = c.name.replace("~", "")
    print clean

map = {
    'fk-naturalist-rescue:R': 'conservify:R',
    'fk-naturalist-rescue:CAPACITOR-CERAMIC': 'conservify:CAPACITOR_CERAMIC',
    'fk-naturalist-rescue:C': 'conservify:CAPACITOR_CERAMIC',
    'fk-naturalist-rescue:LED-SINGLE': 'conservify:LED_SINGLE',
    'fk-naturalist-rescue:MICRO-USB': 'conservify:MICRO_USB',
    'fk-naturalist-rescue:+3V3': 'conservify:3V3',
    'fk-naturalist-rescue:Conn_01x06': 'conservify:CONN_01x06',
    'fk-naturalist-rescue:Conn_01x05': 'conservify:CONN_01x05',
    'fk-naturalist-rescue:Conn_01x02': 'conservify:CONN_01x02',
    'fk-naturalist-rescue:Conn_01x04': 'conservify:CONN_01x04',