Mercurial > p > roundup > code
comparison scripts/spam-remover @ 4661:73129d1a1bc3
Fix file options for spam-remover script, set content to single space.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Thu, 06 Sep 2012 11:24:19 +0200 |
| parents | 9f507a042c1b |
| children | f841a5868101 |
comparison
equal
deleted
inserted
replaced
| 4660:9f507a042c1b | 4661:73129d1a1bc3 |
|---|---|
| 94 tracker = instance.open(opt.instance) | 94 tracker = instance.open(opt.instance) |
| 95 db = tracker.open('admin') | 95 db = tracker.open('admin') |
| 96 users = dict.fromkeys (db.user.lookup(u) for u in opt.users) | 96 users = dict.fromkeys (db.user.lookup(u) for u in opt.users) |
| 97 files_to_remove = {} | 97 files_to_remove = {} |
| 98 for fn in opt.filenames: | 98 for fn in opt.filenames: |
| 99 for fid in db.files.filter(None,name=fn): | 99 for fid in db.file.filter(None,dict(name=fn)): |
| 100 if db.file.get(fid,'name') == fn: | 100 if db.file.get(fid,'name') == fn: |
| 101 files_to_remove[fid] = True | 101 files_to_remove[fid] = True |
| 102 for fn in opt.file_pattern: | 102 for fn in opt.file_pattern: |
| 103 for fid in db.files.filter(None,name=fn): | 103 for fid in db.file.filter(None,dict(name=fn)): |
| 104 if db.file.get(fid,'name').startswith(fn): | 104 if db.file.get(fid,'name').startswith(fn): |
| 105 files_to_remove[fid] = True | 105 files_to_remove[fid] = True |
| 106 files_found = {} | 106 files_found = {} |
| 107 for d in opt.designators: | 107 for d in opt.designators: |
| 108 clsname, id = hyperdb.splitDesignator(d) | 108 clsname, id = hyperdb.splitDesignator(d) |
| 166 journal = newjournal | 166 journal = newjournal |
| 167 if newjournal != oldjournal and opt.doit: | 167 if newjournal != oldjournal and opt.doit: |
| 168 db.setjournal(clsname, id, newjournal) | 168 db.setjournal(clsname, id, newjournal) |
| 169 if opt.doit: | 169 if opt.doit: |
| 170 for f in files_found: | 170 for f in files_found: |
| 171 db.file.set(f, content='') | 171 db.file.set(f, content=' ') |
| 172 db.commit() | 172 db.commit() |
| 173 else: | 173 else: |
| 174 print "Database not changed" | 174 print "Database not changed" |
| 175 | 175 |
| 176 | 176 |
