diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8906247 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +# FreeBSD Ports Makefile For 'tsearchpath' +# $Id: Makefile,v 1.100 2010/06/24 15:27:49 tundra Exp $ + +all: # Just need to create the compiled image + @python -OOOO -c"import py_compile;py_compile.compile('tsearchpath.py')" + +install: + ${BSD_INSTALL_SCRIPT} tsearchpath.py ${PREFIX}/bin + ${BSD_INSTALL_MAN} tsearchpath.1.gz ${PREFIX}/man/man1 diff --git a/WHATSNEW.txt b/WHATSNEW.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/WHATSNEW.txt @@ -0,0 +1 @@ + diff --git a/makefile b/makefile new file mode 100644 index 0000000..1a88c15 --- /dev/null +++ b/makefile @@ -0,0 +1,141 @@ +# Build a release of 'tsearchpath' using 'make' +# $Id: makefile,v 1.100 2010/06/24 15:27:49 tundra Exp $ +# Requires a modern 'make' like GNU. + + +# Uncomment One Of The Following For Early Releases + +#EARLY = Alpha +#EARLY = Beta +#EARLY = RC1 + +##### +# Definitions Relevant To This Program +##### + +PROGNAME = tsearchpath + +PORTNAME = ${PROGNAME} + +PROGFILES = ${PROGNAME}.py + +DOCSOURCES = ${PROGNAME}.rst ${PROGNAME}-license.txt CHANGELOG.txt Makefile \ + READ-1ST.txt WHATSNEW.txt setup.py + +DOCFILES = ${PROGNAME}.html ${PROGNAME}.pdf ${PROGNAME}.ps ${PROGNAME}.py.ps \ + ${PROGNAME}.1.gz + + +##### +# Nothing Should Need To Change Below This Line +##### + + +DIR = ${PORTNAME}-${VERSION} +HEADER1 = "WHATSNEW For '${PROGNAME}' ${VERSION} (`date`)" +HEADER2 = "----------------------------------------------------------------------" +TARBALL = ${DIR}.tar.gz +TMPFILE = tmpfile +VERSION = $(shell rlog -v ${PROGNAME}.py | cut -f 2 -d " ")${EARLY} + + +##### +# Pattern Rules +##### + +### +# 'troff' Sources +### + +# %.1.gz: %.1 +# @gzip $< + +# %.1: %.txt +# @cp $< $@ + +# %.txt: %.1 +# @groff -man -Tascii $< | col -xb >$@ + +# %.html: %.1 +# @manserver $< >$@ + +# %.ps: %.1 +# @groff -man -Tps $< >$@ + +### +# Restructured Text Sources +### + +%.html: %.rst + rst2html $< >$@ + +%.1: %.html + w3m -dump $< >$@ + +%.1.gz: %.1 + @gzip $< + +%.latex: %.rst + rst2latex $< >$@ + +### +# LaTeX, PostScript, & PDF +### + +%.dvi: %.latex + latex $< + +%.pdf: %.dvi + @dvipdf $< $@ + +%.ps: %.dvi + dvips $< >$@ + +### +# Pretty Print Programs & Scripts +### + +%.py.ps: %.py + @enscript -Epython -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + +%.sh.ps: % + @enscript -Esh -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + + +##### +# Actual Build Rules +##### + + +CHANGELOG.txt: + @rlog ${PROGNAME}.py >CHANGELOG.txt + +WHATSNEW.txt: + @co -l $@ + @printf "%s\n%s\n\n" ${HEADER1} ${HEADER2} | cat - $@ >${TMPFILE} + @mv ${TMPFILE} $@ + @emacs $@ + @ci -m${HEADER1} $@ + @co $@ + +clean: + @rm -rf ${DIR} ${DOCFILES} ${PORTNAME} ${PROGFILES} ${DOCSOURCES} ${TARBALL} ${TMPFILE} \ + *.1 *.aux *.dvi *.log *.out *.core *~ + +docs: ${DOCSOURCES} ${DOCFILES} + @chmod 644 ${DOCFILES} ${DOCSOURCES} + @chmod 644 *.gz *.txt + @flip -u *txt + +progs: ${PROGFILES} + chmod 755 ${PROGFILES} + +release: docs progs + @mkdir ${DIR} + @for f in `for f in ${DOCFILES} ${PROGFILES} ${DOCSOURCES};do echo $$f;done | sort`; do mv -v $$f ${DIR};done + @tar -czvf ${TARBALL} ${DIR} + @rm -rf ${DIR} + @mv ${DIR}.tar.gz Releases + +version: + @echo ${VERSION} diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..032ee09 --- /dev/null +++ b/setup.py @@ -0,0 +1,6 @@ +# Install tsearchpath as a Python Module +# Copyright (c) 2010, TundraWare Inc., All Rights Reserved +# $Id: setup.py,v 1.100 2010/06/24 15:27:49 tundra Exp $ + +from distutils.core import setup +setup(name="tsearchpath", py_modules=["tsearchpath"]) diff --git a/tsearchpath-license.txt b/tsearchpath-license.txt new file mode 100644 index 0000000..8c4de47 --- /dev/null +++ b/tsearchpath-license.txt @@ -0,0 +1,106 @@ +$Id: tsearchpath-license.txt,v 1.100 2010/06/24 15:27:49 tundra Exp $ + +In order to use, study, modify, or copy 'tsearchpath', you must read +and agree to all the licensing terms below. If you do not agree with +or do not understand *ANYTHING* you see in this document, you are NOT +granted a license to use, study, modify, or copy 'tsearchpath'. By +using, studying, modifying, or copying 'tsearchpath', you are agreeing +to all the terms of the 'tsearchpath' LICENSE below in their entirety. + + + 'tsearchpath' LICENSE AGREEMENT + + +1) DEFINITIONS + +Throughout this Agreement, the term 'tsearchpath' is used to mean: + +Anything included in the 'tsearchpath' software distribution package +from TundraWare Inc. This includes scripts, programs, documentation, +license text and all other files provided in that original software +distribution package. + +Throughout this Agreement the term "User" is used to mean any person +who is enagaged in any of the following activities: + + a) Uses any files found in the 'tsearchpath' software distribution + in any way. + + b) Reads the 'tsearchpath' documentation. + + c) Reads or studies the 'tsearchpath' program source code or + supporting files. + + d) Makes use of any part of the 'tsearchpath' software distribution + for any purpose. + + e) Duplicates and/or distributes the 'tsearchpath' software distribution. + + +2) OWNERSHIP + +'tsearchpath' Is Copyright (c) 2010 TundraWare Inc. All Rights Reserved. + + +3) TERMS + +Permission is hereby granted to the User for the duplication and use +of 'tsearchpath' so long as ALL the following conditions are met: + + a) There is no license fee for PERSONAL NON-COMMERCIAL use of + 'tsearchpath'. This means use by an individual for personal + applications only, with no remuneration of any kind, direct or + indirect, from the use of 'tsearchpath'. Voluntary donations + from such users are accepted and encouraged. A donation of + $0 US per user is recommended. Information on how to + contribute can be obtained by contacting + tsearchpath@tundraware.com. + + Use of 'tsearchpath' in ANY OTHER SITUATION, including + for-profit organizations, non-profit organizations, + educational institutions, and government organizations, + requires payment of a licensing fee. Contact + tsearchpath@tundraware.com for current pricing information. + + + b) The User of 'tsearchpath' understands and agrees that this is + EXPERIMENTAL SOFTWARE which is provided "AS-IS" with no + warranties expressed or implied by TundraWare Inc. + + c) The User acknowledges 'tsearchpath' has NOT been tested for: + + i) Correct operation + + ii) Freedom from unintended consequences + + iii) Any operation or condition which might cause damage, + compromise, or disruption to the User's or other: + hardware, software, networks, or data, or which might + cause any breach of system security of such systems, + software, and networks. + + d) By using 'tsearchpath' in any way, the User does so at their + own risk and agrees to hold TundraWare Inc. harmless for any + damage, direct or indirect, that this software may or does + cause to the User's computational environment, including, but + not limited to, the User's or others' hardware, software, + network, or data. THE USER FURTHER AGREES TO HOLD TUNDRAWARE + INC. HARMLESS FOR ANY ECONOMIC DAMAGE OR ANY OTHER ADVERSE + CONSEQUENCE, DIRECT OR INDIRECT, CAUSED BY THE USE OF + 'tsearchpath'. + + e) If duplicated and/or distributed, no fee beyond reasonable + duplication charges may be charged for 'tsearchpath'. No + commercial use of 'tsearchpath' which involves any + remuneration beyond these duplication charges is permitted. + + f) Any distributed copies of 'tsearchpath' must include all the + originally provided software, documentation, and licensing + information in their original distribution format and + packaging without any modifications. + +By using any part or all of 'tsearchpath', you are agreeing to be +bound by this license. + +IF YOU DO NOT UNDERSTAND, OR CANNOT ABIDE BY ANY OF THESE CONDITIONS, +DO NOT USE 'tsearchpath'. diff --git a/tsearchpath.py b/tsearchpath.py new file mode 100755 index 0000000..a43dd30 --- /dev/null +++ b/tsearchpath.py @@ -0,0 +1,269 @@ +#!/usr/bin/env python +# tsearchpath.py +# Copyright (c) 2010 TundraWare Inc. +# For Updates See: http://www.tundraware.com/Software/tsearchpath + +# Program Information + +PROGNAME = "tsearchpath" +BASENAME = PROGNAME.split(".py")[0] +PROGENV = BASENAME.upper() +RCSID = "$Id: tsearchpath.py,v 1.100 2010/06/24 15:27:49 tundra Exp $" +VERSION = RCSID.split()[2] + +# Copyright Information + +CPRT = "(c)" +DATE = "2010" +OWNER = "TundraWare Inc." +RIGHTS = "All Rights Reserved." +COPYRIGHT = "Copyright %s %s, %s %s" % (CPRT, DATE, OWNER, RIGHTS) + + +PROGVER = PROGNAME + " " + VERSION + (" - %s" % COPYRIGHT) +HOMEPAGE = "http://www.tundraware.com/Software/%s\n" % BASENAME + + +#----------------------------------------------------------# +# Variables User Might Change # +#----------------------------------------------------------# + + + +#------------------- Nothing Below Here Should Need Changing ------------------# + + +#----------------------------------------------------------# +# Imports # +#----------------------------------------------------------# + +import getopt +import os +import sys +import tconfpy + + +#----------------------------------------------------------# +# Aliases & Redefinitions # +#----------------------------------------------------------# + + + +#----------------------------------------------------------# +# Constants & Literals # +#----------------------------------------------------------# + + + +##### +# Constants +##### + + + +##### +# Literals +##### + + + +#----------------------------------------------------------# +# Prompts, & Application Strings # +#----------------------------------------------------------# + + +##### +# Debug Messages +##### + +##### +# Debug Messages +##### + +DEBUGFLAG = "-d" +dDEBUG = "DEBUG" +dPROGENV = "$" + PROGENV + +##### +# Error Messages +##### + +eBADARG = "Invalid command line: %s!" +eERROR = "ERROR" + + +##### +# Informational Messages +##### + +iINFO = "INFO" + + +##### +# Usage Prompts +##### + +uTable = [PROGVER, + HOMEPAGE, + "usage: " + PROGNAME + " [-fhv]", + " where,", + " -f file configuration file to use", + " -h print this help information", + " -v print detailed version information", + ] + + +#----------------------------------------------------------# +# Global Variables & Data Structures # +#----------------------------------------------------------# + +CFGFILE = os.path.join(os.getenv("HOME"), "." + PROGNAME) # conf file + + +#--------------------------- Code Begins Here ---------------------------------# + + +#----------------------------------------------------------# +# Object Base Class Definitions # +#----------------------------------------------------------# + + + +#----------------------------------------------------------# +# Supporting Function Definitions # +#----------------------------------------------------------# + + +def ColumnPad(list, padchar=" ", padwidth=20): + + retval = "" + for l in list: + l = str(l) + retval += l + ((padwidth - len(l)) * padchar) + + return retval.strip() + +# End of 'ColumnPad()' + + +##### +# Print A Debug Message +##### + +def DebugMsg(msg): + PrintStderr(PROGNAME + " " + dDEBUG + ": " + msg) + +# End of 'DebugMsg()' + + +##### +# Dump The State Of The Program +##### + +def DumpState(): + + # Dump the command line + DebugMsg(ColumnPad(["Command Line", sys.argv])) + + # Names of all the state variables we want dumped + state = [ + ] + + for k in state: + DebugMsg(ColumnPad([k, eval(k)])) + +# End of 'DumpState()' + + +##### +# Print An Error Message +##### + +def ErrorMsg(emsg): + PrintStderr(PROGNAME + " " + eERROR + ": " + emsg) + +# End of 'ErrorMsg()' + + +##### +# Print An Info Message +##### + +def InfoMsg(imsg): + PrintStderr(PROGNAME + " " + iINFO + ": " + imsg) + +# End of 'InfoMsg()' + + +##### +# Print To stderr +##### + +def PrintStderr(msg, trailing="\n"): + sys.stderr.write(msg + trailing) + +# End of 'PrintStderr()' + + +##### +# Print To stdout +##### + +def PrintStdout(msg, trailing="\n"): + sys.stdout.write(msg + trailing) + +# End of 'PrintStdout' + + +##### +# Print Usage Information +##### + +def Usage(): + for line in uTable: + PrintStdout(line) + +# End of 'Usage()' + + +#----------------------------------------------------------# +# Program Entry Point # +#----------------------------------------------------------# + +# Command line processing - Process any options set in the +# environment first, and then those given on the command line + +OPTIONS = sys.argv[1:] +envopt = os.getenv(PROGENV) +if envopt: + OPTIONS = envopt.split() + OPTIONS + +try: + opts, args = getopt.getopt(OPTIONS, '-f:hv') +except getopt.GetoptError as e: + ErrorMsg(eBADARG % e.args[0]) + sys.exit(1) + +for opt, val in opts: + if opt == "-f": + CFGFILE=val + if opt == "-h": + Usage() + sys.exit(0) + if opt == "-v": + print RCSID + sys.exit(0) + +# Process the configuration file + +retval = tconfpy.ParseConfig(CFGFILE, CallingProgram="%s %s " % (PROGNAME, VERSION)) + +# Print any errors or warning generated by the parse + +for x in (retval.ErrMsgs, retval.WarnMsgs): + for y in x: + print y + +# If there were any errors, we're done +if retval.ErrMsgs: + sys.exit(0)