Best Python code snippet using autotest_python
test_two_line_subsections.py
Source:test_two_line_subsections.py
1''' Simple sections experimenting with start and end settings.'''2# %% Imports3import unittest4from typing import List5from pathlib import Path6from pprint import pprint7import re8import sys9#import pandas as pd10#import xlwings as xw11from buffered_iterator import BufferedIterator12import text_reader as tp13from sections import Rule, RuleSet, SectionBreak, ProcessingMethods, Section14# %% Logging15import logging16logging.basicConfig(format='%(name)-20s - %(levelname)s: %(message)s')17logger = logging.getLogger('Two Line SubSection Tests')18logger.setLevel(logging.DEBUG)19#logger.setLevel(logging.INFO)20# %% Test End On First Item21class TestEndOnFirstItem(unittest.TestCase):22 def setUp(self):23 self.test_text = [24 'Text to be ignored',25 'StartSection A',26 'EndSection A',27 'StartSection B',28 'EndSection B',29 'More text to be ignored',30 ]31 def test_false_end_on_first_item(self):32 start_sub_section = Section(33 start_section=SectionBreak('StartSection', break_offset='Before'),34 end_section=SectionBreak('StartSection', break_offset='Before'),35 end_on_first_item=False36 )37 read_1 = start_sub_section.read(self.test_text)38 self.assertListEqual(39 read_1,40 ['StartSection A', 'EndSection A']41 )42 def test_repeating_false_end_on_first_item(self):43 start_sub_section = Section(44 section_name='StartSubSection',45 start_section=SectionBreak('StartSection', break_offset='Before'),46 end_section=SectionBreak('StartSection', break_offset='Before'),47 end_on_first_item=False48 )49 repeating_section = Section(50 section_name='Top Section',51 end_section=SectionBreak('More text to be ignored',52 break_offset='Before'),53 subsections=start_sub_section54 )55 read_1 = repeating_section.read(self.test_text)56 self.assertListEqual(57 read_1,58 [59 ['StartSection A', 'EndSection A'],60 ['StartSection B', 'EndSection B']61 ]62 )63 def test_true_end_on_first_item(self):64 start_sub_section = Section(65 start_section=SectionBreak('StartSection', break_offset='Before'),66 end_section=SectionBreak('StartSection', break_offset='Before'),67 end_on_first_item=True68 )69 read_1 = start_sub_section.read(self.test_text)70 self.assertListEqual(read_1, [])71 def test_end_on_first_item_end_after(self):72 end_sub_section = Section(73 start_section=SectionBreak('EndSection', break_offset='Before'),74 end_section=SectionBreak('EndSection', break_offset='After'),75 end_on_first_item=True76 )77 read_1 = end_sub_section.read(self.test_text)78 self.assertListEqual(read_1, ['EndSection A'])79 def test_no_end_on_first_item_end_after(self):80 end_sub_section = Section(81 start_section=SectionBreak('EndSection', break_offset='Before'),82 end_section=SectionBreak('EndSection', break_offset='After'),83 end_on_first_item=False84 )85 read_1 = end_sub_section.read(self.test_text)86 self.assertListEqual(read_1, ['EndSection A', 'StartSection B', 'EndSection B'])87class TestSingleLineStartSections(unittest.TestCase):88 def setUp(self):89 self.test_text = [90 'Text to be ignored',91 'StartSection A',92 'EndSection A',93 'StartSection B',94 'EndSection B',95 'More text to be ignored',96 ]97 def test_single_line_start_section(self):98 start_sub_section = Section(99 section_name='StartSubSection',100 start_section=SectionBreak('StartSection', break_offset='Before'),101 end_section=SectionBreak('EndSection', break_offset='Before')102 )103 test_iter = BufferedIterator(self.test_text)104 read_1 = start_sub_section.read(test_iter)105 read_2 = start_sub_section.read(test_iter)106 read_3 = start_sub_section.read(test_iter)107 self.assertListEqual(read_1, ['StartSection A'])108 self.assertListEqual(read_2, ['StartSection B'])109 self.assertListEqual(read_3, [])110 def test_single_line_start_section(self):111 start_sub_section = Section(112 section_name='StartSubSection',113 start_section=SectionBreak('StartSection', break_offset='Before'),114 end_section=SectionBreak('EndSection', break_offset='Before')115 )116 full_section = Section(117 section_name='Full',118 end_section=SectionBreak('ignored', break_offset='Before'),119 subsections=[start_sub_section]120 )121 read_1 = full_section.read(self.test_text)122 self.assertListEqual(read_1, [['StartSection A'], ['StartSection B']])123class TestSingleLineEndSections(unittest.TestCase):124 def setUp(self):125 self.test_text = [126 'Text to be ignored',127 'StartSection A',128 'EndSection A',129 'StartSection B',130 'EndSection B',131 'More text to be ignored',132 ]133 def test_single_line_end_like_start_section(self):134 end_sub_section = Section(135 section_name='SubSection',136 start_section=SectionBreak('EndSection', break_offset='Before'),137 end_section=SectionBreak('StartSection', break_offset='Before')138 )139 test_iter = BufferedIterator(self.test_text)140 read_1 = end_sub_section.read(test_iter)141 read_2 = end_sub_section.read(test_iter)142 read_3 = end_sub_section.read(test_iter)143 self.assertListEqual(read_1, ['EndSection A'])144 self.assertListEqual(read_2, ['EndSection B',145 'More text to be ignored'])146 self.assertListEqual(read_3, [])147 def test_single_line_end_before_and_after_section(self):148 end_sub_section = Section(149 section_name='SubSection',150 start_section=SectionBreak('EndSection', break_offset='Before'),151 end_section=SectionBreak('EndSection', break_offset='After')152 )153 test_iter = BufferedIterator(self.test_text)154 read_1 = end_sub_section.read(test_iter)155 read_2 = end_sub_section.read(test_iter)156 read_3 = end_sub_section.read(test_iter)157 self.assertListEqual(read_1, ['EndSection A',158 'StartSection B',159 'EndSection B'])160 self.assertListEqual(read_2, [])161 self.assertListEqual(read_3, [])162 def test_single_line_end_before_and_after_end_on_first_section(self):163 end_sub_section = Section(164 section_name='SubSection',165 start_section=SectionBreak('EndSection', break_offset='Before'),166 end_section=SectionBreak('EndSection', break_offset='After'),167 end_on_first_item=True168 )169 test_iter = BufferedIterator(self.test_text)170 read_1 = end_sub_section.read(test_iter)171 read_2 = end_sub_section.read(test_iter)172 read_3 = end_sub_section.read(test_iter)173 self.assertListEqual(read_1, ['EndSection A'])174 self.assertListEqual(read_2, ['EndSection B'])175 self.assertListEqual(read_3, [])176 def test_single_line_end_before_end_on_first_section(self):177 end_sub_section = Section(178 section_name='SubSection',179 start_section=SectionBreak('EndSection', break_offset='Before'),180 end_section=SectionBreak('EndSection', break_offset='Before'),181 end_on_first_item=True182 )183 test_iter = BufferedIterator(self.test_text)184 read_1 = end_sub_section.read(test_iter)185 read_2 = end_sub_section.read(test_iter)186 read_3 = end_sub_section.read(test_iter)187 self.assertListEqual(read_1, [])188 self.assertListEqual(read_2, [])189 self.assertListEqual(read_3, [])190 def test_single_line_end_always_break_end_on_first_section(self):191 end_sub_section = Section(192 section_name='SubSection',193 start_section=SectionBreak('EndSection', break_offset='Before'),194 end_section=SectionBreak(True, break_offset='After'),195 end_on_first_item=True196 )197 test_iter = BufferedIterator(self.test_text)198 read_1 = end_sub_section.read(test_iter)199 read_2 = end_sub_section.read(test_iter)200 read_3 = end_sub_section.read(test_iter)201 self.assertListEqual(read_1, ['EndSection A'])202 self.assertListEqual(read_2, ['EndSection B'])203 self.assertListEqual(read_3, [])204 def test_single_line_end_always_break_no_end_on_first_section(self):205 end_sub_section = Section(206 section_name='SubSection',207 start_section=SectionBreak('EndSection', break_offset='Before'),208 end_section=SectionBreak(True, break_offset='After'),209 end_on_first_item=False210 )211 test_iter = BufferedIterator(self.test_text)212 read_1 = end_sub_section.read(test_iter)213 read_2 = end_sub_section.read(test_iter)214 read_3 = end_sub_section.read(test_iter)215 self.assertListEqual(read_1, ['EndSection A', 'StartSection B'])216 self.assertListEqual(read_2, ['EndSection B', 'More text to be ignored'])217 self.assertListEqual(read_3, [])218 def test_single_line_end_always_break_section(self):219 end_sub_section = Section(220 section_name='SubSection',221 start_section=SectionBreak('EndSection', break_offset='Before'),222 end_section=SectionBreak(True, break_offset='After')223 )224 test_iter = BufferedIterator(self.test_text)225 read_1 = end_sub_section.read(test_iter)226 read_2 = end_sub_section.read(test_iter)227 read_3 = end_sub_section.read(test_iter)228 self.assertListEqual(read_1, ['EndSection A', 'StartSection B'])229 self.assertListEqual(read_2, ['EndSection B', 'More text to be ignored'])230 self.assertListEqual(read_3, [])231 def test_single_line_end_no_break_section(self):232 end_sub_section = Section(233 section_name='SubSection',234 start_section=SectionBreak('EndSection', break_offset='Before'),235 end_on_first_item=True,236 )237 test_iter = BufferedIterator(self.test_text)238 read_1 = end_sub_section.read(test_iter)239 read_2 = end_sub_section.read(test_iter)240 read_3 = end_sub_section.read(test_iter)241 self.assertListEqual(read_1, ['EndSection A', 'StartSection B',242 'EndSection B',243 'More text to be ignored'])244 self.assertListEqual(read_2, [])245 self.assertListEqual(read_3, [])246class TestCombinedStartEndSingleLineSection(unittest.TestCase):247 def setUp(self):248 self.test_text = [249 'Text to be ignored',250 'StartSection A',251 'EndSection A',252 'StartSection B',253 'EndSection B',254 'More text to be ignored',255 ]256 self.test_text2 = [257 'Text to be ignored',258 'StartSection A',259 'EndSection A',260 'StartSection B',261 'EndSection B',262 'StartSection C',263 'More text to be ignored', # 'ignored' triggers end of top section264 'EndSection C',265 'Even more text to be ignored',266 ]267 self.start_sub_section = Section(268 section_name='StartSubSection',269 start_section=SectionBreak('StartSection', break_offset='Before'),270 end_section=SectionBreak('EndSection', break_offset='Before')271 )272 self.end_sub_section = Section(273 section_name='EndSubSection',274 start_section=SectionBreak('EndSection', break_offset='Before'),275 end_section=SectionBreak(True, break_offset='Before')276 )277 def test_two_single_line_subsections(self):278 full_section = Section(279 section_name='Full',280 subsections=[self.start_sub_section, self.end_sub_section]281 )282 read_1 = full_section.read(self.test_text)283 self.assertListEqual(read_1, [284 [285 ['StartSection A'],286 ['EndSection A']287 ], [288 ['StartSection B'],289 ['EndSection B']290 ]])291 def test_two_single_line_subsections_with_top_section_break(self):292 top_section = Section(293 section_name='Top Section',294 end_section=SectionBreak('ignored', break_offset='Before'),295 subsections=[self.start_sub_section, self.end_sub_section]296 )297 read_1 = top_section.read(self.test_text)298 self.assertListEqual(read_1, [299 [300 ['StartSection A'],301 ['EndSection A']302 ], [303 ['StartSection B'],304 ['EndSection B']305 ]])306 def test_two_single_line_subsections_with_unwanted_middle(self):307 top_section = Section(308 section_name='Top Section',309 end_section=SectionBreak('ignored', break_offset='Before'),310 subsections=[self.start_sub_section, self.end_sub_section]311 )312 read_1 = top_section.read(self.test_text2)313 self.assertListEqual(read_1, [314 [315 ['StartSection A'],316 ['EndSection A']317 ], [318 ['StartSection B'],319 ['EndSection B']320 ], [321 ['StartSection C'],322 [] # Top section stops before reaching 'EndSection C'323 ]])324 def test_two_single_line_subsections_with_unwanted_between_sections(self):325 test_text = [326 'Text to be ignored',327 'StartSection A',328 'EndSection A',329 'More text to be ignored',330 'StartSection B',331 'EndSection B',332 'Even more text to be ignored',333 ]334 full_section = Section(335 section_name='Full',336 subsections=[self.start_sub_section, self.end_sub_section]337 )338 read_1 = full_section.read(test_text)339 self.assertListEqual(read_1, [340 [341 ['StartSection A'],342 ['EndSection A']343 ], [344 ['StartSection B'],345 ['EndSection B']346 ]])347@unittest.skip('Known Failure')348class TestKeepPartial(unittest.TestCase):349 def setUp(self):350 self.test_text = [351 'Text to be ignored',352 'StartSection A',353 'EndSection A',354 'StartSection B',355 'EndSection B',356 'More text to be ignored',357 ]358 self.test_text2 = [359 'Text to be ignored',360 'StartSection A',361 'EndSection A',362 'StartSection B',363 'EndSection B',364 'StartSection C',365 'More text to be ignored', # 'ignored' triggers end of top section366 'EndSection C',367 'Even more text to be ignored',368 ]369 self.start_sub_section = Section(370 section_name='StartSubSection',371 start_section=SectionBreak('StartSection', break_offset='Before'),372 end_section=SectionBreak('EndSection', break_offset='Before')373 )374 self.end_sub_section = Section(375 section_name='EndSubSection',376 start_section=SectionBreak('EndSection', break_offset='Before'),377 end_section=SectionBreak(True, break_offset='Before')378 )379 @unittest.skip('Known Failure')380 def test_keep_partial_False(self):381 top_section = Section(382 section_name='Top Section',383 end_section=SectionBreak('ignored', break_offset='Before'),384 subsections=[self.start_sub_section, self.end_sub_section],385 keep_partial=False386 )387 read_1 = top_section.read(self.test_text2)388 self.assertListEqual(read_1, [389 [390 ['StartSection A'],391 ['EndSection A']392 ], [393 ['StartSection B'],394 ['EndSection B']395 ]])396 @unittest.skip('Known Failure')397 def test_keep_partial_True(self):398 top_section = Section(399 section_name='Top Section',400 end_section=SectionBreak('ignored', break_offset='Before'),401 subsections=[self.start_sub_section, self.end_sub_section],402 keep_partial=True403 )404 read_1 = top_section.read(self.test_text2)405 self.assertListEqual(read_1, [406 [['StartSection A'], ['EndSection A']],407 [['StartSection B'], ['EndSection B']],408 [['StartSection C']]409 ])410 def test_keep_partial_True_simpler_text(self):411 top_section = Section(412 section_name='Top Section',413 end_section=SectionBreak('ignored', break_offset='Before'),414 subsections=[self.start_sub_section, self.end_sub_section],415 keep_partial=True416 )417 read_1 = top_section.read(self.test_text)418 self.assertListEqual(read_1, [419 [['StartSection A'], ['EndSection A']],420 [['StartSection B'], ['EndSection B']]421 ])422 def test_keep_partial_True_only_end_section(self):423 top_section = Section(424 section_name='Top Section',425 end_section=SectionBreak('ignored', break_offset='Before'),426 subsections=[self.end_sub_section],427 keep_partial=True428 )429 read_1 = top_section.read(self.test_text)430 self.assertListEqual(read_1, [['EndSection A'],['EndSection B']])431 @unittest.skip('Known Failure')432 def test_keep_partial_True_missing_end_section(self):433 '''3rd section group should never start because "ignored" top_section434 break line occurs before next "EndSection", so 2nd section never435 finishes.'''436 test_text = [437 'Text to be ignored',438 'StartSection A',439 'EndSection A',440 'StartSection B', # Missing 'EndSection B',441 'StartSection C',442 'More text to be ignored', # 'ignored' triggers end of top section443 'EndSection C',444 'Even more text to be ignored',445 ]446 top_section = Section(447 section_name='Top Section',448 end_section=SectionBreak('ignored', break_offset='Before'),449 subsections=[self.start_sub_section, self.end_sub_section],450 keep_partial=True451 )452 read_1 = top_section.read(test_text)453 self.assertListEqual(read_1, [454 [['StartSection A'], ['EndSection A']],455 [['StartSection B']]456 ])457 def test_keep_partial_False_missing_end_section(self):458 '''3rd section group should never start because "ignored" top_section459 break line occurs before next "EndSection", so 2nd section never460 finishes.'''461 test_text = [462 'Text to be ignored',463 'StartSection A',464 'EndSection A',465 'StartSection B', # Missing 'EndSection B',466 'StartSection C',467 'More text to be ignored', # 'ignored' triggers end of top section468 'EndSection C',469 'Even more text to be ignored',470 ]471 top_section = Section(472 section_name='Top Section',473 end_section=SectionBreak('ignored', break_offset='Before'),474 subsections=[self.start_sub_section, self.end_sub_section],475 keep_partial=False476 )477 read_1 = top_section.read(test_text)478 self.assertListEqual(read_1, [479 [['StartSection A'], ['EndSection A']]480 ])481class TestHysteresis(unittest.TestCase):482 '''Applying repeated "Section.read" calls. Previously, a bug resulted in483 repeated calls produce different effects when full_section contained484 `end_section=SectionBreak('ignored', break_offset='Before')`.485 '''486 def setUp(self):487 self.test_text = [488 'Text to be ignored',489 'StartSection A',490 'EndSection A',491 'StartSection B',492 'EndSection B',493 'More text to be ignored',494 ]495 self.sub_section = Section(496 section_name='SubSection',497 start_section=SectionBreak('StartSection', break_offset='Before', name='SubSectionStart'),498 end_section=SectionBreak('EndSection', break_offset='After', name='SubSectionEnd')499 )500 # Clear Hysteresis by running `full_section` without setting `end_section`501 full_section = Section(502 subsections=self.sub_section,503 keep_partial=False504 )505 a = full_section.read(self.test_text)506 b = full_section.read(self.test_text)507 def test_repeat_calls(self):508 '''Verify that repeat calls to read produce the same result.509 '''510 full_section = Section(511 section_name='Full',512 end_section=SectionBreak('ignored', break_offset='Before'),513 subsections=self.sub_section514 )515 read_1 = full_section.read(self.test_text)516 self.assertListEqual(read_1, [['StartSection A', 'EndSection A'],517 ['StartSection B', 'EndSection B']518 ])519 read_2 = full_section.read(self.test_text)520 self.assertListEqual(read_1, [['StartSection A', 'EndSection A'],521 ['StartSection B', 'EndSection B']522 ])523class TestHysteresis(unittest.TestCase):524 '''Applying repeated "Section.read" calls. Previously, a bug resulted in525 repeated calls produce different effects when full_section contained526 `end_section=SectionBreak('ignored', break_offset='Before')`.527 '''528 def setUp(self):529 self.test_text = [530 'Text to be ignored',531 'StartSection A',532 'EndSection A',533 'StartSection B',534 'EndSection B',535 'More text to be ignored',536 ]537 self.sub_section = Section(538 section_name='SubSection',539 start_section=SectionBreak('StartSection', break_offset='Before', name='SubSectionStart'),540 end_section=SectionBreak('EndSection', break_offset='After', name='SubSectionEnd')541 )542 # Clear Hysteresis by running `full_section` without setting `end_section`543 full_section = Section(544 subsections=self.sub_section,545 keep_partial=False546 )547 a = full_section.read(self.test_text)548 b = full_section.read(self.test_text)549 def test_repeat_calls(self):550 '''Verify that repeat calls to read produce the same result.551 '''552 full_section = Section(553 section_name='Full',554 end_section=SectionBreak('ignored', break_offset='Before'),555 subsections=self.sub_section556 )557 read_1 = full_section.read(self.test_text)558 self.assertListEqual(read_1, [['StartSection A', 'EndSection A'],559 ['StartSection B', 'EndSection B']560 ])561 read_2 = full_section.read(self.test_text)562 self.assertListEqual(read_1, [['StartSection A', 'EndSection A'],563 ['StartSection B', 'EndSection B']564 ])565class TestSourceStatus(unittest.TestCase):566 '''Applying repeated "Section.read" calls. Previously, a bug resulted in567 repeated calls produce different effects when full_section contained568 `end_section=SectionBreak('ignored', break_offset='Before')`.569 '''570 def setUp(self):571 self.test_text = [572 'Text to be ignored',573 'StartSection A',574 'EndSection A',575 'StartSection B',576 'EndSection B',577 'More text to be ignored',578 ]579 def test_repeat_calls(self):580 '''Verify that repeat calls to read produce the same result.581 '''582 sub_section = Section(583 section_name='SubSection',584 start_section=SectionBreak('StartSection', break_offset='Before',585 name='SubSectionStart'),586 end_section=SectionBreak('EndSection', break_offset='After',587 name='SubSectionEnd')588 )589 full_section = Section(590 section_name='Full',591 end_section=SectionBreak('ignored', break_offset='Before'),592 subsections=sub_section593 )594 read_1 = full_section.read(self.test_text)595 self.assertListEqual(read_1,596 [['StartSection A', 'EndSection A'],597 ['StartSection B', 'EndSection B']])598 self.assertListEqual(list(full_section.source.previous_items),599 ['StartSection A', 'EndSection A',600 'StartSection B', 'EndSection B'])601 self.assertListEqual(list(full_section.source.future_items),602 ['More text to be ignored'])603class TestSubsectionContext(unittest.TestCase):604 '''Check full_section and sub_section context dictionaries after reading.605 '''606 def setUp(self):607 self.test_text = [608 'Text to be ignored',609 'StartSection A',610 'EndSection A',611 'Text between sections',612 'StartSection B',613 'EndSection B',614 'More text to be ignored',615 ]616 def test_repeat_calls(self):617 '''Verify that repeat calls to read produce the same result.618 '''619 sub_section = Section(620 section_name='SubSection',621 start_section=SectionBreak('StartSection', break_offset='Before',622 name='SubSectionStart'),623 end_section=SectionBreak('EndSection', break_offset='After',624 name='SubSectionEnd')625 )626 full_section = Section(627 section_name='Top Section',628 end_section=SectionBreak('ignored', break_offset='Before',629 name='End Section'),630 subsections=sub_section631 )632 read_1 = full_section.read(self.test_text, context={'Dummy': 'Blank1'})633 self.assertListEqual(read_1,634 [['StartSection A', 'EndSection A'],635 ['StartSection B', 'EndSection B']])636 self.assertDictEqual(full_section.context, {637 'Break': 'End Section',638 'Current Section': 'Top Section',639 'Dummy': 'Blank1',640 'Event': 'ignored',641 'Skipped Lines': [],642 'Status': 'Break Triggered'643 })644 self.assertDictEqual(sub_section.context, {645 'Break': 'SubSectionStart',646 'Current Section': 'SubSection',647 'Dummy': 'Blank1',648 'Event': 'StartSection',649 'Skipped Lines': ['Text between sections'],650 'Status': 'End of Source'651 })652if __name__ == '__main__':...
GalleryOverlaysUi.js
Source:GalleryOverlaysUi.js
1import DomAccess from './DomAccess';23export default class GalleryOverlaysUi {4 /**5 * @param {Object} obj6 * @param {DomAccess} obj.domAccess7 */8 constructor({ domAccess }) {9 this._domAccess = domAccess;10 this._preloadGauge = null;11 this._preloadGaugeInner = null;12 }1314 /**15 * @param {Object} obj16 * @param {HTMLElement} obj.parent17 * @returns {HTMLElement}18 */19 createBlackScreen({ parent }) {20 return this._domAccess.createElement('div', { parent, id: 'qilvgallery_black_screen' });21 }2223 /**24 * @param {HTMLElement} blackScreen25 * @returns {void}26 */27 removeBlackScreen(blackScreen) {28 this._domAccess.remove(blackScreen);29 }3031 /**32 * @param {Object} params 33 * @param {string} params.id34 * @param {HTMLElement} params.parent35 * @param {HTMLElement[]} params.content36 * @param {string} params.position37 * @param {boolean} params.center38 * @returns {HTMLElement}39 */40 createInfoTip(params) {41 const domAccess = this._domAccess;42 if (params === undefined) {43 params = {};44 }45 const features = {46 className: 'qilvgallery_infotip',47 };4849 if (features.id !== undefined) {50 features.id = params.id;51 }52 if (params.parent) {53 features.parent = params.parent;54 }55 if (params.content) {56 features.content = params.content;57 }58 if (params.classNames) {59 features.classNames = params.classNames;60 }6162 const infoTip = domAccess.createElement('div', features);63 if (params.position) {64 domAccess.setCssProperty(infoTip, "position", params.position);65 }66 if ((params.center !== undefined) && params.center) {67 infoTip.classList.add('qilvgallery_infotip_center')68 }69 if (params.fadeOut !== undefined) {70 setTimeout(() => domAccess.remove(infoTip), params.fadeOut);71 }7273 return infoTip;74 }757677 /**78 * @param {string} message79 * @param {HTMLElement} element80 * @returns {void}81 */82 createTempMessage(message, element) {83 this.createInfoTip({84 fadeOut: 1500,85 parent: element,86 position: "fixed",87 content: [message],88 });89 }9091 /**92 * @param {HTMLElement} infoBox93 * @returns {void}94 */95 removeInfoBox(infoBox) {96 if (infoBox) {97 this._domAccess.remove(infoBox);98 }99 }100101 /**102 * @param {Object} obj103 * @param {HTMLElement} obj.parent104 * @param {string[]} obj.hrefs105 * @param {(href: string) => boolean} obj.isCurrent106 * @return {HTMLElement}107 */108 createInfoBox({ parent, hrefs, isCurrent }) {109 const domAccess = this._domAccess;110 const infoTip = this.createInfoTip({ parent });111 let info_tip_pre = domAccess.createElement('pre', {112 parent: infoTip,113 content: [114 hrefs.map((href) => {115 let subElement = 'span';116 if (isCurrent(href)) {117 subElement = 'b';118 }119 return [120 domAccess.createElement(subElement, { text: href }),121 domAccess.createElement('br'),122 ];123 }),124 ],125 onClick: () => {126 let text = '';127 let maxLength = 0;128 let count = 0;129 hrefs.forEach((href) => {130 text += href;131 text += '\n';132 count += 1;133 if (href.length > maxLength) {134 maxLength = href.length;135 }136 });137 domAccess.remove(info_tip_pre);138139 let info_tip_area = domAccess.createElement('textarea', {140 parent: infoTip,141 attr: {142 rows: `${count + 1}`,143 cols: `${maxLength + 2}`,144 className: 'qilvgallery_infobox_textarea',145 readonly: 1,146 value: text,147 },148 });149 info_tip_area.select();150 },151 });152 return infoTip;153 }154155 /**156 * @param {Object} obj157 * @param {HTMLElement} obj.parent158 * @param {()=>{}} obj.onComplete159 * @param {Object} obj.preloadGaugeInfo160 * @returns {Object}161 */162 showPreloadGauge({ parent, onComplete, preloadGaugeInfo }) {163 if (!preloadGaugeInfo) {164 const preloadGauge = this._domAccess.createElement('div', { parent, className: 'qilvgallery_preload_gauge' });165 const preloadGaugeInner = this._domAccess.createElement('div', { parent: preloadGauge, className: 'qilvgallery_preload_gauge_inner' });166 preloadGaugeInfo = { preloadGauge, preloadGaugeInner, onComplete };167 }168 return preloadGaugeInfo;169 }170171 /**172 * @param {Object} obj173 * @param {Object} obj.preloadGaugeInfo174 * @returns {void}175 */176 hidePreloadGauge({ preloadGaugeInfo }) {177 if (preloadGaugeInfo) {178 this._domAccess.remove(preloadGaugeInfo.preloadGaugeInner);179 this._domAccess.remove(preloadGaugeInfo.preloadGauge);180 }181 }182183 /**184 * @param {Object} obj185 * @param {Number} obj.loaded186 * @param {Number} obj.total187 * @param {Object} obj.preloadGaugeInfo188 * @returns {void}189 */190 updatePreloadGauge({ loaded, total, preloadGaugeInfo }) {191 if (preloadGaugeInfo) {192 const domAccess = this._domAccess;193 const percent = `${Math.floor(loaded * 100 / total)}%`;194 domAccess.setCssProperty(preloadGaugeInfo.preloadGaugeInner, 'width', percent);195 domAccess.setTextContent(preloadGaugeInfo.preloadGaugeInner, percent);196 domAccess.setTextContent(preloadGaugeInfo.preloadGaugeInner, `${loaded} / ${total}`);197 if (loaded === total) {198 // this.hidePreloadGauge();199 preloadGaugeInfo.onComplete();200 }201 }202 }203204205 /**206 * 207 * @param {Object} obj208 * @param {string[]} obj.hrefs209 * @param {() => {}} obj.onImageLoaded210 * @param {HTMLElement} obj.parent211 */212 ensurePreloadAll({ hrefs, onImageLoaded, parent }) {213 if (!this._preloadAllPanel) {214 const domAccess = this._domAccess;215216 this._preloadAllPanel = domAccess.createElement('div', { parent, id: 'qilvgallery_preload_all_panel' });217 hrefs.forEach((href) => {218 const image = domAccess.createElement('img', {219 parent: this._preloadAllPanel,220 onLoad: onImageLoaded,221 attr: {222 'src': '#'223 }224 });225 image.src = href;226 });227 }228 }229230231232 /**233 * @param {HTMLElement} aboutInfoBox 234 */235236 removeAboutInfoBox(aboutInfoBox) {237 const domAccess = this._domAccess;238 domAccess.remove(aboutInfoBox);239 }240241 /**242 * 243 * @param {Object} obj 244 * @param {HTMLElement} obj.parent245 * @param {() => {}} obj.onClick246 * @param {string} obj.version247 * @returns {HTMLElement}248 */249 createAboutInfoBox({ parent, onClick, version }) {250 const domAccess = this._domAccess;251 const url = 'https://github.com/webgiss/qilvgallery';252 return domAccess.createElement('div', {253 parent,254 className: 'qilvgallery_about_infobox',255 content: [256 domAccess.createElement('div', {257 className: 'qilvgallery_infotip_about_blackscreen',258 onClick259 }),260 this.createInfoTip({261 id: 'QILVGallery_About',262 center: true,263 classNames: ['qilvgallery_infotip_about'],264 content: [265 domAccess.createElement('p', {266 text: 'QILV Gallery',267 className: 'qilvgallery_infotip_about_title',268 }),269 domAccess.createElement('p', {270 text: `Version : ${version}`,271 className: 'qilvgallery_infotip_about_version',272 }),273 domAccess.createElement('a', {274 text: url,275 attr: {276 href: url,277 target: '_blank'278 },279 }),280 domAccess.createElement('br'),281 domAccess.createElement('div', {282 text: 'Close',283 className: 'qilvgallery_infotip_about_button',284 onClick285 })286 ],287 })288 ],289 });290 }291292 /**293 * @param {Object} obj294 * @param {HTMLElement} obj.helpInfoTip295 */296 removeHelpInfoTip(helpInfoTip) {297 const domAccess = this._domAccess;298 domAccess.remove(helpInfoTip);299 }300301 /**302 * @param {Object} obj303 * @param {HTMLElement} obj.parent304 * @param {{keyName: string, methodName: string}[]} obj.bindings305 * @param {{comment: string, configured: string, effective: string, defaultValue: string}[]} obj.configurations306 * @param {string} obj.version307 * @returns {HTMLElement}308 */309 createHelpInfoTip({ parent, bindings, configurations, version }) {310 const domAccess = this._domAccess;311312 return this.createInfoTip({313 parent,314 classNames: ['qilvgallery_infotip_help'],315 content: [316 domAccess.createElement('p', {317 text: `Version: ${version}`,318 }),319320 domAccess.createElement('h1', {321 text: 'Keyboard configuration',322 className: 'qilvgallery_infotip_help_title',323 }),324325 domAccess.createElement('div', {326 className: 'qilvgallery_infotip_help_content',327 content: bindings.map(({ keyName, methodName }) => domAccess.createElement('div', {328 content: [329 domAccess.createElement('b', { text: keyName }),330 domAccess.createElement('span', { text: `: ${methodName}` }),331 ],332 })),333 }),334335 domAccess.createElement('h1', {336 text: 'Values',337 className: 'qilvgallery_infotip_help_title',338 }),339340 domAccess.createElement('div', {341 className: 'qilvgallery_infotip_help_content',342 content: configurations.map(({ comment, configured, effective, defaultValue }) => domAccess.createElement('div', {343 content: [344 domAccess.createElement('b', { text: comment }),345 domAccess.createElement('span', { text: `: ${effective} (configured = ${configured} ; default = ${defaultValue})` }),346 ],347 }))348 }),349 ],350 });351 }352353354 /**355 * @returns {HTMLElement}356 */357 createMainElement() {358 return this._domAccess.createElement('div', { parent: document.body, id: 'qilvgallery_main_element' });359 }360361 /**362 * @param {Object} obj363 * @param {HTMLElement} obj.parent364 * @returns {HTMLElement}365 */366 createViewer({ parent }) {367 return this._domAccess.createElement('div', { parent, id: 'qilvgallery_viewer' });368 }369370 /**371 * @returns {{href: string, element: HTMLElement}[]}372 */373 getLinkRefs() {374 return this._domAccess.getElementsByTagName('a').map((this_a) => ({ href: this_a.href, element: this_a }));375 }376377 /**378 * 379 * @param {Object} obj380 * @param {HTMLElement} obj.element381 * @param {string} obj.id382 * @returns {void}383 */384 setImageRef({ element, id }) {385 this._domAccess.addClass(element, 'qilvgallery_source_image');386 this._domAccess.addClass(element, `qilvgallery_source_image_${id}`);387 }388389390 /**391 * 392 * @param {Object} obj393 * @param {HTMLElement} obj.element394 * @param {boolean} obj.relative395 */396 setRelative({ element, relative }) {397 this._domAccess.setClass(element, 'qilv_relative', relative);398 }399400 /**401 * 402 * @param {Object} obj403 * @param {HTMLElement} obj.element404 * @param {boolean} obj.autoX405 */406 setAutoX({ element, autoX }) {407 this._domAccess.setClass(element, 'qilv_autoX', autoX);408 }409410 /**411 * 412 * @param {Object} obj413 * @param {HTMLElement} obj.element414 * @param {boolean} obj.autoY415 */416 setAutoY({ element, autoY }) {417 this._domAccess.setClass(element, 'qilv_autoY', autoY);418 }419420 /**421 * 422 * @param {Object} obj423 * @param {HTMLElement} obj.element424 * @param {boolean} obj.autoY425 */426 setAutoY({ element, autoY }) {427 this._domAccess.setClass(element, 'qilv_autoY', autoY);428 }429430 /**431 * 432 * @param {Object} obj433 * @param {HTMLElement} obj.element434 * @param {boolean} obj.centered435 */436 setCentered({ element, centered }) {437 this._domAccess.setClass(element, 'qilv_centered', centered);438 }439440 /**441 * 442 * @param {Object} obj443 * @param {HTMLElement} obj.element444 * @param {boolean} obj.maxSize445 */446 setMaxSize({ element, maxSize }) {447 this._domAccess.setClass(element, 'qilv_maxSize', maxSize);448 }449450451 /**452 * 453 * @param {Object} obj454 * @param {HTMLElement} obj.element455 * @param {boolean} obj.shown456 */457 setShown({ element, shown }) {458 this._domAccess.setClass(element, 'qilv_shown', shown);459 }460461 /**462 * 463 * @param {Object} obj464 * @param {HTMLElement} element465 * @param {number} transitionTime466 */467 setTransition({ element, transitionTime }) {468 this._domAccess.removeClassStartingWith(element, 'qilv_transition-');469 this._domAccess.addClass(element, `qilv_transition-${transitionTime}`);470 }471472 /**473 * @returns {void}474 */475 installCss() {476 this._domAccess477 .startFluentCss({ important: true })478479 .section()480 .match('#qilvgallery_viewer')481 .property('position', 'absolute')482 .property('z-index', '50000')483 .property('display', 'none')484 .property('top', '0')485 .property('bottom', '0')486 .property('margin', '0')487 .property('left', '0')488 .property('right', '0')489 .endSection()490491 .section()492 .match('#qilvgallery_viewer.qilv_shown')493 .property('z-index', '50001')494 .property('display', 'block')495 .endSection()496497 .section()498 .match('#qilvgallery_viewer.qilv_relative')499 .property('position', 'fixed')500 .endSection()501502 .section()503 .match('.qilvgallery_infotip')504 .property('display', 'block')505 .property('position', 'absolute')506 .property('left', '4px')507 .property('top', '4px')508 .property('padding', '15px')509 .property('font-size', '13px')510 .property('background', 'linear-gradient(180deg, #f8f8f8, #dddddd)')511 .property('color', '#000000')512 .property('font-family', '"consolas","courier new",monospace')513 .property('border', '2px solid')514 .property('border-color', '#ffffff #f8f8f8 #b8b8b8 #f8f8f8')515 .property('border-radius', '5px')516 .property('z-index', '50001')517 .endSection()518519 .section()520 .match('.qilvgallery_infotip > pre')521 .property('margin', '0')522 .endSection()523524 .section()525 .match('.qilvgallery_preload_gauge')526 .property('z-index', '50101')527 .property('border', '1px solid black')528 .property('width', '100%')529 .property('position', 'fixed')530 .property('bottom', '0')531 .property('height', '13px')532 .property('background-color', '#eee')533 .endSection()534535 .section()536 .match('.qilvgallery_preload_gauge_inner')537 .property('z-index', '50102')538 .property('border', '0')539 .property('padding', '0')540 .property('margin', '0')541 .property('width', '0%')542 .property('position', 'static')543 .property('left', '0')544 .property('top', '0')545 .property('height', '100%')546 .property('background-color', '#f03')547 .property('text-align', 'center')548 .property('font-size', '11px')549 .property('font-family', 'Arial,Verdana,sans-serif,Helvetica')550 .property('font-weight', 'bold')551 .property('color', '#000000')552 .endSection()553554 .section()555 .match('.qilvgallery_infotip_about_blackscreen')556 .property('z-index', '50098')557 .property('width', '100%')558 .property('height', '100%')559 .property('position', 'fixed')560 .property('left', '0px')561 .property('top', '0px')562 .property('background', 'black')563 .property('opacity', '0.8')564 .endSection()565566 .section()567 .match('.qilvgallery_infotip_about_title')568 .property('font-size', '20pt')569 .endSection()570571 .section()572 .match('.qilvgallery_infotip_about_button')573 .property('width', '20em')574 .property('border', '1px solid #666')575 .property('background', '#ccc')576 .property('border-radius', '8px')577 .property('background', 'linear-gradient(0, #aaa, #eee)')578 .property('left', '0px')579 .property('right', '0px')580 .property('margin', '100px auto auto')581 .endSection()582583 .section()584 .match('.qilvgallery_infotip_center')585 .property('position', 'fixed')586 .property('left', '0')587 .property('right', '0')588 .property('top', '0')589 .property('bottom', '0')590 .property('margin', 'auto')591 .endSection()592593 .section()594 .match('.qilvgallery_infotip_about')595 .property('font-family', '"Trebuchet MS","Tahoma","Verdana","Arial","sans-serif"')596 .property('font-size', '15pt')597 .property('text-align', 'center')598 .property('max-width', '500px')599 .property('max-height', '300px')600 .property('border', '1px solid white')601 .property('background', 'linear-gradient(180deg, #f8f8f8, #dddddd)')602 .property('z-index', '50100')603 .endSection()604605 .section()606 .match('.qilvgallery_infotip_help')607 .property('display', 'block')608 .property('position', 'absolute')609 .property('left', '4px')610 .property('top', '4px')611 .property('padding', '15px')612 .property('font-size', '13px')613 .property('border', '1px solid white')614 .property('background', 'linear-gradient(180deg, #f8f8f8, #dddddd)')615 .property('color', '#000000')616 .property('font-family', '"courier new"')617 .property('border-radius', '5px')618 .property('z-index', '50001')619 .endSection()620621 .section()622 .match('.qilvgallery_infotip_help_title')623 .property('font-size', '2em')624 .property('font-weight', 'bold')625 .endSection()626627 .section()628 .match('.qilvgallery_infotip_help_content')629 .property('margin-left', '10px')630 .endSection()631632 .section()633 .match('.qilvgallery_infobox_textarea')634 .property('white-space', 'pre')635 .endSection()636637 .section()638 .match('.qilvgallery_about_infobox')639 .property('margin', '0')640 .property('padding', '0')641 .property('border', '0')642 .endSection()643644 .section()645 .match('.qilvgallery_image_outter')646 .property('margin', '0')647 .property('padding', '0')648 .property('border', '0')649 .property('position', 'absolute')650 .property('display', 'block')651 .property('opacity', '0')652 .property('left', '0')653 .property('right', '0')654 .property('top', '0')655 .property('bottom', '0')656 .property('transition', 'opacity ease-out')657 .property('transition-duration', '0s')658 .endSection()659660 .section()661 .match('.qilv_transition-300 .qilvgallery_image_outter')662 .property('transition-duration', '0.3s')663 .endSection()664665 .section()666 .match('.qilv_transition-800 .qilvgallery_image_outter')667 .property('transition-duration', '0.8s')668 .endSection()669670 .section()671 .match('.qilv_transition-1500 .qilvgallery_image_outter')672 .property('transition-duration', '1.5s')673 .endSection()674675 .section()676 .match('.qilvgallery_image_outter.qilv_shown')677 .property('opacity', '1')678 .property('display', 'block')679 .endSection()680681 .section()682 .match('.qilvgallery_image')683 .property('margin', 'unset')684 .property('padding', '0')685 .property('display', 'block')686 .property('position', 'absolute')687 .property('left', '0')688 .property('top', '0')689 .property('z-index', '50000')690 .property('box-sizing', 'border-box')691 .property('border', '2px solid black')692 .property('right', 'unset')693 .property('bottom', 'unset')694 .property('width', 'auto')695 .property('height', 'auto')696 .property('max-width', 'unset')697 .property('max-height', 'unset')698 .endSection()699700 .section()701 .match('.qilv_maxSize .qilvgallery_image')702 .property('max-width', '100%')703 .property('max-height', '100%')704 .endSection()705706 .section()707 .match('.qilv_autoX .qilvgallery_image')708 .property('width', '100%')709 .endSection()710711 .section()712 .match('.qilv_autoY .qilvgallery_image')713 .property('height', '100%')714 .endSection()715716 .section()717 .match('.qilvgallery_image.qilv_loading')718 .property('border', '2px solid red')719 .endSection()720721 .section()722 .match('.qilv_centered .qilvgallery_image')723 .property('right', '0')724 .property('bottom', '0')725 .property('margin', 'auto')726 .endSection()727728 .section()729 .match('#qilvgallery_preload_all_panel')730 .property('display', 'none')731 .endSection()732733 .section()734 .match('#qilvgallery_black_screen')735 .property('z-index', '499998')736 .property('width', '100%')737 .property('height', '100%')738 .property('left', '0')739 .property('top', '0')740 .property('background', 'black')741 .property('margin', '0')742 .property('padding', '0')743 .endSection()744745 .endCss()746 ;747 }
...
pavement.py
Source:pavement.py
1# [[[section imports]]]2from paver.easy import *3import paver.doctools4from paver.setuputils import setup5# [[[endsection]]]6# [[[section setup]]]7setup(8 name="TheNewWay",9 packages=['newway'],10 version="1.0",11 url="http://www.blueskyonmars.com/",12 author="Kevin Dangoor",13 author_email="dangoor@gmail.com"14)15# [[[endsection]]]16# [[[section sphinx]]]17options(18 sphinx=Bunch(19 builddir="_build"20 )21)22# [[[endsection]]]23# [[[section deployoptions]]]24options(25 deploy = Bunch(26 htmldir = path('newway/docs'),27 hosts = ['host1.hostymost.com', 'host2.hostymost.com'],28 hostpath = 'sites/newway'29 )30)31# [[[endsection]]]32# [[[section minilib]]]33options(34 minilib = Bunch(35 extra_files=["doctools"]36 )37)38# [[[endsection]]]39# [[[section sdist]]]40@task41@needs('generate_setup', 'minilib', 'setuptools.command.sdist')42def sdist():43 """Overrides sdist to make sure that our setup.py is generated."""44 pass45# [[[endsection]]]46# [[[section html]]]47@task48@needs('paver.doctools.html')49def html(options):50 """Build the docs and put them into our package."""51 destdir = path('newway/docs')52 destdir.rmtree()53 # [[[section builtdocs]]]54 builtdocs = path("docs") / options.builddir / "html"55 # [[[endsection]]]56 builtdocs.move(destdir)57# [[[endsection]]] 58# [[[section deploy]]]59@task60@cmdopts([61 ('username=', 'u', 'Username to use when logging in to the servers')62])63def deploy(options):64 """Deploy the HTML to the server."""65 for host in options.hosts:66 sh("rsync -avz -e ssh %s/ %s@%s:%s/" % (options.htmldir,67 options.username, host, options.hostpath))68# [[[endsection]]]69# the pass that follows is to work around a weird bug. It looks like70# you can't compile a Python module that ends in a comment....
endSection.js
Source:endSection.js
1'use strict';2 3var Section = require('../classes/SectionClass');4var TextPanel = require('../objects3D/TextPanelObject3D');5var LookAtField = require('../objects3D/LookAtFieldObject3D');6var endSection = new Section('end');7var text = new TextPanel(8 'T H A N K S \n F O R W A T C H I N G',9 {10 align: 'center',11 style: '',12 size: 50,13 lineSpacing: 4014 }15);16endSection.add(text.el);17var field = new LookAtField({18 count: 5019});20endSection.add(field.el);21endSection.onIn(function () {22 text.in();23 field.in();24});25endSection.onOut(function (way) {26 text.out(way);27 field.out(way);28});...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!