[PATCH] support -S option to allow -W to ignore files below a certain size
Martin Dengler
martinatmartindengler.com
Sun Oct 26 19:18:07 EDT 2008
---
lsjournal | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lsjournal b/lsjournal
index 852dc18..43723c4 100755
--- a/lsjournal
+++ b/lsjournal
@@ -65,8 +65,15 @@ def build_option_parser():
help="only return items without a file path",
default=False)
+ parser.add_option("-S", "--ignore-files-smaller-than",
+ dest="ignore_files_smaller_than", type=int,
+ help="consider items with a file smaller than this limit to have no file")
+
return parser
+def realpath(dsobject):
+ return '/home/olpc/.sugar/default/datastore/store/' + dsobject.object_id
+
if __name__ == "__main__":
# Set up things so that this script can run in a terminal. We connect to
@@ -91,9 +98,14 @@ if __name__ == "__main__":
objects, count = datastore.find(query, sorting='-mtime')
for i in range(count):
- if ((options.without_files and objects[i].file_path) or
- (not (options.all or options.without_files)
- and not objects[i].file_path)):
+ has_file = objects[i].file_path is not None
+ if has_file and options.ignore_files_smaller_than and \
+ (os.stat(realpath(objects[i])).st_size
+ < options.ignore_files_smaller_than):
+ has_file = False
+
+ if (( has_file and options.without_files) or
+ (not has_file and not (options.all or options.without_files))):
objects[i].destroy()
continue
if options.debug:
--
1.5.5.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.laptop.org/pipermail/sugar/attachments/20081031/73aef327/attachment.pgp
More information about the Sugar-devel
mailing list