commit
71e7729cae
4 changed files with 75 additions and 0 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
import random |
||||
import json |
||||
import yaml |
||||
|
||||
|
||||
def main(): |
||||
with open('test.yml', 'r') as f: |
||||
doc = yaml.safe_load(f) |
||||
contents = doc['contents'] |
||||
parse_contents_items(contents) |
||||
print(json.dumps(contents, indent=2)) |
||||
|
||||
|
||||
def parse_contents_items(contents, layer=0): |
||||
|
||||
assert(type(contents)==type([])) |
||||
|
||||
for item in contents: |
||||
if 'contents' in item: |
||||
parse_contents_items(item['contents'], layer+1) |
||||
if 'sum' in item['contents'][0].keys(): |
||||
item['sum'] = sum([s['sum'] for s in item['contents']]) |
||||
else: |
||||
item['sum'] = random.randint(100,150) |
||||
|
||||
|
||||
|
||||
if __name__=="__main__": |
||||
main() |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
import json |
||||
import yaml |
||||
|
||||
with open('test.yml', 'r') as f: |
||||
doc = yaml.safe_load(f) |
||||
|
||||
print(json.dumps(doc, indent=4)) |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
id: "9232f040-61e1-4553-afbd-637b436de396" |
||||
title: "Corporate Compliance Certification" |
||||
org: "Panel for Corporate Governance" |
||||
contents: |
||||
- name: "Stage 1" |
||||
contents: |
||||
- name: "Subsection 1.1" |
||||
contents: |
||||
- name: "Subsubsection 1.1.1" |
||||
- name: "Subsubsection 1.1.2" |
||||
- name: "Subsubsection 1.1.3" |
||||
- name: "Subsection 1.2" |
||||
contents: |
||||
- name: "Subsubsection 1.2.1" |
||||
- name: "Subsubsection 1.2.2" |
||||
- name: "Subsubsection 1.2.3" |
||||
- name: "Subsection 1.3" |
||||
contents: |
||||
- name: "Subsubsection 1.2.1" |
||||
- name: "Subsubsection 1.2.2" |
||||
- name: "Subsubsection 1.2.3" |
||||
- name: "Stage 2" |
||||
contents: |
||||
- name: "Subsection 2.1" |
||||
contents: |
||||
- name: "Subsubsection 2.1.1" |
||||
- name: "Subsubsection 2.1.2" |
||||
- name: "Subsubsection 2.1.3" |
||||
- name: "Subsection 2.2" |
||||
contents: |
||||
- name: "Subsubsection 2.2.1" |
||||
- name: "Subsubsection 2.2.2" |
||||
- name: "Subsubsection 2.2.3" |
||||
- name: "Subsection 2.3" |
||||
contents: |
||||
- name: "Subsubsection 2.2.1" |
||||
- name: "Subsubsection 2.2.2" |
||||
- name: "Subsubsection 2.2.3" |
Loading…
Reference in new issue