webtools package¶
Submodules¶
webtools.html_table module¶
webtools.html_table_data module¶
A datastructures that represent an HTML table with cells of variable height.
- class webtools.html_table_data.HTMLTableData(parameters: webtools.html_table_data.Parameters, rows: List[webtools.html_table_data.Row])[source]¶
Bases:
object
- property max_row_height¶
- parameters: Parameters¶
- class webtools.html_table_data.Parameters(headings: Dict[str, webtools.html_table_data.Markdown])[source]¶
Bases:
object
webtools.parallel module¶
Generic parallelization functions using asyncio.
- webtools.parallel.asynchronous(func, inputs, concurrency=4, **kwds)[source]¶
Executes func(task) for every task in tasks.
Parameters¶
func : async funcion(client: aiohttp.ClientSession, *) -> Result tasks : iterable of (unique) input for each function invocation * : constants arguments and keywords to be passed to each function
- webtools.parallel.run(func, items, batch_size, duration, n_threads=2, **kwds)[source]¶
Executes func(i) N x M times. It is assumed that all function invocations are independent.
Parameters¶
func : async funcion(client: aiohttp.ClientSession, *) -> Result items : inputs per function call batch_size : number of function call results that are yielded duration : timeout of the process. This evaluated between batches and not during batches. n_threads : int concurrency : max. number of async connections per thread **kwds : arguments for func. func() must be threadsafe batches : iterable of iterables
webtools.parallel_requests module¶
- async webtools.parallel_requests.get(session: ClientSession, i: int, url='', timeout=10, **kwds)[source]¶
webtools.pipeline module¶
- class webtools.pipeline.Buffer(*args, n=2, **kwds)[source]¶
Bases:
Processor
A Processor with an explicit buffer that can be used to adjust buffer sizes. E.g. group or split up items.
- class webtools.pipeline.Combiner(*args, n=2, **kwds)[source]¶
Bases:
Buffer
Many-to-one e.g. Combiner(n=2) transforms items into pairs of items
- class webtools.pipeline.Distributer(*args, n=2, **kwds)[source]¶
Bases:
Buffer
One-to-many e.g. Distributer(n=2) transforms pairs into items
- class webtools.pipeline.Pipeline(items=[], *, processors: List[Processor] = [])[source]¶
Bases:
Processor
A Processor that combines of multiple processing-stages.
Note that len(Pipeline) returns the length of the buffer of the whole Pipeline and not the total length of all components.
- class webtools.pipeline.Processor(items=[])[source]¶
Bases:
object
A queue-like object that can “process” items.
The superclass list allows the “queue” to be sorted and grouped. * Use .append() or .extend() to add items to the queue/buffer. * Use .process() to handle or process an item.
- static from_function(pure_func)[source]¶
Decorator that defines a “stateless” processor.
Usage¶
new_func = Processor.from_function(func)
Note that new_func and func must have the same name in order to be compatible with pickle.
Parameters¶
pure_func : (object) -> object
- class webtools.pipeline.PushPull(*args, strategy=Strategy.constant, **kwds)[source]¶
Bases:
Pipeline
- property in_queue¶
- n_processors = 1¶
- property out_queue¶
- class webtools.pipeline.Resource(processor: webtools.pipeline.Processor, delivery_queues: Tuple[queue.Queue, queue.Queue], demand_queues: Tuple[queue.Queue, queue.Queue] = None, strategy: webtools.pipeline.Strategy = <Strategy.push: 1>)[source]¶
Bases:
object
webtools.verify_server module¶
- webtools.verify_server.parse_url(url: str, default_scheme='http')[source]¶
Return the scheme, domain, port and path or a url
Parameters¶
The following inputs are supported: - https://example.com - www.example.com:80 - 1.0.0.1:443
Returns¶
- ParseResult(scheme=’http’, netloc=’example.com:443’, path=’/path;parameters’, params=’’,
query=’query’, fragment=’fragment’)
Module contents¶
A collection of web-related tools.
- html_table: Converts Python objects to HTML
- parallel_requests: Load testing
- verify_server: Verify connectivity to a URL