Skip to content

Commit

Permalink
support for pathlib object when saving Element (#103)
Browse files Browse the repository at this point in the history
* support for pathlib object

* Path is the parent for Windows Path and non-Windows Path objects

Co-authored-by: Will Dean <wdean@homepartners.com>
Co-authored-by: Will <swilliam127@gmail.com>
  • Loading branch information
3 people committed Feb 15, 2022
1 parent 629ed34 commit b58682d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion branca/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from urllib.request import urlopen
from binascii import hexlify
from os import urandom
from pathlib import Path

from jinja2 import Environment, PackageLoader, Template

Expand Down Expand Up @@ -159,7 +160,7 @@ def save(self, outfile, close_file=True, **kwargs):
close_file : bool, default True
Whether the file has to be closed after write.
"""
if isinstance(outfile, str) or isinstance(outfile, bytes):
if isinstance(outfile, (str, bytes, Path)):
fid = open(outfile, 'wb')
else:
fid = outfile
Expand Down

0 comments on commit b58682d

Please sign in to comment.