Closed truth-quark closed 6 months ago
Refactor
Stash
class &ATM_STASHLIST
to dict lookup (avoidStash
obj creation to convert/look up codes)
ATM_STASHLIST
is already a dictionary. How do you want to refactor it?
I haven't well understood the picture of the new structure you have in mind.
- Implement custom
__getitem__
,__setitem__
to work withstr
, stash codes etc
In the point below you mentioned removing the Stash
class. Where do you want to implement the custom __getitem__
and __setitem__
methods?
- Remove existing
Stash
class, usedict
interface for standard python interoperability
Not sure why you want to remove the Stash
class. I believe having a STASH object is useful in many different subcommands (future ones as well).
- Move lookup to
um_utils
module as it's part of unified model code
We could move the Stash
class to the um_utils
module.
But I still haven't really understood the structure of such 'lookup' you refer to.
- Delete the
stash_utils
module
This can be done If we move the Stash
class to the um_utils
module.
Refactor
Stash
class &ATM_STASHLIST
to dict lookup (avoidStash
obj creation to convert/look up codes)
ATM_STASHLIST
is already a dictionary. How do you want to refactor it? I haven't well understood the picture of the new structure you have in mind.
- Implement custom
__getitem__
,__setitem__
to work withstr
, stash codes etcIn the point below you mentioned removing the
Stash
class. Where do you want to implement the custom__getitem__
and__setitem__
methods?
Ooops, I mucked up the original ticket text. This should be fixed, explaining refactoring the Stash
class into a customised dict
for the ATM list.
I'm currently working on an example of the above work in another branch...
Captured refactoring of stash_utils in #20
I'll reopen as it covers refactoring the custom Stash
class (which needs some tweaks to bring in line with Python conventions).
@truth-quark Please edit the body of this issue:
I've updated the issue/crossed out the structural changes from #33.
The class modifications need more thought, so I'll update that after another code experiment.
The
Stash
class instash_utils.py
adds another object layer for accessing theATM_STASHLIST
lookup. This has a few problems:Stash
instances are created every time a code is looked up.Ideally,
Stash
should be refactored to a dict for simplification & provide a common Pythonic interface. Each code lookup should return an existingATM_STASHLIST
entry, negating the need to create a newStash
record object.Tasks:
Refactor(see #20)amami/stash_utils/__init__.py
toamami/stash.py
(package to simple module)Stash
class:Stash
class to inherit fromUserDict
__getitem__
,__setitem__
to convertstr
, stash codes etc toint
keysATM_STASHLIST
to instance of the new Stash dict typeMore ideas (see #33):
MoveStash
lookup intoum_utils
module as it's part of unified model codeDelete thestash_utils
module