Subversion Repositories svn.Prod repos

Compare Revisions

No changes between revisions

Ignore whitespace Rev 44 → Rev 45

/filefind/jython/Makefile
0,0 → 1,18
SRC=filefind.py
PRG=$(SRC)
DIR=/var/tmp
.PHONY: test cleantest
 
all: test
 
test:
./$(PRG) $(DIR) > result
sort result > result.sort
find $(DIR) > result2
sort result2 > result2.sort
wc *.sort
diff *.sort
 
cleantest:
rm -f result result.sort
rm -f result2 result2.sort
/filefind/jython/filefind.py
0,0 → 1,46
#! /usr/bin/env jython
import sys
import os.path
 
# =============================================================================
# Functions
# =============================================================================
 
def Usage(mesg):
print ("Usage: " + progname + " directory")
print (mesg)
 
def traverse(directory):
curdir = os.getcwd()
os.chdir(directory)
curdir2 = os.getcwd()
files = os.listdir(curdir2)
for file in files:
pfile = curdir2 + "/" + file
if os.path.isdir(file) and not os.path.islink(file):
print (pfile)
traverse(file)
else:
if os.path.isfile(file) or os.path.islink(file):
print (pfile)
else:
print ("WARNING: Could not process file " + pfile)
os.chdir(curdir)
 
def start_traverse(directory):
print (directory)
traverse(directory)
 
# =============================================================================
# MAIN
# =============================================================================
 
progname = os.path.basename(sys.argv[0])
if (len(sys.argv) == 2):
directory = sys.argv[1]
if os.path.isdir(directory):
start_traverse(directory)
else:
Usage("ERROR: Not a directory : " + directory)
else:
Usage("ERROR: 1 argument expected")
Property changes:
Added: svn:executable
+*
\ No newline at end of property