Permalink
Browse files

MB-100: code cleanup

Change-Id: Iddcad4667e6cf82db267b0a78911da9a5c82ad38
Reviewed-on: http://review.couchbase.org/17995
Tested-by: Pavel Paulau <pavel.paulau@gmail.com>
Reviewed-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
1 parent 324277a commit 9bc42d78c07a19a32bc68d20964b0d1e3143132d @pavel-paulau pavel-paulau committed with pavel-paulau Jul 6, 2012
Showing with 7 additions and 11 deletions.
  1. +7 −11 docloader
View
@@ -13,9 +13,6 @@ from couchbase import client
class DocLoader:
- def __init__(self):
- pass
-
def parse_args(self):
usage = "usage: %prog [options] <directory>|zipfile\n\n" + \
"Example: %prog -u Administrator -p password -n 127.0.0.1:8091 " + \
@@ -55,7 +52,7 @@ class DocLoader:
try:
result['_id'] = result['_id'].encode('UTF-8')
doc_id = bucket.save(result)
- print "just now saving", doc_id
+ print "just now saving %s" % doc_id
except:
doc_id = "_design/testing"
if result['_id'] and 'views' in result:
@@ -69,13 +66,12 @@ class DocLoader:
def list_files(self, bucket, views, subdir=None):
if not subdir:
subdir = self.args[0]
- #print "Files in ", os.path.abspath(dir), ": "
- subdirlist = []
+ subdirlist = list()
for item in os.listdir(subdir):
if os.path.isfile(os.path.join(subdir, item)):
try:
fp = open(os.path.join(subdir, item), 'r')
- print "working with ", item
+ print "working with %s" % item
dockey = self.gen_dockey(item)
self.save_doc(bucket, dockey, fp, views)
fp.close()
@@ -90,7 +86,7 @@ class DocLoader:
zfobj = zipfile.ZipFile(self.args[0])
for name in zfobj.namelist():
if not name.endswith('/'):
- print 'working with ', name
+ print 'working with %s' % name
dockey = self.gen_dockey(name)
temp_file = TemporaryFile()
temp_file.write(zfobj.read(name))
@@ -117,13 +113,13 @@ def main():
except:
newbucket = cb[docloader.options.bucket]
- #upload documents
- views = []
+ # upload documents
+ views = list()
docloader.populate_docs(newbucket, views)
# execute views at least once
for viewpath in views:
- rows = newbucket.view(viewpath, stale="update_after")
+ newbucket.view(viewpath, stale="update_after")
if __name__ == '__main__':
main()

0 comments on commit 9bc42d7

Please sign in to comment.