def _parse_metadata(rootdir, for_yaml, index):
origcwd = os.getcwd()
os.chdir(rootdir)
logger.debug("Parsing metadata:")
for f in for_yaml:
# Make the path to the file relative to the root directory
#f = os.path.relpath(f, rootdir)
logger.debug("Current file:")
logger.debug(f)
#only if there is more than the backbone.
if for_yaml[f]['start'] != '':
logger.debug("start: " + for_yaml[f]['start'])
logger.debug("stop: " + for_yaml[f]['stop'])
y = ''
for i in range(
int(for_yaml[f]['start']),
int(for_yaml[f]['stop'])
):
y = y + linecache.getline(f, i)
logger.debug("y: " + str(y))
metadata = yaml.safe_load(y)
#write the metadata to the index.
for item in metadata:
index['files'][f][item] = metadata[item]
linecache.clearcache()
os.chdir(origcwd)
logger.debug("Parsing metadata: Done.")
return index
评论列表
文章目录