Page MenuHomeHEPForge

swig_fix.tcl
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

swig_fix.tcl

#!/bin/sh
# -*- Tcl -*- the next line restarts using tclsh \
exec tclsh "$0" ${1+"$@"}
proc print_usage {} {
puts stderr ""
puts stderr "Usage: [file tail [info script]] inputfile outputfile"
puts stderr ""
return
}
# Check the input arguments
if {$argc != 2} {
print_usage
exit 1
}
# Parse the arguments
foreach {inputfile outputfile} $argv break
if {![file readable $inputfile]} {
puts stderr "Error: file \"$inputfile\" does not exist (or unreadable)"
exit 1
}
if {[file exists $outputfile]} {
puts stderr "Error: file \"$outputfile\" already exists"
exit 1
}
proc file_contents {filename} {
set chan [open $filename "r"]
set contents [read $chan [file size $filename]]
close $chan
return $contents
}
proc fix_line {line} {
set ind [string first "raise IOError," $line]
if {$ind >= 0} {
set l [string range $line 0 [expr {$ind - 1}]]
append l "raise IOError("
append l [string trim [string range $line [expr {$ind + 14}] end]] ")"
return $l
} else {
return $line
}
}
set chan [open $outputfile "w"]
foreach line [split [file_contents $inputfile] "\n"] {
puts $chan [fix_line $line]
}
close $chan
exit 0

File Metadata

Mime Type
text/x-shellscript
Expires
Tue, Sep 30, 6:08 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6560249
Default Alt Text
swig_fix.tcl (1 KB)

Event Timeline