def __init__(self, source_dir, output_dir, filename): existing_filename = None if os.path.exists(filename): existing_filename = filename else: fn = os.path.join(source_dir, filename) if os.path.exists(fn): existing_filename = fn self.stream = codecs.open(os.path.join( output_dir, optrecord.html_file_name(filename)), 'w', encoding='utf-8') if existing_filename: self.source_stream = open(existing_filename) else: self.source_stream = None print(''' <html> <h1>Unable to locate file {}</h1> </html> '''.format(filename), file=self.stream) self.html_formatter = HtmlFormatter(encoding='utf-8') self.cpp_lexer = CppLexer(stripnl=False)
def __init__(self, source_dir, output_dir, filename): existing_filename = None if os.path.exists(filename): existing_filename = filename else: fn = os.path.join(source_dir, filename) if os.path.exists(fn): existing_filename = fn self.stream = open(os.path.join(output_dir, optrecord.html_file_name(filename)), 'w') if existing_filename: self.source_stream = open(existing_filename) else: self.source_stream = None print(''' <html> <h1>Unable to locate file {}</h1> </html> '''.format(filename), file=self.stream) self.html_formatter = HtmlFormatter(encoding='utf-8') self.cpp_lexer = CppLexer(stripnl=False)