Start a new interface file - genOpts - GeneratorOptions controlling what is generated and how
(self, genOpts)
| 941 | self.madeDirs[path] = None |
| 942 | |
| 943 | def beginFile(self, genOpts): |
| 944 | """Start a new interface file |
| 945 | |
| 946 | - genOpts - GeneratorOptions controlling what is generated and how""" |
| 947 | |
| 948 | self.genOpts = genOpts |
| 949 | if self.genOpts is None: |
| 950 | raise MissingGeneratorOptionsError() |
| 951 | if self.genOpts.conventions is None: |
| 952 | raise MissingGeneratorOptionsConventionsError() |
| 953 | self.should_insert_may_alias_macro = \ |
| 954 | self.genOpts.conventions.should_insert_may_alias_macro(self.genOpts) |
| 955 | self.file_suffix = self.genOpts.conventions.file_suffix |
| 956 | |
| 957 | # Try to import the API dictionary, apimap.py, if it exists. Nothing |
| 958 | # in apimap.py cannot be extracted directly from the XML, and in the |
| 959 | # future we should do that. |
| 960 | if self.genOpts.genpath is not None: |
| 961 | try: |
| 962 | sys.path.insert(0, self.genOpts.genpath) |
| 963 | import apimap |
| 964 | self.apidict = apimap |
| 965 | except ImportError: |
| 966 | self.apidict = None |
| 967 | |
| 968 | self.conventions = genOpts.conventions |
| 969 | |
| 970 | # Open a temporary file for accumulating output. |
| 971 | if self.genOpts.filename is not None: |
| 972 | self.outFile = tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', newline='\n', delete=False) |
| 973 | else: |
| 974 | self.outFile = sys.stdout |
| 975 | |
| 976 | def endFile(self): |
| 977 | if self.errFile: |
no test coverage detected