rootPath = arg
pattern = '*.*'
f = open('facad.csv', 'w')
fname = 'facad.csv'
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
if 'SETQ' and 'findfile' and 'getvar' in open(os.path.join(root, filename), 'rb').read():
data = os.path.join(root, filename)+", ACAD_LSP\n"
f.write(data)
elif 'base.dcl' in open(os.path.join(root, filename)).read():
data = os.path.join(root, filename)+", ACAD_LSP\n"
f.write(data)
elif 'vl-file-copy' in open(os.path.join(root, filename)).read():
data= os.path.join(root, filename)+", ACAD_LSP\n"
f.write(data)
elif 'FAS4-FILE' in open(os.path.join(root, filename)).read():
data = os.path.join(root, filename)+", ACAD_FAS\n"
f.write(data)
elif 'Autodesk' in open(os.path.join(root, filename)).read():
data = os.path.join(root, filename)+", ACAD_LSP\n"
f.write(data)
elif 'acad.lsp' in open(os.path.join(root, filename)).read():
data = os.path.join(root, filename)+", ACAD_LSP\n"
f.write(data)
f.close()
I am getting this error:
C:\Python33>python D:\python\ftacad.py G:\ginipig\acad_and_lisp\ACAD_samples
Traceback (most recent call last):
File "D:\python\ftacad.py", line 62, in <module>
main()
File "D:\python\ftacad.py", line 40, in main
if 'SETQ' and 'findfile' and 'getvar' in open(os.path.join(root, filename),' rb').read():
TypeError: Type str doesn't support the buffer API
I have various types of files to search. Code not running only in 3.x. Runs fine below this version of Python.
ifcondition; your code is not working as designed even in Python 2. See How do I test one variable against multiple values?