Skip to content

Commit

Permalink
attach block attrs to package
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jul 24, 2024
1 parent 189f277 commit 43d21fe
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions flopy4/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ def get_block(pkg_name, block_name, params):

class MFPackageMeta(type):
def __new__(cls, clsname, bases, attrs):
new = super().__new__(cls, clsname, bases, attrs)
if clsname == "MFPackage":
return new
return super().__new__(cls, clsname, bases, attrs)

# detect package name
pkg_name = clsname.replace("Package", "")
Expand All @@ -34,8 +33,7 @@ def __new__(cls, clsname, bases, attrs):
if issubclass(type(v), MFParam)
}
)
new.params = params
new.blocks = MFBlocks(
blocks = MFBlocks(
{
block_name: get_block(
pkg_name=pkg_name,
Expand All @@ -47,7 +45,13 @@ def __new__(cls, clsname, bases, attrs):
)
}
)
return new

attrs["params"] = params
attrs["blocks"] = blocks
for block_name, block in blocks.items():
attrs[block_name] = block

return super().__new__(cls, clsname, bases, attrs)


class MFPackageMappingMeta(MFPackageMeta, ABCMeta):
Expand Down

0 comments on commit 43d21fe

Please sign in to comment.