Skip to content

Instantly share code, notes, and snippets.

@clopez
Created November 10, 2016 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clopez/3d6ba07626e5ce4219a5fc8f67620a4f to your computer and use it in GitHub Desktop.
Save clopez/3d6ba07626e5ce4219a5fc8f67620a4f to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
# Prints the entries on a GResource file (*.gresource)
import os, sys
from gi.repository import Gio
def is_leaf(name):
if type(name) == type(""):
return not name.endswith("/")
return False
def print_resource_tree(name):
if is_leaf(name):
print(name)
else:
for subresource in gioresource.enumerate_children(name, 0):
print_resource_tree(name+subresource)
def print_help():
print("Use: %s path-to-file.gresource" %sys.argv[0])
sys.exit(0)
if len(sys.argv) < 2:
print_help()
gresourcepath = sys.argv[1]
if not os.path.isfile(gresourcepath):
print_help()
gioresource = Gio.Resource.load(gresourcepath)
print_resource_tree("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment