Coverage for src/robotide/context/__init__.py: 92%

70 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# -*- coding: utf-8 -*- 

2# Copyright 2008-2015 Nokia Networks 

3# Copyright 2016- Robot Framework Foundation 

4# 

5# Licensed under the Apache License, Version 2.0 (the "License"); 

6# you may not use this file except in compliance with the License. 

7# You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, software 

12# distributed under the License is distributed on an "AS IS" BASIS, 

13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

14# See the License for the specific language governing permissions and 

15# limitations under the License. 

16 

17import builtins 1ab

18import os 1ab

19import sys 1ab

20import wx 1ab

21 

22from . import logger 1ab

23from ..robotapi import ROBOT_LOGGER 1ab

24from ..version import VERSION 1ab

25 

26_ = wx.GetTranslation # To keep linter/code analyser happy 1ab

27builtins.__dict__['_'] = wx.GetTranslation 1ab

28 

29APP = None 1ab

30LOG = logger.Logger() 1ab

31ROBOT_LOGGER.unregister_console_logger() 1ab

32ROBOT_LOGGER.register_logger(LOG) 1ab

33 

34IS_WINDOWS = os.sep == '\\' 1ab

35IS_MAC = sys.platform == 'darwin' 1ab

36IS_LINUX = sys.platform == 'linux' 1ab

37WX_VERSION = wx.VERSION_STRING 1ab

38IS_WX_410_OR_HIGHER = WX_VERSION >= '4.1.0' 1ab

39EXECUTABLE = sys.executable 1ab

40 

41if IS_WINDOWS: 41 ↛ 42line 41 didn't jump to line 42 because the condition on line 41 was never true1ab

42 SETTINGS_DIRECTORY = os.path.join( 

43 os.environ['APPDATA'], 'RobotFramework', 'ride') 

44else: 

45 SETTINGS_DIRECTORY = os.path.join( 1ab

46 os.path.expanduser('~/.robotframework'), 'ride') 

47LIBRARY_XML_DIRECTORY = os.path.join(SETTINGS_DIRECTORY, 'library_xmls') 1ab

48if not os.path.isdir(LIBRARY_XML_DIRECTORY): 48 ↛ 49line 48 didn't jump to line 49 because the condition on line 48 was never true1ab

49 os.makedirs(LIBRARY_XML_DIRECTORY) 

50 

51SETTING_EDITOR_WIDTH = 450 1ab

52SETTING_LABEL_WIDTH = 150 1ab

53SETTING_ROW_HEIGHT = 40 1ab

54# DEBUG: Make this colour configurable 

55POPUP_BACKGROUND = (240, 242, 80) # (255, 255, 187) 1ab

56POPUP_FOREGROUND = (40, 40, 0) # (255, 255, 187) 1ab

57 

58pyversion = '.'.join(str(v) for v in sys.version_info[:3]) 1ab

59SYSTEM_INFO = _("Started RIDE %s using python version %s with wx version %s in %s.") % \ 1ab

60 (VERSION, pyversion, WX_VERSION, sys.platform) 

61 

62 

63def get_about_ride(): 1ab

64 rf = '<a href="https://robotframework.org/">Robot Framework</a>' 1acdef

65 ghrf = '<a href="https://github.com/robotframework/RIDE">https://github.com/robotframework/RIDE</a>' 1acdef

66 si = '<a href="https://github.com/legacy-icons/famfamfam-silk/">Silk Icons</a>' 1acdef

67 # Note: <!-- Originally from http://www.famfamfam.com/lab/icons/silk/ 404 in 10-june-2023--> 

68 mt = '<a href="https://github.com/HelioGuilherme66">Hélio Guilherme</a>' 1acdef

69 foundation = '<a href="https://robotframework.org/foundation/">Robot Framework Foundation</a>' 1acdef

70 from ..localization.tr_credits import tr_credits 1acdef

71 tr = tr_credits() 1acdef

72 translators = _("Thanks all RIDE translators: %s") % tr 1acdef

73 rfecosys = '<b>Robot Framework Ecosystem Projects 2023</b>' 1acdef

74 heading = _("RIDE -- Robot Framework Test Data Editor") 1acdef

75 content = [] 1acdef

76 content += [_("RIDE %s running on Python %s.") % (VERSION, pyversion)] 1acdef

77 content += ["<br/>" + _("RIDE is a test data editor for %s.") % rf] 1acdef

78 content += [_("For more information, see project pages at %s.") % ghrf] 1acdef

79 content += ["<br/>" + _("Some of the icons are from %s.") % si] 1acdef

80 maintainer = _("%s the maintainer of the project thanks the original authors and all users and collaborators.") % mt 1acdef

81 special = _("A special thanks to %s for having sponsored the development of translated test suites content " 1acdef

82 "compatibility with %s Version 6.1, in their %s.") % (foundation, rf, rfecosys) 

83 build_about = [] 1acdef

84 build_about += [f"<h3>{heading}</h3>"] 1acdef

85 build_about += [f"{line}<br/>" for line in content] 1acdef

86 build_about += [f"<p><br/>{maintainer}<br/></p>"] 1acdef

87 build_about += [f"<p>{special}</p>"] 1acdef

88 build_about += [f"<br/><div>{translators}</div>"] 1acdef

89 

90 return "".join(build_about) 1acdef

91 

92 

93""" 1ab

94ABOUT_RIDE = '''<h3>RIDE -- Robot Framework Test Data Editor</h3> 

95<p>RIDE %s running on Python %s.</p> 

96<p>RIDE is a test data editor for <a href="https://robotframework.org/">Robot Framework</a>. 

97For more information, see project pages at 

98<a href="https://github.com/robotframework/RIDE">https://github.com/robotframework/RIDE</a>.</p> 

99<p>Some of the icons are from <a href="https://github.com/legacy-icons/famfamfam-silk/">Silk Icons</a>.</p> 

100<!-- Originally from http://www.famfamfam.com/lab/icons/silk/ 404 in 10-june-2023--> 

101<p><br/><br/><a href="https://github.com/HelioGuilherme66">Hélio Guilherme</a> the maintainer of the project thanks the  

102original authors and all users and collaborators.<br/> 

103<!-- 

104A very special thanks to <b><a href="https://github.com/Nyral">Nyral</a></b> and <b><a href="https://github.com/jnhyperi 

105on">Johnny.H</a></b> the most commited in helping RIDE development and maintenance. 

106--></p> 

107''' % (VERSION, pyversion) 

108""" 

109 

110 

111def ctrl_or_cmd(): 1ab

112 if IS_MAC: 112 ↛ 114line 112 didn't jump to line 114 because the condition on line 112 was always true1ag

113 return wx.ACCEL_CMD 1ag

114 return wx.ACCEL_CTRL 

115 

116 

117def bind_keys_to_evt_menu(target, actions): 1ab

118 accelrators = [] 

119 for accel, keycode, handler in actions: 

120 _id = wx.NewIdRef() 

121 target.Bind(wx.EVT_MENU, handler, id=_id) 

122 accelrators.append((accel, keycode, _id)) 

123 target.SetAcceleratorTable(wx.AcceleratorTable(accelrators)) 

124 

125 

126SHORTCUT_KEYS = '''<h2>Shortcut keys in RIDE</h2> 1ab

127<table> 

128 <tr align="left"> 

129 <th><b>Shortcut</b></th> 

130 <th><b>What it does</b></th> 

131 </tr> 

132 <tr> 

133 <td>CtrlCmd-S</td> 

134 <td>Save</td> 

135 </tr> 

136 <tr> 

137 <td>CtrlCmd-Shift-S</td> 

138 <td>Save all</td> 

139 </tr> 

140 <tr> 

141 <td>CtrlCmd-O</td> 

142 <td>Open</td> 

143 </tr> 

144 <tr> 

145 <td>CtrlCmd-Shift-O</td> 

146 <td>Open directory</td> 

147 </tr> 

148 <tr> 

149 <td>CtrlCmd-R</td> 

150 <td>Open resource</td> 

151 </tr> 

152 <tr> 

153 <td>CtrlCmd-Shift-R</td> 

154 <td>Refresh directory</td> 

155 </tr> 

156 <tr> 

157 <td>CtrlCmd-N</td> 

158 <td>New project</td> 

159 </tr> 

160 <tr> 

161 <td>CtrlCmd-Shift-N</td> 

162 <td>New resource</td> 

163 </tr> 

164 <tr> 

165 <td>CtrlCmd-Q</td> 

166 <td>Quit RIDE</td> 

167 </tr> 

168 <tr> 

169 <td>Alt-X</td> 

170 <td>Go Forward</td> 

171 </tr> 

172 <tr> 

173 <td>Alt-Z</td> 

174 <td>Go Back</td> 

175 </tr> 

176 <tr> 

177 <td>F6</td> 

178 <td>Open preview</td> 

179 </tr> 

180 <tr> 

181 <td>F5</td> 

182 <td>Open search keywords dialog</td> 

183 </tr> 

184 <tr> 

185 <td>F3</td> 

186 <td>Open search tests dialog</td> 

187 </tr> 

188 <tr> 

189 <td>F8</td> 

190 <td>Run test suite</td> 

191 </tr> 

192 <tr> 

193 <td>CtrlCmd-F8</td> 

194 <td>Stop running test suite</td> 

195 </tr> 

196</table> 

197 

198<h3>Grid</h3> 

199<table> 

200 <tr align="left"> 

201 <th><b>Shortcut</b></th> 

202 <th><b>What it does</b></th> 

203 </tr> 

204 <tr> 

205 <td>Ctrl-Space or Alt-Space</td> 

206 <td>Suggestions and auto completion</td> 

207 </tr> 

208 <tr> 

209 <td>CtrlCmd</td> 

210 <td>Help for cell content</td> 

211 </tr> 

212 <tr> 

213 <td>CtrlCmd-Shift-J</td> 

214 <td>Pop-up JSON Editor</td> 

215 </tr> 

216 <tr> 

217 <td>CtrlCmd-B</td> 

218 <td>Go to Definition</td> 

219 </tr> 

220 <tr> 

221 <td>CtrlCmd-Z</td> 

222 <td>Undo</td> 

223 </tr> 

224 <tr> 

225 <td>CtrlCmd-Y</td> 

226 <td>Redo</td> 

227 </tr> 

228 <tr> 

229 <td>CtrlCmd-1</td> 

230 <td>Make scalar variable body</td> 

231 </tr> 

232 <tr> 

233 <td>CtrlCmd-2</td> 

234 <td>Make list variable body</td> 

235 </tr> 

236 <tr> 

237 <td>CtrlCmd-5</td> 

238 <td>Make dictionary variable body</td> 

239 </tr> 

240 <tr> 

241 <td>CtrlCmd-Shift-3</td> 

242 <td>Comment content with #</td> 

243 </tr> 

244 <tr> 

245 <td>CtrlCmd-Shift-4</td> 

246 <td>Uncomment content from #</td> 

247 </tr> 

248 <tr> 

249 <td>Alt-Enter</td> 

250 <td>Move cursor down</td> 

251 </tr> 

252 <tr> 

253 <td>CtrlCmd-3</td> 

254 <td>Comment row(s)</td> 

255 </tr> 

256 <tr> 

257 <td>CtrlCmd-4</td> 

258 <td>Uncomment row(s)</td> 

259 </tr> 

260 <tr> 

261 <td>Alt-Up</td> 

262 <td>Move row(s) up</td> 

263 </tr> 

264 <tr> 

265 <td>Alt-Down</td> 

266 <td>Move row(s) down</td> 

267 </tr> 

268 <tr> 

269 <td>CtrlCmd-T</td> 

270 <td>Swap row up</td> 

271 </tr> 

272 <tr> 

273 <td>CtrlCmd-Shift-I</td> 

274 <td>Insert cell(s)</td> 

275 </tr> 

276 <tr> 

277 <td>CtrlCmd-Shift-D</td> 

278 <td>Delete cell(s)</td> 

279 </tr> 

280 <tr> 

281 <td>CtrlCmd-I</td> 

282 <td>Insert row(s)</td> 

283 </tr> 

284 <tr> 

285 <td>CtrlCmd-D</td> 

286 <td>Delete row(s)</td> 

287 </tr> 

288 <tr> 

289 <td>CtrlCmd-A</td> 

290 <td>Select all</td> 

291 </tr> 

292 <tr> 

293 <td>CtrlCmd-X</td> 

294 <td>Cut (does not remove cells or rows)</td> 

295 </tr> 

296 <tr> 

297 <td>CtrlCmd-C</td> 

298 <td>Copy</td> 

299 </tr> 

300 <tr> 

301 <td>CtrlCmd-V</td> 

302 <td>Paste (does not move cells or rows)</td> 

303 </tr> 

304 <tr> 

305 <td>CtrlCmd-Shift-V</td> 

306 <td>Insert (adds empty rows and pastes data)</td> 

307 </tr> 

308 <tr> 

309 <td>Del</td> 

310 <td>Remove cell content</td> 

311 </tr> 

312 <tr> 

313 <td>Ctrl-MouseWheel Roll</td> 

314 <td>Increases or Decreases font size (Zoom +/-)</td> 

315 </tr> 

316</table> 

317 

318<h3>Tree view</h3> 

319<table> 

320 <tr align="left"> 

321 <th><b>Shortcut</b></th> 

322 <th><b>What it does</b></th> 

323 </tr> 

324 <tr> 

325 <td>CtrlCmd-Shift-T</td> 

326 <td>Add new test case</td> 

327 </tr> 

328 <tr> 

329 <td>CtrlCmd-Shift-K</td> 

330 <td>Add new keyword</td> 

331 </tr> 

332 <tr> 

333 <td>CtrlCmd-Shift-V</td> 

334 <td>Add new scalar variable</td> 

335 </tr> 

336 <tr> 

337 <td>CtrlCmd-Shift-L</td> 

338 <td>Add new list variable</td> 

339 </tr> 

340 <tr> 

341 <td>F2</td> 

342 <td>Rename</td> 

343 </tr> 

344 <tr> 

345 <td>CtrlCmd-Shift-C</td> 

346 <td>Clone/Copy selected keyword/test case</td> 

347 </tr> 

348 <tr> 

349 <td>CtrlCmd-Up</td> 

350 <td>Move item up</td> 

351 </tr> 

352 <tr> 

353 <td>CtrlCmd-Down</td> 

354 <td>Move item down</td> 

355 </tr> 

356</table> 

357 

358<h3>Text editor</h3> 

359 

360<table> 

361 <tr align="left"> 

362 <th><b>Shortcut</b></th> 

363 <th><b>What it does</b></th> 

364 </tr> 

365 <tr> 

366 <td>Ctrl-Space or Alt-Space</td> 

367 <td>Suggestions and auto completion</td> 

368 </tr> 

369 <tr> 

370 <td>CtrlCmd</td> 

371 <td>Help for content at cursor or selected autocomplete list item</td> 

372 </tr> 

373 <tr> 

374 <td>CtrlCmd-T</td> 

375 <td>Swap current row up</td> 

376 </tr> 

377 <tr> 

378 <td>Tab</td> 

379 <td>Inserts the defined number of spaces</td> 

380 </tr> 

381 <tr> 

382 <td>Shift-Tab</td> 

383 <td>Moves cursor to the left the defined number of spaces</td> 

384 </tr> 

385 <tr> 

386 <td>Ctrl-MouseWheel Roll</td> 

387 <td>Increases or Decreases font size (Zoom +/-)</td> 

388 </tr> 

389 <tr> 

390 <td>CtrlCmd-F</td> 

391 <td>Find in text</td> 

392 </tr> 

393 <tr> 

394 <td>CtrlCmd-G</td> 

395 <td>Find next search result</td> 

396 </tr> 

397 <tr> 

398 <td>CtrlCmd-Shift-G</td> 

399 <td>Find previous search result</td> 

400 </tr> 

401 <tr> 

402 <td>CtrlCmd-Z</td> 

403 <td>Undo</td> 

404 </tr> 

405 <tr> 

406 <td>CtrlCmd-Y</td> 

407 <td>Redo</td> 

408 </tr> 

409 <tr> 

410 <td>CtrlCmd-1</td> 

411 <td>Make scalar variable body</td> 

412 </tr> 

413 <tr> 

414 <td>CtrlCmd-2</td> 

415 <td>Make list variable body</td> 

416 </tr> 

417 <tr> 

418 <td>CtrlCmd-5</td> 

419 <td>Make dictionary variable body</td> 

420 </tr> 

421 <tr> 

422 <td>Alt-Up</td> 

423 <td>Move row(s) up</td> 

424 </tr> 

425 <tr> 

426 <td>Alt-Down</td> 

427 <td>Move row(s) down</td> 

428 </tr> 

429 <tr> 

430 <td>CtrlCmd-D</td> 

431 <td>Delete row(s)</td> 

432 </tr> 

433 <tr> 

434 <td>CtrlCmd-I</td> 

435 <td>Insert row(s)</td> 

436 </tr> 

437 <tr> 

438 <td>CtrlCmd-3</td> 

439 <td>Comment row(s)</td> 

440 </tr> 

441 <tr> 

442 <td>CtrlCmd-Shift-3</td> 

443 <td>Comment content with #</td> 

444 </tr> 

445 <tr> 

446 <td>CtrlCmd-4</td> 

447 <td>Uncomment row(s)</td> 

448 </tr> 

449 <tr> 

450 <td>CtrlCmd-Shift-4</td> 

451 <td>Uncomment content with #</td> 

452 </tr> 

453 <tr> 

454 <td>CtrlCmd-Shift-I</td> 

455 <td>Insert cell(s)</td> 

456 </tr> 

457 <tr> 

458 <td>CtrlCmd-Shift-D</td> 

459 <td>Delete cell(s)</td> 

460 </tr> 

461 <tr> 

462 <td>CtrlCmd-Shift Click on Folding marker</td> 

463 <td>Expands or Collapses all Folding markers</td> 

464 </tr> 

465 <tr> 

466 <td>Enter</td> 

467 <td>When focus is in the search field, find next search result</td> 

468 </tr> 

469 <tr> 

470 <td>Shift-Enter</td> 

471 <td>When focus is in the search field, find previous search result</td> 

472 </tr> 

473</table> 

474 

475<h3>Run tab</h3> 

476 

477<table> 

478 <tr align="left"> 

479 <th><b>Shortcut</b></th> 

480 <th><b>What it does</b></th> 

481 </tr> 

482 <tr> 

483 <td>CtrlCmd-C</td> 

484 <td>Copy from text output when text selected</td> 

485 </tr> 

486 <tr> 

487 <td>CtrlCmd-L</td> 

488 <td>Open HTML log</td> 

489 </tr> 

490 <tr> 

491 <td>CtrlCmd-R</td> 

492 <td>Show HTML report</td> 

493 </tr> 

494 <tr> 

495 <td>Ctrl-MouseWheel Roll</td> 

496 <td>Increases or Decreases font size (Zoom +/-)</td> 

497 </tr> 

498</table> 

499'''