def add_document(self, writer, file_path, config): file_name = str( file_path.replace(".", " ").replace("/", " ").replace( "\\", " ").replace("_", " ").replace("-", " ")) # read file content with codecs.open(file_path, 'r', encoding='utf-8') as f: content = f.read() path = str(file_path) # parse markdown fields parser = MarkdownParser() parser.parse(content, config) modtime = os.path.getmtime(path) print( "adding to index: path: %s size:%d tags:'%s' headlines:'%s' modtime=%d" % (path, len(content), parser.tags, parser.headlines, modtime)) writer.add_document(path=path, filename=file_name, headlines=parser.headlines, tags=parser.tags, content=content, doubleemphasiswords=parser.doubleemphasiswords, emphasiswords=parser.emphasiswords, time=modtime)
def __init__(self): self._markdown_parser = MarkdownParser() self._meta_parsers = {} for c in get_all_classes(["meta_parsers.py"], MetaDataParser): obj = c() self._meta_parsers[obj.flag] = obj self._file_path = ""
def setUp(self): self.md_parser = MarkdownParser()