MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / __init__

Method __init__

gui/updateDialog.py:52–132  ·  view source on GitHub ↗
(self, parent, release, version)

Source from the content-addressed store, hash-verified

50class UpdateDialog(wx.Dialog):
51
52 def __init__(self, parent, release, version):
53 super().__init__(
54 parent, id=wx.ID_ANY, title="pyfa {}" + _t("Update Available"), pos=wx.DefaultPosition,
55 size=wx.Size(550, 450), style=wx.DEFAULT_DIALOG_STYLE)
56
57 self.UpdateSettings = svc_UpdateSettings.getInstance()
58 self.releaseInfo = release
59 self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
60
61 mainSizer = wx.BoxSizer(wx.VERTICAL)
62
63 releaseDate = dateutil.parser.parse(self.releaseInfo['published_at'])
64 notesSizer = wx.BoxSizer(wx.HORIZONTAL)
65 self.browser = wx.html2.WebView.New(self)
66 self.browser.Bind(wx.html2.EVT_WEBVIEW_NEWWINDOW, self.OnNewWindow)
67
68 link_patterns = [
69 (re.compile(r"#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues/\1"),
70 (re.compile(r"@(\w+)", re.I), r"https://github.com/\1")
71 ]
72
73 markdowner = markdown2.Markdown(
74 extras=['cuddled-lists', 'fenced-code-blocks', 'target-blank-links', 'toc', 'link-patterns'],
75 link_patterns=link_patterns)
76
77 release_markup = markdowner.convert(self.releaseInfo['body'])
78
79 # run the text through markup again, this time with the hashing pattern. This is required due to bugs in markdown2:
80 # https://github.com/trentm/python-markdown2/issues/287
81 link_patterns = [
82 (re.compile("([0-9a-f]{6,40})", re.I), r"https://github.com/pyfa-org/Pyfa/commit/\1"),
83 ]
84
85 markdowner = markdown2.Markdown(
86 extras=['cuddled-lists', 'fenced-code-blocks', 'target-blank-links', 'toc', 'link-patterns'],
87 link_patterns=link_patterns)
88
89 # The space here is required, again, due to bug. Again, see https://github.com/trentm/python-markdown2/issues/287
90 release_markup = markdowner.convert(' ' + release_markup)
91
92 self.browser.SetPage(html_tmpl.format(
93 self.releaseInfo['tag_name'],
94 releaseDate.strftime('%B %d, %Y'),
95 "<p class='text-danger'><b>This is a pre-release, be prepared for unstable features</b></p>" if version.is_prerelease else "",
96 release_markup
97 ), "")
98
99 notesSizer.Add(self.browser, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
100 mainSizer.Add(notesSizer, 1, wx.EXPAND, 5)
101
102 self.supressCheckbox = wx.CheckBox(self, wx.ID_ANY, _t("Don't remind me again for this release"),
103 wx.DefaultPosition, wx.DefaultSize, 0)
104 self.supressCheckbox.Bind(wx.EVT_CHECKBOX, self.SuppressChange)
105
106 mainSizer.Add(self.supressCheckbox, 0, wx.ALL, 5)
107 mainSizer.Add(wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0,
108 wx.EXPAND | wx.ALL, 5)
109

Callers

nothing calls this directly

Calls 4

SetPageMethod · 0.80
_tFunction · 0.50
getInstanceMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected