All pastes #586227 Raw Edit

Unnamed

public text v1 · immutable
#586227 ·published 2007-06-23 18:37 UTC
rendered paste body
proc make_cell { } {
    global cell
    global opt


    exec mkdir -p $cell(lib)/$cell(name1)

    set ext ""
    if { $cell(tools) == "xcircuit-schematic" } {
        set ext "ps"
    }
    if { $cell(tools) == "gschem-schematic" } {
        set ext "sch"
    }
    if { $cell(tools) == "magic-layout" } {
        set ext "mag"
    }
    if { $cell(tools) == "pcb-layout" } {
        set ext "pcb"
    }
    exec touch $cell(lib)/$cell(name1)/$cell(view1).$ext

    set design $cell(lib)/$cell(name1)/design.xml

    if [file isfile $design] {
        set fp   [open $design]
        set XML  [read $fp]
        close $fp

        set doc  [dom parse $XML]
        set root [$doc documentElement]
    } else {
        set doc  [dom parse "<Profiles/>"]
        exit
        set root [$doc documentElement]
        $root setAttribute version 0.1
        $root appendXML "<library name='$cell(lib)'/>"
        puts [$root asXML]
        exit
        [$root selectNodes /Profiles/library] appendXML "<cell name='$cell(name1)'/>"
    }

    set cell_name [[$root selectNodes /Profiles/library/cell] getAttribute name]

    if { $cell_name == $cell(name1) } {
        [$root selectNodes /Profiles/library/cell] \
            appendXML "<view name='$cell(view1)' toOpenWith='$cell(tools)'/>"
    } else {
        [$root selectNodes /Profiles/library] appendXML "<cell name='$cell(name1)'/>"

        set node [::WalkXML::NextNode [$root asXML]]

        while {$node ne ""} {
            if {[$node nodeType] eq "TEXT_NODE"} {
                puts "\"[$node nodeValue]\""
            } else {
                if { [$node nodeName] == "cell" } {
                    set cell_name [$node getAttribute name]
                    if { $cell_name == $cell(name1) } {
                        set rode [ [$root selectNodes /Profiles/library] child $count_cell]
                        set rode1 [ $rode nodeName ]
                        $rode appendXML "<view name='$cell(view1)' toOpenWith='$cell(tools)'/>"
                    }
                    set $count_cell [ expr [incr count_cell] ]
                }

            }
            set node [::WalkXML::NextNode]
        }
        set fp [open $cell(lib)/$cell(name1)/design.xml w]
        puts $fp [$root asXML]
        close $fp

    }
}