cfn-json2yaml file-mode bugfix
file-mode wasn't working, also add missing header Change-Id: I75d15fd73de4ab3ce679ae3a274ec1c402802267 Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
parent
87e56e3616
commit
549d26feb2
|
@ -1,5 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
|
@ -12,13 +26,13 @@ def main():
|
|||
if os.path.isdir(path):
|
||||
convert_directory(path)
|
||||
elif os.path.isfile(path):
|
||||
convert_file()
|
||||
convert_file(path)
|
||||
else:
|
||||
print 'File or directory not valid: %s' % path
|
||||
|
||||
def convert_file(path):
|
||||
f = open(path, 'r')
|
||||
print json2yaml(f)
|
||||
print format.convert_json_to_yaml(f.read())
|
||||
|
||||
def convert_directory(dirpath):
|
||||
for path in os.listdir(dirpath):
|
||||
|
@ -33,4 +47,4 @@ def convert_directory(dirpath):
|
|||
out.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue