Server IP : 85.214.239.14 / Your IP : 3.142.55.138 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/usr/share/doc/python3-resolvelib/examples/visualization/ |
Upload File : |
import re import sys from ..reporter_demo import Candidate, Requirement from .generate import generate_html from .reporter import GraphGeneratingReporter def process_arguments(function, args): function_arg_info = { "starting": [], "starting_round": [int], "ending_round": [int, ...], "ending": [...], "adding_requirement": ["requirement", "candidate"], "backtracking": ["candidate"], "pinning": ["candidate"], } assert function in function_arg_info retval = [] argument_types = function_arg_info[function] for arg_type in argument_types: if arg_type is int: to_convert, _, args = args.partition(", ") value = int(to_convert) elif arg_type == "requirement": match = re.match( r"^<Requirement\('?([\w\-\._~]+)(.*?)'?\)>(.*)", args ) assert match, repr(args) name, spec, args = match.groups() value = Requirement(name, spec) elif arg_type == "candidate": match = re.match(r"^(?:<(.+?)==(.+?)>|None)(.*)", args) assert match, repr(args) name, version, args = match.groups() if name and version: value = Candidate(name, version) else: assert not (name or version) value = None elif arg_type is ...: # just consume it value, _, args = args.partition(", ") else: raise RuntimeError() retval.append(value) if args.startswith(","): args = args[1:].lstrip() return function, retval def parse_line(line): one = line.strip() function, _, args = one.partition("(") assert args[-1] == ")" args = args[:-1] return process_arguments(function, args) def run_reporter_from_logs(reporter, *, logs): for line in logs: function_name, args = parse_line(line) function = getattr(reporter, function_name) function(*args) if __name__ == "__main__": usage = "usage: visualization.py reporter-demo-output.txt out.html" assert len(sys.argv) == 3, usage reporter = GraphGeneratingReporter() with open(sys.argv[1]) as f_one: run_reporter_from_logs(reporter, logs=f_one) with open(sys.argv[2], "w") as f_two: generate_html(reporter.evolution, outfile=f_two)