[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: gschem won't connect nets
Hi Bernd,
On Mittwoch, 11. Juni 2008, Bernd Jendrissek wrote:
> On Sun, May 25, 2008 at 4:25 AM, Rick Collins <gnuarm.2007@xxxxxxxxx>
wrote:
> > Or perhaps the software should check this and give a warning when
> > placing a part so that it is not connectable.
>
> It could be cute to have a libgsymcheck which gschem's component
> selector could invoke each time you select a component, having it
> write warnings about the symbol into an alert box.
I'm using a component-library-command that checks the symbol before it's
being displayed in the component selector.
The library command is a small python script that calls gsymcheck. The
gsymcheck output is forwarded to stderr and is displayed in the log
window of gschem.
The connection commands are in an scm file in the gafrc.d directory:
-------
(component-library-command
"/home/werner/oss/geda/nice_sym/connect_symbols.py -l my_gedasymbols"
"/home/werner/oss/geda/nice_sym/connect_symbols.py -p my_gedasymbols"
"gedasymbols")
(component-library-command
"/home/werner/oss/geda/nice_sym/connect_symbols.py -l symbols_def"
"/home/werner/oss/geda/nice_sym/connect_symbols.py -p symbols_def"
"symbols_def")
--------
The python script connect_symbols.py is attached.
Before I've connected the symbols, I've renamed all symbols that are
used by that commands using a SHA1-hash extentions. Symbol BC557-2.sym
is stored as BC557-2_f2073e99.sym in a different directory.
With this stuff I've connected all symbols from www.gedasymbols.org and
a copy of all symbols provided with geda-symbols into gschem.
Regards
Werner
#!/usr/bin/python
# Copyright (C) 2008 Werner Hoch <werner.ho@xxxxxx>
# Released under the terms of the GNU General Public License, version 2
import os, sys, getopt
import dircache
import tempfile, popen2
#################### SETUP VARS
REL_DIR= "./" # relation between this script and the BASE_DIR
BASE_DIR = os.path.join(os.getcwd(),
os.path.dirname(sys.argv[0]),
REL_DIR)
#################### FUNCTIONS
def log(x):
open("connect_symbols.log","at").write(str(x) + "\n")
def usage():
print "usage: " + sys.argv[0] + """ [options], ...
-h --help: print help information
-v --verbose: print debug messages to stderr
-l --list library: list symbol of one library directory
-p --part library part: get a single part of a library"""
#################### MAIN
log(sys.argv)
try:
opts, args = getopt.getopt(sys.argv[1:], "hvl:p:", ["help", "verbose", "list=", "part="])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
verbose = False
listlibrary = False
printpart = False
for o, a in opts:
if o == "-v":
verbose = True
elif o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-v", "--verbose"):
verbose = True
elif o in ("-l", "--list"):
listlibrary = True
librarydir = a
elif o in ("-p", "--part"):
printpart = True
librarydir = a
symbolname = args[0]
else:
assert False, "unhandled option"
if verbose:
log(sys.argv[0] + ": opts:" + str(opts) + " args: " + str(args))
elif listlibrary:
path = os.path.join(BASE_DIR, librarydir)
parts = [ f[:-4] for f in dircache.listdir(path) if f[-4:] == ".sym" ]
sys.stdout.write("\n".join(parts))
sys.exit()
elif printpart:
filename = os.path.join(BASE_DIR, librarydir, symbolname + ".sym")
sys.stderr.write(filename +"\n")
## run gsymcheck over the symbol
command = "gsymcheck -vv " + filename
pop = popen2.Popen3(command, capturestderr=True)
message = pop.fromchild.read()
err = pop.childerr.read()
mlines = message.split("\n")
if len(mlines) > 9:
message = "\n".join(mlines[7:-1]) + "\n"
pop.wait()
sys.stderr.write(message)
sys.stdout.write(open(filename).read())
sys.exit(0)
else:
sys.stderr.write(sys.argv[0] + ": undefined case\n")
usage()
sys.exit(2)
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user