[pp:metadata] add 'newline' option (#8439)
* Add configuration setting to control newline characters in metadata. * update docs/configuration * introduce 'open()' method * add 'newline' test
This commit is contained in:
@@ -117,9 +117,15 @@ class MetadataPP(PostProcessor):
|
||||
self.mtime = options.get("mtime")
|
||||
self.omode = options.get("open", omode)
|
||||
self.encoding = options.get("encoding", "utf-8")
|
||||
self.newline = options.get("newline")
|
||||
self.skip = options.get("skip", False)
|
||||
self.meta_path = options.get("metadata-path")
|
||||
|
||||
def open(self, path):
|
||||
return open(path, self.omode,
|
||||
encoding=self.encoding,
|
||||
newline=self.newline)
|
||||
|
||||
def run(self, pathfmt):
|
||||
archive = self.archive
|
||||
if archive and archive.check(pathfmt.kwdict):
|
||||
@@ -138,11 +144,11 @@ class MetadataPP(PostProcessor):
|
||||
return
|
||||
|
||||
try:
|
||||
with open(path, self.omode, encoding=self.encoding) as fp:
|
||||
with self.open(path) as fp:
|
||||
self.write(fp, pathfmt.kwdict)
|
||||
except FileNotFoundError:
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
with open(path, self.omode, encoding=self.encoding) as fp:
|
||||
with self.open(path) as fp:
|
||||
self.write(fp, pathfmt.kwdict)
|
||||
|
||||
if archive:
|
||||
|
||||
Reference in New Issue
Block a user