mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
Add output options to modparser
This commit is contained in:
parent
3f282e21f1
commit
50a55eca58
1 changed files with 14 additions and 6 deletions
|
@ -1,9 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
'''
|
|
||||||
This script is used to list all python modules that are recursively imported
|
|
||||||
by all python files in a directory. For Salt this is use to obtain a list of
|
|
||||||
all non stdlib modules which are imported by all salt plugins
|
|
||||||
'''
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
@ -11,6 +6,8 @@ import sys
|
||||||
import os
|
import os
|
||||||
import modulefinder
|
import modulefinder
|
||||||
import pprint
|
import pprint
|
||||||
|
import yaml
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def parse():
|
def parse():
|
||||||
|
@ -29,6 +26,11 @@ def parse():
|
||||||
'--bif',
|
'--bif',
|
||||||
dest='bif',
|
dest='bif',
|
||||||
default='site-packages')
|
default='site-packages')
|
||||||
|
parser.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--format',
|
||||||
|
dest='format',
|
||||||
|
default='pprint')
|
||||||
out = parser.parse_args()
|
out = parser.parse_args()
|
||||||
return out.__dict__
|
return out.__dict__
|
||||||
|
|
||||||
|
@ -81,4 +83,10 @@ def scan(opts):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
opts = parse()
|
opts = parse()
|
||||||
pprint.pprint(scan(opts))
|
scand = scan(opts)
|
||||||
|
if opts['format'] == 'yaml':
|
||||||
|
print(yaml.dump(scand))
|
||||||
|
if opts['format'] == 'json':
|
||||||
|
print(json.dumps(scand))
|
||||||
|
else:
|
||||||
|
pprint.pprint(scand)
|
||||||
|
|
Loading…
Add table
Reference in a new issue