scour/scour.py
2009-04-03 19:45:16 -05:00

79 lines
2 KiB
Python
Executable file

#!/usr/local/bin/python
# Scour
# Version 0.01
#
# Copyright 2009 Jeff Schiller
#
# This file is part of Scour, http://www.codedread.com/scour/
#
# Scour is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Scour is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Carve. If not, see http://www.gnu.org/licenses/ .
#
# TODOs:
#
# 6) Read input file into memory using an XML library
# 7) Implement a function that will remove all unreferenced id attributes from
# from an SVG document (xlink:href="#someid", fill="url(#someid)", etc)
# 8) Implement a function that will remove all gradients that have no id
# 9) Implement command-line options to run the above 2 rules
import sys
APP = 'Scour'
VER = '0.01'
COPYRIGHT = 'Copyright Jeff Schiller, 2009'
print APP + ' ' + VER
print COPYRIGHT
# parse command-line arguments
args = sys.argv[1:]
if( len(args) != 4 ):
print 'Error! Invalid number of arguments'
quit()
infile = ''
outfile = ''
# Get input file
if( args[0] == '-i' ):
infile = args[1]
elif( args[2] == '-i' ):
infile = args[3]
# Get output file
if( args[0] == '-o' ):
outfile = args[1]
elif(args[2] == '-o' ):
outfile = args[3]
if( infile == '' ):
print 'Error! -i argument missing'
quit()
if( outfile == '' ):
print 'Error! -o argument is missing'
quit()
# Open input file for reading, throws error if file does not exist
input = open(infile, 'r')
# Open output file for writing, overwriting file if necessary
output = open(outfile, 'w')
output.write(input.read());
# Close input and output files
input.close()
output.close()