[Sugar-devel] [PATCH] prevent view source display of .pyo, .pyc, .so files (#2854)

Sascha Silbe sascha-ml-reply-to-2011-3 at silbe.org
Mon Jul 18 17:19:05 EDT 2011


Excerpts from Walter Bender's message of Mon Jul 04 12:37:00 +0200 2011:

[src/jarabe/view/viewsource.py]
> +_EXCLUDE = ('.pyc', '.pyo', '.so', '.o', '.a', '.la', '.mo', '~', '.xo',
> +            '.tar', '.bz2', '.zip', '.gz', '.deps', '.libs')

.deps and .libs are the exact names of directories. So how about
renaming _EXCLUDE above to _EXCLUDE_EXTENSIONS and adding _EXCLUDE_NAMES
= ['.deps', '.libs'] ?


> @@ -388,7 +392,7 @@ class FileViewer(gtk.ScrolledWindow):
>      def _add_dir_to_model(self, dir_path, parent=None):
>          model = self._tree_view.get_model()
>          for f in os.listdir(dir_path):
> -            if not f.endswith('.pyc'):
> +            if not f.endswith(_EXCLUDE):

Nice trick. Didn't know that endswith() takes a tuple of candidates.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 500 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110718/80257850/attachment.pgp>


More information about the Sugar-devel mailing list