def get_contentinfo(self): """Get info from the markdown content files.""" pattern = '*.md' ignore_patterns = self.get_ignore_patterns() for path, dirnames, filenames in os.walk(workdir): relpath = get_relpath(path, workdir) if any(fnmatch.fnmatch(relpath, ip) for ip in ignore_patterns): continue for fn in filenames: if fnmatch.fnmatch(fn, pattern): relfn = os.path.join(relpath, fn) meta = readers.get_yamlfm(relfn) if meta is None: warn(yamlfm_warning.format(relfn), UrubuWarning) continue fileinfo = self.make_fileinfo(relfn, meta) self.filelist.append(fileinfo) # validate after file info has been added so it can be used self.validate_fileinfo(relfn, fileinfo) self.add_reflink(fileinfo['id'], fileinfo) if fn == 'index.md': # start from fileinfo of index file navinfo = self.make_navinfo(relpath, fileinfo) self.navlist.append(navinfo) self.validate_navinfo(relfn, navinfo) self.add_reflink(navinfo['id'], navinfo) # add nav info to tag map self.add_info_to_tagmap(navinfo) else: # add id for non-index files to tag tags self.add_info_to_tagmap(fileinfo)
def get_contentinfo(self): """Get info from the markdown content files.""" pattern = '*.md' ignore_patterns = self.get_ignore_patterns() for path, dirnames, filenames in os.walk(self.cwd): relpath = get_relpath(path, self.cwd) if any(fnmatch.fnmatch(relpath, ip) for ip in ignore_patterns): continue content_found = index_found = False for fn in filenames: if fnmatch.fnmatch(fn, pattern): # normalize to convert ./foo into foo # to avoid problems with ignore_patterns matching relfn = os.path.normpath(os.path.join(relpath, fn)) if any( fnmatch.fnmatch(relfn, ip) for ip in ignore_patterns): continue meta = readers.get_yamlfm(relfn) if meta is None: urubu_warn(_warning.no_yamlfm, fn=relfn) continue fileinfo = self.make_fileinfo(relfn, meta) self.filelist.append(fileinfo) self.process_info(fileinfo, self.site) # validate after file info has been added so it can be used self.validate_fileinfo(fileinfo) self.add_reflink(fileinfo['id'], fileinfo) if fn == 'index.md': index_found = True # start from fileinfo of index file navinfo = self.make_navinfo(relpath, fileinfo) self.navlist.append(navinfo) self.validate_navinfo(navinfo) self.add_reflink(navinfo['id'], navinfo) # add nav info to tag map self.add_info_to_tagmap(navinfo) else: content_found = True # add id for non-index files to tag tags self.add_info_to_tagmap(fileinfo) # a folder with content but no index is an error if content_found and not index_found: raise UrubuError(_error.no_index, msg='', fn=relpath)
def get_contentinfo(self): """Get info from the markdown content files.""" pattern = '*.md' ignore_patterns = self.get_ignore_patterns() for path, dirnames, filenames in os.walk(self.cwd): relpath = get_relpath(path, self.cwd) if any(fnmatch.fnmatch(relpath, ip) for ip in ignore_patterns): continue content_found = index_found = False for fn in filenames: if fnmatch.fnmatch(fn, pattern): # normalize to convert ./foo into foo # to avoid problems with ignore_patterns matching relfn = os.path.normpath(os.path.join(relpath, fn)) if any(fnmatch.fnmatch(relfn, ip) for ip in ignore_patterns): continue meta = readers.get_yamlfm(relfn) if meta is None: urubu_warn(_warning.no_yamlfm, fn=relfn) continue fileinfo = self.make_fileinfo(relfn, meta) self.filelist.append(fileinfo) self.process_info(fileinfo, self.site) # validate after file info has been added so it can be used self.validate_fileinfo(fileinfo) self.add_reflink(fileinfo['id'], fileinfo) if fn == 'index.md': index_found = True # start from fileinfo of index file navinfo = self.make_navinfo(relpath, fileinfo) self.navlist.append(navinfo) self.validate_navinfo(navinfo) self.add_reflink(navinfo['id'], navinfo) # add nav info to tag map self.add_info_to_tagmap(navinfo) else: content_found = True # add id for non-index files to tag tags self.add_info_to_tagmap(fileinfo) # a folder with content but no index is an error if content_found and not index_found: raise UrubuError(_error.no_index, msg='', fn=relpath)
def get_contentinfo(self): """Get info form the markdown content files.""" pattern = "*.md" for path, dirnames, filenames in os.walk(workdir): relpath = get_relpath(path, workdir) for fn in filenames: if fnmatch.fnmatch(fn, pattern): relfn = os.path.join(relpath, fn) meta = readers.get_yamlfm(relfn) if meta is None: warn(yamlfm_warning.format(relfn), UrubuWarning) continue info = self.make_fileinfo(relfn, meta) self.fileinfo.append(info) # validate after file info has been added so it can be used self.validate_fileinfo(relfn, info) self.add_reflink(info["id"], info) if fn == "index.md": info = self.make_navinfo(relpath, meta) self.navinfo.append(info) self.validate_navinfo(relfn, info) self.add_reflink(info["id"], info)