if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
test ! -f ${st1} && test -f ${f}; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
test ! -f ${st3} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
${echo} 'WARNING: not restoring timestamps. Consider getting and'
${echo} 'installing GNU `touch'\'', distributed in GNU coreutils...'
echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir}
then : ; else ${echo} 'lock directory '${lock_dir}' exists'
exit 1
fi
if mkdir ${lock_dir}
then ${echo} 'x - created lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to create lock directory `'${lock_dir}\''.'
exit 1
fi
# ============= qucsator.py ==============
if test -f 'qucsator.py' && test "$first_param" != -c; then
${echo} 'x -SKIPPING qucsator.py (file already exists)'
else
${echo} 'x - extracting qucsator.py (text)'
sed 's/^X//' << 'SHAR_EOF' > 'qucsator.py' &&
"""
The "qucsator" module modifies file paths and parameters
in the netlist generated by QUCS from the schematic
(usually you can find it in /home/user/.qucs/netlist.txt
after the simulation)
X
Sample use of the module:
X q=qucsator(subst_params={'Rc':'0.6'},
X subst_paths=[
X ['path1','path2'],
X ['/home/user/.qucs/my_prj/','./']
X ] )
X for rc in range(0,10):
X q.result_file="results_"+str(rc)+".txt"
X q.subst_params={'Rc':str(rc)}
X q.run()
"""
import re
import os
class qucsator:
X def __init__(self,netlist="netlist.txt",
X sim_netlist="sim_next.txt",
X results="results.txt",
X subst_paths=[], subst_params={}):
X self.subst_paths=subst_paths
X self.subst_params=subst_params
X self.template_netlist=netlist
X self.simul_netlist=sim_netlist
X self.result_file=results
X self.path_finder=re.compile(r'.*File=\"\{(?P<fn>.*)\}\"')
X self.equ_finder=re.compile(r'Eqn:Eqn.*?\s+(?P<pn>.*?)=\"(?P<pv>.*?)\"')
X
X def try_subst_paths(self,l):
X p=self.path_finder.search(l)
X if p: #There is file reference in this line
X #Try to substitute path
X fn=p.group('fn')
X for i in self.subst_paths:
X pl=len(i[0])
X if i[0]==fn[0:pl]:
X fn=i[1]+fn[pl:]
X s=p.span('fn')
X t=l[:s[0]]+fn+l[s[1]:]
X return t
X return l
X def try_subst_params(self,l):
X p=self.equ_finder.search(l)
X if p: #There is parameter definition in this line
X pn=p.group('pn')
X if self.subst_params.has_key(pn):
X s=p.span('pv')
X t=l[:s[0]]+self.subst_params[pn]+l[s[1]:]
X return t
X return l
X
X def run(self):
X fin=open(self.template_netlist,"r")
X fout=open(self.simul_netlist,"w")
X while True:
X l = fin.readline()
X print l
X if not l:
X break
X l=self.try_subst_paths(l)
X l=self.try_subst_params(l)
X fout.write(l)
X fin.close()
X fout.close()
X os.system("qucsator -i "+self.simul_netlist+\
X " -o "+self.result_file)
X
if __name__ == '__main__':
X q=qucsator(subst_params={'Rc':'0.6'},
X subst_paths=[
X ['path1','path2'],
X ['/home/user/.qucs/my_prj/','./']
X ])
X for rc in range(0,10):
X q.result_file="results_"+str(rc)+".txt"
X q.subst_params={'Rc':str(rc)}
X q.run()
X
SHAR_EOF
(set 20 09 05 05 22 18 34 'qucsator.py'; eval "$shar_touch") &&
chmod 0644 'qucsator.py'
if test $? -ne 0
then ${echo} 'restore of qucsator.py failed'
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'qucsator.py: MD5 check failed'
) << SHAR_EOF
4ee4fcd2d83584b525e6af84cf26e743 qucsator.py
SHAR_EOF
else
test `LC_ALL=C wc -c < 'qucsator.py'` -ne 2684 && \
${echo} 'restoration warning: size of qucsator.py is not 2684'
fi
fi
if rm -fr ${lock_dir}
then ${echo} 'x - removed lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to remove lock directory `'${lock_dir}\''.'
exit 1
fi
exit 0