@@ -2953,15 +2953,15 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2953
2953
elif fmt == "json" or fnmatch (filename .lower (), "*.json*" ):
2954
2954
json_str = json .dumps (self .as_dict ())
2955
2955
if filename :
2956
- with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
2956
+ with zopen (filename , mode = "wt" ) as file :
2957
2957
file .write (json_str )
2958
2958
return json_str
2959
2959
elif fmt == "xsf" or fnmatch (filename .lower (), "*.xsf*" ):
2960
2960
from pymatgen .io .xcrysden import XSF
2961
2961
2962
2962
res_str = XSF (self ).to_str ()
2963
2963
if filename :
2964
- with zopen (filename , mode = "wt" , encoding = "utf-8 " ) as file :
2964
+ with zopen (filename , mode = "wt" , encoding = "utf8 " ) as file :
2965
2965
file .write (res_str )
2966
2966
return res_str
2967
2967
elif (
@@ -2987,15 +2987,15 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
2987
2987
yaml .dump (self .as_dict (), str_io )
2988
2988
yaml_str = str_io .getvalue ()
2989
2989
if filename :
2990
- with zopen (filename , mode = "wt" , encoding = "utf-8" ) as file :
2990
+ with zopen (filename , mode = "wt" ) as file :
2991
2991
file .write (yaml_str )
2992
2992
return yaml_str
2993
2993
elif fmt == "aims" or fnmatch (filename , "geometry.in" ):
2994
2994
from pymatgen .io .aims .inputs import AimsGeometryIn
2995
2995
2996
2996
geom_in = AimsGeometryIn .from_structure (self )
2997
2997
if filename :
2998
- with zopen (filename , mode = "wt" , encoding = "utf-8 " ) as file :
2998
+ with zopen (filename , mode = "w " ) as file :
2999
2999
file .write (geom_in .get_header (filename ))
3000
3000
file .write (geom_in .content )
3001
3001
file .write ("\n " )
@@ -3010,7 +3010,7 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
3010
3010
3011
3011
res_str = ResIO .structure_to_str (self )
3012
3012
if filename :
3013
- with zopen (filename , mode = "wt" , encoding = "utf-8 " ) as file :
3013
+ with zopen (filename , mode = "wt" , encoding = "utf8 " ) as file :
3014
3014
file .write (res_str )
3015
3015
return res_str
3016
3016
elif fmt == "pwmat" or fnmatch (filename .lower (), "*.pwmat" ) or fnmatch (filename .lower (), "*.config" ):
@@ -3173,7 +3173,7 @@ def from_file(
3173
3173
return struct
3174
3174
3175
3175
fname = os .path .basename (filename )
3176
- with zopen (filename , mode = "rt" , errors = "replace" , encoding = "utf-8" ) as file :
3176
+ with zopen (filename , mode = "rt" , errors = "replace" ) as file :
3177
3177
contents = file .read ()
3178
3178
if fnmatch (fname .lower (), "*.cif*" ) or fnmatch (fname .lower (), "*.mcif*" ):
3179
3179
return cls .from_str (
@@ -3919,7 +3919,7 @@ def to(self, filename: str = "", fmt: str = "") -> str | None:
3919
3919
elif fmt == "json" or fnmatch (filename , "*.json*" ) or fnmatch (filename , "*.mson*" ):
3920
3920
json_str = json .dumps (self .as_dict ())
3921
3921
if filename :
3922
- with zopen (filename , mode = "wt" , encoding = "utf-8 " ) as file :
3922
+ with zopen (filename , mode = "wt" , encoding = "utf8 " ) as file :
3923
3923
file .write (json_str )
3924
3924
return json_str
3925
3925
elif fmt in {"yaml" , "yml" } or fnmatch (filename , "*.yaml*" ) or fnmatch (filename , "*.yml*" ):
@@ -3928,7 +3928,7 @@ def to(self, filename: str = "", fmt: str = "") -> str | None:
3928
3928
yaml .dump (self .as_dict (), str_io )
3929
3929
yaml_str = str_io .getvalue ()
3930
3930
if filename :
3931
- with zopen (filename , mode = "wt" , encoding = "utf-8 " ) as file :
3931
+ with zopen (filename , mode = "wt" , encoding = "utf8 " ) as file :
3932
3932
file .write (yaml_str )
3933
3933
return yaml_str
3934
3934
else :
@@ -4010,7 +4010,7 @@ def from_file(cls, filename: PathLike) -> Self | None:
4010
4010
"""
4011
4011
filename = str (filename )
4012
4012
4013
- with zopen (filename , mode = "rt" , encoding = "utf-8" ) as file :
4013
+ with zopen (filename ) as file :
4014
4014
contents = file .read ()
4015
4015
fname = filename .lower ()
4016
4016
if fnmatch (fname , "*.xyz*" ):
0 commit comments