collect scripts in oxtools
This commit is contained in:
commit
4f9c3da160
22 changed files with 1297 additions and 0 deletions
48
bin/oxinfo
Executable file
48
bin/oxinfo
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
# GPL 2009
|
||||
|
||||
import os
|
||||
import sys
|
||||
import Image
|
||||
from optparse import OptionParser
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
|
||||
if os.path.exists(os.path.join(root, 'oxgst')):
|
||||
sys.path.insert(0, root)
|
||||
|
||||
from oxgst import Info
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('-f', '--format', dest='format', help='output format: cfg, json, xml default: cfg')
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
if not args:
|
||||
parser.print_help()
|
||||
sys.exit()
|
||||
|
||||
inputFile = args[0]
|
||||
i = Info(inputFile)
|
||||
info = i.metadata
|
||||
if opts.format == 'xml':
|
||||
xml = ET.Element("gstinfo")
|
||||
el = ET.SubElement(xml, "path")
|
||||
el.text = inputFile
|
||||
for key in sorted(info):
|
||||
el = ET.SubElement(xml, key)
|
||||
el.text = unicode(info[key])
|
||||
print u'<?xml version="1.0" encoding="utf-8"?>\n' + ET.tostring(xml).replace('><', '>\n <').replace(' </', '</')
|
||||
|
||||
elif opts.format == 'json':
|
||||
import simplejson
|
||||
info['path'] = inputFile
|
||||
print simplejson.dumps(info).replace(', ', ',\n ')
|
||||
else:
|
||||
print "[%s]" % inputFile
|
||||
for key in sorted(info):
|
||||
print "%s = %s" % (key, info[key])
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue