Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wumpus-tessaris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lanti Davide
wumpus-tessaris
Commits
e2cb799b
Commit
e2cb799b
authored
3 years ago
by
Tessaris Sergio
Browse files
Options
Downloads
Patches
Plain Diff
chore: better errors reporting
parent
d160b7a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wumpus/runner.py
+8
-4
8 additions, 4 deletions
wumpus/runner.py
with
8 additions
and
4 deletions
wumpus/runner.py
+
8
−
4
View file @
e2cb799b
...
...
@@ -7,6 +7,7 @@ Functions to run the players
import
argparse
import
copy
import
importlib
import
inspect
import
io
import
json
import
os
...
...
@@ -51,17 +52,20 @@ def get_player_class(object_ref: str, path: os.PathLike = None) -> Union[Type[On
# see <https://packaging.python.org/specifications/entry-points/#data-model>
modname
,
qualname_separator
,
qualname
=
object_ref
.
partition
(
'
:
'
)
obj
=
importlib
.
import_module
(
modname
)
try
:
obj
=
importlib
.
import_module
(
modname
)
except
ModuleNotFoundError
as
e
:
raise
ImportError
(
f
'
Cannot find entrypoint
{
object_ref
}
:
{
e
}
'
)
if
qualname_separator
:
for
attr
in
qualname
.
split
(
'
.
'
):
try
:
obj
=
getattr
(
obj
,
attr
)
except
AttributeError
as
e
:
raise
ImportError
(
'
Cannot
import {} object: {}
'
.
format
(
object_ref
,
e
)
)
raise
ImportError
(
f
'
Cannot
find entrypoint
{
object_ref
}
:
{
e
}
'
)
player_class
=
obj
if
not
issubclass
(
player_class
,
(
OnlinePlayer
,
OfflinePlayer
)):
raise
NotImplementedError
(
'
class
{
} is not a
player class
'
.
format
(
player_class
)
)
if
not
inspect
.
isclass
(
player_class
)
or
not
issubclass
(
player_class
,
(
OnlinePlayer
,
OfflinePlayer
)):
raise
RuntimeError
(
f
'
{
player_
class
}
is not a
subclass of OnlinePlayer or OfflinePlayer
'
)
return
player_class
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment