diff options
Diffstat (limited to 'libmproxy/flow.py')
-rw-r--r-- | libmproxy/flow.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 97ebc572..f9e2b94d 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -945,6 +945,25 @@ class FlowMaster(controller.Master): self.stream = None +def read_flows_from_paths(paths): + """ + Given a list of filepaths, read all flows and return a list of them. + From a performance perspective, streaming would be advisable - + however, if there's an error with one of the files, we want it to be raised immediately. + + If an error occurs, a FlowReadError will be raised. + """ + try: + flows = [] + for path in paths: + path = os.path.expanduser(path) + with file(path, "rb") as f: + flows.extend(FlowReader(f).stream()) + except IOError as e: + raise FlowReadError(e.strerror) + return flows + + class FlowWriter: def __init__(self, fo): self.fo = fo |