# colortohtml.py # # Copyright 2011 West - License: Public domain # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import sys import os if len(sys.argv) != 2: print "Usage: colortohtml.py colorfile" sys.exit() file = sys.argv[1] if file < 1: print "Error: Stop screwing around." sys.exit() out = '
' try: f = open(file, 'r') try: for line in f: line = line.strip(os.linesep) out += '\n' % (line) finally: f.close() except IOError: print "Error: unable to read file." sys.exit() print out+''