Skip to content

Commit

Permalink
Skip directory file when processing zip content
Browse files Browse the repository at this point in the history
  • Loading branch information
bcui6611 committed Sep 9, 2011
1 parent b277613 commit e0e8f6f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions docloader
Expand Up @@ -4,7 +4,6 @@
import sys, zipfile, os, os.path
import getopt
import json
import ast
import tempfile
import re

Expand Down Expand Up @@ -74,7 +73,10 @@ def listFiles(bucket, dir, views):
if os.path.isfile(os.path.join(basedir, item)):
with open(os.path.join(basedir, item), 'r') as fp:
print "working with ", item
save_doc(bucket, dockey, fp, views)
fileslashed = re.split(".json", item)
fileinlist = re.split("/", fileslashed[0])
file_for_key = fileinlist.pop()
save_doc(bucket, file_for_key, fp, views)
else:
subdirlist.append(os.path.join(basedir, item))
for subdir in subdirlist:
Expand All @@ -83,10 +85,8 @@ def listFiles(bucket, dir, views):
def unzip_file_and_upload(bucket,file, views):
zfobj = zipfile.ZipFile(file)
for name in zfobj.namelist():
#if name.endswith('/'):
#print "dir:", name
#else:
#print 'file:', name
if not name.endswith('/'):
print 'working with ', name
fileslashed = re.split(".json", name)
fileinlist = re.split("/", fileslashed[0])
file_for_key = fileinlist.pop()
Expand Down Expand Up @@ -120,9 +120,10 @@ def main():
populate_docs(newbucket, dir, views)

# execute views at least once
for viewpath in views:
rows = newbucket.view(viewpath)
#for row in rows:
#print row
try:
for viewpath in views:
rows = newbucket.view(viewpath)
except:
#do nothing, maybe view result is not ready yet

if __name__ == '__main__': main()

0 comments on commit e0e8f6f

Please sign in to comment.