Skip to content

Commit

Permalink
Linting, avoid using built-in names, consistent quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed May 28, 2024
1 parent ffc2ea8 commit fbad7bf
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions mctools/generic/get_spacegroup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

import argparse
import os
from pathlib import Path
from typing import Optional

Expand All @@ -11,19 +10,19 @@

def get_default_file() -> Path:
for candidate in ("geometry.in", "POSCAR", "castep.cell"):
if (input := Path.cwd() / candidate).is_file():
return input
else:
raise ValueError("Input file not specified, no default found.")
if (structure_file := Path.cwd() / candidate).is_file():
return structure_file

raise ValueError("Input file not specified, no default found.")


def get_spacegroup(filename: Optional[Path] = None,
format: Optional[str] = None):
filetype: Optional[str] = None):

if filename is None:
filename = get_default_file()

atoms = ase.io.read(str(filename), format=format)
atoms = ase.io.read(str(filename), format=filetype)
cell = (atoms.cell.array, atoms.get_scaled_positions(), atoms.numbers)

print("| Threshold / Å | Space group |")
Expand All @@ -36,9 +35,9 @@ def get_spacegroup(filename: Optional[Path] = None,

def main():
parser = argparse.ArgumentParser()
parser.add_argument('filename', type=Path, default=None, nargs="?",
parser.add_argument("filename", type=Path, default=None, nargs="?",
help="Input structure file")
parser.add_argument('-f', '--format', type=str, default=None,
parser.add_argument("-f", "--filetype", type=str, default=None,
help="File format for ASE importer")
args = parser.parse_args()
get_spacegroup(filename=args.filename, format=args.format)
get_spacegroup(filename=args.filename, filetype=args.filetype)

0 comments on commit fbad7bf

Please sign in to comment.