Skip to content

Commit b58682d

Browse files
williambdeanWill DeanWill
authored
support for pathlib object when saving Element (#103)
* support for pathlib object * Path is the parent for Windows Path and non-Windows Path objects Co-authored-by: Will Dean <[email protected]> Co-authored-by: Will <[email protected]>
1 parent 629ed34 commit b58682d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

branca/element.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from urllib.request import urlopen
1515
from binascii import hexlify
1616
from os import urandom
17+
from pathlib import Path
1718

1819
from jinja2 import Environment, PackageLoader, Template
1920

@@ -159,7 +160,7 @@ def save(self, outfile, close_file=True, **kwargs):
159160
close_file : bool, default True
160161
Whether the file has to be closed after write.
161162
"""
162-
if isinstance(outfile, str) or isinstance(outfile, bytes):
163+
if isinstance(outfile, (str, bytes, Path)):
163164
fid = open(outfile, 'wb')
164165
else:
165166
fid = outfile

0 commit comments

Comments
 (0)