Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow programmatic setting of missing modules in sc.loadobj() #141

Closed
cliffckerr opened this issue Oct 27, 2020 · 1 comment
Closed

Allow programmatic setting of missing modules in sc.loadobj() #141

cliffckerr opened this issue Oct 27, 2020 · 1 comment
Labels
enhancement New feature
Milestone

Comments

@cliffckerr
Copy link
Member

cliffckerr commented Oct 27, 2020

Automate this:

sc.loadobj('my_old_pickle.obj', remapping={'fp_data.DHS.calobj.CalObj':fp_utils.calobj.CalObj})

e.g. via

def load(*args, **kwargs):
    ''' Tiny alias to sc.loadobj() to load saved calendar objects '''
    import sys
    import types
    import fp_data
    # First, add any placeholder modules that have been subsequently removed
    fp_data.DHS = types.ModuleType('DHS') 
    fp_data.DHS.calobj = types.ModuleType('calobj') 
    sys.modules['fp_data.DHS'] = fp_data.DHS
    sys.modules['fp_data.DHS.calobj'] = fp_data.DHS.calobj
    fp_data.DHS.calobj.CalObj = CalObj
    cal = sc.loadobj(*args, **kwargs)
    assert isinstance(cal, CalObj)
    return cal
@cliffckerr cliffckerr mentioned this issue Nov 29, 2020
20 tasks
@cliffckerr cliffckerr added the enhancement New feature label Dec 6, 2020
@cliffckerr cliffckerr added this to the rc1.03 milestone Mar 12, 2021
@cliffckerr
Copy link
Member Author

Closed by #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

No branches or pull requests

1 participant