File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
aws_doc_sdk_examples_tools Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 44import yaml
55import json
66
7+ from collections import defaultdict
78from dataclasses import dataclass , field , is_dataclass , asdict
9+ from functools import reduce
810from pathlib import Path
911from typing import Dict , Iterable , Optional , Set
1012
@@ -236,6 +238,18 @@ def validate(self):
236238 )
237239
238240 def stats (self ):
241+ values = self .examples .values ()
242+ initial = defaultdict (int )
243+
244+ def count_genai (d : Dict [str , int ], e : Example ):
245+ for lang in e .languages .values ():
246+ for version in lang .versions :
247+ for excerpt in version .excerpts :
248+ d [excerpt .genai ] += 1
249+ return d
250+
251+ genai = reduce (count_genai , values , initial )
252+
239253 return {
240254 "sdks" : len (self .sdks ),
241255 "services" : len (self .services ),
@@ -245,6 +259,7 @@ def stats(self):
245259 for e in self .examples .values ()
246260 ),
247261 "snippets" : len (self .snippets ) + len (self .snippet_files ),
262+ "genai" : genai ,
248263 }
249264
250265
Original file line number Diff line number Diff line change 11from typing import List
22from pathlib import Path
3+ from pprint import pformat
34
45from .doc_gen import DocGen
56
@@ -17,6 +18,8 @@ def main(roots: List[str]):
1718 print (f"Examples { stats ['examples' ]} " )
1819 print (f"Version { stats ['versions' ]} " )
1920 print (f"Snippets { stats ['snippets' ]} " )
21+ genai = pformat (dict (stats ["genai" ]))
22+ print (f"GenAI { genai } " )
2023
2124
2225if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments