[extensions-web] Don't show binary files and directories in the review UI
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Don't show binary files and directories in the review UI
- Date: Sat, 19 Nov 2011 21:15:57 +0000 (UTC)
commit a8f9c1aeae544c62b9eac84ff1f5cee45d223d1f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Nov 19 16:15:25 2011 -0500
Don't show binary files and directories in the review UI
sweettooth/review/views.py | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index 7a88544..eb4bbbd 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -37,6 +37,18 @@ BINARY_TYPES = set(['.mo'])
code_formatter = pygments.formatters.HtmlFormatter(style="borland", cssclass="code")
diff_formatter = NoWrapperHtmlFormatter(style="borland")
+def get_filelist(zipfile):
+ for name in zipfile.namelist():
+ if name.endswith('/'):
+ # There's no directory flag in the info, so I'm
+ # guessing this is the most reliable way to do it.
+ continue
+
+ if name in BINARY_TYPES:
+ continue
+
+ yield name
+
def can_review_extension(user, extension):
if user == extension.creator:
return True
@@ -127,14 +139,14 @@ def ajax_get_file_list_view(request, obj):
old_zipfile, new_zipfile = get_zipfiles(version)
- new_filelist = set(new_zipfile.namelist())
+ new_filelist = set(get_filelist(new_zipfile))
if old_zipfile is None:
return dict(both=[],
- added=sorted(new_zipfile.namelist()),
+ added=sorted(new_filelist),
deleted=[])
- old_filelist = set(old_zipfile.namelist())
+ old_filelist = set(get_filelist(old_zipfile))
both = new_filelist & old_filelist
added = new_filelist - old_filelist
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]