Skip to content

Commit

Permalink
Adapted naming
Browse files Browse the repository at this point in the history
  • Loading branch information
max3-2 authored and john-hen committed Feb 24, 2021
1 parent 08c7989 commit 7b88437
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def load(self, file, reload=False):
file = Path(file)

# Check if model is already loaded
if file in self.modelFiles() and not reload:
logger.info('Found model in memory')
return self.models()[self.modelFiles().index(file)]
if file in self.paths() and not reload:
logger.info('Found model in memory, returning model from memory')
return self.models()[self.paths().index(file)]

tag = self.java.uniquetag('model')
logger.info(f'Loading model "{file.name}".')
Expand Down Expand Up @@ -220,9 +220,9 @@ def models(self):
"""Returns all model objects currently held in memory."""
return [Model(self.java.model(tag)) for tag in self.java.tags()]

def modelFiles(self):
def paths(self):
"""
Returns the file pathes of all models in memory (abspath). Models without
Returns the file paths of all models in memory (abspath). Models without
files will return empty path.
"""
return [Path(str(self.java.model(tag).getFilePath())) for tag in self.java.tags()]
Expand Down
4 changes: 4 additions & 0 deletions mph/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def name(self):
name = name.rsplit('.', maxsplit=1)[0]
return name

def path(self):
"""Returns the abspath of the model's mpf file"""
return Path(str(self.java.getFilePath()))

def parameters(self):
"""
Returns the global model parameters.
Expand Down

0 comments on commit 7b88437

Please sign in to comment.