@@ -3191,109 +3191,109 @@ def from_file( # type:ignore[override]
3191
3191
fname = os .path .basename (filename )
3192
3192
with zopen (filename , mode = "rt" , errors = "replace" , encoding = "utf-8" ) as file :
3193
3193
contents = file .read ()
3194
- if fnmatch (fname .lower (), "*.cif*" ) or fnmatch (fname .lower (), "*.mcif*" ):
3195
- return cls .from_str (
3196
- contents ,
3197
- fmt = "cif" ,
3198
- primitive = primitive ,
3199
- sort = sort ,
3200
- merge_tol = merge_tol ,
3201
- ** kwargs ,
3202
- )
3203
- if fnmatch (fname , "*POSCAR*" ) or fnmatch (fname , "*CONTCAR*" ) or fnmatch (fname , "*.vasp" ):
3204
- struct = cls .from_str (
3205
- contents ,
3206
- fmt = "poscar" ,
3207
- primitive = primitive ,
3208
- sort = sort ,
3209
- merge_tol = merge_tol ,
3210
- ** kwargs ,
3211
- )
3194
+ if fnmatch (fname .lower (), "*.cif*" ) or fnmatch (fname .lower (), "*.mcif*" ):
3195
+ return cls .from_str (
3196
+ contents ,
3197
+ fmt = "cif" ,
3198
+ primitive = primitive ,
3199
+ sort = sort ,
3200
+ merge_tol = merge_tol ,
3201
+ ** kwargs ,
3202
+ )
3203
+ if fnmatch (fname , "*POSCAR*" ) or fnmatch (fname , "*CONTCAR*" ) or fnmatch (fname , "*.vasp" ):
3204
+ struct = cls .from_str (
3205
+ contents ,
3206
+ fmt = "poscar" ,
3207
+ primitive = primitive ,
3208
+ sort = sort ,
3209
+ merge_tol = merge_tol ,
3210
+ ** kwargs ,
3211
+ )
3212
3212
3213
- elif fnmatch (fname , "CHGCAR*" ) or fnmatch (fname , "LOCPOT*" ):
3214
- from pymatgen .io .vasp import Chgcar
3215
-
3216
- struct = Chgcar .from_file (filename , ** kwargs ).structure
3217
- elif fnmatch (fname , "vasprun*.xml*" ):
3218
- from pymatgen .io .vasp import Vasprun
3219
-
3220
- struct = Vasprun (filename , ** kwargs ).final_structure
3221
- elif fnmatch (fname .lower (), "*.cssr*" ):
3222
- return cls .from_str (
3223
- contents ,
3224
- fmt = "cssr" ,
3225
- primitive = primitive ,
3226
- sort = sort ,
3227
- merge_tol = merge_tol ,
3228
- ** kwargs ,
3229
- )
3230
- elif fnmatch (fname , "*.json*" ) or fnmatch (fname , "*.mson*" ):
3231
- return cls .from_str (
3232
- contents ,
3233
- fmt = "json" ,
3234
- primitive = primitive ,
3235
- sort = sort ,
3236
- merge_tol = merge_tol ,
3237
- ** kwargs ,
3238
- )
3239
- elif fnmatch (fname , "*.yaml*" ) or fnmatch (fname , "*.yml*" ):
3240
- return cls .from_str (
3241
- contents ,
3242
- fmt = "yaml" ,
3243
- primitive = primitive ,
3244
- sort = sort ,
3245
- merge_tol = merge_tol ,
3246
- ** kwargs ,
3247
- )
3248
- elif fnmatch (fname , "*.xsf" ):
3249
- return cls .from_str (
3250
- contents ,
3251
- fmt = "xsf" ,
3252
- primitive = primitive ,
3253
- sort = sort ,
3254
- merge_tol = merge_tol ,
3255
- ** kwargs ,
3256
- )
3257
- elif fnmatch (fname , "input*.xml" ):
3258
- from pymatgen .io .exciting import ExcitingInput
3259
-
3260
- return ExcitingInput .from_file (fname , ** kwargs ).structure
3261
- elif fnmatch (fname , "*rndstr.in*" ) or fnmatch (fname , "*lat.in*" ) or fnmatch (fname , "*bestsqs*" ):
3262
- return cls .from_str (
3263
- contents ,
3264
- fmt = "mcsqs" ,
3265
- primitive = primitive ,
3266
- sort = sort ,
3267
- merge_tol = merge_tol ,
3268
- ** kwargs ,
3269
- )
3270
- elif fnmatch (fname , "CTRL*" ):
3271
- from pymatgen .io .lmto import LMTOCtrl
3272
-
3273
- return LMTOCtrl .from_file (filename = filename , ** kwargs ).structure
3274
- elif fnmatch (fname , "geometry.in*" ):
3275
- return cls .from_str (
3276
- contents ,
3277
- fmt = "aims" ,
3278
- primitive = primitive ,
3279
- sort = sort ,
3280
- merge_tol = merge_tol ,
3281
- ** kwargs ,
3282
- )
3283
- elif fnmatch (fname , "inp*.xml" ) or fnmatch (fname , "*.in*" ) or fnmatch (fname , "inp_*" ):
3284
- from pymatgen .io .fleur import FleurInput
3213
+ elif fnmatch (fname , "CHGCAR*" ) or fnmatch (fname , "LOCPOT*" ):
3214
+ from pymatgen .io .vasp import Chgcar
3215
+
3216
+ struct = Chgcar .from_file (filename , ** kwargs ).structure
3217
+ elif fnmatch (fname , "vasprun*.xml*" ):
3218
+ from pymatgen .io .vasp import Vasprun
3219
+
3220
+ struct = Vasprun (filename , ** kwargs ).final_structure
3221
+ elif fnmatch (fname .lower (), "*.cssr*" ):
3222
+ return cls .from_str (
3223
+ contents ,
3224
+ fmt = "cssr" ,
3225
+ primitive = primitive ,
3226
+ sort = sort ,
3227
+ merge_tol = merge_tol ,
3228
+ ** kwargs ,
3229
+ )
3230
+ elif fnmatch (fname , "*.json*" ) or fnmatch (fname , "*.mson*" ):
3231
+ return cls .from_str (
3232
+ contents ,
3233
+ fmt = "json" ,
3234
+ primitive = primitive ,
3235
+ sort = sort ,
3236
+ merge_tol = merge_tol ,
3237
+ ** kwargs ,
3238
+ )
3239
+ elif fnmatch (fname , "*.yaml*" ) or fnmatch (fname , "*.yml*" ):
3240
+ return cls .from_str (
3241
+ contents ,
3242
+ fmt = "yaml" ,
3243
+ primitive = primitive ,
3244
+ sort = sort ,
3245
+ merge_tol = merge_tol ,
3246
+ ** kwargs ,
3247
+ )
3248
+ elif fnmatch (fname , "*.xsf" ):
3249
+ return cls .from_str (
3250
+ contents ,
3251
+ fmt = "xsf" ,
3252
+ primitive = primitive ,
3253
+ sort = sort ,
3254
+ merge_tol = merge_tol ,
3255
+ ** kwargs ,
3256
+ )
3257
+ elif fnmatch (fname , "input*.xml" ):
3258
+ from pymatgen .io .exciting import ExcitingInput
3259
+
3260
+ return ExcitingInput .from_file (fname , ** kwargs ).structure
3261
+ elif fnmatch (fname , "*rndstr.in*" ) or fnmatch (fname , "*lat.in*" ) or fnmatch (fname , "*bestsqs*" ):
3262
+ return cls .from_str (
3263
+ contents ,
3264
+ fmt = "mcsqs" ,
3265
+ primitive = primitive ,
3266
+ sort = sort ,
3267
+ merge_tol = merge_tol ,
3268
+ ** kwargs ,
3269
+ )
3270
+ elif fnmatch (fname , "CTRL*" ):
3271
+ from pymatgen .io .lmto import LMTOCtrl
3272
+
3273
+ return LMTOCtrl .from_file (filename = filename , ** kwargs ).structure
3274
+ elif fnmatch (fname , "geometry.in*" ):
3275
+ return cls .from_str (
3276
+ contents ,
3277
+ fmt = "aims" ,
3278
+ primitive = primitive ,
3279
+ sort = sort ,
3280
+ merge_tol = merge_tol ,
3281
+ ** kwargs ,
3282
+ )
3283
+ elif fnmatch (fname , "inp*.xml" ) or fnmatch (fname , "*.in*" ) or fnmatch (fname , "inp_*" ):
3284
+ from pymatgen .io .fleur import FleurInput
3285
3285
3286
- struct = FleurInput .from_file (filename , ** kwargs ).structure
3287
- elif fnmatch (fname , "*.res" ):
3288
- from pymatgen .io .res import ResIO
3286
+ struct = FleurInput .from_file (filename , ** kwargs ).structure
3287
+ elif fnmatch (fname , "*.res" ):
3288
+ from pymatgen .io .res import ResIO
3289
3289
3290
- struct = ResIO .structure_from_file (filename , ** kwargs )
3291
- elif fnmatch (fname .lower (), "*.config*" ) or fnmatch (fname .lower (), "*.pwmat*" ):
3292
- from pymatgen .io .pwmat import AtomConfig
3290
+ struct = ResIO .structure_from_file (filename , ** kwargs )
3291
+ elif fnmatch (fname .lower (), "*.config*" ) or fnmatch (fname .lower (), "*.pwmat*" ):
3292
+ from pymatgen .io .pwmat import AtomConfig
3293
3293
3294
- struct = AtomConfig .from_file (filename , ** kwargs ).structure
3295
- else :
3296
- raise ValueError (f"Unrecognized extension in { filename = } " )
3294
+ struct = AtomConfig .from_file (filename , ** kwargs ).structure
3295
+ else :
3296
+ raise ValueError (f"Unrecognized extension in { filename = } " )
3297
3297
if sort :
3298
3298
struct = struct .get_sorted_structure ()
3299
3299
if merge_tol :
0 commit comments