| 42 | ''' |
| 43 | |
| 44 | class PlatformView(object): |
| 45 | def __init__(self): |
| 46 | self.slug = "" |
| 47 | |
| 48 | def check_finish(self, title): |
| 49 | return False |
| 50 | |
| 51 | def get_problem(self, id): |
| 52 | return None |
| 53 | |
| 54 | def check_flask(self, id): |
| 55 | return False |
| 56 | |
| 57 | def is_valid_title(self, title): |
| 58 | return title.isdigit() |
| 59 | |
| 60 | def get_module_problem_count(self, m): |
| 61 | c = 0 |
| 62 | for n in m.nodes: |
| 63 | c += len(n.problems) |
| 64 | return c |
| 65 | |
| 66 | def resize_svg(self, svg): |
| 67 | viewBox = svg["viewBox"] |
| 68 | f = viewBox.split() |
| 69 | f[2] = str(float(f[2])+50) |
| 70 | f[3] = str(float(f[3])+50) |
| 71 | svg["viewBox"] = " ".join(f) |
| 72 | svg["width"] = str(int(svg["width"][:-2])+50)+"pt" |
| 73 | svg["height"] = str(int(svg["height"][:-2])+50)+"pt" |
| 74 | |
| 75 | def add_finish_icon(self, path): |
| 76 | c = util.get_file_content(path) |
| 77 | b = BeautifulSoup(c, "xml") |
| 78 | svg = b.select_one("svg") |
| 79 | self.resize_svg(svg) |
| 80 | nodes = b.select("g.node") |
| 81 | graph = b.select_one("g.graph") |
| 82 | for n in nodes: |
| 83 | title = n.title.get_text() |
| 84 | if not self.is_valid_title(title): |
| 85 | continue |
| 86 | self.post_process_problem_node(graph, n) |
| 87 | content = b.prettify() |
| 88 | util.save_file_content(path, content) |
| 89 | |
| 90 | def post_process_problem_node(self, graph, n): |
| 91 | title = n.title.get_text() |
| 92 | |
| 93 | # get positions |
| 94 | points = n.g.polygon['points'].split() |
| 95 | p0 = points[0].split(",") |
| 96 | x0 = float(p0[0]) |
| 97 | y0 = float(p0[1]) |
| 98 | # add finish icon |
| 99 | if self.check_finish(title): |
| 100 | t = BeautifulSoup(svg_icon_finish % (str(x0-8), str(y0-6)), "xml").select_one("g") |
| 101 | n.append(t) |
nothing calls this directly
no outgoing calls
no test coverage detected