Skip to content

Commit

Permalink
Fixes #232
Browse files Browse the repository at this point in the history
  • Loading branch information
khdesai committed Jan 9, 2019
1 parent 06e23b0 commit 7883614
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stix2/datastore/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from stix2 import v20, v21
from stix2.base import _STIXBase
from stix2.core import parse
from stix2.datastore import DataSink, DataSource, DataStoreMixin
from stix2.datastore import DataSink, DataSource, DataStoreMixin, DataSourceError
from stix2.datastore.filters import Filter, FilterSet, apply_common_filters
from stix2.utils import format_datetime, get_type_from_id, is_marking

Expand Down Expand Up @@ -546,7 +546,7 @@ def _check_path_and_write(self, stix_obj, encoding='utf-8'):

# TODO: Better handling of the overwriting case.
if os.path.isfile(file_path):
print("Attempted to overwrite file!", file_path, file=sys.stderr)
raise DataSourceError("Attempted to overwrite file (!) at: {}".format(file_path))
else:
with io.open(file_path, 'w', encoding=encoding) as f:
stix_obj = stix_obj.serialize(pretty=True, encoding=encoding, ensure_ascii=False)
Expand Down

0 comments on commit 7883614

Please sign in to comment.