1 #!/usr/bin/env python3 2 # ex: set filetype=python: 3 4 """Generate source code boilerplate""" 5 6 import os.path 7 import time 8 9 from generators import Boilerplate 10 from generators import find_xdr_program_name, create_jinja2_environment 11 from xdr_ast import _RpcProgram, Specification, get_header_name 12 13 14 class XdrSourceTopGenerator(Boilerplate): 15 """Generate source code boilerplate""" 16 17 def __init__(self, language: str, peer: str): 18 """Initialize an instance of this class""" 19 self.environment = create_jinja2_environment(language, "source_top") 20 self.peer = peer 21 22 def emit_source(self, filename: str, root: Specification) -> None: 23 """Emit the top source boilerplate""" 24 name = find_xdr_program_name(root) 25 template = self.environment.get_template(self.peer + ".j2") 26 print( 27 template.render( 28 program=name, 29 filename=filename, 30 mtime=time.ctime(os.path.getmtime(filename)), 31 ) 32 )
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.