Skip to content

Commit ef787b4

Browse files
author
y-p
committed
BLD: make util/print_versions.py standlone as well
1 parent fe84e8a commit ef787b4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pandas/util/print_versions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ def show_versions(as_json=False):
120120
for k, stat in deps_blob:
121121
print("%s: %s" % (k, stat))
122122

123+
def main():
124+
# optparse is 2.6-safe
125+
from optparse import OptionParser
126+
parser = OptionParser()
127+
parser.add_option("-j", "--json", metavar="FILE", nargs=1,
128+
help="Save output as JSON into file, pass in '-' to output to stdout")
129+
130+
(options, args) = parser.parse_args()
131+
132+
if options.json == "-":
133+
options.json = True
134+
135+
show_versions(as_json=options.json)
136+
137+
return 0
123138

124139
if __name__ == "__main__":
125-
show_versions(as_json=False)
140+
sys.exit(main())

0 commit comments

Comments
 (0)