Skip to content

Commit

Permalink
Added PyMCNP Imports in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
BitterB0NG0 committed Aug 21, 2024
1 parent 4ca5a92 commit ba27921
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/pymcnp/cli/inpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import sys
import datetime

import pymcnp

from . import _io
from . import _save
from ..files.inp import inp
from ..files.inp import cell
from ..files.inp import surface
from ..files.inp import datum


def main(argv: list = sys.argv[1:]) -> None:
Expand All @@ -31,7 +29,7 @@ def main(argv: list = sys.argv[1:]) -> None:
if not os.path.isfile(argv[2]):
_io.error(_io.ERROR_FILE_NOT_FOUND)

inpt = inp.Inp.from_mcnp_file(argv[2])
inpt = pymcnp.inp.Inp.from_mcnp_file(argv[2])

inpts = _save.Save.get_save()
filename = f"mcnp-save-{datetime.datetime.utcnow().timestamp()}"
Expand All @@ -51,7 +49,9 @@ def main(argv: list = sys.argv[1:]) -> None:
if argv[2] not in inpts:
_io.error(_io.ERROR_ALIAS_NOT_FOUND)

inpts[argv[2]][1].cells.append(cell.Cell().from_mcnp(argv[3]))
inpts[argv[2]][1].cells.append(
pymcnp.cell.Cell().from_mcnp(argv[3])
)

with open(inpts[argv[2]][0], "w") as file:
file.write(inpts[argv[2]][1].to_mcnp())
Expand Down
11 changes: 6 additions & 5 deletions src/pymcnp/cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

import sys

import pymcnp

from . import _save
from . import _io
from ..files.inp import inp


class Ls:
Expand All @@ -23,7 +24,7 @@ class Ls:
"""

@staticmethod
def list_cells(inpt: inp.Inp) -> str:
def list_cells(inpt: pymcnp.inp.Inp) -> str:
"""
'list_cells' outputs strings of INP object cell information.
Expand All @@ -44,7 +45,7 @@ def list_cells(inpt: inp.Inp) -> str:
return out

@staticmethod
def list_surfaces(inpt: inp.Inp) -> str:
def list_surfaces(inpt: pymcnp.inp.Inp) -> str:
"""
'list_surfaces' outputs strings of INP object surface information.
Expand All @@ -64,7 +65,7 @@ def list_surfaces(inpt: inp.Inp) -> str:
return out

@staticmethod
def list_data(inpt: inp.Inp) -> str:
def list_data(inpt: pymcnp.inp.Inp) -> str:
"""
'list_data' outputs strings of INP object datum information.
Expand All @@ -85,7 +86,7 @@ def list_data(inpt: inp.Inp) -> str:
return out

@staticmethod
def list_inp(inpt: inp.Inp) -> str:
def list_inp(inpt: pymcnp.inp.Inp) -> str:
"""
'list_inp' outputs strings of all INP object information.
Expand Down
7 changes: 4 additions & 3 deletions src/pymcnp/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import os
import sys

import pymcnp

from . import _io
from . import _save
from ..files import inp


class Run:
Expand All @@ -32,7 +33,7 @@ def __init__(self, path: str, command: str = "mcnp"):
self.inpt: dict = None

@classmethod
def from_inp_object(cls, inpt: inp.Inp):
def from_inp_object(cls, inpt: pymcnp.inp.Inp):
"""
'from_inp_file' populates run objects from INP objects.
Expand Down Expand Up @@ -62,7 +63,7 @@ def from_inp_file(cls, filename: str):
if not os.path.isfile(filename):
raise ValueError

runner.inpt = inp.Inp().from_mcnp_file(filename)
runner.inpt = pymcnp.inp.Inp().from_mcnp_file(filename)
runner.filename = filename

return runner
Expand Down
4 changes: 2 additions & 2 deletions src/pymcnp/files/inp/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def to_mcnp(self) -> str:
INP for cell block objects.
"""

return "\n".join([cell.to_mcnp() for cell in self.cards.values()] + [""])
return "\n".join([cell.to_mcnp() for cell in self._cards.values()] + [""])

def to_arguments(self) -> list:
"""
Expand All @@ -77,4 +77,4 @@ def to_arguments(self) -> list:
List of cell card objects.
"""

return [card.to_arguments() for card in self.cards.values()]
return [card.to_arguments() for card in self._cards.values()]
4 changes: 2 additions & 2 deletions src/pymcnp/files/inp/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def to_mcnp(self) -> str:
source : INP for data block objects.
"""

return "\n".join([datum.to_mcnp() for datum in self.cards.values()])
return "\n".join([datum.to_mcnp() for datum in self._cards.values()])

def to_arguments(self) -> list:
"""
Expand All @@ -68,4 +68,4 @@ def to_arguments(self) -> list:
arguments (list): List of datum block objects.
"""

return [card.to_arguments() for card in self.cards.values()]
return [card.to_arguments() for card in self._cards.values()]
4 changes: 2 additions & 2 deletions src/pymcnp/files/inp/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def to_mcnp(self) -> str:
INP for surface block object.
"""

return "\n".join([surface.to_mcnp() for surface in self.cards.values()] + [""])
return "\n".join([surface.to_mcnp() for surface in self._cards.values()] + [""])

def to_arguments(self) -> list:
"""
Expand All @@ -78,7 +78,7 @@ def to_arguments(self) -> list:
arugments: List of surface blocks object.
"""

return [card.to_arguments() for card in self.cards.values()]
return [card.to_arguments() for card in self._cards.values()]

def to_cadquery(self, hasHeader: bool = False) -> str:
"""
Expand Down

0 comments on commit ba27921

Please sign in to comment.