Changeset 1759:e207929eef6c


Ignore:
Timestamp:
Jan 28, 2019, 8:43:10 PM (3 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
amend_source:
ad9980e598c3a9abc8b2ac7048f26f5bfa200bbe
Message:
Generalize session factory creation

Allow more than one script in the `factory` function. For each script
in `scripts`, a new `ScriptedSession` with the corresponding `script`
will be used when the factory is called by `FTPHost._make_session`.

The implementation seems to work fine, but it's even more difficult
to understand than the previous version. I'm considering implementing
this with a class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/scripted_session.py

    r1758 r1759  
    128128
    129129
    130 def factory(script):
     130def factory(*scripts):
    131131    """
    132132    Return a session factory taking the scripted data from `script`.
     
    143143    # doesn't know about, return the actual factory that will be used
    144144    # by the `FTPHost` instance.
     145    script_iter = iter(scripts)
    145146    def session_factory(host, user, password):
    146147        print("\nCalled session factory\n")
    147         return ScriptedSession(script)
     148        return ScriptedSession(next(script_iter))
    148149    return session_factory
Note: See TracChangeset for help on using the changeset viewer.