diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-29 22:43:35 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-29 22:43:35 -0400 |
commit | 9bc2ab482c42ee3b3f051b1b403713f9f0922a15 (patch) | |
tree | fe6cd9f6fc2706e448cc65342a3172381e356139 /doc | |
parent | 4c4f4ac9dcd7e9377c623ff11cac7cb3a65fc7ce (diff) | |
download | python-coveragepy-git-9bc2ab482c42ee3b3f051b1b403713f9f0922a15.tar.gz |
docs: sample HTML report for 6.1
Diffstat (limited to 'doc')
18 files changed, 4545 insertions, 4698 deletions
diff --git a/doc/sample_html/coverage_html.js b/doc/sample_html/coverage_html.js index 30d3a067..d111289b 100644 --- a/doc/sample_html/coverage_html.js +++ b/doc/sample_html/coverage_html.js @@ -7,227 +7,191 @@ coverage = {}; -// Find all the elements with shortkey_* class, and use them to assign a shortcut key. -coverage.assign_shortkeys = function () { - $("*[class*='shortkey_']").each(function (i, e) { - $.each($(e).attr("class").split(" "), function (i, c) { - if (/^shortkey_/.test(c)) { - $(document).bind('keydown', c.substr(9), function () { - $(e).click(); - }); - } - }); - }); +// General helpers +function debounce(callback, wait) { + let timeoutId = null; + return function(...args) { + clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + callback.apply(this, args); + }, wait); + }; }; -// Create the events for the help panel. -coverage.wire_up_help_panel = function () { - $("#keyboard_icon").click(function () { - // Show the help panel, and position it so the keyboard icon in the - // panel is in the same place as the keyboard icon in the header. - $(".help_panel").show(); - var koff = $("#keyboard_icon").offset(); - var poff = $("#panel_icon").position(); - $(".help_panel").offset({ - top: koff.top-poff.top-1, - left: koff.left-poff.left-1 +function checkVisible(element) { + const rect = element.getBoundingClientRect(); + const viewBottom = Math.max(document.documentElement.clientHeight, window.innerHeight); + const viewTop = 30; + return !(rect.bottom < viewTop || rect.top >= viewBottom); +} + +// Helpers for table sorting +function getCellValue(row, column = 0) { + const cell = row.cells[column] + if (cell.childElementCount == 1) { + const child = cell.firstElementChild + if (child instanceof HTMLTimeElement && child.dateTime) { + return child.dateTime + } else if (child instanceof HTMLDataElement && child.value) { + return child.value + } + } + return cell.innerText || cell.textContent; +} + +function rowComparator(rowA, rowB, column = 0) { + let valueA = getCellValue(rowA, column); + let valueB = getCellValue(rowB, column); + if (!isNaN(valueA) && !isNaN(valueB)) { + return valueA - valueB + } + return valueA.localeCompare(valueB, undefined, {numeric: true}); +} + +function sortColumn(th) { + // Get the current sorting direction of the selected header, + // clear state on other headers and then set the new sorting direction + const currentSortOrder = th.getAttribute("aria-sort"); + [...th.parentElement.cells].forEach(header => header.setAttribute("aria-sort", "none")); + if (currentSortOrder === "none") { + th.setAttribute("aria-sort", th.dataset.defaultSortOrder || "ascending"); + } else { + th.setAttribute("aria-sort", currentSortOrder === "ascending" ? "descending" : "ascending"); + } + + const column = [...th.parentElement.cells].indexOf(th) + + // Sort all rows and afterwards append them in order to move them in the DOM + Array.from(th.closest("table").querySelectorAll("tbody tr")) + .sort((rowA, rowB) => rowComparator(rowA, rowB, column) * (th.getAttribute("aria-sort") === "ascending" ? 1 : -1)) + .forEach(tr => tr.parentElement.appendChild(tr) ); +} + +// Find all the elements with data-shortcut attribute, and use them to assign a shortcut key. +coverage.assign_shortkeys = function () { + document.querySelectorAll("[data-shortcut]").forEach(element => { + document.addEventListener("keypress", event => { + if (event.target.tagName.toLowerCase() === "input") { + return; // ignore keypress from search filter + } + if (event.key === element.dataset.shortcut) { + element.click(); + } }); }); - $("#panel_icon").click(function () { - $(".help_panel").hide(); - }); }; // Create the events for the filter box. coverage.wire_up_filter = function () { // Cache elements. - var table = $("table.index"); - var table_rows = table.find("tbody tr"); - var table_row_names = table_rows.find("td.name a"); - var no_rows = $("#no_rows"); - - // Create a duplicate table footer that we can modify with dynamic summed values. - var table_footer = $("table.index tfoot tr"); - var table_dynamic_footer = table_footer.clone(); - table_dynamic_footer.attr('class', 'total_dynamic hidden'); - table_footer.after(table_dynamic_footer); + const table = document.querySelector("table.index"); + const table_body_rows = table.querySelectorAll("tbody tr"); + const no_rows = document.getElementById("no_rows"); // Observe filter keyevents. - $("#filter").on("keyup change", $.debounce(150, function (event) { - var filter_value = $(this).val(); - - if (filter_value === "") { - // Filter box is empty, remove all filtering. - table_rows.removeClass("hidden"); - - // Show standard footer, hide dynamic footer. - table_footer.removeClass("hidden"); - table_dynamic_footer.addClass("hidden"); - - // Hide placeholder, show table. - if (no_rows.length > 0) { - no_rows.hide(); + document.getElementById("filter").addEventListener("input", debounce(event => { + // Keep running total of each metric, first index contains number of shown rows + const totals = new Array(table.rows[0].cells.length).fill(0); + // Accumulate the percentage as fraction + totals[totals.length - 1] = { "numer": 0, "denom": 0 }; + + // Hide / show elements. + table_body_rows.forEach(row => { + if (!row.cells[0].textContent.includes(event.target.value)) { + // hide + row.classList.add("hidden"); + return; } - table.show(); - } - else { - // Filter table items by value. - var hidden = 0; - var shown = 0; - - // Hide / show elements. - $.each(table_row_names, function () { - var element = $(this).parents("tr"); - - if ($(this).text().indexOf(filter_value) === -1) { - // hide - element.addClass("hidden"); - hidden++; - } - else { - // show - element.removeClass("hidden"); - shown++; - } - }); - - // Show placeholder if no rows will be displayed. - if (no_rows.length > 0) { - if (shown === 0) { - // Show placeholder, hide table. - no_rows.show(); - table.hide(); - } - else { - // Hide placeholder, show table. - no_rows.hide(); - table.show(); + // show + row.classList.remove("hidden"); + totals[0]++; + + for (let column = 1; column < totals.length; column++) { + // Accumulate dynamic totals + cell = row.cells[column] + if (column === totals.length - 1) { + // Last column contains percentage + const [numer, denom] = cell.dataset.ratio.split(" "); + totals[column]["numer"] += parseInt(numer, 10); + totals[column]["denom"] += parseInt(denom, 10); + } else { + totals[column] += parseInt(cell.textContent, 10); } } + }); - // Manage dynamic header: - if (hidden > 0) { - // Calculate new dynamic sum values based on visible rows. - for (var column = 2; column < 20; column++) { - // Calculate summed value. - var cells = table_rows.find('td:nth-child(' + column + ')'); - if (!cells.length) { - // No more columns...! - break; - } - - var sum = 0, numer = 0, denom = 0; - $.each(cells.filter(':visible'), function () { - var ratio = $(this).data("ratio"); - if (ratio) { - var splitted = ratio.split(" "); - numer += parseInt(splitted[0], 10); - denom += parseInt(splitted[1], 10); - } - else { - sum += parseInt(this.innerHTML, 10); - } - }); - - // Get footer cell element. - var footer_cell = table_dynamic_footer.find('td:nth-child(' + column + ')'); - - // Set value into dynamic footer cell element. - if (cells[0].innerHTML.indexOf('%') > -1) { - // Percentage columns use the numerator and denominator, - // and adapt to the number of decimal places. - var match = /\.([0-9]+)/.exec(cells[0].innerHTML); - var places = 0; - if (match) { - places = match[1].length; - } - var pct = numer * 100 / denom; - footer_cell.text(pct.toFixed(places) + '%'); - } - else { - footer_cell.text(sum); - } - } + // Show placeholder if no rows will be displayed. + if (!totals[0]) { + // Show placeholder, hide table. + no_rows.style.display = "block"; + table.style.display = "none"; + return; + } - // Hide standard footer, show dynamic footer. - table_footer.addClass("hidden"); - table_dynamic_footer.removeClass("hidden"); - } - else { - // Show standard footer, hide dynamic footer. - table_footer.removeClass("hidden"); - table_dynamic_footer.addClass("hidden"); + // Hide placeholder, show table. + no_rows.style.display = null; + table.style.display = null; + + const footer = table.tFoot.rows[0]; + // Calculate new dynamic sum values based on visible rows. + for (let column = 1; column < totals.length; column++) { + // Get footer cell element. + const cell = footer.cells[column]; + + // Set value into dynamic footer cell element. + if (column === totals.length - 1) { + // Percentage column uses the numerator and denominator, + // and adapts to the number of decimal places. + const match = /\.([0-9]+)/.exec(cell.textContent); + const places = match ? match[1].length : 0; + const { numer, denom } = totals[column]; + cell.dataset.ratio = `${numer} ${denom}`; + // Check denom to prevent NaN if filtered files contain no statements + cell.textContent = denom + ? `${(numer * 100 / denom).toFixed(places)}%` + : `${(100).toFixed(places)}%`; + } else { + cell.textContent = totals[column]; } } })); // Trigger change event on setup, to force filter on page refresh // (filter value may still be present). - $("#filter").trigger("change"); + document.getElementById("filter").dispatchEvent(new Event("change")); }; +coverage.INDEX_SORT_STORAGE = "COVERAGE_INDEX_SORT_2"; + // Loaded on index.html -coverage.index_ready = function ($) { +coverage.index_ready = function () { + coverage.assign_shortkeys(); + coverage.wire_up_filter(); + document.querySelectorAll("[data-sortable] th[aria-sort]").forEach( + th => th.addEventListener("click", e => sortColumn(e.target)) + ); + // Look for a localStorage item containing previous sort settings: - var sort_list = []; - var storage_name = "COVERAGE_INDEX_SORT"; - var stored_list = undefined; - try { - stored_list = localStorage.getItem(storage_name); - } catch(err) {} + const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE); if (stored_list) { - sort_list = JSON.parse('[[' + stored_list + ']]'); + const {column, direction} = JSON.parse(stored_list); + const th = document.querySelector("[data-sortable]").tHead.rows[0].cells[column]; + th.setAttribute("aria-sort", direction === "ascending" ? "descending" : "ascending"); + th.click() } - // Create a new widget which exists only to save and restore - // the sort order: - $.tablesorter.addWidget({ - id: "persistentSort", - - // Format is called by the widget before displaying: - format: function (table) { - if (table.config.sortList.length === 0 && sort_list.length > 0) { - // This table hasn't been sorted before - we'll use - // our stored settings: - $(table).trigger('sorton', [sort_list]); - } - else { - // This is not the first load - something has - // already defined sorting so we'll just update - // our stored value to match: - sort_list = table.config.sortList; - } - } - }); - - // Configure our tablesorter to handle the variable number of - // columns produced depending on report options: - var headers = []; - var col_count = $("table.index > thead > tr > th").length; - - headers[0] = { sorter: 'text' }; - for (i = 1; i < col_count-1; i++) { - headers[i] = { sorter: 'digit' }; - } - headers[col_count-1] = { sorter: 'percent' }; - - // Enable the table sorter: - $("table.index").tablesorter({ - widgets: ['persistentSort'], - headers: headers - }); - - coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); - coverage.wire_up_filter(); - // Watch for page unload events so we can save the final sort settings: - $(window).on("unload", function () { - try { - localStorage.setItem(storage_name, sort_list.toString()) - } catch(err) {} + window.addEventListener("unload", function () { + const th = document.querySelector('[data-sortable] th[aria-sort="ascending"], [data-sortable] [aria-sort="descending"]'); + if (!th) { + return; + } + localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({ + column: [...th.parentElement.cells].indexOf(th), + direction: th.getAttribute("aria-sort"), + })); }); }; @@ -235,28 +199,25 @@ coverage.index_ready = function ($) { coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS"; -coverage.pyfile_ready = function ($) { +coverage.pyfile_ready = function () { // If we're directed to a particular line number, highlight the line. var frag = location.hash; if (frag.length > 2 && frag[1] === 't') { - $(frag).addClass('highlight'); + document.querySelector(frag).closest(".n").classList.add("highlight"); coverage.set_sel(parseInt(frag.substr(2), 10)); - } - else { + } else { coverage.set_sel(0); } - $(document) - .bind('keydown', 'j', coverage.to_next_chunk_nicely) - .bind('keydown', 'k', coverage.to_prev_chunk_nicely) - .bind('keydown', '0', coverage.to_top) - .bind('keydown', '1', coverage.to_first_chunk) - ; + document.querySelector(".button_toggle_run").addEventListener("click", coverage.toggle_lines); + document.querySelector(".button_toggle_mis").addEventListener("click", coverage.toggle_lines); + document.querySelector(".button_toggle_exc").addEventListener("click", coverage.toggle_lines); + document.querySelector(".button_toggle_par").addEventListener("click", coverage.toggle_lines); - $(".button_toggle_run").click(function (evt) {coverage.toggle_lines(evt.target, "run");}); - $(".button_toggle_exc").click(function (evt) {coverage.toggle_lines(evt.target, "exc");}); - $(".button_toggle_mis").click(function (evt) {coverage.toggle_lines(evt.target, "mis");}); - $(".button_toggle_par").click(function (evt) {coverage.toggle_lines(evt.target, "par");}); + document.querySelector(".button_next_chunk").addEventListener("click", coverage.to_next_chunk_nicely); + document.querySelector(".button_prev_chunk").addEventListener("click", coverage.to_prev_chunk_nicely); + document.querySelector(".button_top_of_page").addEventListener("click", coverage.to_top); + document.querySelector(".button_first_chunk").addEventListener("click", coverage.to_first_chunk); coverage.filters = undefined; try { @@ -275,40 +236,41 @@ coverage.pyfile_ready = function ($) { } coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); - coverage.init_scroll_markers(); + coverage.wire_up_sticky_header(); // Rebuild scroll markers when the window height changes. - $(window).resize(coverage.build_scroll_markers); + window.addEventListener("resize", coverage.build_scroll_markers); }; -coverage.toggle_lines = function (btn, cls) { - var onoff = !$(btn).hasClass("show_" + cls); - coverage.set_line_visibilty(cls, onoff); +coverage.toggle_lines = function (event) { + const btn = event.target.closest("button"); + const category = btn.value + const show = !btn.classList.contains("show_" + category); + coverage.set_line_visibilty(category, show); coverage.build_scroll_markers(); - coverage.filters[cls] = onoff; + coverage.filters[category] = show; try { localStorage.setItem(coverage.LINE_FILTERS_STORAGE, JSON.stringify(coverage.filters)); } catch(err) {} }; -coverage.set_line_visibilty = function (cls, onoff) { - var show = "show_" + cls; - var btn = $(".button_toggle_" + cls); - if (onoff) { - $("#source ." + cls).addClass(show); - btn.addClass(show); +coverage.set_line_visibilty = function (category, should_show) { + const cls = "show_" + category; + const btn = document.querySelector(".button_toggle_" + category); + if (should_show) { + document.querySelectorAll("#source ." + category).forEach(e => e.classList.add(cls)); + btn.classList.add(cls); } else { - $("#source ." + cls).removeClass(show); - btn.removeClass(show); + document.querySelectorAll("#source ." + category).forEach(e => e.classList.remove(cls)); + btn.classList.remove(cls); } }; // Return the nth line div. coverage.line_elt = function (n) { - return $("#t" + n); + return document.getElementById("t" + n)?.closest("p"); }; // Set the selection. b and e are line numbers. @@ -332,25 +294,26 @@ coverage.to_first_chunk = function () { // Return a string indicating what kind of chunk this line belongs to, // or null if not a chunk. coverage.chunk_indicator = function (line_elt) { - var klass = line_elt.attr('class'); - if (klass) { - var m = klass.match(/\bshow_\w+\b/); - if (m) { - return m[0]; - } + const classes = line_elt?.className; + if (!classes) { + return null; + } + const match = classes.match(/\bshow_\w+\b/); + if (!match) { + return null; } - return null; + return match[0]; }; coverage.to_next_chunk = function () { - var c = coverage; + const c = coverage; // Find the start of the next colored chunk. var probe = c.sel_end; var chunk_indicator, probe_line; while (true) { probe_line = c.line_elt(probe); - if (probe_line.length === 0) { + if (!probe_line) { return; } chunk_indicator = c.chunk_indicator(probe_line); @@ -375,19 +338,19 @@ coverage.to_next_chunk = function () { }; coverage.to_prev_chunk = function () { - var c = coverage; + const c = coverage; // Find the end of the prev colored chunk. var probe = c.sel_begin-1; var probe_line = c.line_elt(probe); - if (probe_line.length === 0) { + if (!probe_line) { return; } var chunk_indicator = c.chunk_indicator(probe_line); - while (probe > 0 && !chunk_indicator) { + while (probe > 1 && !chunk_indicator) { probe--; probe_line = c.line_elt(probe); - if (probe_line.length === 0) { + if (!probe_line) { return; } chunk_indicator = c.chunk_indicator(probe_line); @@ -400,6 +363,9 @@ coverage.to_prev_chunk = function () { var prev_indicator = chunk_indicator; while (prev_indicator === chunk_indicator) { probe--; + if (probe <= 0) { + return; + } probe_line = c.line_elt(probe); prev_indicator = c.chunk_indicator(probe_line); } @@ -407,28 +373,6 @@ coverage.to_prev_chunk = function () { c.show_selection(); }; -// Return the line number of the line nearest pixel position pos -coverage.line_at_pos = function (pos) { - var l1 = coverage.line_elt(1), - l2 = coverage.line_elt(2), - result; - if (l1.length && l2.length) { - var l1_top = l1.offset().top, - line_height = l2.offset().top - l1_top, - nlines = (pos - l1_top) / line_height; - if (nlines < 1) { - result = 1; - } - else { - result = Math.ceil(nlines); - } - } - else { - result = 1; - } - return result; -}; - // Returns 0, 1, or 2: how many of the two ends of the selection are on // the screen right now? coverage.selection_ends_on_screen = function () { @@ -436,31 +380,49 @@ coverage.selection_ends_on_screen = function () { return 0; } - var top = coverage.line_elt(coverage.sel_begin); - var next = coverage.line_elt(coverage.sel_end-1); + const begin = coverage.line_elt(coverage.sel_begin); + const end = coverage.line_elt(coverage.sel_end-1); return ( - (top.isOnScreen() ? 1 : 0) + - (next.isOnScreen() ? 1 : 0) + (checkVisible(begin) ? 1 : 0) + + (checkVisible(end) ? 1 : 0) ); }; coverage.to_next_chunk_nicely = function () { - coverage.finish_scrolling(); if (coverage.selection_ends_on_screen() === 0) { - // The selection is entirely off the screen: select the top line on - // the screen. - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop())); + // The selection is entirely off the screen: + // Set the top line on the screen as selection. + + // This will select the top-left of the viewport + // As this is most likely the span with the line number we take the parent + const line = document.elementFromPoint(0, 0).parentElement; + if (line.parentElement !== document.getElementById("source")) { + // The element is not a source line but the header or similar + coverage.select_line_or_chunk(1); + } else { + // We extract the line number from the id + coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10)); + } } coverage.to_next_chunk(); }; coverage.to_prev_chunk_nicely = function () { - coverage.finish_scrolling(); if (coverage.selection_ends_on_screen() === 0) { - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop() + win.height())); + // The selection is entirely off the screen: + // Set the lowest line on the screen as selection. + + // This will select the bottom-left of the viewport + // As this is most likely the span with the line number we take the parent + const line = document.elementFromPoint(document.documentElement.clientHeight-1, 0).parentElement; + if (line.parentElement !== document.getElementById("source")) { + // The element is not a source line but the header or similar + coverage.select_line_or_chunk(coverage.lines_len); + } else { + // We extract the line number from the id + coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10)); + } } coverage.to_prev_chunk(); }; @@ -470,7 +432,7 @@ coverage.to_prev_chunk_nicely = function () { coverage.select_line_or_chunk = function (lineno) { var c = coverage; var probe_line = c.line_elt(lineno); - if (probe_line.length === 0) { + if (!probe_line) { return; } var the_indicator = c.chunk_indicator(probe_line); @@ -482,7 +444,7 @@ coverage.select_line_or_chunk = function (lineno) { while (probe > 0 && indicator === the_indicator) { probe--; probe_line = c.line_elt(probe); - if (probe_line.length === 0) { + if (!probe_line) { break; } indicator = c.chunk_indicator(probe_line); @@ -506,106 +468,100 @@ coverage.select_line_or_chunk = function (lineno) { }; coverage.show_selection = function () { - var c = coverage; - // Highlight the lines in the chunk - $("#source .highlight").removeClass("highlight"); - for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) { - c.line_elt(probe).addClass("highlight"); + document.querySelectorAll("#source .highlight").forEach(e => e.classList.remove("highlight")); + for (let probe = coverage.sel_begin; probe < coverage.sel_end; probe++) { + coverage.line_elt(probe).querySelector(".n").classList.add("highlight"); } - c.scroll_to_selection(); + coverage.scroll_to_selection(); }; coverage.scroll_to_selection = function () { // Scroll the page if the chunk isn't fully visible. if (coverage.selection_ends_on_screen() < 2) { - // Need to move the page. The html,body trick makes it scroll in all - // browsers, got it from http://stackoverflow.com/questions/3042651 - var top = coverage.line_elt(coverage.sel_begin); - var top_pos = parseInt(top.offset().top, 10); - coverage.scroll_window(top_pos - 30); + const element = coverage.line_elt(coverage.sel_begin); + coverage.scroll_window(element.offsetTop - 60); } }; coverage.scroll_window = function (to_pos) { - $("html,body").animate({scrollTop: to_pos}, 200); -}; - -coverage.finish_scrolling = function () { - $("html,body").stop(true, true); + window.scroll({top: to_pos, behavior: "smooth"}); }; coverage.init_scroll_markers = function () { - var c = coverage; // Init some variables - c.lines_len = $('#source p').length; - c.body_h = $('body').height(); - c.header_h = $('div#header').height(); + coverage.lines_len = document.querySelectorAll('#source > p').length; // Build html - c.build_scroll_markers(); + coverage.build_scroll_markers(); }; coverage.build_scroll_markers = function () { - var c = coverage, - min_line_height = 3, - max_line_height = 10, - visible_window_h = $(window).height(); - - c.lines_to_mark = $('#source').find('p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par'); - $('#scroll_marker').remove(); + const temp_scroll_marker = document.getElementById('scroll_marker') + if (temp_scroll_marker) temp_scroll_marker.remove(); // Don't build markers if the window has no scroll bar. - if (c.body_h <= visible_window_h) { + if (document.body.scrollHeight <= window.innerHeight) { return; } - $("body").append("<div id='scroll_marker'> </div>"); - var scroll_marker = $('#scroll_marker'), - marker_scale = scroll_marker.height() / c.body_h, - line_height = scroll_marker.height() / c.lines_len; + const marker_scale = window.innerHeight / document.body.scrollHeight; + const line_height = Math.min(Math.max(3, window.innerHeight / coverage.lines_len), 10); - // Line height must be between the extremes. - if (line_height > min_line_height) { - if (line_height > max_line_height) { - line_height = max_line_height; - } - } - else { - line_height = min_line_height; - } - - var previous_line = -99, - last_mark, - last_top, - offsets = {}; + let previous_line = -99, last_mark, last_top; - // Calculate line offsets outside loop to prevent relayouts - c.lines_to_mark.each(function() { - offsets[this.id] = $(this).offset().top; - }); - c.lines_to_mark.each(function () { - var id_name = $(this).attr('id'), - line_top = Math.round(offsets[id_name] * marker_scale), - line_number = parseInt(id_name.substring(1, id_name.length)); + const scroll_marker = document.createElement("div"); + scroll_marker.id = "scroll_marker"; + document.getElementById('source').querySelectorAll( + 'p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par' + ).forEach(element => { + const line_top = Math.floor(element.offsetTop * marker_scale); + const line_number = parseInt(element.id.substr(1)); if (line_number === previous_line + 1) { // If this solid missed block just make previous mark higher. - last_mark.css({ - 'height': line_top + line_height - last_top - }); - } - else { + last_mark.style.height = `${line_top + line_height - last_top}px`; + } else { // Add colored line in scroll_marker block. - scroll_marker.append('<div id="m' + line_number + '" class="marker"></div>'); - last_mark = $('#m' + line_number); - last_mark.css({ - 'height': line_height, - 'top': line_top - }); + last_mark = document.createElement("div"); + last_mark.id = `m${line_number}`; + last_mark.classList.add("marker"); + last_mark.style.height = `${line_height}px`; + last_mark.style.top = `${line_top}px`; + scroll_marker.append(last_mark); last_top = line_top; } previous_line = line_number; }); + + // Append last to prevent layout calculation + document.body.append(scroll_marker); }; + +coverage.wire_up_sticky_header = function () { + const header = document.querySelector('header'); + const header_bottom = ( + header.querySelector('.content h2').getBoundingClientRect().top - + header.getBoundingClientRect().top + ); + + function updateHeader() { + if (window.scrollY > header_bottom) { + header.classList.add('sticky'); + } else { + header.classList.remove('sticky'); + } + } + + window.addEventListener('scroll', updateHeader); + updateHeader(); +}; + +document.addEventListener("DOMContentLoaded", () => { + if (document.body.classList.contains("indexfile")) { + coverage.index_ready(); + } else { + coverage.pyfile_ready(); + } +}); diff --git a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html index 617fdbef..938496dc 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html @@ -6,70 +6,75 @@ <title>Coverage for cogapp/__init__.py: 100.00%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/__init__.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/__init__.py</b>: <span class="pc_cov">100.00%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 2 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">2 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">0 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">2 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">2<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">0<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Cog content generation tool.</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2015, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Cog content generation tool.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2015, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80___main___py.html b/doc/sample_html/d_7b071bdc2a35fa80___main___py.html index 464019fb..f9652ea1 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80___main___py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80___main___py.html @@ -6,66 +6,71 @@ <title>Coverage for cogapp/__main__.py: 0.00%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/__main__.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/__main__.py</b>: <span class="pc_cov">0.00%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 3 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">0 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">3 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">3 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">0<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">3<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">"""Make Cog runnable directly from the module."""</span> </span><span class="r"></span></p> - <p id="t2" class="mis show_mis"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> - <p id="t3" class="mis show_mis"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="key">from</span> <span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">Cog</span> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t5" class="mis show_mis"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="nam">sys</span><span class="op">.</span><span class="nam">exit</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">"""Make Cog runnable directly from the module."""</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"><span class="key">from</span> <span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">Cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="nam">sys</span><span class="op">.</span><span class="nam">exit</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_backward_py.html b/doc/sample_html/d_7b071bdc2a35fa80_backward_py.html index f997eec8..9a3e9009 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_backward_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_backward_py.html @@ -6,103 +6,108 @@ <title>Coverage for cogapp/backward.py: 69.23%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/backward.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/backward.py</b>: <span class="pc_cov">69.23%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 22 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">16 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">6 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">2 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">22 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">16<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">6<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">2<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">"""Compatibility between Py2 and Py3."""</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t3" class="run"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> - <p id="t4" class="run"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="key">import</span> <span class="nam">unittest</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t6" class="run"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="nam">PY3</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">version_info</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">==</span> <span class="num">3</span> </span><span class="r"></span></p> - <p id="t7" class="pln"><span class="n"><a href="#t7">7</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t8" class="par run show_par"><span class="n"><a href="#t8">8</a></span><span class="t"><span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"><span class="annotate short">8 ↛ 14</span><span class="annotate long">line 8 didn't jump to line 14, because the condition on line 8 was never false</span></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"> <span class="nam">string_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">str</span><span class="op">,</span><span class="nam">bytes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"> <span class="nam">bytes_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">bytes</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"> <span class="key">def</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"> <span class="key">return</span> <span class="nam">s</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="str">'utf8'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t13" class="pln"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t14" class="mis show_mis"><span class="n"><a href="#t14">14</a></span><span class="t"> <span class="nam">string_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">basestring</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t15" class="mis show_mis"><span class="n"><a href="#t15">15</a></span><span class="t"> <span class="nam">bytes_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">str</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t16" class="mis show_mis"><span class="n"><a href="#t16">16</a></span><span class="t"> <span class="key">def</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t17" class="mis show_mis"><span class="n"><a href="#t17">17</a></span><span class="t"> <span class="key">return</span> <span class="nam">s</span> </span><span class="r"></span></p> - <p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="com"># Pythons 2 and 3 differ on where to get StringIO</span> </span><span class="r"></span></p> - <p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"><span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t21" class="run"><span class="n"><a href="#t21">21</a></span><span class="t"> <span class="key">from</span> <span class="nam">cStringIO</span> <span class="key">import</span> <span class="nam">StringIO</span> </span><span class="r"></span></p> - <p id="t22" class="run"><span class="n"><a href="#t22">22</a></span><span class="t"><span class="key">except</span> <span class="nam">ImportError</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t23" class="run"><span class="n"><a href="#t23">23</a></span><span class="t"> <span class="key">from</span> <span class="nam">io</span> <span class="key">import</span> <span class="nam">StringIO</span> </span><span class="r"></span></p> - <p id="t24" class="pln"><span class="n"><a href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t25" class="pln"><span class="n"><a href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t26" class="run"><span class="n"><a href="#t26">26</a></span><span class="t"><span class="key">def</span> <span class="nam">unittest_has</span><span class="op">(</span><span class="nam">method</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t27" class="pln"><span class="n"><a href="#t27">27</a></span><span class="t"> <span class="str">"""Does `unittest.TestCase` have `method` defined?"""</span> </span><span class="r"></span></p> - <p id="t28" class="run"><span class="n"><a href="#t28">28</a></span><span class="t"> <span class="key">return</span> <span class="nam">hasattr</span><span class="op">(</span><span class="nam">unittest</span><span class="op">.</span><span class="nam">TestCase</span><span class="op">,</span> <span class="nam">method</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t31" class="run"><span class="n"><a href="#t31">31</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCase</span><span class="op">(</span><span class="nam">unittest</span><span class="op">.</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t32" class="pln"><span class="n"><a href="#t32">32</a></span><span class="t"> <span class="str">"""Just like unittest.TestCase, but with assert methods added.</span> </span><span class="r"></span></p> - <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t"><span class="str"> Designed to be compatible with 3.1 unittest. Methods are only defined if</span> </span><span class="r"></span></p> - <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t"><span class="str"> `unittest` doesn't have them.</span> </span><span class="r"></span></p> - <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"> <span class="com"># pylint: disable=missing-docstring</span> </span><span class="r"></span></p> - <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t40" class="par run show_par"><span class="n"><a href="#t40">40</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">unittest_has</span><span class="op">(</span><span class="str">'assertRaisesRegex'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">40 ↛ 41</span><span class="annotate long">line 40 didn't jump to line 41, because the condition on line 40 was never true</span></span></p> - <p id="t41" class="mis show_mis"><span class="n"><a href="#t41">41</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="op">*</span><span class="nam">args</span><span class="op">,</span> <span class="op">**</span><span class="nam">kwargs</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t42" class="mis show_mis"><span class="n"><a href="#t42">42</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegexp</span><span class="op">(</span><span class="op">*</span><span class="nam">args</span><span class="op">,</span> <span class="op">**</span><span class="nam">kwargs</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">"""Compatibility between Py2 and Py3."""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="key">import</span> <span class="nam">unittest</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"><span class="nam">PY3</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">version_info</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">==</span> <span class="num">3</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"><span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"><span class="annotate short">8 ↛ 14</span><span class="annotate long">line 8 didn't jump to line 14, because the condition on line 8 was never false</span></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"> <span class="nam">string_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">str</span><span class="op">,</span><span class="nam">bytes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"> <span class="nam">bytes_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">bytes</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"> <span class="key">def</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"> <span class="key">return</span> <span class="nam">s</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="str">'utf8'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"> <span class="nam">string_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">basestring</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"> <span class="nam">bytes_types</span> <span class="op">=</span> <span class="op">(</span><span class="nam">str</span><span class="op">,</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"> <span class="key">def</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"> <span class="key">return</span> <span class="nam">s</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"><span class="com"># Pythons 2 and 3 differ on where to get StringIO</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"><span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"> <span class="key">from</span> <span class="nam">cStringIO</span> <span class="key">import</span> <span class="nam">StringIO</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"><span class="key">except</span> <span class="nam">ImportError</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"> <span class="key">from</span> <span class="nam">io</span> <span class="key">import</span> <span class="nam">StringIO</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"><span class="key">def</span> <span class="nam">unittest_has</span><span class="op">(</span><span class="nam">method</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="str">"""Does `unittest.TestCase` have `method` defined?"""</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> <span class="key">return</span> <span class="nam">hasattr</span><span class="op">(</span><span class="nam">unittest</span><span class="op">.</span><span class="nam">TestCase</span><span class="op">,</span> <span class="nam">method</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCase</span><span class="op">(</span><span class="nam">unittest</span><span class="op">.</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="str">"""Just like unittest.TestCase, but with assert methods added.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"><span class="str"> Designed to be compatible with 3.1 unittest. Methods are only defined if</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"><span class="str"> `unittest` doesn't have them.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"> <span class="com"># pylint: disable=missing-docstring</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">unittest_has</span><span class="op">(</span><span class="str">'assertRaisesRegex'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">40 ↛ 41</span><span class="annotate long">line 40 didn't jump to line 41, because the condition on line 40 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="op">*</span><span class="nam">args</span><span class="op">,</span> <span class="op">**</span><span class="nam">kwargs</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegexp</span><span class="op">(</span><span class="op">*</span><span class="nam">args</span><span class="op">,</span> <span class="op">**</span><span class="nam">kwargs</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html b/doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html index 6fe42303..9793f644 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html @@ -6,871 +6,876 @@ <title>Coverage for cogapp/cogapp.py: 49.42%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/cogapp.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/cogapp.py</b>: <span class="pc_cov">49.42%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 486 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">271 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">215 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">1 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">28 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">486 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">271<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">215<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">1<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">28<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="com"># coding: utf8</span> </span><span class="r"></span></p> - <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str">""" Cog content generation tool.</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t7" class="pln"><span class="n"><a href="#t7">7</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t8" class="run"><span class="n"><a href="#t8">8</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span><span class="op">,</span> <span class="nam">print_function</span> </span><span class="r"></span></p> - <p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">copy</span> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">getopt</span> </span><span class="r"></span></p> - <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">glob</span> </span><span class="r"></span></p> - <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">import</span> <span class="nam">hashlib</span> </span><span class="r"></span></p> - <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="key">import</span> <span class="nam">linecache</span> </span><span class="r"></span></p> - <p id="t15" class="run"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> - <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> - <p id="t17" class="run"><span class="n"><a href="#t17">17</a></span><span class="t"><span class="key">import</span> <span class="nam">shlex</span> </span><span class="r"></span></p> - <p id="t18" class="run"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> - <p id="t19" class="run"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="key">import</span> <span class="nam">traceback</span> </span><span class="r"></span></p> - <p id="t20" class="pln"><span class="n"><a href="#t20">20</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t21" class="run"><span class="n"><a href="#t21">21</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">PY3</span><span class="op">,</span> <span class="nam">StringIO</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">to_bytes</span> </span><span class="r"></span></p> - <p id="t22" class="pln"><span class="n"><a href="#t22">22</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t23" class="run"><span class="n"><a href="#t23">23</a></span><span class="t"><span class="nam">__all__</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Cog'</span><span class="op">,</span> <span class="str">'CogUsageError'</span><span class="op">,</span> <span class="str">'main'</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t24" class="pln"><span class="n"><a href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t25" class="run"><span class="n"><a href="#t25">25</a></span><span class="t"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">'3.1.0'</span> </span><span class="r"></span></p> - <p id="t26" class="pln"><span class="n"><a href="#t26">26</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t27" class="run"><span class="n"><a href="#t27">27</a></span><span class="t"><span class="nam">usage</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t28" class="pln"><span class="n"><a href="#t28">28</a></span><span class="t"><span class="str">cog - generate content with inlined Python code.</span> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t"><span class="str">cog [OPTIONS] [INFILE | @FILELIST] ...</span> </span><span class="r"></span></p> - <p id="t31" class="pln"><span class="n"><a href="#t31">31</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t32" class="pln"><span class="n"><a href="#t32">32</a></span><span class="t"><span class="str">INFILE is the name of an input file, '-' will read from stdin.</span> </span><span class="r"></span></p> - <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t"><span class="str">FILELIST is the name of a text file containing file names or</span> </span><span class="r"></span></p> - <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t"><span class="str"> other @FILELISTs.</span> </span><span class="r"></span></p> - <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t"><span class="str">OPTIONS:</span> </span><span class="r"></span></p> - <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"><span class="str"> -c Checksum the output to protect it against accidental change.</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"><span class="str"> -d Delete the generator code from the output file.</span> </span><span class="r"></span></p> - <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t"><span class="str"> -D name=val Define a global string available to your generator code.</span> </span><span class="r"></span></p> - <p id="t40" class="pln"><span class="n"><a href="#t40">40</a></span><span class="t"><span class="str"> -e Warn if a file has no cog code in it.</span> </span><span class="r"></span></p> - <p id="t41" class="pln"><span class="n"><a href="#t41">41</a></span><span class="t"><span class="str"> -I PATH Add PATH to the list of directories for data files and modules.</span> </span><span class="r"></span></p> - <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"><span class="str"> -n ENCODING Use ENCODING when reading and writing files.</span> </span><span class="r"></span></p> - <p id="t43" class="pln"><span class="n"><a href="#t43">43</a></span><span class="t"><span class="str"> -o OUTNAME Write the output to OUTNAME.</span> </span><span class="r"></span></p> - <p id="t44" class="pln"><span class="n"><a href="#t44">44</a></span><span class="t"><span class="str"> -p PROLOGUE Prepend the generator source with PROLOGUE. Useful to insert an</span> </span><span class="r"></span></p> - <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t"><span class="str"> import line. Example: -p "import math"</span> </span><span class="r"></span></p> - <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t"><span class="str"> -r Replace the input file with the output.</span> </span><span class="r"></span></p> - <p id="t47" class="pln"><span class="n"><a href="#t47">47</a></span><span class="t"><span class="str"> -s STRING Suffix all generated output lines with STRING.</span> </span><span class="r"></span></p> - <p id="t48" class="pln"><span class="n"><a href="#t48">48</a></span><span class="t"><span class="str"> -U Write the output with Unix newlines (only LF line-endings).</span> </span><span class="r"></span></p> - <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t"><span class="str"> -w CMD Use CMD if the output file needs to be made writable.</span> </span><span class="r"></span></p> - <p id="t50" class="pln"><span class="n"><a href="#t50">50</a></span><span class="t"><span class="str"> A %s in the CMD will be filled with the filename.</span> </span><span class="r"></span></p> - <p id="t51" class="pln"><span class="n"><a href="#t51">51</a></span><span class="t"><span class="str"> -x Excise all the generated output without running the generators.</span> </span><span class="r"></span></p> - <p id="t52" class="pln"><span class="n"><a href="#t52">52</a></span><span class="t"><span class="str"> -z The end-output marker can be omitted, and is assumed at eof.</span> </span><span class="r"></span></p> - <p id="t53" class="pln"><span class="n"><a href="#t53">53</a></span><span class="t"><span class="str"> -v Print the version of cog and exit.</span> </span><span class="r"></span></p> - <p id="t54" class="pln"><span class="n"><a href="#t54">54</a></span><span class="t"><span class="str"> --verbosity=VERBOSITY</span> </span><span class="r"></span></p> - <p id="t55" class="pln"><span class="n"><a href="#t55">55</a></span><span class="t"><span class="str"> Control the amount of output. 2 (the default) lists all files,</span> </span><span class="r"></span></p> - <p id="t56" class="pln"><span class="n"><a href="#t56">56</a></span><span class="t"><span class="str"> 1 lists only changed files, 0 lists no files.</span> </span><span class="r"></span></p> - <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t"><span class="str"> --markers='START END END-OUTPUT'</span> </span><span class="r"></span></p> - <p id="t58" class="pln"><span class="n"><a href="#t58">58</a></span><span class="t"><span class="str"> The patterns surrounding cog inline instructions. Should</span> </span><span class="r"></span></p> - <p id="t59" class="pln"><span class="n"><a href="#t59">59</a></span><span class="t"><span class="str"> include three values separated by spaces, the start, end,</span> </span><span class="r"></span></p> - <p id="t60" class="pln"><span class="n"><a href="#t60">60</a></span><span class="t"><span class="str"> and end-output markers. Defaults to '[[[cog ]]] [[[end]]]'.</span> </span><span class="r"></span></p> - <p id="t61" class="pln"><span class="n"><a href="#t61">61</a></span><span class="t"><span class="str"> -h Print this help.</span> </span><span class="r"></span></p> - <p id="t62" class="pln"><span class="n"><a href="#t62">62</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t"><span class="com"># Other package modules</span> </span><span class="r"></span></p> - <p id="t65" class="run"><span class="n"><a href="#t65">65</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> - <p id="t66" class="pln"><span class="n"><a href="#t66">66</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t67" class="run"><span class="n"><a href="#t67">67</a></span><span class="t"><span class="key">class</span> <span class="nam">CogError</span><span class="op">(</span><span class="nam">Exception</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t68" class="pln"><span class="n"><a href="#t68">68</a></span><span class="t"> <span class="str">""" Any exception raised by Cog.</span> </span><span class="r"></span></p> - <p id="t69" class="pln"><span class="n"><a href="#t69">69</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t70" class="run"><span class="n"><a href="#t70">70</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t71" class="run"><span class="n"><a href="#t71">71</a></span><span class="t"> <span class="key">if</span> <span class="nam">file</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t72" class="run"><span class="n"><a href="#t72">72</a></span><span class="t"> <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="str">"%s(%d): %s"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">file</span><span class="op">,</span> <span class="nam">line</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t73" class="pln"><span class="n"><a href="#t73">73</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t74" class="run"><span class="n"><a href="#t74">74</a></span><span class="t"> <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t75" class="pln"><span class="n"><a href="#t75">75</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t76" class="run"><span class="n"><a href="#t76">76</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t77" class="pln"><span class="n"><a href="#t77">77</a></span><span class="t"> <span class="str">""" An error in usage of command-line arguments in cog.</span> </span><span class="r"></span></p> - <p id="t78" class="pln"><span class="n"><a href="#t78">78</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t79" class="run"><span class="n"><a href="#t79">79</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> - <p id="t80" class="pln"><span class="n"><a href="#t80">80</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t81" class="run"><span class="n"><a href="#t81">81</a></span><span class="t"><span class="key">class</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t82" class="pln"><span class="n"><a href="#t82">82</a></span><span class="t"> <span class="str">""" An error in the coding of Cog. Should never happen.</span> </span><span class="r"></span></p> - <p id="t83" class="pln"><span class="n"><a href="#t83">83</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t84" class="run"><span class="n"><a href="#t84">84</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> - <p id="t85" class="pln"><span class="n"><a href="#t85">85</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t86" class="run"><span class="n"><a href="#t86">86</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t87" class="pln"><span class="n"><a href="#t87">87</a></span><span class="t"> <span class="str">""" An error raised by a user's cog generator.</span> </span><span class="r"></span></p> - <p id="t88" class="pln"><span class="n"><a href="#t88">88</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t89" class="run"><span class="n"><a href="#t89">89</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> - <p id="t90" class="pln"><span class="n"><a href="#t90">90</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t91" class="run"><span class="n"><a href="#t91">91</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t92" class="pln"><span class="n"><a href="#t92">92</a></span><span class="t"> <span class="str">""" An exception caught when running a user's cog generator.</span> </span><span class="r"></span></p> - <p id="t93" class="pln"><span class="n"><a href="#t93">93</a></span><span class="t"><span class="str"> The argument is the traceback message to print.</span> </span><span class="r"></span></p> - <p id="t94" class="pln"><span class="n"><a href="#t94">94</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t95" class="run"><span class="n"><a href="#t95">95</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> - <p id="t96" class="pln"><span class="n"><a href="#t96">96</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t97" class="run"><span class="n"><a href="#t97">97</a></span><span class="t"><span class="key">class</span> <span class="nam">Redirectable</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t98" class="pln"><span class="n"><a href="#t98">98</a></span><span class="t"> <span class="str">""" An object with its own stdout and stderr files.</span> </span><span class="r"></span></p> - <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t100" class="run"><span class="n"><a href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t101" class="run"><span class="n"><a href="#t101">101</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdout</span> </span><span class="r"></span></p> - <p id="t102" class="run"><span class="n"><a href="#t102">102</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> </span><span class="r"></span></p> - <p id="t103" class="pln"><span class="n"><a href="#t103">103</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t104" class="run"><span class="n"><a href="#t104">104</a></span><span class="t"> <span class="key">def</span> <span class="nam">setOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">stdout</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">stderr</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t105" class="pln"><span class="n"><a href="#t105">105</a></span><span class="t"> <span class="str">""" Assign new files for standard out and/or standard error.</span> </span><span class="r"></span></p> - <p id="t106" class="pln"><span class="n"><a href="#t106">106</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t107" class="par run show_par"><span class="n"><a href="#t107">107</a></span><span class="t"> <span class="key">if</span> <span class="nam">stdout</span><span class="op">:</span> </span><span class="r"><span class="annotate short">107 ↛ 109</span><span class="annotate long">line 107 didn't jump to line 109, because the condition on line 107 was never false</span></span></p> - <p id="t108" class="run"><span class="n"><a href="#t108">108</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">stdout</span> </span><span class="r"></span></p> - <p id="t109" class="par run show_par"><span class="n"><a href="#t109">109</a></span><span class="t"> <span class="key">if</span> <span class="nam">stderr</span><span class="op">:</span> </span><span class="r"><span class="annotate short">109 ↛ 110</span><span class="annotate long">line 109 didn't jump to line 110, because the condition on line 109 was never true</span></span></p> - <p id="t110" class="mis show_mis"><span class="n"><a href="#t110">110</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">stderr</span> </span><span class="r"></span></p> - <p id="t111" class="pln"><span class="n"><a href="#t111">111</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t112" class="run"><span class="n"><a href="#t112">112</a></span><span class="t"> <span class="key">def</span> <span class="nam">prout</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t113" class="mis show_mis"><span class="n"><a href="#t113">113</a></span><span class="t"> <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t114" class="pln"><span class="n"><a href="#t114">114</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t115" class="run"><span class="n"><a href="#t115">115</a></span><span class="t"> <span class="key">def</span> <span class="nam">prerr</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t116" class="mis show_mis"><span class="n"><a href="#t116">116</a></span><span class="t"> <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t117" class="pln"><span class="n"><a href="#t117">117</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t118" class="pln"><span class="n"><a href="#t118">118</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t119" class="run"><span class="n"><a href="#t119">119</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t120" class="pln"><span class="n"><a href="#t120">120</a></span><span class="t"> <span class="str">""" A generator pulled from a source file.</span> </span><span class="r"></span></p> - <p id="t121" class="pln"><span class="n"><a href="#t121">121</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t122" class="run"><span class="n"><a href="#t122">122</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">options</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t123" class="run"><span class="n"><a href="#t123">123</a></span><span class="t"> <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t124" class="run"><span class="n"><a href="#t124">124</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t125" class="run"><span class="n"><a href="#t125">125</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t126" class="run"><span class="n"><a href="#t126">126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">options</span> <span class="key">or</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t127" class="pln"><span class="n"><a href="#t127">127</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t128" class="run"><span class="n"><a href="#t128">128</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseMarker</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t129" class="run"><span class="n"><a href="#t129">129</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t130" class="pln"><span class="n"><a href="#t130">130</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t131" class="run"><span class="n"><a href="#t131">131</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t132" class="run"><span class="n"><a href="#t132">132</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t133" class="pln"><span class="n"><a href="#t133">133</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t134" class="run"><span class="n"><a href="#t134">134</a></span><span class="t"> <span class="key">def</span> <span class="nam">getCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t135" class="pln"><span class="n"><a href="#t135">135</a></span><span class="t"> <span class="str">""" Extract the executable Python code from the generator.</span> </span><span class="r"></span></p> - <p id="t136" class="pln"><span class="n"><a href="#t136">136</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t137" class="pln"><span class="n"><a href="#t137">137</a></span><span class="t"> <span class="com"># If the markers and lines all have the same prefix</span> </span><span class="r"></span></p> - <p id="t138" class="pln"><span class="n"><a href="#t138">138</a></span><span class="t"> <span class="com"># (end-of-line comment chars, for example),</span> </span><span class="r"></span></p> - <p id="t139" class="pln"><span class="n"><a href="#t139">139</a></span><span class="t"> <span class="com"># then remove it from all the lines.</span> </span><span class="r"></span></p> - <p id="t140" class="run"><span class="n"><a href="#t140">140</a></span><span class="t"> <span class="nam">prefIn</span> <span class="op">=</span> <span class="nam">commonPrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t141" class="run"><span class="n"><a href="#t141">141</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefIn</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t142" class="run"><span class="n"><a href="#t142">142</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">]</span> </span><span class="r"></span></p> - <p id="t143" class="run"><span class="n"><a href="#t143">143</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">]</span> </span><span class="r"></span></p> - <p id="t144" class="pln"><span class="n"><a href="#t144">144</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t145" class="run"><span class="n"><a href="#t145">145</a></span><span class="t"> <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t146" class="pln"><span class="n"><a href="#t146">146</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t147" class="run"><span class="n"><a href="#t147">147</a></span><span class="t"> <span class="key">def</span> <span class="nam">evaluate</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">cog</span><span class="op">,</span> <span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t148" class="pln"><span class="n"><a href="#t148">148</a></span><span class="t"> <span class="com"># figure out the right whitespace prefix for the output</span> </span><span class="r"></span></p> - <p id="t149" class="run"><span class="n"><a href="#t149">149</a></span><span class="t"> <span class="nam">prefOut</span> <span class="op">=</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t150" class="pln"><span class="n"><a href="#t150">150</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t151" class="run"><span class="n"><a href="#t151">151</a></span><span class="t"> <span class="nam">intext</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t152" class="run"><span class="n"><a href="#t152">152</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">intext</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t153" class="run"><span class="n"><a href="#t153">153</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t154" class="pln"><span class="n"><a href="#t154">154</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t155" class="run"><span class="n"><a href="#t155">155</a></span><span class="t"> <span class="nam">prologue</span> <span class="op">=</span> <span class="str">"import "</span> <span class="op">+</span> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">+</span> <span class="str">" as cog\n"</span> </span><span class="r"></span></p> - <p id="t156" class="par run show_par"><span class="n"><a href="#t156">156</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span><span class="op">:</span> </span><span class="r"><span class="annotate short">156 ↛ 157</span><span class="annotate long">line 156 didn't jump to line 157, because the condition on line 156 was never true</span></span></p> - <p id="t157" class="mis show_mis"><span class="n"><a href="#t157">157</a></span><span class="t"> <span class="nam">prologue</span> <span class="op">+=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">+</span> <span class="str">'\n'</span> </span><span class="r"></span></p> - <p id="t158" class="run"><span class="n"><a href="#t158">158</a></span><span class="t"> <span class="nam">code</span> <span class="op">=</span> <span class="nam">compile</span><span class="op">(</span><span class="nam">prologue</span> <span class="op">+</span> <span class="nam">intext</span><span class="op">,</span> <span class="nam">str</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span><span class="op">,</span> <span class="str">'exec'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t159" class="pln"><span class="n"><a href="#t159">159</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t160" class="pln"><span class="n"><a href="#t160">160</a></span><span class="t"> <span class="com"># Make sure the "cog" module has our state.</span> </span><span class="r"></span></p> - <p id="t161" class="run"><span class="n"><a href="#t161">161</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">msg</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">msg</span> </span><span class="r"></span></p> - <p id="t162" class="run"><span class="n"><a href="#t162">162</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">out</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span> </span><span class="r"></span></p> - <p id="t163" class="run"><span class="n"><a href="#t163">163</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outl</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outl</span> </span><span class="r"></span></p> - <p id="t164" class="run"><span class="n"><a href="#t164">164</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">error</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">error</span> </span><span class="r"></span></p> - <p id="t165" class="pln"><span class="n"><a href="#t165">165</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t166" class="run"><span class="n"><a href="#t166">166</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t167" class="run"><span class="n"><a href="#t167">167</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t168" class="run"><span class="n"><a href="#t168">168</a></span><span class="t"> <span class="nam">eval</span><span class="op">(</span><span class="nam">code</span><span class="op">,</span> <span class="nam">globals</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t169" class="par run show_par"><span class="n"><a href="#t169">169</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogError</span><span class="op">:</span> </span><span class="r"><span class="annotate short">169 ↛ 170</span><span class="annotate long">line 169 didn't jump to line 170, because the exception caught by line 169 didn't happen</span></span></p> - <p id="t170" class="mis show_mis"><span class="n"><a href="#t170">170</a></span><span class="t"> <span class="key">raise</span> </span><span class="r"></span></p> - <p id="t171" class="run"><span class="n"><a href="#t171">171</a></span><span class="t"> <span class="key">except</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t172" class="run"><span class="n"><a href="#t172">172</a></span><span class="t"> <span class="nam">typ</span><span class="op">,</span> <span class="nam">err</span><span class="op">,</span> <span class="nam">tb</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">exc_info</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t173" class="run"><span class="n"><a href="#t173">173</a></span><span class="t"> <span class="nam">frames</span> <span class="op">=</span> <span class="op">(</span><span class="nam">tuple</span><span class="op">(</span><span class="nam">fr</span><span class="op">)</span> <span class="key">for</span> <span class="nam">fr</span> <span class="key">in</span> <span class="nam">traceback</span><span class="op">.</span><span class="nam">extract_tb</span><span class="op">(</span><span class="nam">tb</span><span class="op">.</span><span class="nam">tb_next</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t174" class="run"><span class="n"><a href="#t174">174</a></span><span class="t"> <span class="nam">frames</span> <span class="op">=</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frames</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t175" class="run"><span class="n"><a href="#t175">175</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">""</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">traceback</span><span class="op">.</span><span class="nam">format_list</span><span class="op">(</span><span class="nam">frames</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t176" class="run"><span class="n"><a href="#t176">176</a></span><span class="t"> <span class="nam">msg</span> <span class="op">+=</span> <span class="str">"{}: {}"</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">typ</span><span class="op">.</span><span class="nam">__name__</span><span class="op">,</span> <span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t177" class="run"><span class="n"><a href="#t177">177</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t178" class="pln"><span class="n"><a href="#t178">178</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t179" class="pln"><span class="n"><a href="#t179">179</a></span><span class="t"> <span class="com"># We need to make sure that the last line in the output</span> </span><span class="r"></span></p> - <p id="t180" class="pln"><span class="n"><a href="#t180">180</a></span><span class="t"> <span class="com"># ends with a newline, or it will be joined to the</span> </span><span class="r"></span></p> - <p id="t181" class="pln"><span class="n"><a href="#t181">181</a></span><span class="t"> <span class="com"># end-output line, ruining cog's idempotency.</span> </span><span class="r"></span></p> - <p id="t182" class="run"><span class="n"><a href="#t182">182</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> <span class="op">!=</span> <span class="str">'\n'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t183" class="run"><span class="n"><a href="#t183">183</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="str">'\n'</span> </span><span class="r"></span></p> - <p id="t184" class="pln"><span class="n"><a href="#t184">184</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t185" class="run"><span class="n"><a href="#t185">185</a></span><span class="t"> <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">,</span> <span class="nam">prefOut</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t186" class="pln"><span class="n"><a href="#t186">186</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t187" class="run"><span class="n"><a href="#t187">187</a></span><span class="t"> <span class="key">def</span> <span class="nam">msg</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t188" class="mis show_mis"><span class="n"><a href="#t188">188</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Message: "</span><span class="op">+</span><span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t189" class="pln"><span class="n"><a href="#t189">189</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t190" class="run"><span class="n"><a href="#t190">190</a></span><span class="t"> <span class="key">def</span> <span class="nam">out</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">dedent</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">trimblanklines</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t191" class="pln"><span class="n"><a href="#t191">191</a></span><span class="t"> <span class="str">""" The cog.out function.</span> </span><span class="r"></span></p> - <p id="t192" class="pln"><span class="n"><a href="#t192">192</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t193" class="run"><span class="n"><a href="#t193">193</a></span><span class="t"> <span class="key">if</span> <span class="nam">trimblanklines</span> <span class="key">and</span> <span class="op">(</span><span class="str">'\n'</span> <span class="key">in</span> <span class="nam">sOut</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t194" class="run"><span class="n"><a href="#t194">194</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">sOut</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t195" class="run"><span class="n"><a href="#t195">195</a></span><span class="t"> <span class="key">if</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t196" class="run"><span class="n"><a href="#t196">196</a></span><span class="t"> <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t197" class="run"><span class="n"><a href="#t197">197</a></span><span class="t"> <span class="key">if</span> <span class="nam">lines</span> <span class="key">and</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t198" class="run"><span class="n"><a href="#t198">198</a></span><span class="t"> <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t199" class="run"><span class="n"><a href="#t199">199</a></span><span class="t"> <span class="nam">sOut</span> <span class="op">=</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">lines</span><span class="op">)</span><span class="op">+</span><span class="str">'\n'</span> </span><span class="r"></span></p> - <p id="t200" class="run"><span class="n"><a href="#t200">200</a></span><span class="t"> <span class="key">if</span> <span class="nam">dedent</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t201" class="run"><span class="n"><a href="#t201">201</a></span><span class="t"> <span class="nam">sOut</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">sOut</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t202" class="run"><span class="n"><a href="#t202">202</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="nam">sOut</span> </span><span class="r"></span></p> - <p id="t203" class="pln"><span class="n"><a href="#t203">203</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t204" class="run"><span class="n"><a href="#t204">204</a></span><span class="t"> <span class="key">def</span> <span class="nam">outl</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t205" class="pln"><span class="n"><a href="#t205">205</a></span><span class="t"> <span class="str">""" The cog.outl function.</span> </span><span class="r"></span></p> - <p id="t206" class="pln"><span class="n"><a href="#t206">206</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t207" class="run"><span class="n"><a href="#t207">207</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="nam">sOut</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t208" class="run"><span class="n"><a href="#t208">208</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t209" class="pln"><span class="n"><a href="#t209">209</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t210" class="run"><span class="n"><a href="#t210">210</a></span><span class="t"> <span class="key">def</span> <span class="nam">error</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">=</span><span class="str">'Error raised by cog generator.'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t211" class="pln"><span class="n"><a href="#t211">211</a></span><span class="t"> <span class="str">""" The cog.error function.</span> </span><span class="r"></span></p> - <p id="t212" class="pln"><span class="n"><a href="#t212">212</a></span><span class="t"><span class="str"> Instead of raising standard python errors, cog generators can use</span> </span><span class="r"></span></p> - <p id="t213" class="pln"><span class="n"><a href="#t213">213</a></span><span class="t"><span class="str"> this function. It will display the error without a scary Python</span> </span><span class="r"></span></p> - <p id="t214" class="pln"><span class="n"><a href="#t214">214</a></span><span class="t"><span class="str"> traceback.</span> </span><span class="r"></span></p> - <p id="t215" class="pln"><span class="n"><a href="#t215">215</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t216" class="mis show_mis"><span class="n"><a href="#t216">216</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t217" class="pln"><span class="n"><a href="#t217">217</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t218" class="pln"><span class="n"><a href="#t218">218</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t219" class="run"><span class="n"><a href="#t219">219</a></span><span class="t"><span class="key">class</span> <span class="nam">NumberedFileReader</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t220" class="pln"><span class="n"><a href="#t220">220</a></span><span class="t"> <span class="str">""" A decorator for files that counts the readline()'s called.</span> </span><span class="r"></span></p> - <p id="t221" class="pln"><span class="n"><a href="#t221">221</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t222" class="run"><span class="n"><a href="#t222">222</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">f</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t223" class="run"><span class="n"><a href="#t223">223</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">f</span> <span class="op">=</span> <span class="nam">f</span> </span><span class="r"></span></p> - <p id="t224" class="run"><span class="n"><a href="#t224">224</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">=</span> <span class="num">0</span> </span><span class="r"></span></p> - <p id="t225" class="pln"><span class="n"><a href="#t225">225</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t226" class="run"><span class="n"><a href="#t226">226</a></span><span class="t"> <span class="key">def</span> <span class="nam">readline</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t227" class="run"><span class="n"><a href="#t227">227</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">f</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t228" class="run"><span class="n"><a href="#t228">228</a></span><span class="t"> <span class="key">if</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t229" class="run"><span class="n"><a href="#t229">229</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">+=</span> <span class="num">1</span> </span><span class="r"></span></p> - <p id="t230" class="run"><span class="n"><a href="#t230">230</a></span><span class="t"> <span class="key">return</span> <span class="nam">l</span> </span><span class="r"></span></p> - <p id="t231" class="pln"><span class="n"><a href="#t231">231</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t232" class="run"><span class="n"><a href="#t232">232</a></span><span class="t"> <span class="key">def</span> <span class="nam">linenumber</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t233" class="run"><span class="n"><a href="#t233">233</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> </span><span class="r"></span></p> - <p id="t234" class="pln"><span class="n"><a href="#t234">234</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t235" class="pln"><span class="n"><a href="#t235">235</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t236" class="run"><span class="n"><a href="#t236">236</a></span><span class="t"><span class="key">class</span> <span class="nam">CogOptions</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t237" class="pln"><span class="n"><a href="#t237">237</a></span><span class="t"> <span class="str">""" Options for a run of cog.</span> </span><span class="r"></span></p> - <p id="t238" class="pln"><span class="n"><a href="#t238">238</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t239" class="run"><span class="n"><a href="#t239">239</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t240" class="pln"><span class="n"><a href="#t240">240</a></span><span class="t"> <span class="com"># Defaults for argument values.</span> </span><span class="r"></span></p> - <p id="t241" class="run"><span class="n"><a href="#t241">241</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t242" class="run"><span class="n"><a href="#t242">242</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t243" class="run"><span class="n"><a href="#t243">243</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t244" class="run"><span class="n"><a href="#t244">244</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t245" class="run"><span class="n"><a href="#t245">245</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> - <p id="t246" class="run"><span class="n"><a href="#t246">246</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t247" class="run"><span class="n"><a href="#t247">247</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t248" class="run"><span class="n"><a href="#t248">248</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> - <p id="t249" class="run"><span class="n"><a href="#t249">249</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t250" class="run"><span class="n"><a href="#t250">250</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t251" class="run"><span class="n"><a href="#t251">251</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t252" class="run"><span class="n"><a href="#t252">252</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t253" class="run"><span class="n"><a href="#t253">253</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> - <p id="t254" class="run"><span class="n"><a href="#t254">254</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t255" class="run"><span class="n"><a href="#t255">255</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="op">=</span> <span class="str">'[[[cog'</span> </span><span class="r"></span></p> - <p id="t256" class="run"><span class="n"><a href="#t256">256</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="op">=</span> <span class="str">']]]'</span> </span><span class="r"></span></p> - <p id="t257" class="run"><span class="n"><a href="#t257">257</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="str">'[[[end]]]'</span> </span><span class="r"></span></p> - <p id="t258" class="run"><span class="n"><a href="#t258">258</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="str">"utf-8"</span> </span><span class="r"></span></p> - <p id="t259" class="run"><span class="n"><a href="#t259">259</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="num">2</span> </span><span class="r"></span></p> - <p id="t260" class="run"><span class="n"><a href="#t260">260</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t261" class="pln"><span class="n"><a href="#t261">261</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t262" class="run"><span class="n"><a href="#t262">262</a></span><span class="t"> <span class="key">def</span> <span class="nam">__eq__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">other</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t263" class="pln"><span class="n"><a href="#t263">263</a></span><span class="t"> <span class="str">""" Comparison operator for tests to use.</span> </span><span class="r"></span></p> - <p id="t264" class="pln"><span class="n"><a href="#t264">264</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t265" class="mis show_mis"><span class="n"><a href="#t265">265</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">__dict__</span> <span class="op">==</span> <span class="nam">other</span><span class="op">.</span><span class="nam">__dict__</span> </span><span class="r"></span></p> - <p id="t266" class="pln"><span class="n"><a href="#t266">266</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t267" class="run"><span class="n"><a href="#t267">267</a></span><span class="t"> <span class="key">def</span> <span class="nam">clone</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t268" class="pln"><span class="n"><a href="#t268">268</a></span><span class="t"> <span class="str">""" Make a clone of these options, for further refinement.</span> </span><span class="r"></span></p> - <p id="t269" class="pln"><span class="n"><a href="#t269">269</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t270" class="mis show_mis"><span class="n"><a href="#t270">270</a></span><span class="t"> <span class="key">return</span> <span class="nam">copy</span><span class="op">.</span><span class="nam">deepcopy</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t271" class="pln"><span class="n"><a href="#t271">271</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t272" class="run"><span class="n"><a href="#t272">272</a></span><span class="t"> <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">dirs</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t273" class="pln"><span class="n"><a href="#t273">273</a></span><span class="t"> <span class="str">""" Add directories to the include path.</span> </span><span class="r"></span></p> - <p id="t274" class="pln"><span class="n"><a href="#t274">274</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t275" class="mis show_mis"><span class="n"><a href="#t275">275</a></span><span class="t"> <span class="nam">dirs</span> <span class="op">=</span> <span class="nam">dirs</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">pathsep</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t276" class="mis show_mis"><span class="n"><a href="#t276">276</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">dirs</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t277" class="pln"><span class="n"><a href="#t277">277</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t278" class="run"><span class="n"><a href="#t278">278</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseArgs</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t279" class="pln"><span class="n"><a href="#t279">279</a></span><span class="t"> <span class="com"># Parse the command line arguments.</span> </span><span class="r"></span></p> - <p id="t280" class="mis show_mis"><span class="n"><a href="#t280">280</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t281" class="mis show_mis"><span class="n"><a href="#t281">281</a></span><span class="t"> <span class="nam">opts</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">getopt</span><span class="op">(</span> </span><span class="r"></span></p> - <p id="t282" class="pln"><span class="n"><a href="#t282">282</a></span><span class="t"> <span class="nam">argv</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t283" class="pln"><span class="n"><a href="#t283">283</a></span><span class="t"> <span class="str">'cdD:eI:n:o:rs:p:Uvw:xz'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t284" class="pln"><span class="n"><a href="#t284">284</a></span><span class="t"> <span class="op">[</span> </span><span class="r"></span></p> - <p id="t285" class="pln"><span class="n"><a href="#t285">285</a></span><span class="t"> <span class="str">'markers='</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t286" class="pln"><span class="n"><a href="#t286">286</a></span><span class="t"> <span class="str">'verbosity='</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t287" class="pln"><span class="n"><a href="#t287">287</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> - <p id="t288" class="pln"><span class="n"><a href="#t288">288</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> - <p id="t289" class="mis show_mis"><span class="n"><a href="#t289">289</a></span><span class="t"> <span class="key">except</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">error</span> <span class="key">as</span> <span class="nam">msg</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t290" class="mis show_mis"><span class="n"><a href="#t290">290</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t291" class="pln"><span class="n"><a href="#t291">291</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t292" class="pln"><span class="n"><a href="#t292">292</a></span><span class="t"> <span class="com"># Handle the command line arguments.</span> </span><span class="r"></span></p> - <p id="t293" class="mis show_mis"><span class="n"><a href="#t293">293</a></span><span class="t"> <span class="key">for</span> <span class="nam">o</span><span class="op">,</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">opts</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t294" class="mis show_mis"><span class="n"><a href="#t294">294</a></span><span class="t"> <span class="key">if</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-c'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t295" class="mis show_mis"><span class="n"><a href="#t295">295</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t296" class="mis show_mis"><span class="n"><a href="#t296">296</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-d'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t297" class="mis show_mis"><span class="n"><a href="#t297">297</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t298" class="mis show_mis"><span class="n"><a href="#t298">298</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-D'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t299" class="mis show_mis"><span class="n"><a href="#t299">299</a></span><span class="t"> <span class="key">if</span> <span class="nam">a</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="str">'='</span><span class="op">)</span> <span class="op"><</span> <span class="num">1</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t300" class="mis show_mis"><span class="n"><a href="#t300">300</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"-D takes a name=value argument"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t301" class="mis show_mis"><span class="n"><a href="#t301">301</a></span><span class="t"> <span class="nam">name</span><span class="op">,</span> <span class="nam">value</span> <span class="op">=</span> <span class="nam">a</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'='</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t302" class="mis show_mis"><span class="n"><a href="#t302">302</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span><span class="op">[</span><span class="nam">name</span><span class="op">]</span> <span class="op">=</span> <span class="nam">value</span> </span><span class="r"></span></p> - <p id="t303" class="mis show_mis"><span class="n"><a href="#t303">303</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-e'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t304" class="mis show_mis"><span class="n"><a href="#t304">304</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t305" class="mis show_mis"><span class="n"><a href="#t305">305</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-I'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t306" class="mis show_mis"><span class="n"><a href="#t306">306</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t307" class="mis show_mis"><span class="n"><a href="#t307">307</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-n'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t308" class="mis show_mis"><span class="n"><a href="#t308">308</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> - <p id="t309" class="mis show_mis"><span class="n"><a href="#t309">309</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-o'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t310" class="mis show_mis"><span class="n"><a href="#t310">310</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> - <p id="t311" class="mis show_mis"><span class="n"><a href="#t311">311</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-r'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t312" class="mis show_mis"><span class="n"><a href="#t312">312</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t313" class="mis show_mis"><span class="n"><a href="#t313">313</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-s'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t314" class="mis show_mis"><span class="n"><a href="#t314">314</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> - <p id="t315" class="mis show_mis"><span class="n"><a href="#t315">315</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-p'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t316" class="mis show_mis"><span class="n"><a href="#t316">316</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> - <p id="t317" class="mis show_mis"><span class="n"><a href="#t317">317</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-U'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t318" class="mis show_mis"><span class="n"><a href="#t318">318</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t319" class="mis show_mis"><span class="n"><a href="#t319">319</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-v'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t320" class="mis show_mis"><span class="n"><a href="#t320">320</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t321" class="mis show_mis"><span class="n"><a href="#t321">321</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-w'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t322" class="mis show_mis"><span class="n"><a href="#t322">322</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> - <p id="t323" class="mis show_mis"><span class="n"><a href="#t323">323</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-x'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t324" class="mis show_mis"><span class="n"><a href="#t324">324</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t325" class="mis show_mis"><span class="n"><a href="#t325">325</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-z'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t326" class="mis show_mis"><span class="n"><a href="#t326">326</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t327" class="mis show_mis"><span class="n"><a href="#t327">327</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--markers'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t328" class="mis show_mis"><span class="n"><a href="#t328">328</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t329" class="mis show_mis"><span class="n"><a href="#t329">329</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--verbosity'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t330" class="mis show_mis"><span class="n"><a href="#t330">330</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t331" class="pln"><span class="n"><a href="#t331">331</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t332" class="pln"><span class="n"><a href="#t332">332</a></span><span class="t"> <span class="com"># Since getopt.getopt is given a list of possible flags,</span> </span><span class="r"></span></p> - <p id="t333" class="pln"><span class="n"><a href="#t333">333</a></span><span class="t"> <span class="com"># this is an internal error.</span> </span><span class="r"></span></p> - <p id="t334" class="exc show_exc"><span class="n"><a href="#t334">334</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="str">"Don't understand argument %s"</span> <span class="op">%</span> <span class="nam">o</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t335" class="pln"><span class="n"><a href="#t335">335</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t336" class="run"><span class="n"><a href="#t336">336</a></span><span class="t"> <span class="key">def</span> <span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">val</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t337" class="mis show_mis"><span class="n"><a href="#t337">337</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t338" class="mis show_mis"><span class="n"><a href="#t338">338</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="nam">val</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t339" class="mis show_mis"><span class="n"><a href="#t339">339</a></span><span class="t"> <span class="key">except</span> <span class="nam">ValueError</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t340" class="mis show_mis"><span class="n"><a href="#t340">340</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span> </span><span class="r"></span></p> - <p id="t341" class="pln"><span class="n"><a href="#t341">341</a></span><span class="t"> <span class="str">'--markers requires 3 values separated by spaces, could not parse %r'</span> <span class="op">%</span> <span class="nam">val</span> </span><span class="r"></span></p> - <p id="t342" class="pln"><span class="n"><a href="#t342">342</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> - <p id="t343" class="pln"><span class="n"><a href="#t343">343</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t344" class="run"><span class="n"><a href="#t344">344</a></span><span class="t"> <span class="key">def</span> <span class="nam">validate</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t345" class="pln"><span class="n"><a href="#t345">345</a></span><span class="t"> <span class="str">""" Does nothing if everything is OK, raises CogError's if it's not.</span> </span><span class="r"></span></p> - <p id="t346" class="pln"><span class="n"><a href="#t346">346</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t347" class="mis show_mis"><span class="n"><a href="#t347">347</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t348" class="mis show_mis"><span class="n"><a href="#t348">348</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -d with -r (or you would delete all your source!)"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t349" class="pln"><span class="n"><a href="#t349">349</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t350" class="mis show_mis"><span class="n"><a href="#t350">350</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t351" class="mis show_mis"><span class="n"><a href="#t351">351</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with -r (they are opposites)"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t352" class="pln"><span class="n"><a href="#t352">352</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t353" class="pln"><span class="n"><a href="#t353">353</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t354" class="run"><span class="n"><a href="#t354">354</a></span><span class="t"><span class="key">class</span> <span class="nam">Cog</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t355" class="pln"><span class="n"><a href="#t355">355</a></span><span class="t"> <span class="str">""" The Cog engine.</span> </span><span class="r"></span></p> - <p id="t356" class="pln"><span class="n"><a href="#t356">356</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t357" class="run"><span class="n"><a href="#t357">357</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t358" class="run"><span class="n"><a href="#t358">358</a></span><span class="t"> <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t359" class="run"><span class="n"><a href="#t359">359</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t360" class="run"><span class="n"><a href="#t360">360</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t361" class="run"><span class="n"><a href="#t361">361</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">"cog"</span> </span><span class="r"></span></p> - <p id="t362" class="run"><span class="n"><a href="#t362">362</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">createCogModule</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t363" class="pln"><span class="n"><a href="#t363">363</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t364" class="run"><span class="n"><a href="#t364">364</a></span><span class="t"> <span class="key">def</span> <span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t365" class="run"><span class="n"><a href="#t365">365</a></span><span class="t"> <span class="nam">end_output</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">escape</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t366" class="run"><span class="n"><a href="#t366">366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="nam">end_output</span> <span class="op">+</span> <span class="str">r'(?P<hashsect> *\(checksum: (?P<hash>[a-f0-9]+)\))'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t367" class="run"><span class="n"><a href="#t367">367</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">+</span> <span class="str">' (checksum: %s)'</span> </span><span class="r"></span></p> - <p id="t368" class="pln"><span class="n"><a href="#t368">368</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t369" class="run"><span class="n"><a href="#t369">369</a></span><span class="t"> <span class="key">def</span> <span class="nam">showWarning</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t370" class="mis show_mis"><span class="n"><a href="#t370">370</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Warning: "</span><span class="op">+</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t371" class="pln"><span class="n"><a href="#t371">371</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t372" class="run"><span class="n"><a href="#t372">372</a></span><span class="t"> <span class="key">def</span> <span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t373" class="run"><span class="n"><a href="#t373">373</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="key">in</span> <span class="nam">s</span> </span><span class="r"></span></p> - <p id="t374" class="pln"><span class="n"><a href="#t374">374</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t375" class="run"><span class="n"><a href="#t375">375</a></span><span class="t"> <span class="key">def</span> <span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t376" class="run"><span class="n"><a href="#t376">376</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="key">in</span> <span class="nam">s</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t377" class="pln"><span class="n"><a href="#t377">377</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t378" class="run"><span class="n"><a href="#t378">378</a></span><span class="t"> <span class="key">def</span> <span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t379" class="run"><span class="n"><a href="#t379">379</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="key">in</span> <span class="nam">s</span> </span><span class="r"></span></p> - <p id="t380" class="pln"><span class="n"><a href="#t380">380</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t381" class="run"><span class="n"><a href="#t381">381</a></span><span class="t"> <span class="key">def</span> <span class="nam">createCogModule</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t382" class="pln"><span class="n"><a href="#t382">382</a></span><span class="t"> <span class="str">""" Make a cog "module" object so that imported Python modules</span> </span><span class="r"></span></p> - <p id="t383" class="pln"><span class="n"><a href="#t383">383</a></span><span class="t"><span class="str"> can say "import cog" and get our state.</span> </span><span class="r"></span></p> - <p id="t384" class="pln"><span class="n"><a href="#t384">384</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t385" class="run"><span class="n"><a href="#t385">385</a></span><span class="t"> <span class="key">class</span> <span class="nam">DummyModule</span><span class="op">(</span><span class="nam">object</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t386" class="pln"><span class="n"><a href="#t386">386</a></span><span class="t"> <span class="str">"""Modules don't have to be anything special, just an object will do."""</span> </span><span class="r"></span></p> - <p id="t387" class="run"><span class="n"><a href="#t387">387</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> - <p id="t388" class="run"><span class="n"><a href="#t388">388</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> <span class="op">=</span> <span class="nam">DummyModule</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t389" class="run"><span class="n"><a href="#t389">389</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t390" class="pln"><span class="n"><a href="#t390">390</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t391" class="run"><span class="n"><a href="#t391">391</a></span><span class="t"> <span class="key">def</span> <span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t392" class="pln"><span class="n"><a href="#t392">392</a></span><span class="t"> <span class="str">""" Open an output file, taking all the details into account.</span> </span><span class="r"></span></p> - <p id="t393" class="pln"><span class="n"><a href="#t393">393</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t394" class="mis show_mis"><span class="n"><a href="#t394">394</a></span><span class="t"> <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t395" class="mis show_mis"><span class="n"><a href="#t395">395</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">"w"</span> </span><span class="r"></span></p> - <p id="t396" class="mis show_mis"><span class="n"><a href="#t396">396</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t397" class="mis show_mis"><span class="n"><a href="#t397">397</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span> </span><span class="r"></span></p> - <p id="t398" class="mis show_mis"><span class="n"><a href="#t398">398</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNewlines</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t399" class="mis show_mis"><span class="n"><a href="#t399">399</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t400" class="mis show_mis"><span class="n"><a href="#t400">400</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'newline'</span><span class="op">]</span> <span class="op">=</span> <span class="str">"\n"</span> </span><span class="r"></span></p> - <p id="t401" class="pln"><span class="n"><a href="#t401">401</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t402" class="mis show_mis"><span class="n"><a href="#t402">402</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">"wb"</span> </span><span class="r"></span></p> - <p id="t403" class="mis show_mis"><span class="n"><a href="#t403">403</a></span><span class="t"> <span class="nam">fdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t404" class="mis show_mis"><span class="n"><a href="#t404">404</a></span><span class="t"> <span class="key">if</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t405" class="mis show_mis"><span class="n"><a href="#t405">405</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">makedirs</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t406" class="mis show_mis"><span class="n"><a href="#t406">406</a></span><span class="t"> <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="nam">mode</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t407" class="pln"><span class="n"><a href="#t407">407</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t408" class="run"><span class="n"><a href="#t408">408</a></span><span class="t"> <span class="key">def</span> <span class="nam">openInputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t409" class="pln"><span class="n"><a href="#t409">409</a></span><span class="t"> <span class="str">""" Open an input file. """</span> </span><span class="r"></span></p> - <p id="t410" class="mis show_mis"><span class="n"><a href="#t410">410</a></span><span class="t"> <span class="key">if</span> <span class="nam">fname</span> <span class="op">==</span> <span class="str">"-"</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t411" class="mis show_mis"><span class="n"><a href="#t411">411</a></span><span class="t"> <span class="key">return</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> </span><span class="r"></span></p> - <p id="t412" class="pln"><span class="n"><a href="#t412">412</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t413" class="mis show_mis"><span class="n"><a href="#t413">413</a></span><span class="t"> <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t414" class="mis show_mis"><span class="n"><a href="#t414">414</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t415" class="mis show_mis"><span class="n"><a href="#t415">415</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span> </span><span class="r"></span></p> - <p id="t416" class="mis show_mis"><span class="n"><a href="#t416">416</a></span><span class="t"> <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="str">"r"</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t417" class="pln"><span class="n"><a href="#t417">417</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t418" class="run"><span class="n"><a href="#t418">418</a></span><span class="t"> <span class="key">def</span> <span class="nam">processFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fIn</span><span class="op">,</span> <span class="nam">fOut</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t419" class="pln"><span class="n"><a href="#t419">419</a></span><span class="t"> <span class="str">""" Process an input file object to an output file object.</span> </span><span class="r"></span></p> - <p id="t420" class="pln"><span class="n"><a href="#t420">420</a></span><span class="t"><span class="str"> fIn and fOut can be file objects, or file names.</span> </span><span class="r"></span></p> - <p id="t421" class="pln"><span class="n"><a href="#t421">421</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t422" class="pln"><span class="n"><a href="#t422">422</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t423" class="run"><span class="n"><a href="#t423">423</a></span><span class="t"> <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t424" class="run"><span class="n"><a href="#t424">424</a></span><span class="t"> <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t425" class="run"><span class="n"><a href="#t425">425</a></span><span class="t"> <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> - <p id="t426" class="pln"><span class="n"><a href="#t426">426</a></span><span class="t"> <span class="com"># Convert filenames to files.</span> </span><span class="r"></span></p> - <p id="t427" class="par run show_par"><span class="n"><a href="#t427">427</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fIn</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">427 ↛ 429</span><span class="annotate long">line 427 didn't jump to line 429, because the condition on line 427 was never true</span></span></p> - <p id="t428" class="pln"><span class="n"><a href="#t428">428</a></span><span class="t"> <span class="com"># Open the input file.</span> </span><span class="r"></span></p> - <p id="t429" class="mis show_mis"><span class="n"><a href="#t429">429</a></span><span class="t"> <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fIn</span> </span><span class="r"></span></p> - <p id="t430" class="mis show_mis"><span class="n"><a href="#t430">430</a></span><span class="t"> <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t431" class="par run show_par"><span class="n"><a href="#t431">431</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fOut</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">431 ↛ 433</span><span class="annotate long">line 431 didn't jump to line 433, because the condition on line 431 was never true</span></span></p> - <p id="t432" class="pln"><span class="n"><a href="#t432">432</a></span><span class="t"> <span class="com"># Open the output file.</span> </span><span class="r"></span></p> - <p id="t433" class="mis show_mis"><span class="n"><a href="#t433">433</a></span><span class="t"> <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fOut</span> </span><span class="r"></span></p> - <p id="t434" class="mis show_mis"><span class="n"><a href="#t434">434</a></span><span class="t"> <span class="nam">fOut</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">fOut</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t435" class="pln"><span class="n"><a href="#t435">435</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t436" class="run"><span class="n"><a href="#t436">436</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t437" class="run"><span class="n"><a href="#t437">437</a></span><span class="t"> <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">NumberedFileReader</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t438" class="pln"><span class="n"><a href="#t438">438</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t439" class="run"><span class="n"><a href="#t439">439</a></span><span class="t"> <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t440" class="pln"><span class="n"><a href="#t440">440</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t441" class="run"><span class="n"><a href="#t441">441</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">inFile</span> <span class="op">=</span> <span class="nam">sFileIn</span> </span><span class="r"></span></p> - <p id="t442" class="run"><span class="n"><a href="#t442">442</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outFile</span> <span class="op">=</span> <span class="nam">sFileOut</span> </span><span class="r"></span></p> - <p id="t443" class="run"><span class="n"><a href="#t443">443</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">'cog_'</span> <span class="op">+</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="nam">sFileOut</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t444" class="run"><span class="n"><a href="#t444">444</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> </span><span class="r"></span></p> - <p id="t445" class="pln"><span class="n"><a href="#t445">445</a></span><span class="t"> <span class="com"># if "import cog" explicitly done in code by user, note threading will cause clashes.</span> </span><span class="r"></span></p> - <p id="t446" class="run"><span class="n"><a href="#t446">446</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="str">'cog'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> </span><span class="r"></span></p> - <p id="t447" class="pln"><span class="n"><a href="#t447">447</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t448" class="pln"><span class="n"><a href="#t448">448</a></span><span class="t"> <span class="com"># The globals dict we'll use for this file.</span> </span><span class="r"></span></p> - <p id="t449" class="par run show_par"><span class="n"><a href="#t449">449</a></span><span class="t"> <span class="key">if</span> <span class="nam">globals</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span> </span><span class="r"><span class="annotate short">449 ↛ 453</span><span class="annotate long">line 449 didn't jump to line 453, because the condition on line 449 was never false</span></span></p> - <p id="t450" class="run"><span class="n"><a href="#t450">450</a></span><span class="t"> <span class="nam">globals</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t451" class="pln"><span class="n"><a href="#t451">451</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t452" class="pln"><span class="n"><a href="#t452">452</a></span><span class="t"> <span class="com"># If there are any global defines, put them in the globals.</span> </span><span class="r"></span></p> - <p id="t453" class="run"><span class="n"><a href="#t453">453</a></span><span class="t"> <span class="nam">globals</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">defines</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t454" class="pln"><span class="n"><a href="#t454">454</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t455" class="pln"><span class="n"><a href="#t455">455</a></span><span class="t"> <span class="com"># loop over generator chunks</span> </span><span class="r"></span></p> - <p id="t456" class="run"><span class="n"><a href="#t456">456</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t457" class="run"><span class="n"><a href="#t457">457</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t458" class="pln"><span class="n"><a href="#t458">458</a></span><span class="t"> <span class="com"># Find the next spec begin</span> </span><span class="r"></span></p> - <p id="t459" class="run"><span class="n"><a href="#t459">459</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t460" class="par run show_par"><span class="n"><a href="#t460">460</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">460 ↛ 461</span><span class="annotate long">line 460 didn't jump to line 461, because the condition on line 460 was never true</span></span></p> - <p id="t461" class="mis show_mis"><span class="n"><a href="#t461">461</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t462" class="pln"><span class="n"><a href="#t462">462</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t463" class="par run show_par"><span class="n"><a href="#t463">463</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">463 ↛ 464</span><span class="annotate long">line 463 didn't jump to line 464, because the condition on line 463 was never true</span></span></p> - <p id="t464" class="mis show_mis"><span class="n"><a href="#t464">464</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t465" class="pln"><span class="n"><a href="#t465">465</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t466" class="run"><span class="n"><a href="#t466">466</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t467" class="run"><span class="n"><a href="#t467">467</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t468" class="run"><span class="n"><a href="#t468">468</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t469" class="run"><span class="n"><a href="#t469">469</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> - <p id="t470" class="par run show_par"><span class="n"><a href="#t470">470</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">470 ↛ 474</span><span class="annotate long">line 470 didn't jump to line 474, because the condition on line 470 was never false</span></span></p> - <p id="t471" class="run"><span class="n"><a href="#t471">471</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t472" class="pln"><span class="n"><a href="#t472">472</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t473" class="pln"><span class="n"><a href="#t473">473</a></span><span class="t"> <span class="com"># l is the begin spec</span> </span><span class="r"></span></p> - <p id="t474" class="run"><span class="n"><a href="#t474">474</a></span><span class="t"> <span class="nam">gen</span> <span class="op">=</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">options</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t475" class="run"><span class="n"><a href="#t475">475</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stdout</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t476" class="run"><span class="n"><a href="#t476">476</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t477" class="run"><span class="n"><a href="#t477">477</a></span><span class="t"> <span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t478" class="run"><span class="n"><a href="#t478">478</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">firstLineNum</span> </span><span class="r"></span></p> - <p id="t479" class="pln"><span class="n"><a href="#t479">479</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t480" class="pln"><span class="n"><a href="#t480">480</a></span><span class="t"> <span class="com"># If the spec begin is also a spec end, then process the single</span> </span><span class="r"></span></p> - <p id="t481" class="pln"><span class="n"><a href="#t481">481</a></span><span class="t"> <span class="com"># line of code inside.</span> </span><span class="r"></span></p> - <p id="t482" class="run"><span class="n"><a href="#t482">482</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t483" class="run"><span class="n"><a href="#t483">483</a></span><span class="t"> <span class="nam">beg</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t484" class="run"><span class="n"><a href="#t484">484</a></span><span class="t"> <span class="nam">end</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t485" class="run"><span class="n"><a href="#t485">485</a></span><span class="t"> <span class="key">if</span> <span class="nam">beg</span> <span class="op">></span> <span class="nam">end</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t486" class="run"><span class="n"><a href="#t486">486</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Cog code markers inverted"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t487" class="pln"><span class="n"><a href="#t487">487</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t488" class="pln"><span class="n"><a href="#t488">488</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t489" class="run"><span class="n"><a href="#t489">489</a></span><span class="t"> <span class="nam">sCode</span> <span class="op">=</span> <span class="nam">l</span><span class="op">[</span><span class="nam">beg</span><span class="op">+</span><span class="nam">len</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span><span class="op">:</span><span class="nam">end</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t490" class="run"><span class="n"><a href="#t490">490</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">sCode</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t491" class="pln"><span class="n"><a href="#t491">491</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t492" class="pln"><span class="n"><a href="#t492">492</a></span><span class="t"> <span class="com"># Deal with an ordinary code block.</span> </span><span class="r"></span></p> - <p id="t493" class="run"><span class="n"><a href="#t493">493</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t494" class="pln"><span class="n"><a href="#t494">494</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t495" class="pln"><span class="n"><a href="#t495">495</a></span><span class="t"> <span class="com"># Get all the lines in the spec</span> </span><span class="r"></span></p> - <p id="t496" class="run"><span class="n"><a href="#t496">496</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t497" class="par run show_par"><span class="n"><a href="#t497">497</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">497 ↛ 498</span><span class="annotate long">line 497 didn't jump to line 498, because the condition on line 497 was never true</span></span></p> - <p id="t498" class="mis show_mis"><span class="n"><a href="#t498">498</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t499" class="pln"><span class="n"><a href="#t499">499</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t500" class="par run show_par"><span class="n"><a href="#t500">500</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">500 ↛ 501</span><span class="annotate long">line 500 didn't jump to line 501, because the condition on line 500 was never true</span></span></p> - <p id="t501" class="mis show_mis"><span class="n"><a href="#t501">501</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t502" class="pln"><span class="n"><a href="#t502">502</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t503" class="par run show_par"><span class="n"><a href="#t503">503</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">503 ↛ 505</span><span class="annotate long">line 503 didn't jump to line 505, because the condition on line 503 was never false</span></span></p> - <p id="t504" class="run"><span class="n"><a href="#t504">504</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t505" class="run"><span class="n"><a href="#t505">505</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t506" class="run"><span class="n"><a href="#t506">506</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t507" class="par run show_par"><span class="n"><a href="#t507">507</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"><span class="annotate short">507 ↛ 508</span><span class="annotate long">line 507 didn't jump to line 508, because the condition on line 507 was never true</span></span></p> - <p id="t508" class="mis show_mis"><span class="n"><a href="#t508">508</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span> </span><span class="r"></span></p> - <p id="t509" class="pln"><span class="n"><a href="#t509">509</a></span><span class="t"> <span class="str">"Cog block begun but never ended."</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t510" class="pln"><span class="n"><a href="#t510">510</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t511" class="pln"><span class="n"><a href="#t511">511</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t512" class="par run show_par"><span class="n"><a href="#t512">512</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">512 ↛ 514</span><span class="annotate long">line 512 didn't jump to line 514, because the condition on line 512 was never false</span></span></p> - <p id="t513" class="run"><span class="n"><a href="#t513">513</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t514" class="run"><span class="n"><a href="#t514">514</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t515" class="pln"><span class="n"><a href="#t515">515</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t516" class="run"><span class="n"><a href="#t516">516</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t517" class="pln"><span class="n"><a href="#t517">517</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t518" class="pln"><span class="n"><a href="#t518">518</a></span><span class="t"> <span class="com"># Eat all the lines in the output section. While reading past</span> </span><span class="r"></span></p> - <p id="t519" class="pln"><span class="n"><a href="#t519">519</a></span><span class="t"> <span class="com"># them, compute the md5 hash of the old output.</span> </span><span class="r"></span></p> - <p id="t520" class="run"><span class="n"><a href="#t520">520</a></span><span class="t"> <span class="nam">previous</span> <span class="op">=</span> <span class="str">""</span> </span><span class="r"></span></p> - <p id="t521" class="run"><span class="n"><a href="#t521">521</a></span><span class="t"> <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t522" class="run"><span class="n"><a href="#t522">522</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t523" class="par run show_par"><span class="n"><a href="#t523">523</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">523 ↛ 524</span><span class="annotate long">line 523 didn't jump to line 524, because the condition on line 523 was never true</span></span></p> - <p id="t524" class="mis show_mis"><span class="n"><a href="#t524">524</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t525" class="pln"><span class="n"><a href="#t525">525</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t526" class="par run show_par"><span class="n"><a href="#t526">526</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">526 ↛ 527</span><span class="annotate long">line 526 didn't jump to line 527, because the condition on line 526 was never true</span></span></p> - <p id="t527" class="mis show_mis"><span class="n"><a href="#t527">527</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t528" class="pln"><span class="n"><a href="#t528">528</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t529" class="run"><span class="n"><a href="#t529">529</a></span><span class="t"> <span class="nam">previous</span> <span class="op">+=</span> <span class="nam">l</span> </span><span class="r"></span></p> - <p id="t530" class="run"><span class="n"><a href="#t530">530</a></span><span class="t"> <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t531" class="run"><span class="n"><a href="#t531">531</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t532" class="run"><span class="n"><a href="#t532">532</a></span><span class="t"> <span class="nam">curHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t533" class="pln"><span class="n"><a href="#t533">533</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t534" class="par run show_par"><span class="n"><a href="#t534">534</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span><span class="op">:</span> </span><span class="r"><span class="annotate short">534 ↛ 536</span><span class="annotate long">line 534 didn't jump to line 536, because the condition on line 534 was never true</span></span></p> - <p id="t535" class="pln"><span class="n"><a href="#t535">535</a></span><span class="t"> <span class="com"># We reached end of file before we found the end output line.</span> </span><span class="r"></span></p> - <p id="t536" class="mis show_mis"><span class="n"><a href="#t536">536</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Missing '%s' before end of file."</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t537" class="pln"><span class="n"><a href="#t537">537</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t538" class="pln"><span class="n"><a href="#t538">538</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t539" class="pln"><span class="n"><a href="#t539">539</a></span><span class="t"> <span class="com"># Make the previous output available to the current code</span> </span><span class="r"></span></p> - <p id="t540" class="run"><span class="n"><a href="#t540">540</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">previous</span> <span class="op">=</span> <span class="nam">previous</span> </span><span class="r"></span></p> - <p id="t541" class="pln"><span class="n"><a href="#t541">541</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t542" class="pln"><span class="n"><a href="#t542">542</a></span><span class="t"> <span class="com"># Write the output of the spec to be the new output if we're</span> </span><span class="r"></span></p> - <p id="t543" class="pln"><span class="n"><a href="#t543">543</a></span><span class="t"> <span class="com"># supposed to generate code.</span> </span><span class="r"></span></p> - <p id="t544" class="run"><span class="n"><a href="#t544">544</a></span><span class="t"> <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t545" class="par run show_par"><span class="n"><a href="#t545">545</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNoGenerate</span><span class="op">:</span> </span><span class="r"><span class="annotate short">545 ↛ 551</span><span class="annotate long">line 545 didn't jump to line 551, because the condition on line 545 was never false</span></span></p> - <p id="t546" class="run"><span class="n"><a href="#t546">546</a></span><span class="t"> <span class="nam">sFile</span> <span class="op">=</span> <span class="str">"<cog %s:%d>"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t547" class="run"><span class="n"><a href="#t547">547</a></span><span class="t"> <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">gen</span><span class="op">.</span><span class="nam">evaluate</span><span class="op">(</span><span class="nam">cog</span><span class="op">=</span><span class="nam">self</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t548" class="run"><span class="n"><a href="#t548">548</a></span><span class="t"> <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">suffixLines</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t549" class="run"><span class="n"><a href="#t549">549</a></span><span class="t"> <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t550" class="run"><span class="n"><a href="#t550">550</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t551" class="run"><span class="n"><a href="#t551">551</a></span><span class="t"> <span class="nam">newHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t552" class="pln"><span class="n"><a href="#t552">552</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t553" class="run"><span class="n"><a href="#t553">553</a></span><span class="t"> <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t554" class="pln"><span class="n"><a href="#t554">554</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t555" class="pln"><span class="n"><a href="#t555">555</a></span><span class="t"> <span class="com"># Write the ending output line</span> </span><span class="r"></span></p> - <p id="t556" class="run"><span class="n"><a href="#t556">556</a></span><span class="t"> <span class="nam">hashMatch</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t557" class="par run show_par"><span class="n"><a href="#t557">557</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bHashOutput</span><span class="op">:</span> </span><span class="r"><span class="annotate short">557 ↛ 558</span><span class="annotate long">line 557 didn't jump to line 558, because the condition on line 557 was never true</span></span></p> - <p id="t558" class="mis show_mis"><span class="n"><a href="#t558">558</a></span><span class="t"> <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t559" class="mis show_mis"><span class="n"><a href="#t559">559</a></span><span class="t"> <span class="nam">oldHash</span> <span class="op">=</span> <span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hash'</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t560" class="mis show_mis"><span class="n"><a href="#t560">560</a></span><span class="t"> <span class="key">if</span> <span class="nam">oldHash</span> <span class="op">!=</span> <span class="nam">curHash</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t561" class="mis show_mis"><span class="n"><a href="#t561">561</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Output has been edited! Delete old checksum to unprotect."</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t562" class="pln"><span class="n"><a href="#t562">562</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t563" class="pln"><span class="n"><a href="#t563">563</a></span><span class="t"> <span class="com"># Create a new end line with the correct hash.</span> </span><span class="r"></span></p> - <p id="t564" class="mis show_mis"><span class="n"><a href="#t564">564</a></span><span class="t"> <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">group</span><span class="op">(</span><span class="num">0</span><span class="op">)</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t565" class="pln"><span class="n"><a href="#t565">565</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t566" class="pln"><span class="n"><a href="#t566">566</a></span><span class="t"> <span class="com"># There was no old hash, but we want a new hash.</span> </span><span class="r"></span></p> - <p id="t567" class="mis show_mis"><span class="n"><a href="#t567">567</a></span><span class="t"> <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t568" class="mis show_mis"><span class="n"><a href="#t568">568</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">%</span> <span class="nam">newHash</span><span class="op">)</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">endpieces</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t569" class="pln"><span class="n"><a href="#t569">569</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t570" class="pln"><span class="n"><a href="#t570">570</a></span><span class="t"> <span class="com"># We don't want hashes output, so if there was one, get rid of</span> </span><span class="r"></span></p> - <p id="t571" class="pln"><span class="n"><a href="#t571">571</a></span><span class="t"> <span class="com"># it.</span> </span><span class="r"></span></p> - <p id="t572" class="par run show_par"><span class="n"><a href="#t572">572</a></span><span class="t"> <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span> </span><span class="r"><span class="annotate short">572 ↛ 573</span><span class="annotate long">line 572 didn't jump to line 573, because the condition on line 572 was never true</span></span></p> - <p id="t573" class="mis show_mis"><span class="n"><a href="#t573">573</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hashsect'</span><span class="op">]</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t574" class="pln"><span class="n"><a href="#t574">574</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t575" class="par run show_par"><span class="n"><a href="#t575">575</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">575 ↛ 577</span><span class="annotate long">line 575 didn't jump to line 577, because the condition on line 575 was never false</span></span></p> - <p id="t576" class="run"><span class="n"><a href="#t576">576</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t577" class="run"><span class="n"><a href="#t577">577</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t578" class="pln"><span class="n"><a href="#t578">578</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t579" class="par run show_par"><span class="n"><a href="#t579">579</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">bSawCog</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bWarnEmpty</span><span class="op">:</span> </span><span class="r"><span class="annotate short">579 ↛ 580</span><span class="annotate long">line 579 didn't jump to line 580, because the condition on line 579 was never true</span></span></p> - <p id="t580" class="mis show_mis"><span class="n"><a href="#t580">580</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">showWarning</span><span class="op">(</span><span class="str">"no cog code found in %s"</span> <span class="op">%</span> <span class="nam">sFileIn</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t581" class="pln"><span class="n"><a href="#t581">581</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t582" class="par run show_par"><span class="n"><a href="#t582">582</a></span><span class="t"> <span class="key">if</span> <span class="nam">fInToClose</span><span class="op">:</span> </span><span class="r"><span class="annotate short">582 ↛ 583</span><span class="annotate long">line 582 didn't jump to line 583, because the condition on line 582 was never true</span></span></p> - <p id="t583" class="mis show_mis"><span class="n"><a href="#t583">583</a></span><span class="t"> <span class="nam">fInToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t584" class="par run show_par"><span class="n"><a href="#t584">584</a></span><span class="t"> <span class="key">if</span> <span class="nam">fOutToClose</span><span class="op">:</span> </span><span class="r"><span class="annotate short">584 ↛ 585</span><span class="annotate long">line 584 didn't jump to line 585, because the condition on line 584 was never true</span></span></p> - <p id="t585" class="mis show_mis"><span class="n"><a href="#t585">585</a></span><span class="t"> <span class="nam">fOutToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t586" class="pln"><span class="n"><a href="#t586">586</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t587" class="pln"><span class="n"><a href="#t587">587</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t588" class="pln"><span class="n"><a href="#t588">588</a></span><span class="t"> <span class="com"># A regex for non-empty lines, used by suffixLines.</span> </span><span class="r"></span></p> - <p id="t589" class="run"><span class="n"><a href="#t589">589</a></span><span class="t"> <span class="nam">reNonEmptyLines</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="str">r"^\s*\S+.*$"</span><span class="op">,</span> <span class="nam">re</span><span class="op">.</span><span class="nam">MULTILINE</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t590" class="pln"><span class="n"><a href="#t590">590</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t591" class="run"><span class="n"><a href="#t591">591</a></span><span class="t"> <span class="key">def</span> <span class="nam">suffixLines</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t592" class="pln"><span class="n"><a href="#t592">592</a></span><span class="t"> <span class="str">""" Add suffixes to the lines in text, if our options desire it.</span> </span><span class="r"></span></p> - <p id="t593" class="pln"><span class="n"><a href="#t593">593</a></span><span class="t"><span class="str"> text is many lines, as a single string.</span> </span><span class="r"></span></p> - <p id="t594" class="pln"><span class="n"><a href="#t594">594</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t595" class="par run show_par"><span class="n"><a href="#t595">595</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">:</span> </span><span class="r"><span class="annotate short">595 ↛ 597</span><span class="annotate long">line 595 didn't jump to line 597, because the condition on line 595 was never true</span></span></p> - <p id="t596" class="pln"><span class="n"><a href="#t596">596</a></span><span class="t"> <span class="com"># Find all non-blank lines, and add the suffix to the end.</span> </span><span class="r"></span></p> - <p id="t597" class="mis show_mis"><span class="n"><a href="#t597">597</a></span><span class="t"> <span class="nam">repl</span> <span class="op">=</span> <span class="str">r"\g<0>"</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'\\'</span><span class="op">,</span> <span class="str">'\\\\'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t598" class="mis show_mis"><span class="n"><a href="#t598">598</a></span><span class="t"> <span class="nam">text</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reNonEmptyLines</span><span class="op">.</span><span class="nam">sub</span><span class="op">(</span><span class="nam">repl</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t599" class="run"><span class="n"><a href="#t599">599</a></span><span class="t"> <span class="key">return</span> <span class="nam">text</span> </span><span class="r"></span></p> - <p id="t600" class="pln"><span class="n"><a href="#t600">600</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t601" class="run"><span class="n"><a href="#t601">601</a></span><span class="t"> <span class="key">def</span> <span class="nam">processString</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sInput</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t602" class="pln"><span class="n"><a href="#t602">602</a></span><span class="t"> <span class="str">""" Process sInput as the text to cog.</span> </span><span class="r"></span></p> - <p id="t603" class="pln"><span class="n"><a href="#t603">603</a></span><span class="t"><span class="str"> Return the cogged output as a string.</span> </span><span class="r"></span></p> - <p id="t604" class="pln"><span class="n"><a href="#t604">604</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t605" class="run"><span class="n"><a href="#t605">605</a></span><span class="t"> <span class="nam">fOld</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="nam">sInput</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t606" class="run"><span class="n"><a href="#t606">606</a></span><span class="t"> <span class="nam">fNew</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t607" class="run"><span class="n"><a href="#t607">607</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">fOld</span><span class="op">,</span> <span class="nam">fNew</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">fname</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t608" class="run"><span class="n"><a href="#t608">608</a></span><span class="t"> <span class="key">return</span> <span class="nam">fNew</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t609" class="pln"><span class="n"><a href="#t609">609</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t610" class="run"><span class="n"><a href="#t610">610</a></span><span class="t"> <span class="key">def</span> <span class="nam">replaceFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t611" class="pln"><span class="n"><a href="#t611">611</a></span><span class="t"> <span class="str">""" Replace file sOldPath with the contents sNewText</span> </span><span class="r"></span></p> - <p id="t612" class="pln"><span class="n"><a href="#t612">612</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t613" class="mis show_mis"><span class="n"><a href="#t613">613</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t614" class="pln"><span class="n"><a href="#t614">614</a></span><span class="t"> <span class="com"># Need to ensure we can write.</span> </span><span class="r"></span></p> - <p id="t615" class="mis show_mis"><span class="n"><a href="#t615">615</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t616" class="pln"><span class="n"><a href="#t616">616</a></span><span class="t"> <span class="com"># Use an external command to make the file writable.</span> </span><span class="r"></span></p> - <p id="t617" class="mis show_mis"><span class="n"><a href="#t617">617</a></span><span class="t"> <span class="nam">cmd</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'%s'</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t618" class="mis show_mis"><span class="n"><a href="#t618">618</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">popen</span><span class="op">(</span><span class="nam">cmd</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t619" class="mis show_mis"><span class="n"><a href="#t619">619</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t620" class="mis show_mis"><span class="n"><a href="#t620">620</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Couldn't make %s writable"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t621" class="pln"><span class="n"><a href="#t621">621</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t622" class="pln"><span class="n"><a href="#t622">622</a></span><span class="t"> <span class="com"># Can't write!</span> </span><span class="r"></span></p> - <p id="t623" class="mis show_mis"><span class="n"><a href="#t623">623</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Can't overwrite %s"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t624" class="mis show_mis"><span class="n"><a href="#t624">624</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t625" class="mis show_mis"><span class="n"><a href="#t625">625</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sNewText</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t626" class="mis show_mis"><span class="n"><a href="#t626">626</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t627" class="pln"><span class="n"><a href="#t627">627</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t628" class="run"><span class="n"><a href="#t628">628</a></span><span class="t"> <span class="key">def</span> <span class="nam">saveIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t629" class="mis show_mis"><span class="n"><a href="#t629">629</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t630" class="mis show_mis"><span class="n"><a href="#t630">630</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t631" class="pln"><span class="n"><a href="#t631">631</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t632" class="run"><span class="n"><a href="#t632">632</a></span><span class="t"> <span class="key">def</span> <span class="nam">restoreIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t633" class="mis show_mis"><span class="n"><a href="#t633">633</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span> </span><span class="r"></span></p> - <p id="t634" class="mis show_mis"><span class="n"><a href="#t634">634</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span> </span><span class="r"></span></p> - <p id="t635" class="mis show_mis"><span class="n"><a href="#t635">635</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span> </span><span class="r"></span></p> - <p id="t636" class="pln"><span class="n"><a href="#t636">636</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t637" class="run"><span class="n"><a href="#t637">637</a></span><span class="t"> <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">includePath</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t638" class="mis show_mis"><span class="n"><a href="#t638">638</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t639" class="mis show_mis"><span class="n"><a href="#t639">639</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t640" class="pln"><span class="n"><a href="#t640">640</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t641" class="run"><span class="n"><a href="#t641">641</a></span><span class="t"> <span class="key">def</span> <span class="nam">processOneFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t642" class="pln"><span class="n"><a href="#t642">642</a></span><span class="t"> <span class="str">""" Process one filename through cog.</span> </span><span class="r"></span></p> - <p id="t643" class="pln"><span class="n"><a href="#t643">643</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t644" class="pln"><span class="n"><a href="#t644">644</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t645" class="mis show_mis"><span class="n"><a href="#t645">645</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">saveIncludePath</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t646" class="mis show_mis"><span class="n"><a href="#t646">646</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t647" class="pln"><span class="n"><a href="#t647">647</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t648" class="mis show_mis"><span class="n"><a href="#t648">648</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t649" class="mis show_mis"><span class="n"><a href="#t649">649</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t650" class="pln"><span class="n"><a href="#t650">650</a></span><span class="t"> <span class="com"># Since we know where the input file came from,</span> </span><span class="r"></span></p> - <p id="t651" class="pln"><span class="n"><a href="#t651">651</a></span><span class="t"> <span class="com"># push its directory onto the include path.</span> </span><span class="r"></span></p> - <p id="t652" class="mis show_mis"><span class="n"><a href="#t652">652</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="op">[</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t653" class="pln"><span class="n"><a href="#t653">653</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t654" class="pln"><span class="n"><a href="#t654">654</a></span><span class="t"> <span class="com"># How we process the file depends on where the output is going.</span> </span><span class="r"></span></p> - <p id="t655" class="mis show_mis"><span class="n"><a href="#t655">655</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t656" class="mis show_mis"><span class="n"><a href="#t656">656</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t657" class="mis show_mis"><span class="n"><a href="#t657">657</a></span><span class="t"> <span class="key">elif</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bReplace</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t658" class="pln"><span class="n"><a href="#t658">658</a></span><span class="t"> <span class="com"># We want to replace the cog file with the output,</span> </span><span class="r"></span></p> - <p id="t659" class="pln"><span class="n"><a href="#t659">659</a></span><span class="t"> <span class="com"># but only if they differ.</span> </span><span class="r"></span></p> - <p id="t660" class="mis show_mis"><span class="n"><a href="#t660">660</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">2</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t661" class="mis show_mis"><span class="n"><a href="#t661">661</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t662" class="mis show_mis"><span class="n"><a href="#t662">662</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t663" class="pln"><span class="n"><a href="#t663">663</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t664" class="mis show_mis"><span class="n"><a href="#t664">664</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t665" class="mis show_mis"><span class="n"><a href="#t665">665</a></span><span class="t"> <span class="nam">fOldFile</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t666" class="mis show_mis"><span class="n"><a href="#t666">666</a></span><span class="t"> <span class="nam">sOldText</span> <span class="op">=</span> <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t667" class="mis show_mis"><span class="n"><a href="#t667">667</a></span><span class="t"> <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t668" class="mis show_mis"><span class="n"><a href="#t668">668</a></span><span class="t"> <span class="nam">sNewText</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">sOldText</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t669" class="mis show_mis"><span class="n"><a href="#t669">669</a></span><span class="t"> <span class="key">if</span> <span class="nam">sOldText</span> <span class="op">!=</span> <span class="nam">sNewText</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t670" class="mis show_mis"><span class="n"><a href="#t670">670</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">1</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t671" class="mis show_mis"><span class="n"><a href="#t671">671</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op"><</span> <span class="num">2</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t672" class="mis show_mis"><span class="n"><a href="#t672">672</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t673" class="mis show_mis"><span class="n"><a href="#t673">673</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">" (changed)"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t674" class="mis show_mis"><span class="n"><a href="#t674">674</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> - <p id="t675" class="mis show_mis"><span class="n"><a href="#t675">675</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">replaceFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t676" class="pln"><span class="n"><a href="#t676">676</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t677" class="pln"><span class="n"><a href="#t677">677</a></span><span class="t"> <span class="com"># The try-finally block is so we can print a partial line</span> </span><span class="r"></span></p> - <p id="t678" class="pln"><span class="n"><a href="#t678">678</a></span><span class="t"> <span class="com"># with the name of the file, and print (changed) on the</span> </span><span class="r"></span></p> - <p id="t679" class="pln"><span class="n"><a href="#t679">679</a></span><span class="t"> <span class="com"># same line, but also make sure to break the line before</span> </span><span class="r"></span></p> - <p id="t680" class="pln"><span class="n"><a href="#t680">680</a></span><span class="t"> <span class="com"># any traceback.</span> </span><span class="r"></span></p> - <p id="t681" class="mis show_mis"><span class="n"><a href="#t681">681</a></span><span class="t"> <span class="key">if</span> <span class="nam">bNeedNewline</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t682" class="mis show_mis"><span class="n"><a href="#t682">682</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t683" class="pln"><span class="n"><a href="#t683">683</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t684" class="mis show_mis"><span class="n"><a href="#t684">684</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t685" class="pln"><span class="n"><a href="#t685">685</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t686" class="mis show_mis"><span class="n"><a href="#t686">686</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">restoreIncludePath</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t687" class="pln"><span class="n"><a href="#t687">687</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t688" class="run"><span class="n"><a href="#t688">688</a></span><span class="t"> <span class="key">def</span> <span class="nam">processWildcards</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t689" class="mis show_mis"><span class="n"><a href="#t689">689</a></span><span class="t"> <span class="nam">files</span> <span class="op">=</span> <span class="nam">glob</span><span class="op">.</span><span class="nam">glob</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t690" class="mis show_mis"><span class="n"><a href="#t690">690</a></span><span class="t"> <span class="key">if</span> <span class="nam">files</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t691" class="mis show_mis"><span class="n"><a href="#t691">691</a></span><span class="t"> <span class="key">for</span> <span class="nam">sMatchingFile</span> <span class="key">in</span> <span class="nam">files</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t692" class="mis show_mis"><span class="n"><a href="#t692">692</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sMatchingFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t693" class="pln"><span class="n"><a href="#t693">693</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t694" class="mis show_mis"><span class="n"><a href="#t694">694</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t695" class="pln"><span class="n"><a href="#t695">695</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t696" class="run"><span class="n"><a href="#t696">696</a></span><span class="t"> <span class="key">def</span> <span class="nam">processFileList</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFileList</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t697" class="pln"><span class="n"><a href="#t697">697</a></span><span class="t"> <span class="str">""" Process the files in a file list.</span> </span><span class="r"></span></p> - <p id="t698" class="pln"><span class="n"><a href="#t698">698</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t699" class="mis show_mis"><span class="n"><a href="#t699">699</a></span><span class="t"> <span class="nam">flist</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFileList</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t700" class="mis show_mis"><span class="n"><a href="#t700">700</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">flist</span><span class="op">.</span><span class="nam">readlines</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t701" class="mis show_mis"><span class="n"><a href="#t701">701</a></span><span class="t"> <span class="nam">flist</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t702" class="mis show_mis"><span class="n"><a href="#t702">702</a></span><span class="t"> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">lines</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t703" class="pln"><span class="n"><a href="#t703">703</a></span><span class="t"> <span class="com"># Use shlex to parse the line like a shell.</span> </span><span class="r"></span></p> - <p id="t704" class="mis show_mis"><span class="n"><a href="#t704">704</a></span><span class="t"> <span class="nam">lex</span> <span class="op">=</span> <span class="nam">shlex</span><span class="op">.</span><span class="nam">shlex</span><span class="op">(</span><span class="nam">l</span><span class="op">,</span> <span class="nam">posix</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t705" class="mis show_mis"><span class="n"><a href="#t705">705</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">whitespace_split</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t706" class="mis show_mis"><span class="n"><a href="#t706">706</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">commenters</span> <span class="op">=</span> <span class="str">'#'</span> </span><span class="r"></span></p> - <p id="t707" class="pln"><span class="n"><a href="#t707">707</a></span><span class="t"> <span class="com"># No escapes, so that backslash can be part of the path</span> </span><span class="r"></span></p> - <p id="t708" class="mis show_mis"><span class="n"><a href="#t708">708</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">escape</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t709" class="mis show_mis"><span class="n"><a href="#t709">709</a></span><span class="t"> <span class="nam">args</span> <span class="op">=</span> <span class="nam">list</span><span class="op">(</span><span class="nam">lex</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t710" class="mis show_mis"><span class="n"><a href="#t710">710</a></span><span class="t"> <span class="key">if</span> <span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t711" class="mis show_mis"><span class="n"><a href="#t711">711</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="nam">args</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t712" class="pln"><span class="n"><a href="#t712">712</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t713" class="run"><span class="n"><a href="#t713">713</a></span><span class="t"> <span class="key">def</span> <span class="nam">processArguments</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t714" class="pln"><span class="n"><a href="#t714">714</a></span><span class="t"> <span class="str">""" Process one command-line.</span> </span><span class="r"></span></p> - <p id="t715" class="pln"><span class="n"><a href="#t715">715</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t716" class="mis show_mis"><span class="n"><a href="#t716">716</a></span><span class="t"> <span class="nam">saved_options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> </span><span class="r"></span></p> - <p id="t717" class="mis show_mis"><span class="n"><a href="#t717">717</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">clone</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t718" class="pln"><span class="n"><a href="#t718">718</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t719" class="mis show_mis"><span class="n"><a href="#t719">719</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t720" class="mis show_mis"><span class="n"><a href="#t720">720</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t721" class="pln"><span class="n"><a href="#t721">721</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t722" class="mis show_mis"><span class="n"><a href="#t722">722</a></span><span class="t"> <span class="key">if</span> <span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">==</span> <span class="str">'@'</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t723" class="mis show_mis"><span class="n"><a href="#t723">723</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t724" class="mis show_mis"><span class="n"><a href="#t724">724</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with @file"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t725" class="mis show_mis"><span class="n"><a href="#t725">725</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFileList</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t726" class="pln"><span class="n"><a href="#t726">726</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t727" class="mis show_mis"><span class="n"><a href="#t727">727</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processWildcards</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t728" class="pln"><span class="n"><a href="#t728">728</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t729" class="mis show_mis"><span class="n"><a href="#t729">729</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">saved_options</span> </span><span class="r"></span></p> - <p id="t730" class="pln"><span class="n"><a href="#t730">730</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t731" class="run"><span class="n"><a href="#t731">731</a></span><span class="t"> <span class="key">def</span> <span class="nam">callableMain</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t732" class="pln"><span class="n"><a href="#t732">732</a></span><span class="t"> <span class="str">""" All of command-line cog, but in a callable form.</span> </span><span class="r"></span></p> - <p id="t733" class="pln"><span class="n"><a href="#t733">733</a></span><span class="t"><span class="str"> This is used by main.</span> </span><span class="r"></span></p> - <p id="t734" class="pln"><span class="n"><a href="#t734">734</a></span><span class="t"><span class="str"> argv is the equivalent of sys.argv.</span> </span><span class="r"></span></p> - <p id="t735" class="pln"><span class="n"><a href="#t735">735</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t736" class="mis show_mis"><span class="n"><a href="#t736">736</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="nam">argv</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t737" class="pln"><span class="n"><a href="#t737">737</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t738" class="pln"><span class="n"><a href="#t738">738</a></span><span class="t"> <span class="com"># Provide help if asked for anywhere in the command line.</span> </span><span class="r"></span></p> - <p id="t739" class="mis show_mis"><span class="n"><a href="#t739">739</a></span><span class="t"> <span class="key">if</span> <span class="str">'-?'</span> <span class="key">in</span> <span class="nam">argv</span> <span class="key">or</span> <span class="str">'-h'</span> <span class="key">in</span> <span class="nam">argv</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t740" class="mis show_mis"><span class="n"><a href="#t740">740</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">usage</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t741" class="mis show_mis"><span class="n"><a href="#t741">741</a></span><span class="t"> <span class="key">return</span> </span><span class="r"></span></p> - <p id="t742" class="pln"><span class="n"><a href="#t742">742</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t743" class="mis show_mis"><span class="n"><a href="#t743">743</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t744" class="mis show_mis"><span class="n"><a href="#t744">744</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t745" class="mis show_mis"><span class="n"><a href="#t745">745</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t746" class="pln"><span class="n"><a href="#t746">746</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t747" class="mis show_mis"><span class="n"><a href="#t747">747</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bShowVersion</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t748" class="mis show_mis"><span class="n"><a href="#t748">748</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cog version %s"</span> <span class="op">%</span> <span class="nam">__version__</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t749" class="mis show_mis"><span class="n"><a href="#t749">749</a></span><span class="t"> <span class="key">return</span> </span><span class="r"></span></p> - <p id="t750" class="pln"><span class="n"><a href="#t750">750</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t751" class="mis show_mis"><span class="n"><a href="#t751">751</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t752" class="mis show_mis"><span class="n"><a href="#t752">752</a></span><span class="t"> <span class="key">for</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t753" class="mis show_mis"><span class="n"><a href="#t753">753</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="op">[</span><span class="nam">a</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t754" class="pln"><span class="n"><a href="#t754">754</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t755" class="mis show_mis"><span class="n"><a href="#t755">755</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"No files to process"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t756" class="pln"><span class="n"><a href="#t756">756</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t757" class="run"><span class="n"><a href="#t757">757</a></span><span class="t"> <span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t758" class="pln"><span class="n"><a href="#t758">758</a></span><span class="t"> <span class="str">""" Handle the command-line execution for cog.</span> </span><span class="r"></span></p> - <p id="t759" class="pln"><span class="n"><a href="#t759">759</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t760" class="pln"><span class="n"><a href="#t760">760</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t761" class="mis show_mis"><span class="n"><a href="#t761">761</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t762" class="mis show_mis"><span class="n"><a href="#t762">762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t763" class="mis show_mis"><span class="n"><a href="#t763">763</a></span><span class="t"> <span class="key">return</span> <span class="num">0</span> </span><span class="r"></span></p> - <p id="t764" class="mis show_mis"><span class="n"><a href="#t764">764</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogUsageError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t765" class="mis show_mis"><span class="n"><a href="#t765">765</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t766" class="mis show_mis"><span class="n"><a href="#t766">766</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"(for help use -?)"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t767" class="mis show_mis"><span class="n"><a href="#t767">767</a></span><span class="t"> <span class="key">return</span> <span class="num">2</span> </span><span class="r"></span></p> - <p id="t768" class="mis show_mis"><span class="n"><a href="#t768">768</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogGeneratedError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t769" class="mis show_mis"><span class="n"><a href="#t769">769</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Error: %s"</span> <span class="op">%</span> <span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t770" class="mis show_mis"><span class="n"><a href="#t770">770</a></span><span class="t"> <span class="key">return</span> <span class="num">3</span> </span><span class="r"></span></p> - <p id="t771" class="mis show_mis"><span class="n"><a href="#t771">771</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogUserException</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t772" class="mis show_mis"><span class="n"><a href="#t772">772</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Traceback (most recent call last):"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t773" class="mis show_mis"><span class="n"><a href="#t773">773</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t774" class="mis show_mis"><span class="n"><a href="#t774">774</a></span><span class="t"> <span class="key">return</span> <span class="num">4</span> </span><span class="r"></span></p> - <p id="t775" class="mis show_mis"><span class="n"><a href="#t775">775</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t776" class="mis show_mis"><span class="n"><a href="#t776">776</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t777" class="mis show_mis"><span class="n"><a href="#t777">777</a></span><span class="t"> <span class="key">return</span> <span class="num">1</span> </span><span class="r"></span></p> - <p id="t778" class="pln"><span class="n"><a href="#t778">778</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t779" class="pln"><span class="n"><a href="#t779">779</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t780" class="run"><span class="n"><a href="#t780">780</a></span><span class="t"><span class="key">def</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frame_summary</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t781" class="pln"><span class="n"><a href="#t781">781</a></span><span class="t"> <span class="str">"""Find cog source lines in a frame summary list, for printing tracebacks.</span> </span><span class="r"></span></p> - <p id="t782" class="pln"><span class="n"><a href="#t782">782</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t783" class="pln"><span class="n"><a href="#t783">783</a></span><span class="t"><span class="str"> Arguments:</span> </span><span class="r"></span></p> - <p id="t784" class="pln"><span class="n"><a href="#t784">784</a></span><span class="t"><span class="str"> frame_summary: a list of 4-item tuples, as returned by traceback.extract_tb.</span> </span><span class="r"></span></p> - <p id="t785" class="pln"><span class="n"><a href="#t785">785</a></span><span class="t"><span class="str"> prologue: the text of the code prologue.</span> </span><span class="r"></span></p> - <p id="t786" class="pln"><span class="n"><a href="#t786">786</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t787" class="pln"><span class="n"><a href="#t787">787</a></span><span class="t"><span class="str"> Returns</span> </span><span class="r"></span></p> - <p id="t788" class="pln"><span class="n"><a href="#t788">788</a></span><span class="t"><span class="str"> A list of 4-item tuples, updated to correct the cog entries.</span> </span><span class="r"></span></p> - <p id="t789" class="pln"><span class="n"><a href="#t789">789</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t790" class="pln"><span class="n"><a href="#t790">790</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t791" class="run"><span class="n"><a href="#t791">791</a></span><span class="t"> <span class="nam">prolines</span> <span class="op">=</span> <span class="nam">prologue</span><span class="op">.</span><span class="nam">splitlines</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t792" class="run"><span class="n"><a href="#t792">792</a></span><span class="t"> <span class="key">for</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span> <span class="key">in</span> <span class="nam">frame_summary</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t793" class="par run show_par"><span class="n"><a href="#t793">793</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">source</span><span class="op">:</span> </span><span class="r"><span class="annotate short">793 ↛ 805</span><span class="annotate long">line 793 didn't jump to line 805, because the condition on line 793 was never false</span></span></p> - <p id="t794" class="run"><span class="n"><a href="#t794">794</a></span><span class="t"> <span class="nam">m</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="str">r"^<cog ([^:]+):(\d+)>$"</span><span class="op">,</span> <span class="nam">filename</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t795" class="par run show_par"><span class="n"><a href="#t795">795</a></span><span class="t"> <span class="key">if</span> <span class="nam">m</span><span class="op">:</span> </span><span class="r"><span class="annotate short">795 ↛ 796</span><span class="annotate long">line 795 didn't jump to line 796, because the condition on line 795 was never true</span></span></p> - <p id="t796" class="mis show_mis"><span class="n"><a href="#t796">796</a></span><span class="t"> <span class="key">if</span> <span class="nam">lineno</span> <span class="op"><=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t797" class="mis show_mis"><span class="n"><a href="#t797">797</a></span><span class="t"> <span class="nam">filename</span> <span class="op">=</span> <span class="str">'<prologue>'</span> </span><span class="r"></span></p> - <p id="t798" class="mis show_mis"><span class="n"><a href="#t798">798</a></span><span class="t"> <span class="nam">source</span> <span class="op">=</span> <span class="nam">prolines</span><span class="op">[</span><span class="nam">lineno</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t799" class="mis show_mis"><span class="n"><a href="#t799">799</a></span><span class="t"> <span class="nam">lineno</span> <span class="op">-=</span> <span class="num">1</span> <span class="com"># Because "import cog" is the first line in the prologue</span> </span><span class="r"></span></p> - <p id="t800" class="pln"><span class="n"><a href="#t800">800</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t801" class="mis show_mis"><span class="n"><a href="#t801">801</a></span><span class="t"> <span class="nam">filename</span><span class="op">,</span> <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">m</span><span class="op">.</span><span class="nam">groups</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t802" class="mis show_mis"><span class="n"><a href="#t802">802</a></span><span class="t"> <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">coglineno</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t803" class="mis show_mis"><span class="n"><a href="#t803">803</a></span><span class="t"> <span class="nam">lineno</span> <span class="op">+=</span> <span class="nam">coglineno</span> <span class="op">-</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t804" class="mis show_mis"><span class="n"><a href="#t804">804</a></span><span class="t"> <span class="nam">source</span> <span class="op">=</span> <span class="nam">linecache</span><span class="op">.</span><span class="nam">getline</span><span class="op">(</span><span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">)</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t805" class="run"><span class="n"><a href="#t805">805</a></span><span class="t"> <span class="key">yield</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span> </span><span class="r"></span></p> - <p id="t806" class="pln"><span class="n"><a href="#t806">806</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t807" class="pln"><span class="n"><a href="#t807">807</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t808" class="run"><span class="n"><a href="#t808">808</a></span><span class="t"><span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t809" class="pln"><span class="n"><a href="#t809">809</a></span><span class="t"> <span class="str">"""Main function for entry_points to use."""</span> </span><span class="r"></span></p> - <p id="t810" class="mis show_mis"><span class="n"><a href="#t810">810</a></span><span class="t"> <span class="key">return</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="com"># coding: utf8</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str">""" Cog content generation tool.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span><span class="op">,</span> <span class="nam">print_function</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">copy</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">getopt</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">glob</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">import</span> <span class="nam">hashlib</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"><span class="key">import</span> <span class="nam">linecache</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"><span class="key">import</span> <span class="nam">shlex</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"><span class="key">import</span> <span class="nam">traceback</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">PY3</span><span class="op">,</span> <span class="nam">StringIO</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">to_bytes</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"><span class="nam">__all__</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Cog'</span><span class="op">,</span> <span class="str">'CogUsageError'</span><span class="op">,</span> <span class="str">'main'</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">'3.1.0'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"><span class="nam">usage</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"><span class="str">cog - generate content with inlined Python code.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"><span class="str">cog [OPTIONS] [INFILE | @FILELIST] ...</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"><span class="str">INFILE is the name of an input file, '-' will read from stdin.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"><span class="str">FILELIST is the name of a text file containing file names or</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"><span class="str"> other @FILELISTs.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"><span class="str">OPTIONS:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"><span class="str"> -c Checksum the output to protect it against accidental change.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"><span class="str"> -d Delete the generator code from the output file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"><span class="str"> -D name=val Define a global string available to your generator code.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"><span class="str"> -e Warn if a file has no cog code in it.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"><span class="str"> -I PATH Add PATH to the list of directories for data files and modules.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"><span class="str"> -n ENCODING Use ENCODING when reading and writing files.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"><span class="str"> -o OUTNAME Write the output to OUTNAME.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"><span class="str"> -p PROLOGUE Prepend the generator source with PROLOGUE. Useful to insert an</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"><span class="str"> import line. Example: -p "import math"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"><span class="str"> -r Replace the input file with the output.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"><span class="str"> -s STRING Suffix all generated output lines with STRING.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"><span class="str"> -U Write the output with Unix newlines (only LF line-endings).</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"><span class="str"> -w CMD Use CMD if the output file needs to be made writable.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"><span class="str"> A %s in the CMD will be filled with the filename.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"><span class="str"> -x Excise all the generated output without running the generators.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"><span class="str"> -z The end-output marker can be omitted, and is assumed at eof.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"><span class="str"> -v Print the version of cog and exit.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"><span class="str"> --verbosity=VERBOSITY</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"><span class="str"> Control the amount of output. 2 (the default) lists all files,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"><span class="str"> 1 lists only changed files, 0 lists no files.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"><span class="str"> --markers='START END END-OUTPUT'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"><span class="str"> The patterns surrounding cog inline instructions. Should</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"><span class="str"> include three values separated by spaces, the start, end,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"><span class="str"> and end-output markers. Defaults to '[[[cog ]]] [[[end]]]'.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"><span class="str"> -h Print this help.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"><span class="com"># Other package modules</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"><span class="key">class</span> <span class="nam">CogError</span><span class="op">(</span><span class="nam">Exception</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"> <span class="str">""" Any exception raised by Cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> <span class="key">if</span> <span class="nam">file</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="str">"%s(%d): %s"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">file</span><span class="op">,</span> <span class="nam">line</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t74" href="#t74">74</a></span><span class="t"> <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t75" href="#t75">75</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t76" href="#t76">76</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t77" href="#t77">77</a></span><span class="t"> <span class="str">""" An error in usage of command-line arguments in cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t78" href="#t78">78</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t79" href="#t79">79</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t80" href="#t80">80</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t81" href="#t81">81</a></span><span class="t"><span class="key">class</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t82" href="#t82">82</a></span><span class="t"> <span class="str">""" An error in the coding of Cog. Should never happen.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t83" href="#t83">83</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t84" href="#t84">84</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t85" href="#t85">85</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t86" href="#t86">86</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t87" href="#t87">87</a></span><span class="t"> <span class="str">""" An error raised by a user's cog generator.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t88" href="#t88">88</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t89" href="#t89">89</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t90" href="#t90">90</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t91" href="#t91">91</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t92" href="#t92">92</a></span><span class="t"> <span class="str">""" An exception caught when running a user's cog generator.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t93" href="#t93">93</a></span><span class="t"><span class="str"> The argument is the traceback message to print.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t94" href="#t94">94</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t95" href="#t95">95</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t96" href="#t96">96</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t97" href="#t97">97</a></span><span class="t"><span class="key">class</span> <span class="nam">Redirectable</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t98" href="#t98">98</a></span><span class="t"> <span class="str">""" An object with its own stdout and stderr files.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t99" href="#t99">99</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t100" href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t101" href="#t101">101</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdout</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t102" href="#t102">102</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t103" href="#t103">103</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t104" href="#t104">104</a></span><span class="t"> <span class="key">def</span> <span class="nam">setOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">stdout</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">stderr</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t105" href="#t105">105</a></span><span class="t"> <span class="str">""" Assign new files for standard out and/or standard error.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t106" href="#t106">106</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t107" href="#t107">107</a></span><span class="t"> <span class="key">if</span> <span class="nam">stdout</span><span class="op">:</span> </span><span class="r"><span class="annotate short">107 ↛ 109</span><span class="annotate long">line 107 didn't jump to line 109, because the condition on line 107 was never false</span></span></p> + <p class="run"><span class="n"><a id="t108" href="#t108">108</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">stdout</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t109" href="#t109">109</a></span><span class="t"> <span class="key">if</span> <span class="nam">stderr</span><span class="op">:</span> </span><span class="r"><span class="annotate short">109 ↛ 110</span><span class="annotate long">line 109 didn't jump to line 110, because the condition on line 109 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t110" href="#t110">110</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">stderr</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t111" href="#t111">111</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t112" href="#t112">112</a></span><span class="t"> <span class="key">def</span> <span class="nam">prout</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t113" href="#t113">113</a></span><span class="t"> <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t114" href="#t114">114</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t115" href="#t115">115</a></span><span class="t"> <span class="key">def</span> <span class="nam">prerr</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t116" href="#t116">116</a></span><span class="t"> <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t117" href="#t117">117</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t118" href="#t118">118</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t119" href="#t119">119</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t120" href="#t120">120</a></span><span class="t"> <span class="str">""" A generator pulled from a source file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t121" href="#t121">121</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t122" href="#t122">122</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">options</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t123" href="#t123">123</a></span><span class="t"> <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t124" href="#t124">124</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t125" href="#t125">125</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t126" href="#t126">126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">options</span> <span class="key">or</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t127" href="#t127">127</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t128" href="#t128">128</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseMarker</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t129" href="#t129">129</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t130" href="#t130">130</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t131" href="#t131">131</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t132" href="#t132">132</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t133" href="#t133">133</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t134" href="#t134">134</a></span><span class="t"> <span class="key">def</span> <span class="nam">getCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t135" href="#t135">135</a></span><span class="t"> <span class="str">""" Extract the executable Python code from the generator.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t136" href="#t136">136</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t137" href="#t137">137</a></span><span class="t"> <span class="com"># If the markers and lines all have the same prefix</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t138" href="#t138">138</a></span><span class="t"> <span class="com"># (end-of-line comment chars, for example),</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t139" href="#t139">139</a></span><span class="t"> <span class="com"># then remove it from all the lines.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t140" href="#t140">140</a></span><span class="t"> <span class="nam">prefIn</span> <span class="op">=</span> <span class="nam">commonPrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t141" href="#t141">141</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefIn</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t142" href="#t142">142</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t143" href="#t143">143</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t144" href="#t144">144</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t145" href="#t145">145</a></span><span class="t"> <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t146" href="#t146">146</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t147" href="#t147">147</a></span><span class="t"> <span class="key">def</span> <span class="nam">evaluate</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">cog</span><span class="op">,</span> <span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t148" href="#t148">148</a></span><span class="t"> <span class="com"># figure out the right whitespace prefix for the output</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t149" href="#t149">149</a></span><span class="t"> <span class="nam">prefOut</span> <span class="op">=</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t150" href="#t150">150</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t151" href="#t151">151</a></span><span class="t"> <span class="nam">intext</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t152" href="#t152">152</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">intext</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t153" href="#t153">153</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t154" href="#t154">154</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t155" href="#t155">155</a></span><span class="t"> <span class="nam">prologue</span> <span class="op">=</span> <span class="str">"import "</span> <span class="op">+</span> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">+</span> <span class="str">" as cog\n"</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t156" href="#t156">156</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span><span class="op">:</span> </span><span class="r"><span class="annotate short">156 ↛ 157</span><span class="annotate long">line 156 didn't jump to line 157, because the condition on line 156 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t157" href="#t157">157</a></span><span class="t"> <span class="nam">prologue</span> <span class="op">+=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">+</span> <span class="str">'\n'</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t158" href="#t158">158</a></span><span class="t"> <span class="nam">code</span> <span class="op">=</span> <span class="nam">compile</span><span class="op">(</span><span class="nam">prologue</span> <span class="op">+</span> <span class="nam">intext</span><span class="op">,</span> <span class="nam">str</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span><span class="op">,</span> <span class="str">'exec'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t159" href="#t159">159</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t160" href="#t160">160</a></span><span class="t"> <span class="com"># Make sure the "cog" module has our state.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t161" href="#t161">161</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">msg</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">msg</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t162" href="#t162">162</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">out</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t163" href="#t163">163</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outl</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outl</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t164" href="#t164">164</a></span><span class="t"> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">error</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">error</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t165" href="#t165">165</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t166" href="#t166">166</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t167" href="#t167">167</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t168" href="#t168">168</a></span><span class="t"> <span class="nam">eval</span><span class="op">(</span><span class="nam">code</span><span class="op">,</span> <span class="nam">globals</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t169" href="#t169">169</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogError</span><span class="op">:</span> </span><span class="r"><span class="annotate short">169 ↛ 170</span><span class="annotate long">line 169 didn't jump to line 170, because the exception caught by line 169 didn't happen</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t170" href="#t170">170</a></span><span class="t"> <span class="key">raise</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t171" href="#t171">171</a></span><span class="t"> <span class="key">except</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t172" href="#t172">172</a></span><span class="t"> <span class="nam">typ</span><span class="op">,</span> <span class="nam">err</span><span class="op">,</span> <span class="nam">tb</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">exc_info</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t173" href="#t173">173</a></span><span class="t"> <span class="nam">frames</span> <span class="op">=</span> <span class="op">(</span><span class="nam">tuple</span><span class="op">(</span><span class="nam">fr</span><span class="op">)</span> <span class="key">for</span> <span class="nam">fr</span> <span class="key">in</span> <span class="nam">traceback</span><span class="op">.</span><span class="nam">extract_tb</span><span class="op">(</span><span class="nam">tb</span><span class="op">.</span><span class="nam">tb_next</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t174" href="#t174">174</a></span><span class="t"> <span class="nam">frames</span> <span class="op">=</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frames</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t175" href="#t175">175</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">""</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">traceback</span><span class="op">.</span><span class="nam">format_list</span><span class="op">(</span><span class="nam">frames</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t176" href="#t176">176</a></span><span class="t"> <span class="nam">msg</span> <span class="op">+=</span> <span class="str">"{}: {}"</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">typ</span><span class="op">.</span><span class="nam">__name__</span><span class="op">,</span> <span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t177" href="#t177">177</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t178" href="#t178">178</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t179" href="#t179">179</a></span><span class="t"> <span class="com"># We need to make sure that the last line in the output</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t180" href="#t180">180</a></span><span class="t"> <span class="com"># ends with a newline, or it will be joined to the</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t181" href="#t181">181</a></span><span class="t"> <span class="com"># end-output line, ruining cog's idempotency.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t182" href="#t182">182</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> <span class="op">!=</span> <span class="str">'\n'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t183" href="#t183">183</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="str">'\n'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t184" href="#t184">184</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t185" href="#t185">185</a></span><span class="t"> <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">,</span> <span class="nam">prefOut</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t186" href="#t186">186</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t187" href="#t187">187</a></span><span class="t"> <span class="key">def</span> <span class="nam">msg</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t188" href="#t188">188</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Message: "</span><span class="op">+</span><span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t189" href="#t189">189</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t190" href="#t190">190</a></span><span class="t"> <span class="key">def</span> <span class="nam">out</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">dedent</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">trimblanklines</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t191" href="#t191">191</a></span><span class="t"> <span class="str">""" The cog.out function.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t192" href="#t192">192</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t193" href="#t193">193</a></span><span class="t"> <span class="key">if</span> <span class="nam">trimblanklines</span> <span class="key">and</span> <span class="op">(</span><span class="str">'\n'</span> <span class="key">in</span> <span class="nam">sOut</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t194" href="#t194">194</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">sOut</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t195" href="#t195">195</a></span><span class="t"> <span class="key">if</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t196" href="#t196">196</a></span><span class="t"> <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t197" href="#t197">197</a></span><span class="t"> <span class="key">if</span> <span class="nam">lines</span> <span class="key">and</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t198" href="#t198">198</a></span><span class="t"> <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t199" href="#t199">199</a></span><span class="t"> <span class="nam">sOut</span> <span class="op">=</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">lines</span><span class="op">)</span><span class="op">+</span><span class="str">'\n'</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t200" href="#t200">200</a></span><span class="t"> <span class="key">if</span> <span class="nam">dedent</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t201" href="#t201">201</a></span><span class="t"> <span class="nam">sOut</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">sOut</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t202" href="#t202">202</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="nam">sOut</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t203" href="#t203">203</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t204" href="#t204">204</a></span><span class="t"> <span class="key">def</span> <span class="nam">outl</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t205" href="#t205">205</a></span><span class="t"> <span class="str">""" The cog.outl function.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t206" href="#t206">206</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t207" href="#t207">207</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="nam">sOut</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t208" href="#t208">208</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t209" href="#t209">209</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t210" href="#t210">210</a></span><span class="t"> <span class="key">def</span> <span class="nam">error</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">=</span><span class="str">'Error raised by cog generator.'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t211" href="#t211">211</a></span><span class="t"> <span class="str">""" The cog.error function.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t212" href="#t212">212</a></span><span class="t"><span class="str"> Instead of raising standard python errors, cog generators can use</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t213" href="#t213">213</a></span><span class="t"><span class="str"> this function. It will display the error without a scary Python</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t214" href="#t214">214</a></span><span class="t"><span class="str"> traceback.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t215" href="#t215">215</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t216" href="#t216">216</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t217" href="#t217">217</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t218" href="#t218">218</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t219" href="#t219">219</a></span><span class="t"><span class="key">class</span> <span class="nam">NumberedFileReader</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t220" href="#t220">220</a></span><span class="t"> <span class="str">""" A decorator for files that counts the readline()'s called.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t221" href="#t221">221</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t222" href="#t222">222</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">f</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t223" href="#t223">223</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">f</span> <span class="op">=</span> <span class="nam">f</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t224" href="#t224">224</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">=</span> <span class="num">0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t225" href="#t225">225</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t226" href="#t226">226</a></span><span class="t"> <span class="key">def</span> <span class="nam">readline</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t227" href="#t227">227</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">f</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t228" href="#t228">228</a></span><span class="t"> <span class="key">if</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t229" href="#t229">229</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">+=</span> <span class="num">1</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t230" href="#t230">230</a></span><span class="t"> <span class="key">return</span> <span class="nam">l</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t231" href="#t231">231</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t232" href="#t232">232</a></span><span class="t"> <span class="key">def</span> <span class="nam">linenumber</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t233" href="#t233">233</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t234" href="#t234">234</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t235" href="#t235">235</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t236" href="#t236">236</a></span><span class="t"><span class="key">class</span> <span class="nam">CogOptions</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t237" href="#t237">237</a></span><span class="t"> <span class="str">""" Options for a run of cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t238" href="#t238">238</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t239" href="#t239">239</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t240" href="#t240">240</a></span><span class="t"> <span class="com"># Defaults for argument values.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t241" href="#t241">241</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t242" href="#t242">242</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t243" href="#t243">243</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t244" href="#t244">244</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t245" href="#t245">245</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t246" href="#t246">246</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t247" href="#t247">247</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t248" href="#t248">248</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t249" href="#t249">249</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t250" href="#t250">250</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t251" href="#t251">251</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t252" href="#t252">252</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t253" href="#t253">253</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t254" href="#t254">254</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t255" href="#t255">255</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="op">=</span> <span class="str">'[[[cog'</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t256" href="#t256">256</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="op">=</span> <span class="str">']]]'</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t257" href="#t257">257</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="str">'[[[end]]]'</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t258" href="#t258">258</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="str">"utf-8"</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t259" href="#t259">259</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="num">2</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t260" href="#t260">260</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t261" href="#t261">261</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t262" href="#t262">262</a></span><span class="t"> <span class="key">def</span> <span class="nam">__eq__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">other</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t263" href="#t263">263</a></span><span class="t"> <span class="str">""" Comparison operator for tests to use.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t264" href="#t264">264</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t265" href="#t265">265</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">__dict__</span> <span class="op">==</span> <span class="nam">other</span><span class="op">.</span><span class="nam">__dict__</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t266" href="#t266">266</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t267" href="#t267">267</a></span><span class="t"> <span class="key">def</span> <span class="nam">clone</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t268" href="#t268">268</a></span><span class="t"> <span class="str">""" Make a clone of these options, for further refinement.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t269" href="#t269">269</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t270" href="#t270">270</a></span><span class="t"> <span class="key">return</span> <span class="nam">copy</span><span class="op">.</span><span class="nam">deepcopy</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t271" href="#t271">271</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t272" href="#t272">272</a></span><span class="t"> <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">dirs</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t273" href="#t273">273</a></span><span class="t"> <span class="str">""" Add directories to the include path.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t274" href="#t274">274</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t275" href="#t275">275</a></span><span class="t"> <span class="nam">dirs</span> <span class="op">=</span> <span class="nam">dirs</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">pathsep</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t276" href="#t276">276</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">dirs</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t277" href="#t277">277</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t278" href="#t278">278</a></span><span class="t"> <span class="key">def</span> <span class="nam">parseArgs</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t279" href="#t279">279</a></span><span class="t"> <span class="com"># Parse the command line arguments.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t280" href="#t280">280</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t281" href="#t281">281</a></span><span class="t"> <span class="nam">opts</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">getopt</span><span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t282" href="#t282">282</a></span><span class="t"> <span class="nam">argv</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t283" href="#t283">283</a></span><span class="t"> <span class="str">'cdD:eI:n:o:rs:p:Uvw:xz'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t284" href="#t284">284</a></span><span class="t"> <span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t285" href="#t285">285</a></span><span class="t"> <span class="str">'markers='</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t286" href="#t286">286</a></span><span class="t"> <span class="str">'verbosity='</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t287" href="#t287">287</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t288" href="#t288">288</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t289" href="#t289">289</a></span><span class="t"> <span class="key">except</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">error</span> <span class="key">as</span> <span class="nam">msg</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t290" href="#t290">290</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t291" href="#t291">291</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t292" href="#t292">292</a></span><span class="t"> <span class="com"># Handle the command line arguments.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t293" href="#t293">293</a></span><span class="t"> <span class="key">for</span> <span class="nam">o</span><span class="op">,</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">opts</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t294" href="#t294">294</a></span><span class="t"> <span class="key">if</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-c'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t295" href="#t295">295</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t296" href="#t296">296</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-d'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t297" href="#t297">297</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t298" href="#t298">298</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-D'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t299" href="#t299">299</a></span><span class="t"> <span class="key">if</span> <span class="nam">a</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="str">'='</span><span class="op">)</span> <span class="op"><</span> <span class="num">1</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t300" href="#t300">300</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"-D takes a name=value argument"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t301" href="#t301">301</a></span><span class="t"> <span class="nam">name</span><span class="op">,</span> <span class="nam">value</span> <span class="op">=</span> <span class="nam">a</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'='</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t302" href="#t302">302</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span><span class="op">[</span><span class="nam">name</span><span class="op">]</span> <span class="op">=</span> <span class="nam">value</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t303" href="#t303">303</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-e'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t304" href="#t304">304</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t305" href="#t305">305</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-I'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t306" href="#t306">306</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t307" href="#t307">307</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-n'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t308" href="#t308">308</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t309" href="#t309">309</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-o'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t310" href="#t310">310</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t311" href="#t311">311</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-r'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t312" href="#t312">312</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t313" href="#t313">313</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-s'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t314" href="#t314">314</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t315" href="#t315">315</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-p'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t316" href="#t316">316</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t317" href="#t317">317</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-U'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t318" href="#t318">318</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t319" href="#t319">319</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-v'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t320" href="#t320">320</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t321" href="#t321">321</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-w'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t322" href="#t322">322</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="nam">a</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t323" href="#t323">323</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-x'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t324" href="#t324">324</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t325" href="#t325">325</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-z'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t326" href="#t326">326</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t327" href="#t327">327</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--markers'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t328" href="#t328">328</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t329" href="#t329">329</a></span><span class="t"> <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--verbosity'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t330" href="#t330">330</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t331" href="#t331">331</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t332" href="#t332">332</a></span><span class="t"> <span class="com"># Since getopt.getopt is given a list of possible flags,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t333" href="#t333">333</a></span><span class="t"> <span class="com"># this is an internal error.</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t334" href="#t334">334</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="str">"Don't understand argument %s"</span> <span class="op">%</span> <span class="nam">o</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t335" href="#t335">335</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t336" href="#t336">336</a></span><span class="t"> <span class="key">def</span> <span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">val</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t337" href="#t337">337</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t338" href="#t338">338</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="nam">val</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t339" href="#t339">339</a></span><span class="t"> <span class="key">except</span> <span class="nam">ValueError</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t340" href="#t340">340</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t341" href="#t341">341</a></span><span class="t"> <span class="str">'--markers requires 3 values separated by spaces, could not parse %r'</span> <span class="op">%</span> <span class="nam">val</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t342" href="#t342">342</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t343" href="#t343">343</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t344" href="#t344">344</a></span><span class="t"> <span class="key">def</span> <span class="nam">validate</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t345" href="#t345">345</a></span><span class="t"> <span class="str">""" Does nothing if everything is OK, raises CogError's if it's not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t346" href="#t346">346</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t347" href="#t347">347</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t348" href="#t348">348</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -d with -r (or you would delete all your source!)"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t349" href="#t349">349</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t350" href="#t350">350</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t351" href="#t351">351</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with -r (they are opposites)"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t352" href="#t352">352</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t353" href="#t353">353</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t354" href="#t354">354</a></span><span class="t"><span class="key">class</span> <span class="nam">Cog</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t355" href="#t355">355</a></span><span class="t"> <span class="str">""" The Cog engine.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t356" href="#t356">356</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t357" href="#t357">357</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t358" href="#t358">358</a></span><span class="t"> <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t359" href="#t359">359</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t360" href="#t360">360</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t361" href="#t361">361</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">"cog"</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t362" href="#t362">362</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">createCogModule</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t363" href="#t363">363</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t364" href="#t364">364</a></span><span class="t"> <span class="key">def</span> <span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t365" href="#t365">365</a></span><span class="t"> <span class="nam">end_output</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">escape</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t366" href="#t366">366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="nam">end_output</span> <span class="op">+</span> <span class="str">r'(?P<hashsect> *\(checksum: (?P<hash>[a-f0-9]+)\))'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t367" href="#t367">367</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">+</span> <span class="str">' (checksum: %s)'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t368" href="#t368">368</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t369" href="#t369">369</a></span><span class="t"> <span class="key">def</span> <span class="nam">showWarning</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t370" href="#t370">370</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Warning: "</span><span class="op">+</span><span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t371" href="#t371">371</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t372" href="#t372">372</a></span><span class="t"> <span class="key">def</span> <span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t373" href="#t373">373</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="key">in</span> <span class="nam">s</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t374" href="#t374">374</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t375" href="#t375">375</a></span><span class="t"> <span class="key">def</span> <span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t376" href="#t376">376</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="key">in</span> <span class="nam">s</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t377" href="#t377">377</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t378" href="#t378">378</a></span><span class="t"> <span class="key">def</span> <span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t379" href="#t379">379</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="key">in</span> <span class="nam">s</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t380" href="#t380">380</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t381" href="#t381">381</a></span><span class="t"> <span class="key">def</span> <span class="nam">createCogModule</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t382" href="#t382">382</a></span><span class="t"> <span class="str">""" Make a cog "module" object so that imported Python modules</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t383" href="#t383">383</a></span><span class="t"><span class="str"> can say "import cog" and get our state.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t384" href="#t384">384</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t385" href="#t385">385</a></span><span class="t"> <span class="key">class</span> <span class="nam">DummyModule</span><span class="op">(</span><span class="nam">object</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t386" href="#t386">386</a></span><span class="t"> <span class="str">"""Modules don't have to be anything special, just an object will do."""</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t387" href="#t387">387</a></span><span class="t"> <span class="key">pass</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t388" href="#t388">388</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> <span class="op">=</span> <span class="nam">DummyModule</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t389" href="#t389">389</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t390" href="#t390">390</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t391" href="#t391">391</a></span><span class="t"> <span class="key">def</span> <span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t392" href="#t392">392</a></span><span class="t"> <span class="str">""" Open an output file, taking all the details into account.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t393" href="#t393">393</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t394" href="#t394">394</a></span><span class="t"> <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t395" href="#t395">395</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">"w"</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t396" href="#t396">396</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t397" href="#t397">397</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t398" href="#t398">398</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNewlines</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t399" href="#t399">399</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t400" href="#t400">400</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'newline'</span><span class="op">]</span> <span class="op">=</span> <span class="str">"\n"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t401" href="#t401">401</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t402" href="#t402">402</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">"wb"</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t403" href="#t403">403</a></span><span class="t"> <span class="nam">fdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t404" href="#t404">404</a></span><span class="t"> <span class="key">if</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t405" href="#t405">405</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">makedirs</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t406" href="#t406">406</a></span><span class="t"> <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="nam">mode</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t407" href="#t407">407</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t408" href="#t408">408</a></span><span class="t"> <span class="key">def</span> <span class="nam">openInputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t409" href="#t409">409</a></span><span class="t"> <span class="str">""" Open an input file. """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t410" href="#t410">410</a></span><span class="t"> <span class="key">if</span> <span class="nam">fname</span> <span class="op">==</span> <span class="str">"-"</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t411" href="#t411">411</a></span><span class="t"> <span class="key">return</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t412" href="#t412">412</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t413" href="#t413">413</a></span><span class="t"> <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t414" href="#t414">414</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t415" href="#t415">415</a></span><span class="t"> <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t416" href="#t416">416</a></span><span class="t"> <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="str">"r"</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t417" href="#t417">417</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t418" href="#t418">418</a></span><span class="t"> <span class="key">def</span> <span class="nam">processFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fIn</span><span class="op">,</span> <span class="nam">fOut</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t419" href="#t419">419</a></span><span class="t"> <span class="str">""" Process an input file object to an output file object.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t420" href="#t420">420</a></span><span class="t"><span class="str"> fIn and fOut can be file objects, or file names.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t421" href="#t421">421</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t422" href="#t422">422</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t423" href="#t423">423</a></span><span class="t"> <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t424" href="#t424">424</a></span><span class="t"> <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t425" href="#t425">425</a></span><span class="t"> <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="key">None</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t426" href="#t426">426</a></span><span class="t"> <span class="com"># Convert filenames to files.</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t427" href="#t427">427</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fIn</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">427 ↛ 429</span><span class="annotate long">line 427 didn't jump to line 429, because the condition on line 427 was never true</span></span></p> + <p class="pln"><span class="n"><a id="t428" href="#t428">428</a></span><span class="t"> <span class="com"># Open the input file.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t429" href="#t429">429</a></span><span class="t"> <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fIn</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t430" href="#t430">430</a></span><span class="t"> <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t431" href="#t431">431</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fOut</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">431 ↛ 433</span><span class="annotate long">line 431 didn't jump to line 433, because the condition on line 431 was never true</span></span></p> + <p class="pln"><span class="n"><a id="t432" href="#t432">432</a></span><span class="t"> <span class="com"># Open the output file.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t433" href="#t433">433</a></span><span class="t"> <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fOut</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t434" href="#t434">434</a></span><span class="t"> <span class="nam">fOut</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">fOut</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t435" href="#t435">435</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t436" href="#t436">436</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t437" href="#t437">437</a></span><span class="t"> <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">NumberedFileReader</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t438" href="#t438">438</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t439" href="#t439">439</a></span><span class="t"> <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t440" href="#t440">440</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t441" href="#t441">441</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">inFile</span> <span class="op">=</span> <span class="nam">sFileIn</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t442" href="#t442">442</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outFile</span> <span class="op">=</span> <span class="nam">sFileOut</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t443" href="#t443">443</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">'cog_'</span> <span class="op">+</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="nam">sFileOut</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t444" href="#t444">444</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t445" href="#t445">445</a></span><span class="t"> <span class="com"># if "import cog" explicitly done in code by user, note threading will cause clashes.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t446" href="#t446">446</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="str">'cog'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t447" href="#t447">447</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t448" href="#t448">448</a></span><span class="t"> <span class="com"># The globals dict we'll use for this file.</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t449" href="#t449">449</a></span><span class="t"> <span class="key">if</span> <span class="nam">globals</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span> </span><span class="r"><span class="annotate short">449 ↛ 453</span><span class="annotate long">line 449 didn't jump to line 453, because the condition on line 449 was never false</span></span></p> + <p class="run"><span class="n"><a id="t450" href="#t450">450</a></span><span class="t"> <span class="nam">globals</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t451" href="#t451">451</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t452" href="#t452">452</a></span><span class="t"> <span class="com"># If there are any global defines, put them in the globals.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t453" href="#t453">453</a></span><span class="t"> <span class="nam">globals</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">defines</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t454" href="#t454">454</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t455" href="#t455">455</a></span><span class="t"> <span class="com"># loop over generator chunks</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t456" href="#t456">456</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t457" href="#t457">457</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t458" href="#t458">458</a></span><span class="t"> <span class="com"># Find the next spec begin</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t459" href="#t459">459</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t460" href="#t460">460</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">460 ↛ 461</span><span class="annotate long">line 460 didn't jump to line 461, because the condition on line 460 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t461" href="#t461">461</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t462" href="#t462">462</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t463" href="#t463">463</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">463 ↛ 464</span><span class="annotate long">line 463 didn't jump to line 464, because the condition on line 463 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t464" href="#t464">464</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t465" href="#t465">465</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t466" href="#t466">466</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t467" href="#t467">467</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t468" href="#t468">468</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t469" href="#t469">469</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t470" href="#t470">470</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">470 ↛ 474</span><span class="annotate long">line 470 didn't jump to line 474, because the condition on line 470 was never false</span></span></p> + <p class="run"><span class="n"><a id="t471" href="#t471">471</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t472" href="#t472">472</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t473" href="#t473">473</a></span><span class="t"> <span class="com"># l is the begin spec</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t474" href="#t474">474</a></span><span class="t"> <span class="nam">gen</span> <span class="op">=</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">options</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t475" href="#t475">475</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stdout</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t476" href="#t476">476</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t477" href="#t477">477</a></span><span class="t"> <span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t478" href="#t478">478</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">firstLineNum</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t479" href="#t479">479</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t480" href="#t480">480</a></span><span class="t"> <span class="com"># If the spec begin is also a spec end, then process the single</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t481" href="#t481">481</a></span><span class="t"> <span class="com"># line of code inside.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t482" href="#t482">482</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t483" href="#t483">483</a></span><span class="t"> <span class="nam">beg</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t484" href="#t484">484</a></span><span class="t"> <span class="nam">end</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t485" href="#t485">485</a></span><span class="t"> <span class="key">if</span> <span class="nam">beg</span> <span class="op">></span> <span class="nam">end</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t486" href="#t486">486</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Cog code markers inverted"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t487" href="#t487">487</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t488" href="#t488">488</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t489" href="#t489">489</a></span><span class="t"> <span class="nam">sCode</span> <span class="op">=</span> <span class="nam">l</span><span class="op">[</span><span class="nam">beg</span><span class="op">+</span><span class="nam">len</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span><span class="op">:</span><span class="nam">end</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t490" href="#t490">490</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">sCode</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t491" href="#t491">491</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t492" href="#t492">492</a></span><span class="t"> <span class="com"># Deal with an ordinary code block.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t493" href="#t493">493</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t494" href="#t494">494</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t495" href="#t495">495</a></span><span class="t"> <span class="com"># Get all the lines in the spec</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t496" href="#t496">496</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t497" href="#t497">497</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">497 ↛ 498</span><span class="annotate long">line 497 didn't jump to line 498, because the condition on line 497 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t498" href="#t498">498</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t499" href="#t499">499</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t500" href="#t500">500</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">500 ↛ 501</span><span class="annotate long">line 500 didn't jump to line 501, because the condition on line 500 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t501" href="#t501">501</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t502" href="#t502">502</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t503" href="#t503">503</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">503 ↛ 505</span><span class="annotate long">line 503 didn't jump to line 505, because the condition on line 503 was never false</span></span></p> + <p class="run"><span class="n"><a id="t504" href="#t504">504</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t505" href="#t505">505</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t506" href="#t506">506</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t507" href="#t507">507</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span> </span><span class="r"><span class="annotate short">507 ↛ 508</span><span class="annotate long">line 507 didn't jump to line 508, because the condition on line 507 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t508" href="#t508">508</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t509" href="#t509">509</a></span><span class="t"> <span class="str">"Cog block begun but never ended."</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t510" href="#t510">510</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t511" href="#t511">511</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t512" href="#t512">512</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">512 ↛ 514</span><span class="annotate long">line 512 didn't jump to line 514, because the condition on line 512 was never false</span></span></p> + <p class="run"><span class="n"><a id="t513" href="#t513">513</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t514" href="#t514">514</a></span><span class="t"> <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t515" href="#t515">515</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t516" href="#t516">516</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t517" href="#t517">517</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t518" href="#t518">518</a></span><span class="t"> <span class="com"># Eat all the lines in the output section. While reading past</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t519" href="#t519">519</a></span><span class="t"> <span class="com"># them, compute the md5 hash of the old output.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t520" href="#t520">520</a></span><span class="t"> <span class="nam">previous</span> <span class="op">=</span> <span class="str">""</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t521" href="#t521">521</a></span><span class="t"> <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t522" href="#t522">522</a></span><span class="t"> <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t523" href="#t523">523</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">523 ↛ 524</span><span class="annotate long">line 523 didn't jump to line 524, because the condition on line 523 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t524" href="#t524">524</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t525" href="#t525">525</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t526" href="#t526">526</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">526 ↛ 527</span><span class="annotate long">line 526 didn't jump to line 527, because the condition on line 526 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t527" href="#t527">527</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t528" href="#t528">528</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t529" href="#t529">529</a></span><span class="t"> <span class="nam">previous</span> <span class="op">+=</span> <span class="nam">l</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t530" href="#t530">530</a></span><span class="t"> <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t531" href="#t531">531</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t532" href="#t532">532</a></span><span class="t"> <span class="nam">curHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t533" href="#t533">533</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t534" href="#t534">534</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span><span class="op">:</span> </span><span class="r"><span class="annotate short">534 ↛ 536</span><span class="annotate long">line 534 didn't jump to line 536, because the condition on line 534 was never true</span></span></p> + <p class="pln"><span class="n"><a id="t535" href="#t535">535</a></span><span class="t"> <span class="com"># We reached end of file before we found the end output line.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t536" href="#t536">536</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Missing '%s' before end of file."</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t537" href="#t537">537</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t538" href="#t538">538</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t539" href="#t539">539</a></span><span class="t"> <span class="com"># Make the previous output available to the current code</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t540" href="#t540">540</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">previous</span> <span class="op">=</span> <span class="nam">previous</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t541" href="#t541">541</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t542" href="#t542">542</a></span><span class="t"> <span class="com"># Write the output of the spec to be the new output if we're</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t543" href="#t543">543</a></span><span class="t"> <span class="com"># supposed to generate code.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t544" href="#t544">544</a></span><span class="t"> <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t545" href="#t545">545</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNoGenerate</span><span class="op">:</span> </span><span class="r"><span class="annotate short">545 ↛ 551</span><span class="annotate long">line 545 didn't jump to line 551, because the condition on line 545 was never false</span></span></p> + <p class="run"><span class="n"><a id="t546" href="#t546">546</a></span><span class="t"> <span class="nam">sFile</span> <span class="op">=</span> <span class="str">"<cog %s:%d>"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">firstLineNum</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t547" href="#t547">547</a></span><span class="t"> <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">gen</span><span class="op">.</span><span class="nam">evaluate</span><span class="op">(</span><span class="nam">cog</span><span class="op">=</span><span class="nam">self</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t548" href="#t548">548</a></span><span class="t"> <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">suffixLines</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t549" href="#t549">549</a></span><span class="t"> <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t550" href="#t550">550</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t551" href="#t551">551</a></span><span class="t"> <span class="nam">newHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t552" href="#t552">552</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t553" href="#t553">553</a></span><span class="t"> <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t554" href="#t554">554</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t555" href="#t555">555</a></span><span class="t"> <span class="com"># Write the ending output line</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t556" href="#t556">556</a></span><span class="t"> <span class="nam">hashMatch</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t557" href="#t557">557</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bHashOutput</span><span class="op">:</span> </span><span class="r"><span class="annotate short">557 ↛ 558</span><span class="annotate long">line 557 didn't jump to line 558, because the condition on line 557 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t558" href="#t558">558</a></span><span class="t"> <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t559" href="#t559">559</a></span><span class="t"> <span class="nam">oldHash</span> <span class="op">=</span> <span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hash'</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t560" href="#t560">560</a></span><span class="t"> <span class="key">if</span> <span class="nam">oldHash</span> <span class="op">!=</span> <span class="nam">curHash</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t561" href="#t561">561</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Output has been edited! Delete old checksum to unprotect."</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t562" href="#t562">562</a></span><span class="t"> <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t563" href="#t563">563</a></span><span class="t"> <span class="com"># Create a new end line with the correct hash.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t564" href="#t564">564</a></span><span class="t"> <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">group</span><span class="op">(</span><span class="num">0</span><span class="op">)</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t565" href="#t565">565</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t566" href="#t566">566</a></span><span class="t"> <span class="com"># There was no old hash, but we want a new hash.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t567" href="#t567">567</a></span><span class="t"> <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t568" href="#t568">568</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">%</span> <span class="nam">newHash</span><span class="op">)</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">endpieces</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t569" href="#t569">569</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t570" href="#t570">570</a></span><span class="t"> <span class="com"># We don't want hashes output, so if there was one, get rid of</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t571" href="#t571">571</a></span><span class="t"> <span class="com"># it.</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t572" href="#t572">572</a></span><span class="t"> <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span> </span><span class="r"><span class="annotate short">572 ↛ 573</span><span class="annotate long">line 572 didn't jump to line 573, because the condition on line 572 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t573" href="#t573">573</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hashsect'</span><span class="op">]</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t574" href="#t574">574</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t575" href="#t575">575</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span> </span><span class="r"><span class="annotate short">575 ↛ 577</span><span class="annotate long">line 575 didn't jump to line 577, because the condition on line 575 was never false</span></span></p> + <p class="run"><span class="n"><a id="t576" href="#t576">576</a></span><span class="t"> <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t577" href="#t577">577</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t578" href="#t578">578</a></span><span class="t"> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t579" href="#t579">579</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">bSawCog</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bWarnEmpty</span><span class="op">:</span> </span><span class="r"><span class="annotate short">579 ↛ 580</span><span class="annotate long">line 579 didn't jump to line 580, because the condition on line 579 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t580" href="#t580">580</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">showWarning</span><span class="op">(</span><span class="str">"no cog code found in %s"</span> <span class="op">%</span> <span class="nam">sFileIn</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t581" href="#t581">581</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t582" href="#t582">582</a></span><span class="t"> <span class="key">if</span> <span class="nam">fInToClose</span><span class="op">:</span> </span><span class="r"><span class="annotate short">582 ↛ 583</span><span class="annotate long">line 582 didn't jump to line 583, because the condition on line 582 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t583" href="#t583">583</a></span><span class="t"> <span class="nam">fInToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t584" href="#t584">584</a></span><span class="t"> <span class="key">if</span> <span class="nam">fOutToClose</span><span class="op">:</span> </span><span class="r"><span class="annotate short">584 ↛ 585</span><span class="annotate long">line 584 didn't jump to line 585, because the condition on line 584 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t585" href="#t585">585</a></span><span class="t"> <span class="nam">fOutToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t586" href="#t586">586</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t587" href="#t587">587</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t588" href="#t588">588</a></span><span class="t"> <span class="com"># A regex for non-empty lines, used by suffixLines.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t589" href="#t589">589</a></span><span class="t"> <span class="nam">reNonEmptyLines</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="str">r"^\s*\S+.*$"</span><span class="op">,</span> <span class="nam">re</span><span class="op">.</span><span class="nam">MULTILINE</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t590" href="#t590">590</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t591" href="#t591">591</a></span><span class="t"> <span class="key">def</span> <span class="nam">suffixLines</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t592" href="#t592">592</a></span><span class="t"> <span class="str">""" Add suffixes to the lines in text, if our options desire it.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t593" href="#t593">593</a></span><span class="t"><span class="str"> text is many lines, as a single string.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t594" href="#t594">594</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t595" href="#t595">595</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">:</span> </span><span class="r"><span class="annotate short">595 ↛ 597</span><span class="annotate long">line 595 didn't jump to line 597, because the condition on line 595 was never true</span></span></p> + <p class="pln"><span class="n"><a id="t596" href="#t596">596</a></span><span class="t"> <span class="com"># Find all non-blank lines, and add the suffix to the end.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t597" href="#t597">597</a></span><span class="t"> <span class="nam">repl</span> <span class="op">=</span> <span class="str">r"\g<0>"</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'\\'</span><span class="op">,</span> <span class="str">'\\\\'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t598" href="#t598">598</a></span><span class="t"> <span class="nam">text</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reNonEmptyLines</span><span class="op">.</span><span class="nam">sub</span><span class="op">(</span><span class="nam">repl</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t599" href="#t599">599</a></span><span class="t"> <span class="key">return</span> <span class="nam">text</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t600" href="#t600">600</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t601" href="#t601">601</a></span><span class="t"> <span class="key">def</span> <span class="nam">processString</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sInput</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t602" href="#t602">602</a></span><span class="t"> <span class="str">""" Process sInput as the text to cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t603" href="#t603">603</a></span><span class="t"><span class="str"> Return the cogged output as a string.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t604" href="#t604">604</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t605" href="#t605">605</a></span><span class="t"> <span class="nam">fOld</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="nam">sInput</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t606" href="#t606">606</a></span><span class="t"> <span class="nam">fNew</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t607" href="#t607">607</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">fOld</span><span class="op">,</span> <span class="nam">fNew</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">fname</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t608" href="#t608">608</a></span><span class="t"> <span class="key">return</span> <span class="nam">fNew</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t609" href="#t609">609</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t610" href="#t610">610</a></span><span class="t"> <span class="key">def</span> <span class="nam">replaceFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t611" href="#t611">611</a></span><span class="t"> <span class="str">""" Replace file sOldPath with the contents sNewText</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t612" href="#t612">612</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t613" href="#t613">613</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t614" href="#t614">614</a></span><span class="t"> <span class="com"># Need to ensure we can write.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t615" href="#t615">615</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t616" href="#t616">616</a></span><span class="t"> <span class="com"># Use an external command to make the file writable.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t617" href="#t617">617</a></span><span class="t"> <span class="nam">cmd</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'%s'</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t618" href="#t618">618</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">popen</span><span class="op">(</span><span class="nam">cmd</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t619" href="#t619">619</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t620" href="#t620">620</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Couldn't make %s writable"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t621" href="#t621">621</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t622" href="#t622">622</a></span><span class="t"> <span class="com"># Can't write!</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t623" href="#t623">623</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Can't overwrite %s"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t624" href="#t624">624</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t625" href="#t625">625</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sNewText</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t626" href="#t626">626</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t627" href="#t627">627</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t628" href="#t628">628</a></span><span class="t"> <span class="key">def</span> <span class="nam">saveIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t629" href="#t629">629</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t630" href="#t630">630</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t631" href="#t631">631</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t632" href="#t632">632</a></span><span class="t"> <span class="key">def</span> <span class="nam">restoreIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t633" href="#t633">633</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t634" href="#t634">634</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t635" href="#t635">635</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t636" href="#t636">636</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t637" href="#t637">637</a></span><span class="t"> <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">includePath</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t638" href="#t638">638</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t639" href="#t639">639</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t640" href="#t640">640</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t641" href="#t641">641</a></span><span class="t"> <span class="key">def</span> <span class="nam">processOneFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t642" href="#t642">642</a></span><span class="t"> <span class="str">""" Process one filename through cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t643" href="#t643">643</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t644" href="#t644">644</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t645" href="#t645">645</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">saveIncludePath</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t646" href="#t646">646</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t647" href="#t647">647</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t648" href="#t648">648</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t649" href="#t649">649</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t650" href="#t650">650</a></span><span class="t"> <span class="com"># Since we know where the input file came from,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t651" href="#t651">651</a></span><span class="t"> <span class="com"># push its directory onto the include path.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t652" href="#t652">652</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="op">[</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t653" href="#t653">653</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t654" href="#t654">654</a></span><span class="t"> <span class="com"># How we process the file depends on where the output is going.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t655" href="#t655">655</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t656" href="#t656">656</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t657" href="#t657">657</a></span><span class="t"> <span class="key">elif</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bReplace</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t658" href="#t658">658</a></span><span class="t"> <span class="com"># We want to replace the cog file with the output,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t659" href="#t659">659</a></span><span class="t"> <span class="com"># but only if they differ.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t660" href="#t660">660</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">2</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t661" href="#t661">661</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t662" href="#t662">662</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t663" href="#t663">663</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t664" href="#t664">664</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t665" href="#t665">665</a></span><span class="t"> <span class="nam">fOldFile</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t666" href="#t666">666</a></span><span class="t"> <span class="nam">sOldText</span> <span class="op">=</span> <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t667" href="#t667">667</a></span><span class="t"> <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t668" href="#t668">668</a></span><span class="t"> <span class="nam">sNewText</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">sOldText</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t669" href="#t669">669</a></span><span class="t"> <span class="key">if</span> <span class="nam">sOldText</span> <span class="op">!=</span> <span class="nam">sNewText</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t670" href="#t670">670</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">1</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t671" href="#t671">671</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op"><</span> <span class="num">2</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t672" href="#t672">672</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t673" href="#t673">673</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">" (changed)"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t674" href="#t674">674</a></span><span class="t"> <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t675" href="#t675">675</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">replaceFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t676" href="#t676">676</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t677" href="#t677">677</a></span><span class="t"> <span class="com"># The try-finally block is so we can print a partial line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t678" href="#t678">678</a></span><span class="t"> <span class="com"># with the name of the file, and print (changed) on the</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t679" href="#t679">679</a></span><span class="t"> <span class="com"># same line, but also make sure to break the line before</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t680" href="#t680">680</a></span><span class="t"> <span class="com"># any traceback.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t681" href="#t681">681</a></span><span class="t"> <span class="key">if</span> <span class="nam">bNeedNewline</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t682" href="#t682">682</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t683" href="#t683">683</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t684" href="#t684">684</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t685" href="#t685">685</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t686" href="#t686">686</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">restoreIncludePath</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t687" href="#t687">687</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t688" href="#t688">688</a></span><span class="t"> <span class="key">def</span> <span class="nam">processWildcards</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t689" href="#t689">689</a></span><span class="t"> <span class="nam">files</span> <span class="op">=</span> <span class="nam">glob</span><span class="op">.</span><span class="nam">glob</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t690" href="#t690">690</a></span><span class="t"> <span class="key">if</span> <span class="nam">files</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t691" href="#t691">691</a></span><span class="t"> <span class="key">for</span> <span class="nam">sMatchingFile</span> <span class="key">in</span> <span class="nam">files</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t692" href="#t692">692</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sMatchingFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t693" href="#t693">693</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t694" href="#t694">694</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t695" href="#t695">695</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t696" href="#t696">696</a></span><span class="t"> <span class="key">def</span> <span class="nam">processFileList</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFileList</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t697" href="#t697">697</a></span><span class="t"> <span class="str">""" Process the files in a file list.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t698" href="#t698">698</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t699" href="#t699">699</a></span><span class="t"> <span class="nam">flist</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFileList</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t700" href="#t700">700</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">flist</span><span class="op">.</span><span class="nam">readlines</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t701" href="#t701">701</a></span><span class="t"> <span class="nam">flist</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t702" href="#t702">702</a></span><span class="t"> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">lines</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t703" href="#t703">703</a></span><span class="t"> <span class="com"># Use shlex to parse the line like a shell.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t704" href="#t704">704</a></span><span class="t"> <span class="nam">lex</span> <span class="op">=</span> <span class="nam">shlex</span><span class="op">.</span><span class="nam">shlex</span><span class="op">(</span><span class="nam">l</span><span class="op">,</span> <span class="nam">posix</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t705" href="#t705">705</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">whitespace_split</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t706" href="#t706">706</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">commenters</span> <span class="op">=</span> <span class="str">'#'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t707" href="#t707">707</a></span><span class="t"> <span class="com"># No escapes, so that backslash can be part of the path</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t708" href="#t708">708</a></span><span class="t"> <span class="nam">lex</span><span class="op">.</span><span class="nam">escape</span> <span class="op">=</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t709" href="#t709">709</a></span><span class="t"> <span class="nam">args</span> <span class="op">=</span> <span class="nam">list</span><span class="op">(</span><span class="nam">lex</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t710" href="#t710">710</a></span><span class="t"> <span class="key">if</span> <span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t711" href="#t711">711</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="nam">args</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t712" href="#t712">712</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t713" href="#t713">713</a></span><span class="t"> <span class="key">def</span> <span class="nam">processArguments</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t714" href="#t714">714</a></span><span class="t"> <span class="str">""" Process one command-line.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t715" href="#t715">715</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t716" href="#t716">716</a></span><span class="t"> <span class="nam">saved_options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t717" href="#t717">717</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">clone</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t718" href="#t718">718</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t719" href="#t719">719</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t720" href="#t720">720</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t721" href="#t721">721</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t722" href="#t722">722</a></span><span class="t"> <span class="key">if</span> <span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">==</span> <span class="str">'@'</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t723" href="#t723">723</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t724" href="#t724">724</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with @file"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t725" href="#t725">725</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processFileList</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t726" href="#t726">726</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t727" href="#t727">727</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processWildcards</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t728" href="#t728">728</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t729" href="#t729">729</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">saved_options</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t730" href="#t730">730</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t731" href="#t731">731</a></span><span class="t"> <span class="key">def</span> <span class="nam">callableMain</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t732" href="#t732">732</a></span><span class="t"> <span class="str">""" All of command-line cog, but in a callable form.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t733" href="#t733">733</a></span><span class="t"><span class="str"> This is used by main.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t734" href="#t734">734</a></span><span class="t"><span class="str"> argv is the equivalent of sys.argv.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t735" href="#t735">735</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t736" href="#t736">736</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="nam">argv</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t737" href="#t737">737</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t738" href="#t738">738</a></span><span class="t"> <span class="com"># Provide help if asked for anywhere in the command line.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t739" href="#t739">739</a></span><span class="t"> <span class="key">if</span> <span class="str">'-?'</span> <span class="key">in</span> <span class="nam">argv</span> <span class="key">or</span> <span class="str">'-h'</span> <span class="key">in</span> <span class="nam">argv</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t740" href="#t740">740</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">usage</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t741" href="#t741">741</a></span><span class="t"> <span class="key">return</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t742" href="#t742">742</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t743" href="#t743">743</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t744" href="#t744">744</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t745" href="#t745">745</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t746" href="#t746">746</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t747" href="#t747">747</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bShowVersion</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t748" href="#t748">748</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cog version %s"</span> <span class="op">%</span> <span class="nam">__version__</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t749" href="#t749">749</a></span><span class="t"> <span class="key">return</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t750" href="#t750">750</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t751" href="#t751">751</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t752" href="#t752">752</a></span><span class="t"> <span class="key">for</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t753" href="#t753">753</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="op">[</span><span class="nam">a</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t754" href="#t754">754</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t755" href="#t755">755</a></span><span class="t"> <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"No files to process"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t756" href="#t756">756</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t757" href="#t757">757</a></span><span class="t"> <span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t758" href="#t758">758</a></span><span class="t"> <span class="str">""" Handle the command-line execution for cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t759" href="#t759">759</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t760" href="#t760">760</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t761" href="#t761">761</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t762" href="#t762">762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t763" href="#t763">763</a></span><span class="t"> <span class="key">return</span> <span class="num">0</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t764" href="#t764">764</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogUsageError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t765" href="#t765">765</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t766" href="#t766">766</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"(for help use -?)"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t767" href="#t767">767</a></span><span class="t"> <span class="key">return</span> <span class="num">2</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t768" href="#t768">768</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogGeneratedError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t769" href="#t769">769</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Error: %s"</span> <span class="op">%</span> <span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t770" href="#t770">770</a></span><span class="t"> <span class="key">return</span> <span class="num">3</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t771" href="#t771">771</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogUserException</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t772" href="#t772">772</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Traceback (most recent call last):"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t773" href="#t773">773</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t774" href="#t774">774</a></span><span class="t"> <span class="key">return</span> <span class="num">4</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t775" href="#t775">775</a></span><span class="t"> <span class="key">except</span> <span class="nam">CogError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t776" href="#t776">776</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t777" href="#t777">777</a></span><span class="t"> <span class="key">return</span> <span class="num">1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t778" href="#t778">778</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t779" href="#t779">779</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t780" href="#t780">780</a></span><span class="t"><span class="key">def</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frame_summary</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t781" href="#t781">781</a></span><span class="t"> <span class="str">"""Find cog source lines in a frame summary list, for printing tracebacks.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t782" href="#t782">782</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t783" href="#t783">783</a></span><span class="t"><span class="str"> Arguments:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t784" href="#t784">784</a></span><span class="t"><span class="str"> frame_summary: a list of 4-item tuples, as returned by traceback.extract_tb.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t785" href="#t785">785</a></span><span class="t"><span class="str"> prologue: the text of the code prologue.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t786" href="#t786">786</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t787" href="#t787">787</a></span><span class="t"><span class="str"> Returns</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t788" href="#t788">788</a></span><span class="t"><span class="str"> A list of 4-item tuples, updated to correct the cog entries.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t789" href="#t789">789</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t790" href="#t790">790</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t791" href="#t791">791</a></span><span class="t"> <span class="nam">prolines</span> <span class="op">=</span> <span class="nam">prologue</span><span class="op">.</span><span class="nam">splitlines</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t792" href="#t792">792</a></span><span class="t"> <span class="key">for</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span> <span class="key">in</span> <span class="nam">frame_summary</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t793" href="#t793">793</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">source</span><span class="op">:</span> </span><span class="r"><span class="annotate short">793 ↛ 805</span><span class="annotate long">line 793 didn't jump to line 805, because the condition on line 793 was never false</span></span></p> + <p class="run"><span class="n"><a id="t794" href="#t794">794</a></span><span class="t"> <span class="nam">m</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="str">r"^<cog ([^:]+):(\d+)>$"</span><span class="op">,</span> <span class="nam">filename</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t795" href="#t795">795</a></span><span class="t"> <span class="key">if</span> <span class="nam">m</span><span class="op">:</span> </span><span class="r"><span class="annotate short">795 ↛ 796</span><span class="annotate long">line 795 didn't jump to line 796, because the condition on line 795 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t796" href="#t796">796</a></span><span class="t"> <span class="key">if</span> <span class="nam">lineno</span> <span class="op"><=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t797" href="#t797">797</a></span><span class="t"> <span class="nam">filename</span> <span class="op">=</span> <span class="str">'<prologue>'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t798" href="#t798">798</a></span><span class="t"> <span class="nam">source</span> <span class="op">=</span> <span class="nam">prolines</span><span class="op">[</span><span class="nam">lineno</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t799" href="#t799">799</a></span><span class="t"> <span class="nam">lineno</span> <span class="op">-=</span> <span class="num">1</span> <span class="com"># Because "import cog" is the first line in the prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t800" href="#t800">800</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t801" href="#t801">801</a></span><span class="t"> <span class="nam">filename</span><span class="op">,</span> <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">m</span><span class="op">.</span><span class="nam">groups</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t802" href="#t802">802</a></span><span class="t"> <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">coglineno</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t803" href="#t803">803</a></span><span class="t"> <span class="nam">lineno</span> <span class="op">+=</span> <span class="nam">coglineno</span> <span class="op">-</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t804" href="#t804">804</a></span><span class="t"> <span class="nam">source</span> <span class="op">=</span> <span class="nam">linecache</span><span class="op">.</span><span class="nam">getline</span><span class="op">(</span><span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">)</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t805" href="#t805">805</a></span><span class="t"> <span class="key">yield</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t806" href="#t806">806</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t807" href="#t807">807</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t808" href="#t808">808</a></span><span class="t"><span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t809" href="#t809">809</a></span><span class="t"> <span class="str">"""Main function for entry_points to use."""</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t810" href="#t810">810</a></span><span class="t"> <span class="key">return</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html b/doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html index c591fba9..6fc42807 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html @@ -6,107 +6,112 @@ <title>Coverage for cogapp/makefiles.py: 17.07%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/makefiles.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/makefiles.py</b>: <span class="pc_cov">17.07%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 27 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">7 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">20 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">27 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">7<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">20<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Dictionary-to-filetree functions, to create test files for testing.</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span> </span><span class="r"></span></p> - <p id="t10" class="pln"><span class="n"><a href="#t10">10</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">bytes_types</span> </span><span class="r"></span></p> - <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="nam">reindentBlock</span> </span><span class="r"></span></p> - <p id="t13" class="pln"><span class="n"><a href="#t13">13</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="nam">__all__</span> <span class="op">=</span> <span class="op">[</span><span class="str">'makeFiles'</span><span class="op">,</span> <span class="str">'removeFiles'</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="key">def</span> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">basedir</span><span class="op">=</span><span class="str">'.'</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t"> <span class="str">""" Create files from the dictionary `d`, in the directory named by `basedir`.</span> </span><span class="r"></span></p> - <p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="str"> If `bytes` is true, then treat bytestrings as bytes, else as text.</span> </span><span class="r"></span></p> - <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t20" class="mis show_mis"><span class="n"><a href="#t20">20</a></span><span class="t"> <span class="key">for</span> <span class="nam">name</span><span class="op">,</span> <span class="nam">contents</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t21" class="mis show_mis"><span class="n"><a href="#t21">21</a></span><span class="t"> <span class="nam">child</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">basedir</span><span class="op">,</span> <span class="nam">name</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t22" class="mis show_mis"><span class="n"><a href="#t22">22</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">'w'</span> </span><span class="r"></span></p> - <p id="t24" class="mis show_mis"><span class="n"><a href="#t24">24</a></span><span class="t"> <span class="key">if</span> <span class="nam">bytes</span> <span class="key">and</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t25" class="mis show_mis"><span class="n"><a href="#t25">25</a></span><span class="t"> <span class="nam">mode</span> <span class="op">+=</span> <span class="str">"b"</span> </span><span class="r"></span></p> - <p id="t26" class="mis show_mis"><span class="n"><a href="#t26">26</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">child</span><span class="op">,</span> <span class="nam">mode</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t27" class="mis show_mis"><span class="n"><a href="#t27">27</a></span><span class="t"> <span class="nam">contents</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">contents</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">contents</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t29" class="mis show_mis"><span class="n"><a href="#t29">29</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t31" class="mis show_mis"><span class="n"><a href="#t31">31</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t32" class="mis show_mis"><span class="n"><a href="#t32">32</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t33" class="mis show_mis"><span class="n"><a href="#t33">33</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t35" class="run"><span class="n"><a href="#t35">35</a></span><span class="t"><span class="key">def</span> <span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">basedir</span><span class="op">=</span><span class="str">'.'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t"> <span class="str">""" Remove the files created by makeFiles.</span> </span><span class="r"></span></p> - <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"><span class="str"> Directories are removed if they are empty.</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t39" class="mis show_mis"><span class="n"><a href="#t39">39</a></span><span class="t"> <span class="key">for</span> <span class="nam">name</span><span class="op">,</span> <span class="nam">contents</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t40" class="mis show_mis"><span class="n"><a href="#t40">40</a></span><span class="t"> <span class="nam">child</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">basedir</span><span class="op">,</span> <span class="nam">name</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t41" class="mis show_mis"><span class="n"><a href="#t41">41</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t42" class="mis show_mis"><span class="n"><a href="#t42">42</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">remove</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t43" class="pln"><span class="n"><a href="#t43">43</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t44" class="mis show_mis"><span class="n"><a href="#t44">44</a></span><span class="t"> <span class="nam">removeFiles</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t45" class="mis show_mis"><span class="n"><a href="#t45">45</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">listdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t46" class="mis show_mis"><span class="n"><a href="#t46">46</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">rmdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Dictionary-to-filetree functions, to create test files for testing.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">bytes_types</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="nam">reindentBlock</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"><span class="nam">__all__</span> <span class="op">=</span> <span class="op">[</span><span class="str">'makeFiles'</span><span class="op">,</span> <span class="str">'removeFiles'</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"><span class="key">def</span> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">basedir</span><span class="op">=</span><span class="str">'.'</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"> <span class="str">""" Create files from the dictionary `d`, in the directory named by `basedir`.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"><span class="str"> If `bytes` is true, then treat bytestrings as bytes, else as text.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> <span class="key">for</span> <span class="nam">name</span><span class="op">,</span> <span class="nam">contents</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"> <span class="nam">child</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">basedir</span><span class="op">,</span> <span class="nam">name</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"> <span class="nam">mode</span> <span class="op">=</span> <span class="str">'w'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> <span class="key">if</span> <span class="nam">bytes</span> <span class="key">and</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> <span class="nam">mode</span> <span class="op">+=</span> <span class="str">"b"</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">child</span><span class="op">,</span> <span class="nam">mode</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="nam">contents</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">contents</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">contents</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"><span class="key">def</span> <span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">basedir</span><span class="op">=</span><span class="str">'.'</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="str">""" Remove the files created by makeFiles.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"><span class="str"> Directories are removed if they are empty.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="key">for</span> <span class="nam">name</span><span class="op">,</span> <span class="nam">contents</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="nam">child</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">basedir</span><span class="op">,</span> <span class="nam">name</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">remove</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"> <span class="nam">removeFiles</span><span class="op">(</span><span class="nam">contents</span><span class="op">,</span> <span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">listdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">rmdir</span><span class="op">(</span><span class="nam">child</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html b/doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html index 07e6fa9c..3c78ddee 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html @@ -6,2539 +6,2544 @@ <title>Coverage for cogapp/test_cogapp.py: 30.07%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/test_cogapp.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/test_cogapp.py</b>: <span class="pc_cov">30.07%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 788 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">241 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">547 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">8 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">788 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">241<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">547<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">8<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Test cogapp.</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> - <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">random</span> </span><span class="r"></span></p> - <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> - <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">import</span> <span class="nam">shutil</span> </span><span class="r"></span></p> - <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="key">import</span> <span class="nam">stat</span> </span><span class="r"></span></p> - <p id="t15" class="run"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> - <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="key">import</span> <span class="nam">tempfile</span> </span><span class="r"></span></p> - <p id="t17" class="run"><span class="n"><a href="#t17">17</a></span><span class="t"><span class="key">import</span> <span class="nam">threading</span> </span><span class="r"></span></p> - <p id="t18" class="pln"><span class="n"><a href="#t18">18</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t19" class="run"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">StringIO</span><span class="op">,</span> <span class="nam">to_bytes</span><span class="op">,</span> <span class="nam">TestCase</span><span class="op">,</span> <span class="nam">PY3</span> </span><span class="r"></span></p> - <p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">Cog</span><span class="op">,</span> <span class="nam">CogOptions</span><span class="op">,</span> <span class="nam">CogGenerator</span> </span><span class="r"></span></p> - <p id="t21" class="run"><span class="n"><a href="#t21">21</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">CogError</span><span class="op">,</span> <span class="nam">CogUsageError</span><span class="op">,</span> <span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="nam">CogUserException</span> </span><span class="r"></span></p> - <p id="t22" class="run"><span class="n"><a href="#t22">22</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">usage</span><span class="op">,</span> <span class="nam">__version__</span><span class="op">,</span> <span class="nam">main</span> </span><span class="r"></span></p> - <p id="t23" class="run"><span class="n"><a href="#t23">23</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">makefiles</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> - <p id="t24" class="run"><span class="n"><a href="#t24">24</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="nam">reindentBlock</span> </span><span class="r"></span></p> - <p id="t25" class="pln"><span class="n"><a href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t26" class="pln"><span class="n"><a href="#t26">26</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t27" class="run"><span class="n"><a href="#t27">27</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestsInMemory</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t28" class="pln"><span class="n"><a href="#t28">28</a></span><span class="t"> <span class="str">""" Test cases for cogapp.Cog()</span> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t31" class="run"><span class="n"><a href="#t31">31</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t32" class="run"><span class="n"><a href="#t32">32</a></span><span class="t"> <span class="nam">strings</span> <span class="op">=</span> <span class="op">[</span> </span><span class="r"></span></p> - <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t"> <span class="str">''</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t"> <span class="str">' '</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t"> <span class="str">' \t \t \tx'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t"> <span class="str">'hello'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"> <span class="str">'the cat\nin the\nhat.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"> <span class="str">'Horton\n\tHears A\n\t\tWho'</span> </span><span class="r"></span></p> - <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> - <p id="t40" class="run"><span class="n"><a href="#t40">40</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t41" class="run"><span class="n"><a href="#t41">41</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t43" class="run"><span class="n"><a href="#t43">43</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t44" class="run"><span class="n"><a href="#t44">44</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> - <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t47" class="pln"><span class="n"><a href="#t47">47</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t48" class="pln"><span class="n"><a href="#t48">48</a></span><span class="t"><span class="str"> cog.outl("This is line one\\n")</span> </span><span class="r"></span></p> - <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t"><span class="str"> cog.outl("This is line two")</span> </span><span class="r"></span></p> - <p id="t50" class="pln"><span class="n"><a href="#t50">50</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t51" class="pln"><span class="n"><a href="#t51">51</a></span><span class="t"><span class="str"> gobbledegook.</span> </span><span class="r"></span></p> - <p id="t52" class="pln"><span class="n"><a href="#t52">52</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t53" class="pln"><span class="n"><a href="#t53">53</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> - <p id="t54" class="pln"><span class="n"><a href="#t54">54</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t55" class="pln"><span class="n"><a href="#t55">55</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t56" class="run"><span class="n"><a href="#t56">56</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> - <p id="t58" class="pln"><span class="n"><a href="#t58">58</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t59" class="pln"><span class="n"><a href="#t59">59</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t60" class="pln"><span class="n"><a href="#t60">60</a></span><span class="t"><span class="str"> cog.outl("This is line one\\n")</span> </span><span class="r"></span></p> - <p id="t61" class="pln"><span class="n"><a href="#t61">61</a></span><span class="t"><span class="str"> cog.outl("This is line two")</span> </span><span class="r"></span></p> - <p id="t62" class="pln"><span class="n"><a href="#t62">62</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> - <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t65" class="pln"><span class="n"><a href="#t65">65</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> - <p id="t66" class="pln"><span class="n"><a href="#t66">66</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t67" class="pln"><span class="n"><a href="#t67">67</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> - <p id="t68" class="pln"><span class="n"><a href="#t68">68</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t69" class="pln"><span class="n"><a href="#t69">69</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t70" class="run"><span class="n"><a href="#t70">70</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">outfile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t71" class="pln"><span class="n"><a href="#t71">71</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t72" class="run"><span class="n"><a href="#t72">72</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptyCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t73" class="pln"><span class="n"><a href="#t73">73</a></span><span class="t"> <span class="com"># The cog clause can be totally empty. Not sure why you'd want it,</span> </span><span class="r"></span></p> - <p id="t74" class="pln"><span class="n"><a href="#t74">74</a></span><span class="t"> <span class="com"># but it works.</span> </span><span class="r"></span></p> - <p id="t75" class="run"><span class="n"><a href="#t75">75</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t"><span class="str"> hello</span> </span><span class="r"></span></p> - <p id="t77" class="pln"><span class="n"><a href="#t77">77</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t78" class="pln"><span class="n"><a href="#t78">78</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t80" class="pln"><span class="n"><a href="#t80">80</a></span><span class="t"><span class="str"> goodbye</span> </span><span class="r"></span></p> - <p id="t81" class="pln"><span class="n"><a href="#t81">81</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t82" class="pln"><span class="n"><a href="#t82">82</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t83" class="run"><span class="n"><a href="#t83">83</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t84" class="run"><span class="n"><a href="#t84">84</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t85" class="pln"><span class="n"><a href="#t85">85</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t86" class="run"><span class="n"><a href="#t86">86</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMultipleCogs</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t87" class="pln"><span class="n"><a href="#t87">87</a></span><span class="t"> <span class="com"># One file can have many cog chunks, even abutting each other.</span> </span><span class="r"></span></p> - <p id="t88" class="run"><span class="n"><a href="#t88">88</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t89" class="pln"><span class="n"><a href="#t89">89</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t90" class="pln"><span class="n"><a href="#t90">90</a></span><span class="t"><span class="str"> cog.out("chunk1")</span> </span><span class="r"></span></p> - <p id="t91" class="pln"><span class="n"><a href="#t91">91</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t92" class="pln"><span class="n"><a href="#t92">92</a></span><span class="t"><span class="str"> chunk1</span> </span><span class="r"></span></p> - <p id="t93" class="pln"><span class="n"><a href="#t93">93</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t94" class="pln"><span class="n"><a href="#t94">94</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t95" class="pln"><span class="n"><a href="#t95">95</a></span><span class="t"><span class="str"> cog.out("chunk2")</span> </span><span class="r"></span></p> - <p id="t96" class="pln"><span class="n"><a href="#t96">96</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t97" class="pln"><span class="n"><a href="#t97">97</a></span><span class="t"><span class="str"> chunk2</span> </span><span class="r"></span></p> - <p id="t98" class="pln"><span class="n"><a href="#t98">98</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t"><span class="str"> between chunks</span> </span><span class="r"></span></p> - <p id="t100" class="pln"><span class="n"><a href="#t100">100</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t101" class="pln"><span class="n"><a href="#t101">101</a></span><span class="t"><span class="str"> cog.out("chunk3")</span> </span><span class="r"></span></p> - <p id="t102" class="pln"><span class="n"><a href="#t102">102</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t103" class="pln"><span class="n"><a href="#t103">103</a></span><span class="t"><span class="str"> chunk3</span> </span><span class="r"></span></p> - <p id="t104" class="pln"><span class="n"><a href="#t104">104</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t105" class="pln"><span class="n"><a href="#t105">105</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t106" class="pln"><span class="n"><a href="#t106">106</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t107" class="run"><span class="n"><a href="#t107">107</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t108" class="run"><span class="n"><a href="#t108">108</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t109" class="pln"><span class="n"><a href="#t109">109</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t110" class="run"><span class="n"><a href="#t110">110</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimBlankLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t111" class="run"><span class="n"><a href="#t111">111</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t112" class="pln"><span class="n"><a href="#t112">112</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t113" class="pln"><span class="n"><a href="#t113">113</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t114" class="pln"><span class="n"><a href="#t114">114</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> - <p id="t115" class="pln"><span class="n"><a href="#t115">115</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> - <p id="t116" class="pln"><span class="n"><a href="#t116">116</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t117" class="pln"><span class="n"><a href="#t117">117</a></span><span class="t"><span class="str"> cog.outl("This is line three", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t118" class="pln"><span class="n"><a href="#t118">118</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t119" class="pln"><span class="n"><a href="#t119">119</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> - <p id="t120" class="pln"><span class="n"><a href="#t120">120</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> - <p id="t121" class="pln"><span class="n"><a href="#t121">121</a></span><span class="t"><span class="str"> This is line three</span> </span><span class="r"></span></p> - <p id="t122" class="pln"><span class="n"><a href="#t122">122</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t123" class="pln"><span class="n"><a href="#t123">123</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t124" class="pln"><span class="n"><a href="#t124">124</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t125" class="run"><span class="n"><a href="#t125">125</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t126" class="run"><span class="n"><a href="#t126">126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t127" class="pln"><span class="n"><a href="#t127">127</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t128" class="run"><span class="n"><a href="#t128">128</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimEmptyBlankLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t129" class="run"><span class="n"><a href="#t129">129</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t130" class="pln"><span class="n"><a href="#t130">130</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t131" class="pln"><span class="n"><a href="#t131">131</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t132" class="pln"><span class="n"><a href="#t132">132</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> - <p id="t133" class="pln"><span class="n"><a href="#t133">133</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> - <p id="t134" class="pln"><span class="n"><a href="#t134">134</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t135" class="pln"><span class="n"><a href="#t135">135</a></span><span class="t"><span class="str"> cog.out('', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t136" class="pln"><span class="n"><a href="#t136">136</a></span><span class="t"><span class="str"> cog.outl("This is line three", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t137" class="pln"><span class="n"><a href="#t137">137</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t138" class="pln"><span class="n"><a href="#t138">138</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> - <p id="t139" class="pln"><span class="n"><a href="#t139">139</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> - <p id="t140" class="pln"><span class="n"><a href="#t140">140</a></span><span class="t"><span class="str"> This is line three</span> </span><span class="r"></span></p> - <p id="t141" class="pln"><span class="n"><a href="#t141">141</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t142" class="pln"><span class="n"><a href="#t142">142</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t143" class="pln"><span class="n"><a href="#t143">143</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t144" class="run"><span class="n"><a href="#t144">144</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t145" class="run"><span class="n"><a href="#t145">145</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t146" class="pln"><span class="n"><a href="#t146">146</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t147" class="run"><span class="n"><a href="#t147">147</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimBlankLinesWithLastPartial</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t148" class="run"><span class="n"><a href="#t148">148</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t149" class="pln"><span class="n"><a href="#t149">149</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t150" class="pln"><span class="n"><a href="#t150">150</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t151" class="pln"><span class="n"><a href="#t151">151</a></span><span class="t"><span class="str"> cog.out("\\nLine two\\nLine three", trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t152" class="pln"><span class="n"><a href="#t152">152</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t153" class="pln"><span class="n"><a href="#t153">153</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> - <p id="t154" class="pln"><span class="n"><a href="#t154">154</a></span><span class="t"><span class="str"> Line two</span> </span><span class="r"></span></p> - <p id="t155" class="pln"><span class="n"><a href="#t155">155</a></span><span class="t"><span class="str"> Line three</span> </span><span class="r"></span></p> - <p id="t156" class="pln"><span class="n"><a href="#t156">156</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t157" class="pln"><span class="n"><a href="#t157">157</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t158" class="pln"><span class="n"><a href="#t158">158</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t159" class="run"><span class="n"><a href="#t159">159</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t160" class="run"><span class="n"><a href="#t160">160</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t161" class="pln"><span class="n"><a href="#t161">161</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t162" class="run"><span class="n"><a href="#t162">162</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCogOutDedent</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t163" class="run"><span class="n"><a href="#t163">163</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t164" class="pln"><span class="n"><a href="#t164">164</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t165" class="pln"><span class="n"><a href="#t165">165</a></span><span class="t"><span class="str"> cog.out("This is the first line\\n")</span> </span><span class="r"></span></p> - <p id="t166" class="pln"><span class="n"><a href="#t166">166</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> - <p id="t167" class="pln"><span class="n"><a href="#t167">167</a></span><span class="t"><span class="str"> This is dedent=True 1</span> </span><span class="r"></span></p> - <p id="t168" class="pln"><span class="n"><a href="#t168">168</a></span><span class="t"><span class="str"> This is dedent=True 2</span> </span><span class="r"></span></p> - <p id="t169" class="pln"><span class="n"><a href="#t169">169</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t170" class="pln"><span class="n"><a href="#t170">170</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> - <p id="t171" class="pln"><span class="n"><a href="#t171">171</a></span><span class="t"><span class="str"> This is dedent=False 1</span> </span><span class="r"></span></p> - <p id="t172" class="pln"><span class="n"><a href="#t172">172</a></span><span class="t"><span class="str"> This is dedent=False 2</span> </span><span class="r"></span></p> - <p id="t173" class="pln"><span class="n"><a href="#t173">173</a></span><span class="t"><span class="str"> ''', dedent=False, trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t174" class="pln"><span class="n"><a href="#t174">174</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> - <p id="t175" class="pln"><span class="n"><a href="#t175">175</a></span><span class="t"><span class="str"> This is dedent=default 1</span> </span><span class="r"></span></p> - <p id="t176" class="pln"><span class="n"><a href="#t176">176</a></span><span class="t"><span class="str"> This is dedent=default 2</span> </span><span class="r"></span></p> - <p id="t177" class="pln"><span class="n"><a href="#t177">177</a></span><span class="t"><span class="str"> ''', trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t178" class="pln"><span class="n"><a href="#t178">178</a></span><span class="t"><span class="str"> cog.out("This is the last line\\n")</span> </span><span class="r"></span></p> - <p id="t179" class="pln"><span class="n"><a href="#t179">179</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t180" class="pln"><span class="n"><a href="#t180">180</a></span><span class="t"><span class="str"> This is the first line</span> </span><span class="r"></span></p> - <p id="t181" class="pln"><span class="n"><a href="#t181">181</a></span><span class="t"><span class="str"> This is dedent=True 1</span> </span><span class="r"></span></p> - <p id="t182" class="pln"><span class="n"><a href="#t182">182</a></span><span class="t"><span class="str"> This is dedent=True 2</span> </span><span class="r"></span></p> - <p id="t183" class="pln"><span class="n"><a href="#t183">183</a></span><span class="t"><span class="str"> This is dedent=False 1</span> </span><span class="r"></span></p> - <p id="t184" class="pln"><span class="n"><a href="#t184">184</a></span><span class="t"><span class="str"> This is dedent=False 2</span> </span><span class="r"></span></p> - <p id="t185" class="pln"><span class="n"><a href="#t185">185</a></span><span class="t"><span class="str"> This is dedent=default 1</span> </span><span class="r"></span></p> - <p id="t186" class="pln"><span class="n"><a href="#t186">186</a></span><span class="t"><span class="str"> This is dedent=default 2</span> </span><span class="r"></span></p> - <p id="t187" class="pln"><span class="n"><a href="#t187">187</a></span><span class="t"><span class="str"> This is the last line</span> </span><span class="r"></span></p> - <p id="t188" class="pln"><span class="n"><a href="#t188">188</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t189" class="pln"><span class="n"><a href="#t189">189</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t190" class="pln"><span class="n"><a href="#t190">190</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t191" class="run"><span class="n"><a href="#t191">191</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t192" class="run"><span class="n"><a href="#t192">192</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t193" class="pln"><span class="n"><a href="#t193">193</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t194" class="run"><span class="n"><a href="#t194">194</a></span><span class="t"> <span class="key">def</span> <span class="nam">test22EndOfLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t195" class="pln"><span class="n"><a href="#t195">195</a></span><span class="t"> <span class="com"># In Python 2.2, this cog file was not parsing because the</span> </span><span class="r"></span></p> - <p id="t196" class="pln"><span class="n"><a href="#t196">196</a></span><span class="t"> <span class="com"># last line is indented but didn't end with a newline.</span> </span><span class="r"></span></p> - <p id="t197" class="run"><span class="n"><a href="#t197">197</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t198" class="pln"><span class="n"><a href="#t198">198</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t199" class="pln"><span class="n"><a href="#t199">199</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t200" class="pln"><span class="n"><a href="#t200">200</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> - <p id="t201" class="pln"><span class="n"><a href="#t201">201</a></span><span class="t"><span class="str"> cog.out("%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t202" class="pln"><span class="n"><a href="#t202">202</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t203" class="pln"><span class="n"><a href="#t203">203</a></span><span class="t"><span class="str"> 0</span> </span><span class="r"></span></p> - <p id="t204" class="pln"><span class="n"><a href="#t204">204</a></span><span class="t"><span class="str"> 1</span> </span><span class="r"></span></p> - <p id="t205" class="pln"><span class="n"><a href="#t205">205</a></span><span class="t"><span class="str"> 2</span> </span><span class="r"></span></p> - <p id="t206" class="pln"><span class="n"><a href="#t206">206</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t207" class="pln"><span class="n"><a href="#t207">207</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t208" class="pln"><span class="n"><a href="#t208">208</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t209" class="run"><span class="n"><a href="#t209">209</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t210" class="run"><span class="n"><a href="#t210">210</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t211" class="pln"><span class="n"><a href="#t211">211</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t212" class="run"><span class="n"><a href="#t212">212</a></span><span class="t"> <span class="key">def</span> <span class="nam">testIndentedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t213" class="run"><span class="n"><a href="#t213">213</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t214" class="pln"><span class="n"><a href="#t214">214</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t215" class="pln"><span class="n"><a href="#t215">215</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t216" class="pln"><span class="n"><a href="#t216">216</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t217" class="pln"><span class="n"><a href="#t217">217</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> - <p id="t218" class="pln"><span class="n"><a href="#t218">218</a></span><span class="t"><span class="str"> cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t219" class="pln"><span class="n"><a href="#t219">219</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t220" class="pln"><span class="n"><a href="#t220">220</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> - <p id="t221" class="pln"><span class="n"><a href="#t221">221</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> - <p id="t222" class="pln"><span class="n"><a href="#t222">222</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> - <p id="t223" class="pln"><span class="n"><a href="#t223">223</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t224" class="pln"><span class="n"><a href="#t224">224</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t225" class="pln"><span class="n"><a href="#t225">225</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t226" class="pln"><span class="n"><a href="#t226">226</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t227" class="run"><span class="n"><a href="#t227">227</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t228" class="run"><span class="n"><a href="#t228">228</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t229" class="pln"><span class="n"><a href="#t229">229</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t230" class="run"><span class="n"><a href="#t230">230</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrefixedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t231" class="run"><span class="n"><a href="#t231">231</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t232" class="pln"><span class="n"><a href="#t232">232</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> - <p id="t233" class="pln"><span class="n"><a href="#t233">233</a></span><span class="t"><span class="str"> --import cog</span> </span><span class="r"></span></p> - <p id="t234" class="pln"><span class="n"><a href="#t234">234</a></span><span class="t"><span class="str"> --for i in range(3):</span> </span><span class="r"></span></p> - <p id="t235" class="pln"><span class="n"><a href="#t235">235</a></span><span class="t"><span class="str"> -- cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t236" class="pln"><span class="n"><a href="#t236">236</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> - <p id="t237" class="pln"><span class="n"><a href="#t237">237</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> - <p id="t238" class="pln"><span class="n"><a href="#t238">238</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> - <p id="t239" class="pln"><span class="n"><a href="#t239">239</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> - <p id="t240" class="pln"><span class="n"><a href="#t240">240</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t241" class="pln"><span class="n"><a href="#t241">241</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t242" class="pln"><span class="n"><a href="#t242">242</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t243" class="run"><span class="n"><a href="#t243">243</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t244" class="run"><span class="n"><a href="#t244">244</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t245" class="pln"><span class="n"><a href="#t245">245</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t246" class="run"><span class="n"><a href="#t246">246</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrefixedIndentedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t247" class="run"><span class="n"><a href="#t247">247</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t248" class="pln"><span class="n"><a href="#t248">248</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t249" class="pln"><span class="n"><a href="#t249">249</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> - <p id="t250" class="pln"><span class="n"><a href="#t250">250</a></span><span class="t"><span class="str"> -- import cog</span> </span><span class="r"></span></p> - <p id="t251" class="pln"><span class="n"><a href="#t251">251</a></span><span class="t"><span class="str"> -- for i in range(3):</span> </span><span class="r"></span></p> - <p id="t252" class="pln"><span class="n"><a href="#t252">252</a></span><span class="t"><span class="str"> -- cog.out("xy%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t253" class="pln"><span class="n"><a href="#t253">253</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> - <p id="t254" class="pln"><span class="n"><a href="#t254">254</a></span><span class="t"><span class="str"> xy0</span> </span><span class="r"></span></p> - <p id="t255" class="pln"><span class="n"><a href="#t255">255</a></span><span class="t"><span class="str"> xy1</span> </span><span class="r"></span></p> - <p id="t256" class="pln"><span class="n"><a href="#t256">256</a></span><span class="t"><span class="str"> xy2</span> </span><span class="r"></span></p> - <p id="t257" class="pln"><span class="n"><a href="#t257">257</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t258" class="pln"><span class="n"><a href="#t258">258</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t259" class="pln"><span class="n"><a href="#t259">259</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t260" class="run"><span class="n"><a href="#t260">260</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t261" class="run"><span class="n"><a href="#t261">261</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t262" class="pln"><span class="n"><a href="#t262">262</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t263" class="run"><span class="n"><a href="#t263">263</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBogusPrefixMatch</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t264" class="run"><span class="n"><a href="#t264">264</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t265" class="pln"><span class="n"><a href="#t265">265</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t266" class="pln"><span class="n"><a href="#t266">266</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t267" class="pln"><span class="n"><a href="#t267">267</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t268" class="pln"><span class="n"><a href="#t268">268</a></span><span class="t"><span class="str"> # This comment should not be clobbered by removing the pound sign.</span> </span><span class="r"></span></p> - <p id="t269" class="pln"><span class="n"><a href="#t269">269</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> - <p id="t270" class="pln"><span class="n"><a href="#t270">270</a></span><span class="t"><span class="str"> cog.out("xy%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t271" class="pln"><span class="n"><a href="#t271">271</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t272" class="pln"><span class="n"><a href="#t272">272</a></span><span class="t"><span class="str"> xy0</span> </span><span class="r"></span></p> - <p id="t273" class="pln"><span class="n"><a href="#t273">273</a></span><span class="t"><span class="str"> xy1</span> </span><span class="r"></span></p> - <p id="t274" class="pln"><span class="n"><a href="#t274">274</a></span><span class="t"><span class="str"> xy2</span> </span><span class="r"></span></p> - <p id="t275" class="pln"><span class="n"><a href="#t275">275</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t276" class="pln"><span class="n"><a href="#t276">276</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t277" class="pln"><span class="n"><a href="#t277">277</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t278" class="run"><span class="n"><a href="#t278">278</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t279" class="run"><span class="n"><a href="#t279">279</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t280" class="pln"><span class="n"><a href="#t280">280</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t281" class="run"><span class="n"><a href="#t281">281</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoFinalNewline</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t282" class="pln"><span class="n"><a href="#t282">282</a></span><span class="t"> <span class="com"># If the cog'ed output has no final newline,</span> </span><span class="r"></span></p> - <p id="t283" class="pln"><span class="n"><a href="#t283">283</a></span><span class="t"> <span class="com"># it shouldn't eat up the cog terminator.</span> </span><span class="r"></span></p> - <p id="t284" class="run"><span class="n"><a href="#t284">284</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t285" class="pln"><span class="n"><a href="#t285">285</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t286" class="pln"><span class="n"><a href="#t286">286</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t287" class="pln"><span class="n"><a href="#t287">287</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t288" class="pln"><span class="n"><a href="#t288">288</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> - <p id="t289" class="pln"><span class="n"><a href="#t289">289</a></span><span class="t"><span class="str"> cog.out("%d" % i)</span> </span><span class="r"></span></p> - <p id="t290" class="pln"><span class="n"><a href="#t290">290</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t291" class="pln"><span class="n"><a href="#t291">291</a></span><span class="t"><span class="str"> 012</span> </span><span class="r"></span></p> - <p id="t292" class="pln"><span class="n"><a href="#t292">292</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t293" class="pln"><span class="n"><a href="#t293">293</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> - <p id="t294" class="pln"><span class="n"><a href="#t294">294</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t295" class="pln"><span class="n"><a href="#t295">295</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t296" class="run"><span class="n"><a href="#t296">296</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t297" class="run"><span class="n"><a href="#t297">297</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t298" class="pln"><span class="n"><a href="#t298">298</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t299" class="run"><span class="n"><a href="#t299">299</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoOutputAtAll</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t300" class="pln"><span class="n"><a href="#t300">300</a></span><span class="t"> <span class="com"># If there is absolutely no cog output, that's ok.</span> </span><span class="r"></span></p> - <p id="t301" class="run"><span class="n"><a href="#t301">301</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t302" class="pln"><span class="n"><a href="#t302">302</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t303" class="pln"><span class="n"><a href="#t303">303</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t304" class="pln"><span class="n"><a href="#t304">304</a></span><span class="t"><span class="str"> i = 1</span> </span><span class="r"></span></p> - <p id="t305" class="pln"><span class="n"><a href="#t305">305</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t306" class="pln"><span class="n"><a href="#t306">306</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t307" class="pln"><span class="n"><a href="#t307">307</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> - <p id="t308" class="pln"><span class="n"><a href="#t308">308</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t309" class="pln"><span class="n"><a href="#t309">309</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t310" class="run"><span class="n"><a href="#t310">310</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t311" class="run"><span class="n"><a href="#t311">311</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t312" class="pln"><span class="n"><a href="#t312">312</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t313" class="run"><span class="n"><a href="#t313">313</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPurelyBlankLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t314" class="pln"><span class="n"><a href="#t314">314</a></span><span class="t"> <span class="com"># If there is a blank line in the cog code with no whitespace</span> </span><span class="r"></span></p> - <p id="t315" class="pln"><span class="n"><a href="#t315">315</a></span><span class="t"> <span class="com"># prefix, that should be OK.</span> </span><span class="r"></span></p> - <p id="t316" class="pln"><span class="n"><a href="#t316">316</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t317" class="run"><span class="n"><a href="#t317">317</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t318" class="pln"><span class="n"><a href="#t318">318</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t319" class="pln"><span class="n"><a href="#t319">319</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t320" class="pln"><span class="n"><a href="#t320">320</a></span><span class="t"><span class="str"> import sys</span> </span><span class="r"></span></p> - <p id="t321" class="pln"><span class="n"><a href="#t321">321</a></span><span class="t"><span class="str"> cog.out("Hello")</span> </span><span class="r"></span></p> - <p id="t322" class="pln"><span class="n"><a href="#t322">322</a></span><span class="t"><span class="str"> $</span> </span><span class="r"></span></p> - <p id="t323" class="pln"><span class="n"><a href="#t323">323</a></span><span class="t"><span class="str"> cog.out("There")</span> </span><span class="r"></span></p> - <p id="t324" class="pln"><span class="n"><a href="#t324">324</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t325" class="pln"><span class="n"><a href="#t325">325</a></span><span class="t"><span class="str"> HelloThere</span> </span><span class="r"></span></p> - <p id="t326" class="pln"><span class="n"><a href="#t326">326</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t327" class="pln"><span class="n"><a href="#t327">327</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> - <p id="t328" class="pln"><span class="n"><a href="#t328">328</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t329" class="pln"><span class="n"><a href="#t329">329</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t330" class="run"><span class="n"><a href="#t330">330</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'$'</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t331" class="run"><span class="n"><a href="#t331">331</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t332" class="pln"><span class="n"><a href="#t332">332</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t333" class="run"><span class="n"><a href="#t333">333</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptyOutl</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t334" class="pln"><span class="n"><a href="#t334">334</a></span><span class="t"> <span class="com"># Alexander Belchenko suggested the string argument to outl should</span> </span><span class="r"></span></p> - <p id="t335" class="pln"><span class="n"><a href="#t335">335</a></span><span class="t"> <span class="com"># be optional. Does it work?</span> </span><span class="r"></span></p> - <p id="t336" class="pln"><span class="n"><a href="#t336">336</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t337" class="run"><span class="n"><a href="#t337">337</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t338" class="pln"><span class="n"><a href="#t338">338</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> - <p id="t339" class="pln"><span class="n"><a href="#t339">339</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t340" class="pln"><span class="n"><a href="#t340">340</a></span><span class="t"><span class="str"> cog.outl("x")</span> </span><span class="r"></span></p> - <p id="t341" class="pln"><span class="n"><a href="#t341">341</a></span><span class="t"><span class="str"> cog.outl()</span> </span><span class="r"></span></p> - <p id="t342" class="pln"><span class="n"><a href="#t342">342</a></span><span class="t"><span class="str"> cog.outl("y")</span> </span><span class="r"></span></p> - <p id="t343" class="pln"><span class="n"><a href="#t343">343</a></span><span class="t"><span class="str"> cog.out() # Also optional, a complete no-op.</span> </span><span class="r"></span></p> - <p id="t344" class="pln"><span class="n"><a href="#t344">344</a></span><span class="t"><span class="str"> cog.outl(trimblanklines=True)</span> </span><span class="r"></span></p> - <p id="t345" class="pln"><span class="n"><a href="#t345">345</a></span><span class="t"><span class="str"> cog.outl("z")</span> </span><span class="r"></span></p> - <p id="t346" class="pln"><span class="n"><a href="#t346">346</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t347" class="pln"><span class="n"><a href="#t347">347</a></span><span class="t"><span class="str"> x</span> </span><span class="r"></span></p> - <p id="t348" class="pln"><span class="n"><a href="#t348">348</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t349" class="pln"><span class="n"><a href="#t349">349</a></span><span class="t"><span class="str"> y</span> </span><span class="r"></span></p> - <p id="t350" class="pln"><span class="n"><a href="#t350">350</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t351" class="pln"><span class="n"><a href="#t351">351</a></span><span class="t"><span class="str"> z</span> </span><span class="r"></span></p> - <p id="t352" class="pln"><span class="n"><a href="#t352">352</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t353" class="pln"><span class="n"><a href="#t353">353</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> - <p id="t354" class="pln"><span class="n"><a href="#t354">354</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t355" class="pln"><span class="n"><a href="#t355">355</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t356" class="run"><span class="n"><a href="#t356">356</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t357" class="run"><span class="n"><a href="#t357">357</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t358" class="pln"><span class="n"><a href="#t358">358</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t359" class="run"><span class="n"><a href="#t359">359</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFirstLineNum</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t360" class="run"><span class="n"><a href="#t360">360</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t361" class="pln"><span class="n"><a href="#t361">361</a></span><span class="t"><span class="str"> fooey</span> </span><span class="r"></span></p> - <p id="t362" class="pln"><span class="n"><a href="#t362">362</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t363" class="pln"><span class="n"><a href="#t363">363</a></span><span class="t"><span class="str"> cog.outl("started at line number %d" % cog.firstLineNum)</span> </span><span class="r"></span></p> - <p id="t364" class="pln"><span class="n"><a href="#t364">364</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t365" class="pln"><span class="n"><a href="#t365">365</a></span><span class="t"><span class="str"> started at line number 2</span> </span><span class="r"></span></p> - <p id="t366" class="pln"><span class="n"><a href="#t366">366</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t367" class="pln"><span class="n"><a href="#t367">367</a></span><span class="t"><span class="str"> blah blah</span> </span><span class="r"></span></p> - <p id="t368" class="pln"><span class="n"><a href="#t368">368</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t369" class="pln"><span class="n"><a href="#t369">369</a></span><span class="t"><span class="str"> cog.outl("and again at line %d" % cog.firstLineNum)</span> </span><span class="r"></span></p> - <p id="t370" class="pln"><span class="n"><a href="#t370">370</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t371" class="pln"><span class="n"><a href="#t371">371</a></span><span class="t"><span class="str"> and again at line 8</span> </span><span class="r"></span></p> - <p id="t372" class="pln"><span class="n"><a href="#t372">372</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t373" class="pln"><span class="n"><a href="#t373">373</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t374" class="pln"><span class="n"><a href="#t374">374</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t375" class="run"><span class="n"><a href="#t375">375</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t376" class="run"><span class="n"><a href="#t376">376</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t377" class="pln"><span class="n"><a href="#t377">377</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t378" class="run"><span class="n"><a href="#t378">378</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompactOneLineCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t379" class="run"><span class="n"><a href="#t379">379</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t380" class="pln"><span class="n"><a href="#t380">380</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t381" class="pln"><span class="n"><a href="#t381">381</a></span><span class="t"><span class="str"> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span> </span><span class="r"></span></p> - <p id="t382" class="pln"><span class="n"><a href="#t382">382</a></span><span class="t"><span class="str"> get rid of this!</span> </span><span class="r"></span></p> - <p id="t383" class="pln"><span class="n"><a href="#t383">383</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t384" class="pln"><span class="n"><a href="#t384">384</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t385" class="pln"><span class="n"><a href="#t385">385</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t386" class="pln"><span class="n"><a href="#t386">386</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t387" class="run"><span class="n"><a href="#t387">387</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t388" class="pln"><span class="n"><a href="#t388">388</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t389" class="pln"><span class="n"><a href="#t389">389</a></span><span class="t"><span class="str"> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span> </span><span class="r"></span></p> - <p id="t390" class="pln"><span class="n"><a href="#t390">390</a></span><span class="t"><span class="str"> hello 81</span> </span><span class="r"></span></p> - <p id="t391" class="pln"><span class="n"><a href="#t391">391</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t392" class="pln"><span class="n"><a href="#t392">392</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t393" class="pln"><span class="n"><a href="#t393">393</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t394" class="pln"><span class="n"><a href="#t394">394</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t395" class="run"><span class="n"><a href="#t395">395</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t396" class="run"><span class="n"><a href="#t396">396</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t397" class="pln"><span class="n"><a href="#t397">397</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t398" class="run"><span class="n"><a href="#t398">398</a></span><span class="t"> <span class="key">def</span> <span class="nam">testInsideOutCompact</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t399" class="run"><span class="n"><a href="#t399">399</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t400" class="pln"><span class="n"><a href="#t400">400</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t401" class="pln"><span class="n"><a href="#t401">401</a></span><span class="t"><span class="str"> hey?: ]]] what is this? [[[cog strange!</span> </span><span class="r"></span></p> - <p id="t402" class="pln"><span class="n"><a href="#t402">402</a></span><span class="t"><span class="str"> get rid of this!</span> </span><span class="r"></span></p> - <p id="t403" class="pln"><span class="n"><a href="#t403">403</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t404" class="pln"><span class="n"><a href="#t404">404</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t405" class="pln"><span class="n"><a href="#t405">405</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t406" class="run"><span class="n"><a href="#t406">406</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^infile.txt\(2\): Cog code markers inverted$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t407" class="run"><span class="n"><a href="#t407">407</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="str">"infile.txt"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t408" class="pln"><span class="n"><a href="#t408">408</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t409" class="run"><span class="n"><a href="#t409">409</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSharingGlobals</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t410" class="run"><span class="n"><a href="#t410">410</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t411" class="pln"><span class="n"><a href="#t411">411</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t412" class="pln"><span class="n"><a href="#t412">412</a></span><span class="t"><span class="str"> hey: [[[cog s="hey there" ]]] looky!</span> </span><span class="r"></span></p> - <p id="t413" class="pln"><span class="n"><a href="#t413">413</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t414" class="pln"><span class="n"><a href="#t414">414</a></span><span class="t"><span class="str"> more literal junk.</span> </span><span class="r"></span></p> - <p id="t415" class="pln"><span class="n"><a href="#t415">415</a></span><span class="t"><span class="str"> [[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> - <p id="t416" class="pln"><span class="n"><a href="#t416">416</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t417" class="pln"><span class="n"><a href="#t417">417</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t418" class="pln"><span class="n"><a href="#t418">418</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t419" class="pln"><span class="n"><a href="#t419">419</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t420" class="run"><span class="n"><a href="#t420">420</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t421" class="pln"><span class="n"><a href="#t421">421</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> - <p id="t422" class="pln"><span class="n"><a href="#t422">422</a></span><span class="t"><span class="str"> hey: [[[cog s="hey there" ]]] looky!</span> </span><span class="r"></span></p> - <p id="t423" class="pln"><span class="n"><a href="#t423">423</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t424" class="pln"><span class="n"><a href="#t424">424</a></span><span class="t"><span class="str"> more literal junk.</span> </span><span class="r"></span></p> - <p id="t425" class="pln"><span class="n"><a href="#t425">425</a></span><span class="t"><span class="str"> [[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> - <p id="t426" class="pln"><span class="n"><a href="#t426">426</a></span><span class="t"><span class="str"> hey there</span> </span><span class="r"></span></p> - <p id="t427" class="pln"><span class="n"><a href="#t427">427</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t428" class="pln"><span class="n"><a href="#t428">428</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> - <p id="t429" class="pln"><span class="n"><a href="#t429">429</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t430" class="pln"><span class="n"><a href="#t430">430</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t431" class="run"><span class="n"><a href="#t431">431</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t432" class="run"><span class="n"><a href="#t432">432</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t433" class="pln"><span class="n"><a href="#t433">433</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t434" class="run"><span class="n"><a href="#t434">434</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAssertInCogCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t435" class="pln"><span class="n"><a href="#t435">435</a></span><span class="t"> <span class="com"># Check that we can test assertions in cog code in the test framework.</span> </span><span class="r"></span></p> - <p id="t436" class="run"><span class="n"><a href="#t436">436</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t437" class="pln"><span class="n"><a href="#t437">437</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t438" class="pln"><span class="n"><a href="#t438">438</a></span><span class="t"><span class="str"> assert 1 == 2, "Oops"</span> </span><span class="r"></span></p> - <p id="t439" class="pln"><span class="n"><a href="#t439">439</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t440" class="pln"><span class="n"><a href="#t440">440</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t441" class="pln"><span class="n"><a href="#t441">441</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t442" class="run"><span class="n"><a href="#t442">442</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t443" class="run"><span class="n"><a href="#t443">443</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUserException</span><span class="op">,</span> <span class="str">"AssertionError: Oops"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t444" class="run"><span class="n"><a href="#t444">444</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t445" class="pln"><span class="n"><a href="#t445">445</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t446" class="run"><span class="n"><a href="#t446">446</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCogPrevious</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t447" class="pln"><span class="n"><a href="#t447">447</a></span><span class="t"> <span class="com"># Check that we can access the previous run's output.</span> </span><span class="r"></span></p> - <p id="t448" class="run"><span class="n"><a href="#t448">448</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t449" class="pln"><span class="n"><a href="#t449">449</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t450" class="pln"><span class="n"><a href="#t450">450</a></span><span class="t"><span class="str"> assert cog.previous == "Hello there!\\n", "WTF??"</span> </span><span class="r"></span></p> - <p id="t451" class="pln"><span class="n"><a href="#t451">451</a></span><span class="t"><span class="str"> cog.out(cog.previous)</span> </span><span class="r"></span></p> - <p id="t452" class="pln"><span class="n"><a href="#t452">452</a></span><span class="t"><span class="str"> cog.outl("Ran again!")</span> </span><span class="r"></span></p> - <p id="t453" class="pln"><span class="n"><a href="#t453">453</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t454" class="pln"><span class="n"><a href="#t454">454</a></span><span class="t"><span class="str"> Hello there!</span> </span><span class="r"></span></p> - <p id="t455" class="pln"><span class="n"><a href="#t455">455</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t456" class="pln"><span class="n"><a href="#t456">456</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t457" class="pln"><span class="n"><a href="#t457">457</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t458" class="run"><span class="n"><a href="#t458">458</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t459" class="pln"><span class="n"><a href="#t459">459</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> - <p id="t460" class="pln"><span class="n"><a href="#t460">460</a></span><span class="t"><span class="str"> assert cog.previous == "Hello there!\\n", "WTF??"</span> </span><span class="r"></span></p> - <p id="t461" class="pln"><span class="n"><a href="#t461">461</a></span><span class="t"><span class="str"> cog.out(cog.previous)</span> </span><span class="r"></span></p> - <p id="t462" class="pln"><span class="n"><a href="#t462">462</a></span><span class="t"><span class="str"> cog.outl("Ran again!")</span> </span><span class="r"></span></p> - <p id="t463" class="pln"><span class="n"><a href="#t463">463</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> - <p id="t464" class="pln"><span class="n"><a href="#t464">464</a></span><span class="t"><span class="str"> Hello there!</span> </span><span class="r"></span></p> - <p id="t465" class="pln"><span class="n"><a href="#t465">465</a></span><span class="t"><span class="str"> Ran again!</span> </span><span class="r"></span></p> - <p id="t466" class="pln"><span class="n"><a href="#t466">466</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t467" class="pln"><span class="n"><a href="#t467">467</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t468" class="pln"><span class="n"><a href="#t468">468</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t469" class="run"><span class="n"><a href="#t469">469</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t470" class="run"><span class="n"><a href="#t470">470</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t471" class="pln"><span class="n"><a href="#t471">471</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t472" class="pln"><span class="n"><a href="#t472">472</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t473" class="run"><span class="n"><a href="#t473">473</a></span><span class="t"><span class="key">class</span> <span class="nam">CogOptionsTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t474" class="pln"><span class="n"><a href="#t474">474</a></span><span class="t"> <span class="str">""" Test the CogOptions class.</span> </span><span class="r"></span></p> - <p id="t475" class="pln"><span class="n"><a href="#t475">475</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t476" class="pln"><span class="n"><a href="#t476">476</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t477" class="run"><span class="n"><a href="#t477">477</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEquality</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t478" class="mis show_mis"><span class="n"><a href="#t478">478</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t479" class="mis show_mis"><span class="n"><a href="#t479">479</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t480" class="mis show_mis"><span class="n"><a href="#t480">480</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t481" class="mis show_mis"><span class="n"><a href="#t481">481</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-r'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t482" class="mis show_mis"><span class="n"><a href="#t482">482</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t483" class="mis show_mis"><span class="n"><a href="#t483">483</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-r'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t484" class="mis show_mis"><span class="n"><a href="#t484">484</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t485" class="pln"><span class="n"><a href="#t485">485</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t486" class="run"><span class="n"><a href="#t486">486</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCloning</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t487" class="mis show_mis"><span class="n"><a href="#t487">487</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t488" class="mis show_mis"><span class="n"><a href="#t488">488</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'booey'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' /*x*/'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t489" class="mis show_mis"><span class="n"><a href="#t489">489</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">o</span><span class="op">.</span><span class="nam">clone</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t490" class="mis show_mis"><span class="n"><a href="#t490">490</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t491" class="mis show_mis"><span class="n"><a href="#t491">491</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'huey'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'foo=quux'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t492" class="mis show_mis"><span class="n"><a href="#t492">492</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t493" class="mis show_mis"><span class="n"><a href="#t493">493</a></span><span class="t"> <span class="nam">q</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t494" class="mis show_mis"><span class="n"><a href="#t494">494</a></span><span class="t"> <span class="nam">q</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'booey'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' /*x*/'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'huey'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'foo=quux'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t495" class="mis show_mis"><span class="n"><a href="#t495">495</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">p</span><span class="op">,</span> <span class="nam">q</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t496" class="pln"><span class="n"><a href="#t496">496</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t497" class="run"><span class="n"><a href="#t497">497</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCombiningFlags</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t498" class="pln"><span class="n"><a href="#t498">498</a></span><span class="t"> <span class="com"># Single-character flags can be combined.</span> </span><span class="r"></span></p> - <p id="t499" class="mis show_mis"><span class="n"><a href="#t499">499</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t500" class="mis show_mis"><span class="n"><a href="#t500">500</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-e'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t501" class="mis show_mis"><span class="n"><a href="#t501">501</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t502" class="mis show_mis"><span class="n"><a href="#t502">502</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-erz'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t503" class="mis show_mis"><span class="n"><a href="#t503">503</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t504" class="pln"><span class="n"><a href="#t504">504</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t505" class="run"><span class="n"><a href="#t505">505</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t506" class="mis show_mis"><span class="n"><a href="#t506">506</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t507" class="mis show_mis"><span class="n"><a href="#t507">507</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">_parse_markers</span><span class="op">(</span><span class="str">'a b c'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t508" class="mis show_mis"><span class="n"><a href="#t508">508</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'a'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t509" class="mis show_mis"><span class="n"><a href="#t509">509</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'b'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t510" class="mis show_mis"><span class="n"><a href="#t510">510</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'c'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t511" class="pln"><span class="n"><a href="#t511">511</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t512" class="run"><span class="n"><a href="#t512">512</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMarkersSwitch</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t513" class="mis show_mis"><span class="n"><a href="#t513">513</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t514" class="mis show_mis"><span class="n"><a href="#t514">514</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'--markers'</span><span class="op">,</span> <span class="str">'a b c'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t515" class="mis show_mis"><span class="n"><a href="#t515">515</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'a'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t516" class="mis show_mis"><span class="n"><a href="#t516">516</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'b'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t517" class="mis show_mis"><span class="n"><a href="#t517">517</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'c'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t518" class="pln"><span class="n"><a href="#t518">518</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t519" class="pln"><span class="n"><a href="#t519">519</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t520" class="run"><span class="n"><a href="#t520">520</a></span><span class="t"><span class="key">class</span> <span class="nam">FileStructureTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t521" class="pln"><span class="n"><a href="#t521">521</a></span><span class="t"> <span class="str">""" Test cases to check that we're properly strict about the structure</span> </span><span class="r"></span></p> - <p id="t522" class="pln"><span class="n"><a href="#t522">522</a></span><span class="t"><span class="str"> of files.</span> </span><span class="r"></span></p> - <p id="t523" class="pln"><span class="n"><a href="#t523">523</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t524" class="pln"><span class="n"><a href="#t524">524</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t525" class="run"><span class="n"><a href="#t525">525</a></span><span class="t"> <span class="key">def</span> <span class="nam">isBad</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">infile</span><span class="op">,</span> <span class="nam">msg</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t526" class="mis show_mis"><span class="n"><a href="#t526">526</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t527" class="mis show_mis"><span class="n"><a href="#t527">527</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^"</span><span class="op">+</span><span class="nam">re</span><span class="op">.</span><span class="nam">escape</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span><span class="op">+</span><span class="str">"$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t528" class="mis show_mis"><span class="n"><a href="#t528">528</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">'infile.txt'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t529" class="pln"><span class="n"><a href="#t529">529</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t530" class="run"><span class="n"><a href="#t530">530</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBeginNoEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t531" class="mis show_mis"><span class="n"><a href="#t531">531</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t532" class="pln"><span class="n"><a href="#t532">532</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> - <p id="t533" class="pln"><span class="n"><a href="#t533">533</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t534" class="pln"><span class="n"><a href="#t534">534</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t535" class="pln"><span class="n"><a href="#t535">535</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t536" class="mis show_mis"><span class="n"><a href="#t536">536</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(2): Cog block begun but never ended."</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t537" class="pln"><span class="n"><a href="#t537">537</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t538" class="run"><span class="n"><a href="#t538">538</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoEoo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t539" class="mis show_mis"><span class="n"><a href="#t539">539</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t540" class="pln"><span class="n"><a href="#t540">540</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> - <p id="t541" class="pln"><span class="n"><a href="#t541">541</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t542" class="pln"><span class="n"><a href="#t542">542</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t543" class="pln"><span class="n"><a href="#t543">543</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t544" class="pln"><span class="n"><a href="#t544">544</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t545" class="mis show_mis"><span class="n"><a href="#t545">545</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(4): Missing '[[[end]]]' before end of file."</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t546" class="pln"><span class="n"><a href="#t546">546</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t547" class="mis show_mis"><span class="n"><a href="#t547">547</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t548" class="pln"><span class="n"><a href="#t548">548</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> - <p id="t549" class="pln"><span class="n"><a href="#t549">549</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t550" class="pln"><span class="n"><a href="#t550">550</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t551" class="pln"><span class="n"><a href="#t551">551</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t552" class="pln"><span class="n"><a href="#t552">552</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t553" class="pln"><span class="n"><a href="#t553">553</a></span><span class="t"><span class="str"> cog.outl('goodbye')</span> </span><span class="r"></span></p> - <p id="t554" class="pln"><span class="n"><a href="#t554">554</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t555" class="pln"><span class="n"><a href="#t555">555</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t556" class="mis show_mis"><span class="n"><a href="#t556">556</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t557" class="pln"><span class="n"><a href="#t557">557</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t558" class="run"><span class="n"><a href="#t558">558</a></span><span class="t"> <span class="key">def</span> <span class="nam">testStartWithEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t559" class="mis show_mis"><span class="n"><a href="#t559">559</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t560" class="pln"><span class="n"><a href="#t560">560</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t561" class="pln"><span class="n"><a href="#t561">561</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t562" class="mis show_mis"><span class="n"><a href="#t562">562</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(1): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t563" class="pln"><span class="n"><a href="#t563">563</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t564" class="mis show_mis"><span class="n"><a href="#t564">564</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t565" class="pln"><span class="n"><a href="#t565">565</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t566" class="pln"><span class="n"><a href="#t566">566</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t567" class="pln"><span class="n"><a href="#t567">567</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t568" class="pln"><span class="n"><a href="#t568">568</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t569" class="pln"><span class="n"><a href="#t569">569</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t570" class="pln"><span class="n"><a href="#t570">570</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t571" class="mis show_mis"><span class="n"><a href="#t571">571</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t572" class="pln"><span class="n"><a href="#t572">572</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t573" class="run"><span class="n"><a href="#t573">573</a></span><span class="t"> <span class="key">def</span> <span class="nam">testStartWithEoo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t574" class="mis show_mis"><span class="n"><a href="#t574">574</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t575" class="pln"><span class="n"><a href="#t575">575</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t576" class="pln"><span class="n"><a href="#t576">576</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t577" class="mis show_mis"><span class="n"><a href="#t577">577</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(1): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t578" class="pln"><span class="n"><a href="#t578">578</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t579" class="mis show_mis"><span class="n"><a href="#t579">579</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t580" class="pln"><span class="n"><a href="#t580">580</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t581" class="pln"><span class="n"><a href="#t581">581</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t582" class="pln"><span class="n"><a href="#t582">582</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t583" class="pln"><span class="n"><a href="#t583">583</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t584" class="pln"><span class="n"><a href="#t584">584</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t585" class="pln"><span class="n"><a href="#t585">585</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t586" class="mis show_mis"><span class="n"><a href="#t586">586</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t587" class="pln"><span class="n"><a href="#t587">587</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t588" class="run"><span class="n"><a href="#t588">588</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t589" class="mis show_mis"><span class="n"><a href="#t589">589</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t590" class="pln"><span class="n"><a href="#t590">590</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t591" class="pln"><span class="n"><a href="#t591">591</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t592" class="pln"><span class="n"><a href="#t592">592</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t593" class="pln"><span class="n"><a href="#t593">593</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t594" class="mis show_mis"><span class="n"><a href="#t594">594</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(3): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t595" class="pln"><span class="n"><a href="#t595">595</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t596" class="mis show_mis"><span class="n"><a href="#t596">596</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t597" class="pln"><span class="n"><a href="#t597">597</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t598" class="pln"><span class="n"><a href="#t598">598</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> - <p id="t599" class="pln"><span class="n"><a href="#t599">599</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t600" class="pln"><span class="n"><a href="#t600">600</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t601" class="pln"><span class="n"><a href="#t601">601</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t602" class="pln"><span class="n"><a href="#t602">602</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t603" class="pln"><span class="n"><a href="#t603">603</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t604" class="pln"><span class="n"><a href="#t604">604</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t605" class="mis show_mis"><span class="n"><a href="#t605">605</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(7): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t606" class="pln"><span class="n"><a href="#t606">606</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t607" class="run"><span class="n"><a href="#t607">607</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoBegins</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t608" class="mis show_mis"><span class="n"><a href="#t608">608</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t609" class="pln"><span class="n"><a href="#t609">609</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t610" class="pln"><span class="n"><a href="#t610">610</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t611" class="pln"><span class="n"><a href="#t611">611</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t612" class="pln"><span class="n"><a href="#t612">612</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t613" class="pln"><span class="n"><a href="#t613">613</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t614" class="pln"><span class="n"><a href="#t614">614</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t615" class="mis show_mis"><span class="n"><a href="#t615">615</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(2): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t616" class="pln"><span class="n"><a href="#t616">616</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t617" class="mis show_mis"><span class="n"><a href="#t617">617</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t618" class="pln"><span class="n"><a href="#t618">618</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t619" class="pln"><span class="n"><a href="#t619">619</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t620" class="pln"><span class="n"><a href="#t620">620</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t621" class="pln"><span class="n"><a href="#t621">621</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t622" class="pln"><span class="n"><a href="#t622">622</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t623" class="pln"><span class="n"><a href="#t623">623</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t624" class="pln"><span class="n"><a href="#t624">624</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t625" class="pln"><span class="n"><a href="#t625">625</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t626" class="pln"><span class="n"><a href="#t626">626</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t627" class="pln"><span class="n"><a href="#t627">627</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t628" class="mis show_mis"><span class="n"><a href="#t628">628</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(6): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t629" class="pln"><span class="n"><a href="#t629">629</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t630" class="run"><span class="n"><a href="#t630">630</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoEnds</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t631" class="mis show_mis"><span class="n"><a href="#t631">631</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t632" class="pln"><span class="n"><a href="#t632">632</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t633" class="pln"><span class="n"><a href="#t633">633</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t634" class="pln"><span class="n"><a href="#t634">634</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t635" class="pln"><span class="n"><a href="#t635">635</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t636" class="pln"><span class="n"><a href="#t636">636</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t637" class="pln"><span class="n"><a href="#t637">637</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t638" class="mis show_mis"><span class="n"><a href="#t638">638</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(4): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t639" class="pln"><span class="n"><a href="#t639">639</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t640" class="mis show_mis"><span class="n"><a href="#t640">640</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t641" class="pln"><span class="n"><a href="#t641">641</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t642" class="pln"><span class="n"><a href="#t642">642</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t643" class="pln"><span class="n"><a href="#t643">643</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t644" class="pln"><span class="n"><a href="#t644">644</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t645" class="pln"><span class="n"><a href="#t645">645</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t646" class="pln"><span class="n"><a href="#t646">646</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> - <p id="t647" class="pln"><span class="n"><a href="#t647">647</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t648" class="pln"><span class="n"><a href="#t648">648</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t649" class="pln"><span class="n"><a href="#t649">649</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t650" class="pln"><span class="n"><a href="#t650">650</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t651" class="mis show_mis"><span class="n"><a href="#t651">651</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(8): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t652" class="pln"><span class="n"><a href="#t652">652</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t653" class="pln"><span class="n"><a href="#t653">653</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t654" class="run"><span class="n"><a href="#t654">654</a></span><span class="t"><span class="key">class</span> <span class="nam">CogErrorTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t655" class="pln"><span class="n"><a href="#t655">655</a></span><span class="t"> <span class="str">""" Test cases for cog.error().</span> </span><span class="r"></span></p> - <p id="t656" class="pln"><span class="n"><a href="#t656">656</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t657" class="pln"><span class="n"><a href="#t657">657</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t658" class="run"><span class="n"><a href="#t658">658</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorMsg</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t659" class="mis show_mis"><span class="n"><a href="#t659">659</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t660" class="pln"><span class="n"><a href="#t660">660</a></span><span class="t"><span class="str"> [[[cog cog.error("This ain't right!")]]]</span> </span><span class="r"></span></p> - <p id="t661" class="pln"><span class="n"><a href="#t661">661</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t662" class="pln"><span class="n"><a href="#t662">662</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t663" class="pln"><span class="n"><a href="#t663">663</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t664" class="mis show_mis"><span class="n"><a href="#t664">664</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t665" class="mis show_mis"><span class="n"><a href="#t665">665</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="str">"^This ain't right!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t666" class="mis show_mis"><span class="n"><a href="#t666">666</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t667" class="pln"><span class="n"><a href="#t667">667</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t668" class="run"><span class="n"><a href="#t668">668</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorNoMsg</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t669" class="mis show_mis"><span class="n"><a href="#t669">669</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t670" class="pln"><span class="n"><a href="#t670">670</a></span><span class="t"><span class="str"> [[[cog cog.error()]]]</span> </span><span class="r"></span></p> - <p id="t671" class="pln"><span class="n"><a href="#t671">671</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t672" class="pln"><span class="n"><a href="#t672">672</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t673" class="pln"><span class="n"><a href="#t673">673</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t674" class="mis show_mis"><span class="n"><a href="#t674">674</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t675" class="mis show_mis"><span class="n"><a href="#t675">675</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="str">"^Error raised by cog generator.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t676" class="mis show_mis"><span class="n"><a href="#t676">676</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t677" class="pln"><span class="n"><a href="#t677">677</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t678" class="run"><span class="n"><a href="#t678">678</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoErrorIfErrorNotCalled</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t679" class="mis show_mis"><span class="n"><a href="#t679">679</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t680" class="pln"><span class="n"><a href="#t680">680</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> - <p id="t681" class="pln"><span class="n"><a href="#t681">681</a></span><span class="t"><span class="str"> --import cog</span> </span><span class="r"></span></p> - <p id="t682" class="pln"><span class="n"><a href="#t682">682</a></span><span class="t"><span class="str"> --for i in range(3):</span> </span><span class="r"></span></p> - <p id="t683" class="pln"><span class="n"><a href="#t683">683</a></span><span class="t"><span class="str"> -- if i > 10:</span> </span><span class="r"></span></p> - <p id="t684" class="pln"><span class="n"><a href="#t684">684</a></span><span class="t"><span class="str"> -- cog.error("Something is amiss!")</span> </span><span class="r"></span></p> - <p id="t685" class="pln"><span class="n"><a href="#t685">685</a></span><span class="t"><span class="str"> -- cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> - <p id="t686" class="pln"><span class="n"><a href="#t686">686</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> - <p id="t687" class="pln"><span class="n"><a href="#t687">687</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> - <p id="t688" class="pln"><span class="n"><a href="#t688">688</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> - <p id="t689" class="pln"><span class="n"><a href="#t689">689</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> - <p id="t690" class="pln"><span class="n"><a href="#t690">690</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t691" class="pln"><span class="n"><a href="#t691">691</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t692" class="pln"><span class="n"><a href="#t692">692</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t693" class="mis show_mis"><span class="n"><a href="#t693">693</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t694" class="mis show_mis"><span class="n"><a href="#t694">694</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t695" class="pln"><span class="n"><a href="#t695">695</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t696" class="pln"><span class="n"><a href="#t696">696</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t697" class="run"><span class="n"><a href="#t697">697</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGeneratorGetCodeTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t698" class="pln"><span class="n"><a href="#t698">698</a></span><span class="t"> <span class="str">""" Unit tests against CogGenerator to see if its getCode() method works</span> </span><span class="r"></span></p> - <p id="t699" class="pln"><span class="n"><a href="#t699">699</a></span><span class="t"><span class="str"> properly.</span> </span><span class="r"></span></p> - <p id="t700" class="pln"><span class="n"><a href="#t700">700</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t701" class="pln"><span class="n"><a href="#t701">701</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t702" class="run"><span class="n"><a href="#t702">702</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t703" class="pln"><span class="n"><a href="#t703">703</a></span><span class="t"> <span class="str">""" All tests get a generator to use, and short same-length names for</span> </span><span class="r"></span></p> - <p id="t704" class="pln"><span class="n"><a href="#t704">704</a></span><span class="t"><span class="str"> the functions we're going to use.</span> </span><span class="r"></span></p> - <p id="t705" class="pln"><span class="n"><a href="#t705">705</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t706" class="mis show_mis"><span class="n"><a href="#t706">706</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span> <span class="op">=</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t707" class="mis show_mis"><span class="n"><a href="#t707">707</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span> </span><span class="r"></span></p> - <p id="t708" class="mis show_mis"><span class="n"><a href="#t708">708</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span> </span><span class="r"></span></p> - <p id="t709" class="pln"><span class="n"><a href="#t709">709</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t710" class="run"><span class="n"><a href="#t710">710</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmpty</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t711" class="mis show_mis"><span class="n"><a href="#t711">711</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t712" class="mis show_mis"><span class="n"><a href="#t712">712</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t713" class="mis show_mis"><span class="n"><a href="#t713">713</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t714" class="pln"><span class="n"><a href="#t714">714</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t715" class="run"><span class="n"><a href="#t715">715</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t716" class="mis show_mis"><span class="n"><a href="#t716">716</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t717" class="mis show_mis"><span class="n"><a href="#t717">717</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">' print "hello"'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t718" class="mis show_mis"><span class="n"><a href="#t718">718</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">' print "bye"'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t719" class="mis show_mis"><span class="n"><a href="#t719">719</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t720" class="mis show_mis"><span class="n"><a href="#t720">720</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'print "hello"\nprint "bye"'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t721" class="pln"><span class="n"><a href="#t721">721</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t722" class="run"><span class="n"><a href="#t722">722</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed1</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t723" class="pln"><span class="n"><a href="#t723">723</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> - <p id="t724" class="mis show_mis"><span class="n"><a href="#t724">724</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t725" class="mis show_mis"><span class="n"><a href="#t725">725</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'// hello'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t726" class="mis show_mis"><span class="n"><a href="#t726">726</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'// bye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t727" class="mis show_mis"><span class="n"><a href="#t727">727</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t728" class="mis show_mis"><span class="n"><a href="#t728">728</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t729" class="pln"><span class="n"><a href="#t729">729</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t730" class="run"><span class="n"><a href="#t730">730</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t731" class="pln"><span class="n"><a href="#t731">731</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> - <p id="t732" class="mis show_mis"><span class="n"><a href="#t732">732</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t733" class="mis show_mis"><span class="n"><a href="#t733">733</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'hello'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t734" class="mis show_mis"><span class="n"><a href="#t734">734</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t735" class="mis show_mis"><span class="n"><a href="#t735">735</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t736" class="mis show_mis"><span class="n"><a href="#t736">736</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t737" class="pln"><span class="n"><a href="#t737">737</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t738" class="run"><span class="n"><a href="#t738">738</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed3</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t739" class="pln"><span class="n"><a href="#t739">739</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> - <p id="t740" class="mis show_mis"><span class="n"><a href="#t740">740</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t741" class="mis show_mis"><span class="n"><a href="#t741">741</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'print """hello'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t742" class="mis show_mis"><span class="n"><a href="#t742">742</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t743" class="mis show_mis"><span class="n"><a href="#t743">743</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t744" class="mis show_mis"><span class="n"><a href="#t744">744</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'print """hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t745" class="pln"><span class="n"><a href="#t745">745</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t746" class="run"><span class="n"><a href="#t746">746</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed4</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t747" class="pln"><span class="n"><a href="#t747">747</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> - <p id="t748" class="mis show_mis"><span class="n"><a href="#t748">748</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t749" class="mis show_mis"><span class="n"><a href="#t749">749</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'hello'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t750" class="mis show_mis"><span class="n"><a href="#t750">750</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye""")'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t751" class="mis show_mis"><span class="n"><a href="#t751">751</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t752" class="mis show_mis"><span class="n"><a href="#t752">752</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye""")'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t753" class="pln"><span class="n"><a href="#t753">753</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t754" class="run"><span class="n"><a href="#t754">754</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCommonPrefixForMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t755" class="pln"><span class="n"><a href="#t755">755</a></span><span class="t"> <span class="com"># It's important to be able to use #if 0 to hide lines from a</span> </span><span class="r"></span></p> - <p id="t756" class="pln"><span class="n"><a href="#t756">756</a></span><span class="t"> <span class="com"># C++ compiler.</span> </span><span class="r"></span></p> - <p id="t757" class="mis show_mis"><span class="n"><a href="#t757">757</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'#if 0 //[[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t758" class="mis show_mis"><span class="n"><a href="#t758">758</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'\timport cog, sys'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t759" class="mis show_mis"><span class="n"><a href="#t759">759</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t760" class="mis show_mis"><span class="n"><a href="#t760">760</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'\tprint sys.argv'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t761" class="mis show_mis"><span class="n"><a href="#t761">761</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'#endif //]]]'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t762" class="mis show_mis"><span class="n"><a href="#t762">762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'import cog, sys\n\nprint sys.argv'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t763" class="pln"><span class="n"><a href="#t763">763</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t764" class="pln"><span class="n"><a href="#t764">764</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t765" class="run"><span class="n"><a href="#t765">765</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCaseWithTempDir</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t766" class="pln"><span class="n"><a href="#t766">766</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t767" class="run"><span class="n"><a href="#t767">767</a></span><span class="t"> <span class="key">def</span> <span class="nam">newCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t768" class="pln"><span class="n"><a href="#t768">768</a></span><span class="t"> <span class="str">""" Initialize the cog members for another run.</span> </span><span class="r"></span></p> - <p id="t769" class="pln"><span class="n"><a href="#t769">769</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t770" class="pln"><span class="n"><a href="#t770">770</a></span><span class="t"> <span class="com"># Create a cog engine, and catch its output.</span> </span><span class="r"></span></p> - <p id="t771" class="mis show_mis"><span class="n"><a href="#t771">771</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span> <span class="op">=</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t772" class="mis show_mis"><span class="n"><a href="#t772">772</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t773" class="mis show_mis"><span class="n"><a href="#t773">773</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stdout</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">,</span> <span class="nam">stderr</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t774" class="pln"><span class="n"><a href="#t774">774</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t775" class="run"><span class="n"><a href="#t775">775</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t776" class="pln"><span class="n"><a href="#t776">776</a></span><span class="t"> <span class="com"># Create a temporary directory.</span> </span><span class="r"></span></p> - <p id="t777" class="mis show_mis"><span class="n"><a href="#t777">777</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">tempfile</span><span class="op">.</span><span class="nam">gettempdir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'testcog_tempdir_'</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">random</span><span class="op">.</span><span class="nam">random</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">[</span><span class="num">2</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t778" class="mis show_mis"><span class="n"><a href="#t778">778</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t779" class="mis show_mis"><span class="n"><a href="#t779">779</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">olddir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">getcwd</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t780" class="mis show_mis"><span class="n"><a href="#t780">780</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t781" class="mis show_mis"><span class="n"><a href="#t781">781</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t782" class="pln"><span class="n"><a href="#t782">782</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t783" class="run"><span class="n"><a href="#t783">783</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t784" class="mis show_mis"><span class="n"><a href="#t784">784</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">olddir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t785" class="pln"><span class="n"><a href="#t785">785</a></span><span class="t"> <span class="com"># Get rid of the temporary directory.</span> </span><span class="r"></span></p> - <p id="t786" class="mis show_mis"><span class="n"><a href="#t786">786</a></span><span class="t"> <span class="nam">shutil</span><span class="op">.</span><span class="nam">rmtree</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t787" class="pln"><span class="n"><a href="#t787">787</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t788" class="run"><span class="n"><a href="#t788">788</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertFilesSame</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFName1</span><span class="op">,</span> <span class="nam">sFName2</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t789" class="mis show_mis"><span class="n"><a href="#t789">789</a></span><span class="t"> <span class="nam">text1</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName1</span><span class="op">)</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t790" class="mis show_mis"><span class="n"><a href="#t790">790</a></span><span class="t"> <span class="nam">text2</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName2</span><span class="op">)</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t791" class="mis show_mis"><span class="n"><a href="#t791">791</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">text1</span><span class="op">,</span> <span class="nam">text2</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t792" class="pln"><span class="n"><a href="#t792">792</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t793" class="run"><span class="n"><a href="#t793">793</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertFileContent</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFName</span><span class="op">,</span> <span class="nam">sContent</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t794" class="mis show_mis"><span class="n"><a href="#t794">794</a></span><span class="t"> <span class="nam">sAbsName</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t795" class="mis show_mis"><span class="n"><a href="#t795">795</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">sAbsName</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t796" class="mis show_mis"><span class="n"><a href="#t796">796</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t797" class="mis show_mis"><span class="n"><a href="#t797">797</a></span><span class="t"> <span class="nam">sFileContent</span> <span class="op">=</span> <span class="nam">f</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t798" class="pln"><span class="n"><a href="#t798">798</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t799" class="mis show_mis"><span class="n"><a href="#t799">799</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t800" class="mis show_mis"><span class="n"><a href="#t800">800</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">sFileContent</span><span class="op">,</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">sContent</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t801" class="pln"><span class="n"><a href="#t801">801</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t802" class="pln"><span class="n"><a href="#t802">802</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t803" class="run"><span class="n"><a href="#t803">803</a></span><span class="t"><span class="key">class</span> <span class="nam">ArgumentHandlingTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t804" class="pln"><span class="n"><a href="#t804">804</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t805" class="run"><span class="n"><a href="#t805">805</a></span><span class="t"> <span class="key">def</span> <span class="nam">testArgumentFailure</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t806" class="pln"><span class="n"><a href="#t806">806</a></span><span class="t"> <span class="com"># Return value 2 means usage problem.</span> </span><span class="r"></span></p> - <p id="t807" class="mis show_mis"><span class="n"><a href="#t807">807</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-j'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="num">2</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t808" class="mis show_mis"><span class="n"><a href="#t808">808</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t809" class="mis show_mis"><span class="n"><a href="#t809">809</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"option -j not recognized"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t810" class="mis show_mis"><span class="n"><a href="#t810">810</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^No files to process$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t811" class="mis show_mis"><span class="n"><a href="#t811">811</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t812" class="mis show_mis"><span class="n"><a href="#t812">812</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^option -j not recognized$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t813" class="mis show_mis"><span class="n"><a href="#t813">813</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-j'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t814" class="pln"><span class="n"><a href="#t814">814</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t815" class="run"><span class="n"><a href="#t815">815</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoDashOAndAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t816" class="mis show_mis"><span class="n"><a href="#t816">816</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t817" class="pln"><span class="n"><a href="#t817">817</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t818" class="pln"><span class="n"><a href="#t818">818</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t819" class="pln"><span class="n"><a href="#t819">819</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t820" class="pln"><span class="n"><a href="#t820">820</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t821" class="pln"><span class="n"><a href="#t821">821</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t822" class="mis show_mis"><span class="n"><a href="#t822">822</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t823" class="mis show_mis"><span class="n"><a href="#t823">823</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -o with @file$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t824" class="mis show_mis"><span class="n"><a href="#t824">824</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'foo'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t825" class="pln"><span class="n"><a href="#t825">825</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t826" class="run"><span class="n"><a href="#t826">826</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashV</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t827" class="mis show_mis"><span class="n"><a href="#t827">827</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-v'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t828" class="mis show_mis"><span class="n"><a href="#t828">828</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t829" class="mis show_mis"><span class="n"><a href="#t829">829</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'Cog version %s\n'</span> <span class="op">%</span> <span class="nam">__version__</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t830" class="pln"><span class="n"><a href="#t830">830</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t831" class="run"><span class="n"><a href="#t831">831</a></span><span class="t"> <span class="key">def</span> <span class="nam">producesHelp</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t832" class="mis show_mis"><span class="n"><a href="#t832">832</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t833" class="mis show_mis"><span class="n"><a href="#t833">833</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">'argv0'</span><span class="op">]</span> <span class="op">+</span> <span class="nam">args</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t834" class="mis show_mis"><span class="n"><a href="#t834">834</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t835" class="mis show_mis"><span class="n"><a href="#t835">835</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">usage</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t836" class="pln"><span class="n"><a href="#t836">836</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t837" class="run"><span class="n"><a href="#t837">837</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashH</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t838" class="pln"><span class="n"><a href="#t838">838</a></span><span class="t"> <span class="com"># -h or -? anywhere on the command line should just print help.</span> </span><span class="r"></span></p> - <p id="t839" class="mis show_mis"><span class="n"><a href="#t839">839</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-h"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t840" class="mis show_mis"><span class="n"><a href="#t840">840</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-?"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t841" class="mis show_mis"><span class="n"><a href="#t841">841</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"fooey.txt -h"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t842" class="mis show_mis"><span class="n"><a href="#t842">842</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-o -r @fooey.txt -? @booey.txt"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t843" class="pln"><span class="n"><a href="#t843">843</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t844" class="run"><span class="n"><a href="#t844">844</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashOAndDashR</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t845" class="mis show_mis"><span class="n"><a href="#t845">845</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t846" class="pln"><span class="n"><a href="#t846">846</a></span><span class="t"> <span class="str">'cogfile.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t847" class="pln"><span class="n"><a href="#t847">847</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t848" class="pln"><span class="n"><a href="#t848">848</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t849" class="pln"><span class="n"><a href="#t849">849</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t850" class="pln"><span class="n"><a href="#t850">850</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t851" class="mis show_mis"><span class="n"><a href="#t851">851</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t852" class="mis show_mis"><span class="n"><a href="#t852">852</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -o with -r \(they are opposites\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t853" class="mis show_mis"><span class="n"><a href="#t853">853</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'foo'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cogfile.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t854" class="pln"><span class="n"><a href="#t854">854</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t855" class="run"><span class="n"><a href="#t855">855</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashZ</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t856" class="mis show_mis"><span class="n"><a href="#t856">856</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t857" class="pln"><span class="n"><a href="#t857">857</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t858" class="pln"><span class="n"><a href="#t858">858</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t859" class="pln"><span class="n"><a href="#t859">859</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t860" class="pln"><span class="n"><a href="#t860">860</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t861" class="pln"><span class="n"><a href="#t861">861</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t862" class="pln"><span class="n"><a href="#t862">862</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t863" class="pln"><span class="n"><a href="#t863">863</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t864" class="pln"><span class="n"><a href="#t864">864</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t865" class="pln"><span class="n"><a href="#t865">865</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t866" class="pln"><span class="n"><a href="#t866">866</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t867" class="pln"><span class="n"><a href="#t867">867</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t868" class="pln"><span class="n"><a href="#t868">868</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t869" class="pln"><span class="n"><a href="#t869">869</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t870" class="pln"><span class="n"><a href="#t870">870</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t871" class="pln"><span class="n"><a href="#t871">871</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t872" class="pln"><span class="n"><a href="#t872">872</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t873" class="pln"><span class="n"><a href="#t873">873</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t874" class="pln"><span class="n"><a href="#t874">874</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t875" class="pln"><span class="n"><a href="#t875">875</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t876" class="pln"><span class="n"><a href="#t876">876</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t877" class="pln"><span class="n"><a href="#t877">877</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t878" class="pln"><span class="n"><a href="#t878">878</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t879" class="mis show_mis"><span class="n"><a href="#t879">879</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t880" class="mis show_mis"><span class="n"><a href="#t880">880</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^test.cog\(6\): Missing '\[\[\[end\]\]\]' before end of file.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t881" class="mis show_mis"><span class="n"><a href="#t881">881</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t882" class="mis show_mis"><span class="n"><a href="#t882">882</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t883" class="mis show_mis"><span class="n"><a href="#t883">883</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t884" class="mis show_mis"><span class="n"><a href="#t884">884</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t885" class="pln"><span class="n"><a href="#t885">885</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t886" class="run"><span class="n"><a href="#t886">886</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBadDashD</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t887" class="mis show_mis"><span class="n"><a href="#t887">887</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^-D takes a name=value argument$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t888" class="mis show_mis"><span class="n"><a href="#t888">888</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-Dfooey'</span><span class="op">,</span> <span class="str">'cog.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t889" class="mis show_mis"><span class="n"><a href="#t889">889</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^-D takes a name=value argument$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t890" class="mis show_mis"><span class="n"><a href="#t890">890</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'cog.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t891" class="pln"><span class="n"><a href="#t891">891</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t892" class="run"><span class="n"><a href="#t892">892</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBadMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t893" class="mis show_mis"><span class="n"><a href="#t893">893</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^--markers requires 3 values separated by spaces, could not parse 'X'$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t894" class="mis show_mis"><span class="n"><a href="#t894">894</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'--markers=X'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t895" class="mis show_mis"><span class="n"><a href="#t895">895</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^--markers requires 3 values separated by spaces, could not parse 'A B C D'$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t896" class="mis show_mis"><span class="n"><a href="#t896">896</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'--markers=A B C D'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t897" class="pln"><span class="n"><a href="#t897">897</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t898" class="pln"><span class="n"><a href="#t898">898</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t899" class="run"><span class="n"><a href="#t899">899</a></span><span class="t"><span class="key">class</span> <span class="nam">TestMain</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t900" class="run"><span class="n"><a href="#t900">900</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t901" class="mis show_mis"><span class="n"><a href="#t901">901</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestMain</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t902" class="mis show_mis"><span class="n"><a href="#t902">902</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">old_argv</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t903" class="mis show_mis"><span class="n"><a href="#t903">903</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">old_stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> </span><span class="r"></span></p> - <p id="t904" class="mis show_mis"><span class="n"><a href="#t904">904</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t905" class="pln"><span class="n"><a href="#t905">905</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t906" class="run"><span class="n"><a href="#t906">906</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t907" class="mis show_mis"><span class="n"><a href="#t907">907</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">old_stderr</span> </span><span class="r"></span></p> - <p id="t908" class="mis show_mis"><span class="n"><a href="#t908">908</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">old_argv</span> </span><span class="r"></span></p> - <p id="t909" class="mis show_mis"><span class="n"><a href="#t909">909</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">.</span><span class="nam">pop</span><span class="op">(</span><span class="str">'mycode'</span><span class="op">,</span> <span class="key">None</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t910" class="mis show_mis"><span class="n"><a href="#t910">910</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestMain</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t911" class="pln"><span class="n"><a href="#t911">911</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t912" class="run"><span class="n"><a href="#t912">912</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_main_function</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t913" class="mis show_mis"><span class="n"><a href="#t913">913</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">,</span> <span class="str">"-Z"</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t914" class="mis show_mis"><span class="n"><a href="#t914">914</a></span><span class="t"> <span class="nam">ret</span> <span class="op">=</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t915" class="mis show_mis"><span class="n"><a href="#t915">915</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">ret</span><span class="op">,</span> <span class="num">2</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t916" class="mis show_mis"><span class="n"><a href="#t916">916</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t917" class="mis show_mis"><span class="n"><a href="#t917">917</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">stderr</span><span class="op">,</span> <span class="str">'option -Z not recognized\n(for help use -?)\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t918" class="pln"><span class="n"><a href="#t918">918</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t919" class="run"><span class="n"><a href="#t919">919</a></span><span class="t"> <span class="nam">files</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t920" class="pln"><span class="n"><a href="#t920">920</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t921" class="pln"><span class="n"><a href="#t921">921</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t922" class="pln"><span class="n"><a href="#t922">922</a></span><span class="t"><span class="str"> def func():</span> </span><span class="r"></span></p> - <p id="t923" class="pln"><span class="n"><a href="#t923">923</a></span><span class="t"><span class="str"> import mycode</span> </span><span class="r"></span></p> - <p id="t924" class="pln"><span class="n"><a href="#t924">924</a></span><span class="t"><span class="str"> mycode.boom()</span> </span><span class="r"></span></p> - <p id="t925" class="pln"><span class="n"><a href="#t925">925</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t926" class="pln"><span class="n"><a href="#t926">926</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t927" class="pln"><span class="n"><a href="#t927">927</a></span><span class="t"><span class="str"> -----</span> </span><span class="r"></span></p> - <p id="t928" class="pln"><span class="n"><a href="#t928">928</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t929" class="pln"><span class="n"><a href="#t929">929</a></span><span class="t"><span class="str"> func()</span> </span><span class="r"></span></p> - <p id="t930" class="pln"><span class="n"><a href="#t930">930</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t931" class="pln"><span class="n"><a href="#t931">931</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t932" class="pln"><span class="n"><a href="#t932">932</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t933" class="pln"><span class="n"><a href="#t933">933</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t934" class="pln"><span class="n"><a href="#t934">934</a></span><span class="t"> <span class="str">'mycode.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t935" class="pln"><span class="n"><a href="#t935">935</a></span><span class="t"><span class="str"> def boom():</span> </span><span class="r"></span></p> - <p id="t936" class="pln"><span class="n"><a href="#t936">936</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> - <p id="t937" class="pln"><span class="n"><a href="#t937">937</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t938" class="pln"><span class="n"><a href="#t938">938</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t939" class="pln"><span class="n"><a href="#t939">939</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t940" class="run"><span class="n"><a href="#t940">940</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_report</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t941" class="mis show_mis"><span class="n"><a href="#t941">941</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">check_error_report</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t942" class="pln"><span class="n"><a href="#t942">942</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t943" class="run"><span class="n"><a href="#t943">943</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_report_with_prologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t944" class="mis show_mis"><span class="n"><a href="#t944">944</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">check_error_report</span><span class="op">(</span><span class="str">"-p"</span><span class="op">,</span> <span class="str">"#1\n#2"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t945" class="pln"><span class="n"><a href="#t945">945</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t946" class="run"><span class="n"><a href="#t946">946</a></span><span class="t"> <span class="key">def</span> <span class="nam">check_error_report</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="op">*</span><span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t947" class="pln"><span class="n"><a href="#t947">947</a></span><span class="t"> <span class="str">"""Check that the error report is right."""</span> </span><span class="r"></span></p> - <p id="t948" class="mis show_mis"><span class="n"><a href="#t948">948</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">files</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t949" class="mis show_mis"><span class="n"><a href="#t949">949</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">]</span> <span class="op">+</span> <span class="nam">list</span><span class="op">(</span><span class="nam">args</span><span class="op">)</span> <span class="op">+</span> <span class="op">[</span><span class="str">"-r"</span><span class="op">,</span> <span class="str">"test.cog"</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t950" class="mis show_mis"><span class="n"><a href="#t950">950</a></span><span class="t"> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t951" class="mis show_mis"><span class="n"><a href="#t951">951</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t952" class="pln"><span class="n"><a href="#t952">952</a></span><span class="t"><span class="str"> Traceback (most recent call last):</span> </span><span class="r"></span></p> - <p id="t953" class="pln"><span class="n"><a href="#t953">953</a></span><span class="t"><span class="str"> File "test.cog", line 9, in <module></span> </span><span class="r"></span></p> - <p id="t954" class="pln"><span class="n"><a href="#t954">954</a></span><span class="t"><span class="str"> func()</span> </span><span class="r"></span></p> - <p id="t955" class="pln"><span class="n"><a href="#t955">955</a></span><span class="t"><span class="str"> File "test.cog", line 4, in func</span> </span><span class="r"></span></p> - <p id="t956" class="pln"><span class="n"><a href="#t956">956</a></span><span class="t"><span class="str"> mycode.boom()</span> </span><span class="r"></span></p> - <p id="t957" class="pln"><span class="n"><a href="#t957">957</a></span><span class="t"><span class="str"> File "MYCODE", line 2, in boom</span> </span><span class="r"></span></p> - <p id="t958" class="pln"><span class="n"><a href="#t958">958</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> - <p id="t959" class="pln"><span class="n"><a href="#t959">959</a></span><span class="t"><span class="str"> IndexError: list index out of range</span> </span><span class="r"></span></p> - <p id="t960" class="pln"><span class="n"><a href="#t960">960</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t961" class="mis show_mis"><span class="n"><a href="#t961">961</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t962" class="mis show_mis"><span class="n"><a href="#t962">962</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="str">"mycode.py"</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t963" class="pln"><span class="n"><a href="#t963">963</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t964" class="mis show_mis"><span class="n"><a href="#t964">964</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="str">"mycode.py"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t965" class="mis show_mis"><span class="n"><a href="#t965">965</a></span><span class="t"> <span class="key">assert</span> <span class="nam">expected</span> <span class="op">==</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t966" class="pln"><span class="n"><a href="#t966">966</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t967" class="run"><span class="n"><a href="#t967">967</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_in_prologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t968" class="mis show_mis"><span class="n"><a href="#t968">968</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">files</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t969" class="mis show_mis"><span class="n"><a href="#t969">969</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">,</span> <span class="str">"-p"</span><span class="op">,</span> <span class="str">"import mycode; mycode.boom()"</span><span class="op">,</span> <span class="str">"-r"</span><span class="op">,</span> <span class="str">"test.cog"</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t970" class="mis show_mis"><span class="n"><a href="#t970">970</a></span><span class="t"> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t971" class="mis show_mis"><span class="n"><a href="#t971">971</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t972" class="pln"><span class="n"><a href="#t972">972</a></span><span class="t"><span class="str"> Traceback (most recent call last):</span> </span><span class="r"></span></p> - <p id="t973" class="pln"><span class="n"><a href="#t973">973</a></span><span class="t"><span class="str"> File "<prologue>", line 1, in <module></span> </span><span class="r"></span></p> - <p id="t974" class="pln"><span class="n"><a href="#t974">974</a></span><span class="t"><span class="str"> import mycode; mycode.boom()</span> </span><span class="r"></span></p> - <p id="t975" class="pln"><span class="n"><a href="#t975">975</a></span><span class="t"><span class="str"> File "MYCODE", line 2, in boom</span> </span><span class="r"></span></p> - <p id="t976" class="pln"><span class="n"><a href="#t976">976</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> - <p id="t977" class="pln"><span class="n"><a href="#t977">977</a></span><span class="t"><span class="str"> IndexError: list index out of range</span> </span><span class="r"></span></p> - <p id="t978" class="pln"><span class="n"><a href="#t978">978</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t979" class="mis show_mis"><span class="n"><a href="#t979">979</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t980" class="mis show_mis"><span class="n"><a href="#t980">980</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="str">"mycode.py"</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t981" class="pln"><span class="n"><a href="#t981">981</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t982" class="mis show_mis"><span class="n"><a href="#t982">982</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="str">"mycode.py"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t983" class="mis show_mis"><span class="n"><a href="#t983">983</a></span><span class="t"> <span class="key">assert</span> <span class="nam">expected</span> <span class="op">==</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t984" class="pln"><span class="n"><a href="#t984">984</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t985" class="pln"><span class="n"><a href="#t985">985</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t986" class="pln"><span class="n"><a href="#t986">986</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t987" class="run"><span class="n"><a href="#t987">987</a></span><span class="t"><span class="key">class</span> <span class="nam">TestFileHandling</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t988" class="pln"><span class="n"><a href="#t988">988</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t989" class="run"><span class="n"><a href="#t989">989</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t990" class="mis show_mis"><span class="n"><a href="#t990">990</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t991" class="pln"><span class="n"><a href="#t991">991</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t992" class="pln"><span class="n"><a href="#t992">992</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t993" class="pln"><span class="n"><a href="#t993">993</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t994" class="pln"><span class="n"><a href="#t994">994</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t995" class="pln"><span class="n"><a href="#t995">995</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t996" class="pln"><span class="n"><a href="#t996">996</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t997" class="pln"><span class="n"><a href="#t997">997</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t998" class="pln"><span class="n"><a href="#t998">998</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t999" class="pln"><span class="n"><a href="#t999">999</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1000" class="pln"><span class="n"><a href="#t1000">1000</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1001" class="pln"><span class="n"><a href="#t1001">1001</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1002" class="pln"><span class="n"><a href="#t1002">1002</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1003" class="pln"><span class="n"><a href="#t1003">1003</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1004" class="pln"><span class="n"><a href="#t1004">1004</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1005" class="pln"><span class="n"><a href="#t1005">1005</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1006" class="pln"><span class="n"><a href="#t1006">1006</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1007" class="pln"><span class="n"><a href="#t1007">1007</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1008" class="pln"><span class="n"><a href="#t1008">1008</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t1009" class="pln"><span class="n"><a href="#t1009">1009</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t1010" class="pln"><span class="n"><a href="#t1010">1010</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t1011" class="pln"><span class="n"><a href="#t1011">1011</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1012" class="pln"><span class="n"><a href="#t1012">1012</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1013" class="pln"><span class="n"><a href="#t1013">1013</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1014" class="pln"><span class="n"><a href="#t1014">1014</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1015" class="mis show_mis"><span class="n"><a href="#t1015">1015</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1016" class="mis show_mis"><span class="n"><a href="#t1016">1016</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1017" class="mis show_mis"><span class="n"><a href="#t1017">1017</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1018" class="mis show_mis"><span class="n"><a href="#t1018">1018</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1019" class="mis show_mis"><span class="n"><a href="#t1019">1019</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1020" class="pln"><span class="n"><a href="#t1020">1020</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1021" class="run"><span class="n"><a href="#t1021">1021</a></span><span class="t"> <span class="key">def</span> <span class="nam">testWildcards</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1022" class="mis show_mis"><span class="n"><a href="#t1022">1022</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1023" class="pln"><span class="n"><a href="#t1023">1023</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1024" class="pln"><span class="n"><a href="#t1024">1024</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1025" class="pln"><span class="n"><a href="#t1025">1025</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1026" class="pln"><span class="n"><a href="#t1026">1026</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1027" class="pln"><span class="n"><a href="#t1027">1027</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1028" class="pln"><span class="n"><a href="#t1028">1028</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1029" class="pln"><span class="n"><a href="#t1029">1029</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1030" class="pln"><span class="n"><a href="#t1030">1030</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1031" class="pln"><span class="n"><a href="#t1031">1031</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1032" class="pln"><span class="n"><a href="#t1032">1032</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1033" class="pln"><span class="n"><a href="#t1033">1033</a></span><span class="t"> <span class="str">'test2.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1034" class="pln"><span class="n"><a href="#t1034">1034</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1035" class="pln"><span class="n"><a href="#t1035">1035</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1036" class="pln"><span class="n"><a href="#t1036">1036</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1037" class="pln"><span class="n"><a href="#t1037">1037</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1038" class="pln"><span class="n"><a href="#t1038">1038</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1039" class="pln"><span class="n"><a href="#t1039">1039</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1040" class="pln"><span class="n"><a href="#t1040">1040</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1041" class="pln"><span class="n"><a href="#t1041">1041</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1042" class="pln"><span class="n"><a href="#t1042">1042</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1043" class="pln"><span class="n"><a href="#t1043">1043</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1044" class="pln"><span class="n"><a href="#t1044">1044</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1045" class="pln"><span class="n"><a href="#t1045">1045</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1046" class="pln"><span class="n"><a href="#t1046">1046</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1047" class="pln"><span class="n"><a href="#t1047">1047</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1048" class="pln"><span class="n"><a href="#t1048">1048</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1049" class="pln"><span class="n"><a href="#t1049">1049</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1050" class="pln"><span class="n"><a href="#t1050">1050</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t1051" class="pln"><span class="n"><a href="#t1051">1051</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t1052" class="pln"><span class="n"><a href="#t1052">1052</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t1053" class="pln"><span class="n"><a href="#t1053">1053</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1054" class="pln"><span class="n"><a href="#t1054">1054</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1055" class="pln"><span class="n"><a href="#t1055">1055</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1056" class="pln"><span class="n"><a href="#t1056">1056</a></span><span class="t"> <span class="str">'not_this_one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1057" class="pln"><span class="n"><a href="#t1057">1057</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1058" class="pln"><span class="n"><a href="#t1058">1058</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1059" class="pln"><span class="n"><a href="#t1059">1059</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1060" class="pln"><span class="n"><a href="#t1060">1060</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1061" class="pln"><span class="n"><a href="#t1061">1061</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1062" class="pln"><span class="n"><a href="#t1062">1062</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1063" class="pln"><span class="n"><a href="#t1063">1063</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1064" class="pln"><span class="n"><a href="#t1064">1064</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1065" class="pln"><span class="n"><a href="#t1065">1065</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1066" class="pln"><span class="n"><a href="#t1066">1066</a></span><span class="t"> <span class="str">'not_this_one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1067" class="pln"><span class="n"><a href="#t1067">1067</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1068" class="pln"><span class="n"><a href="#t1068">1068</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1069" class="pln"><span class="n"><a href="#t1069">1069</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1070" class="pln"><span class="n"><a href="#t1070">1070</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1071" class="pln"><span class="n"><a href="#t1071">1071</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1072" class="pln"><span class="n"><a href="#t1072">1072</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1073" class="pln"><span class="n"><a href="#t1073">1073</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1074" class="pln"><span class="n"><a href="#t1074">1074</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1075" class="pln"><span class="n"><a href="#t1075">1075</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1076" class="pln"><span class="n"><a href="#t1076">1076</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1077" class="mis show_mis"><span class="n"><a href="#t1077">1077</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1078" class="mis show_mis"><span class="n"><a href="#t1078">1078</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'t*.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1079" class="mis show_mis"><span class="n"><a href="#t1079">1079</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1080" class="mis show_mis"><span class="n"><a href="#t1080">1080</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test2.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1081" class="mis show_mis"><span class="n"><a href="#t1081">1081</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'not_this_one.cog'</span><span class="op">,</span> <span class="str">'not_this_one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1082" class="mis show_mis"><span class="n"><a href="#t1082">1082</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1083" class="mis show_mis"><span class="n"><a href="#t1083">1083</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1084" class="pln"><span class="n"><a href="#t1084">1084</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1085" class="run"><span class="n"><a href="#t1085">1085</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1086" class="pln"><span class="n"><a href="#t1086">1086</a></span><span class="t"> <span class="com"># -o sets the output file.</span> </span><span class="r"></span></p> - <p id="t1087" class="mis show_mis"><span class="n"><a href="#t1087">1087</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1088" class="pln"><span class="n"><a href="#t1088">1088</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1089" class="pln"><span class="n"><a href="#t1089">1089</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1090" class="pln"><span class="n"><a href="#t1090">1090</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1091" class="pln"><span class="n"><a href="#t1091">1091</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1092" class="pln"><span class="n"><a href="#t1092">1092</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1093" class="pln"><span class="n"><a href="#t1093">1093</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1094" class="pln"><span class="n"><a href="#t1094">1094</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1095" class="pln"><span class="n"><a href="#t1095">1095</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1096" class="pln"><span class="n"><a href="#t1096">1096</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1097" class="pln"><span class="n"><a href="#t1097">1097</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1098" class="pln"><span class="n"><a href="#t1098">1098</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1099" class="pln"><span class="n"><a href="#t1099">1099</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1100" class="pln"><span class="n"><a href="#t1100">1100</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1101" class="pln"><span class="n"><a href="#t1101">1101</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t1102" class="pln"><span class="n"><a href="#t1102">1102</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t1103" class="pln"><span class="n"><a href="#t1103">1103</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t1104" class="pln"><span class="n"><a href="#t1104">1104</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1105" class="pln"><span class="n"><a href="#t1105">1105</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t1106" class="pln"><span class="n"><a href="#t1106">1106</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t1107" class="pln"><span class="n"><a href="#t1107">1107</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t1108" class="pln"><span class="n"><a href="#t1108">1108</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1109" class="pln"><span class="n"><a href="#t1109">1109</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1110" class="pln"><span class="n"><a href="#t1110">1110</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1111" class="pln"><span class="n"><a href="#t1111">1111</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1112" class="mis show_mis"><span class="n"><a href="#t1112">1112</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1113" class="mis show_mis"><span class="n"><a href="#t1113">1113</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'in/a/dir/test.cogged'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1114" class="mis show_mis"><span class="n"><a href="#t1114">1114</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1115" class="pln"><span class="n"><a href="#t1115">1115</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1116" class="run"><span class="n"><a href="#t1116">1116</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1117" class="mis show_mis"><span class="n"><a href="#t1117">1117</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1118" class="pln"><span class="n"><a href="#t1118">1118</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1119" class="pln"><span class="n"><a href="#t1119">1119</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1120" class="pln"><span class="n"><a href="#t1120">1120</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1121" class="pln"><span class="n"><a href="#t1121">1121</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1122" class="pln"><span class="n"><a href="#t1122">1122</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1123" class="pln"><span class="n"><a href="#t1123">1123</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1124" class="pln"><span class="n"><a href="#t1124">1124</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1125" class="pln"><span class="n"><a href="#t1125">1125</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1126" class="pln"><span class="n"><a href="#t1126">1126</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1127" class="pln"><span class="n"><a href="#t1127">1127</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1128" class="pln"><span class="n"><a href="#t1128">1128</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1129" class="pln"><span class="n"><a href="#t1129">1129</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> - <p id="t1130" class="pln"><span class="n"><a href="#t1130">1130</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1131" class="pln"><span class="n"><a href="#t1131">1131</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1132" class="pln"><span class="n"><a href="#t1132">1132</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1133" class="pln"><span class="n"><a href="#t1133">1133</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1134" class="pln"><span class="n"><a href="#t1134">1134</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1135" class="pln"><span class="n"><a href="#t1135">1135</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> - <p id="t1136" class="pln"><span class="n"><a href="#t1136">1136</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1137" class="pln"><span class="n"><a href="#t1137">1137</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1138" class="pln"><span class="n"><a href="#t1138">1138</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1139" class="pln"><span class="n"><a href="#t1139">1139</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1140" class="pln"><span class="n"><a href="#t1140">1140</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1141" class="pln"><span class="n"><a href="#t1141">1141</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1142" class="pln"><span class="n"><a href="#t1142">1142</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> - <p id="t1143" class="pln"><span class="n"><a href="#t1143">1143</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1144" class="pln"><span class="n"><a href="#t1144">1144</a></span><span class="t"><span class="str"> goodbye cruel world</span> </span><span class="r"></span></p> - <p id="t1145" class="pln"><span class="n"><a href="#t1145">1145</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1146" class="pln"><span class="n"><a href="#t1146">1146</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1147" class="pln"><span class="n"><a href="#t1147">1147</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1148" class="pln"><span class="n"><a href="#t1148">1148</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1149" class="pln"><span class="n"><a href="#t1149">1149</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1150" class="pln"><span class="n"><a href="#t1150">1150</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> - <p id="t1151" class="pln"><span class="n"><a href="#t1151">1151</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1152" class="pln"><span class="n"><a href="#t1152">1152</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> - <p id="t1153" class="pln"><span class="n"><a href="#t1153">1153</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1154" class="pln"><span class="n"><a href="#t1154">1154</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1155" class="pln"><span class="n"><a href="#t1155">1155</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1156" class="mis show_mis"><span class="n"><a href="#t1156">1156</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1157" class="mis show_mis"><span class="n"><a href="#t1157">1157</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1158" class="mis show_mis"><span class="n"><a href="#t1158">1158</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1159" class="mis show_mis"><span class="n"><a href="#t1159">1159</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1160" class="mis show_mis"><span class="n"><a href="#t1160">1160</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1161" class="mis show_mis"><span class="n"><a href="#t1161">1161</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1162" class="pln"><span class="n"><a href="#t1162">1162</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1163" class="run"><span class="n"><a href="#t1163">1163</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNestedAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1164" class="mis show_mis"><span class="n"><a href="#t1164">1164</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1165" class="pln"><span class="n"><a href="#t1165">1165</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1166" class="pln"><span class="n"><a href="#t1166">1166</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1167" class="pln"><span class="n"><a href="#t1167">1167</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1168" class="pln"><span class="n"><a href="#t1168">1168</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1169" class="pln"><span class="n"><a href="#t1169">1169</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1170" class="pln"><span class="n"><a href="#t1170">1170</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1171" class="pln"><span class="n"><a href="#t1171">1171</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1172" class="pln"><span class="n"><a href="#t1172">1172</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1173" class="pln"><span class="n"><a href="#t1173">1173</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1174" class="pln"><span class="n"><a href="#t1174">1174</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1175" class="pln"><span class="n"><a href="#t1175">1175</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1176" class="pln"><span class="n"><a href="#t1176">1176</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> - <p id="t1177" class="pln"><span class="n"><a href="#t1177">1177</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1178" class="pln"><span class="n"><a href="#t1178">1178</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1179" class="pln"><span class="n"><a href="#t1179">1179</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1180" class="pln"><span class="n"><a href="#t1180">1180</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1181" class="pln"><span class="n"><a href="#t1181">1181</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1182" class="pln"><span class="n"><a href="#t1182">1182</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> - <p id="t1183" class="pln"><span class="n"><a href="#t1183">1183</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1184" class="pln"><span class="n"><a href="#t1184">1184</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1185" class="pln"><span class="n"><a href="#t1185">1185</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1186" class="pln"><span class="n"><a href="#t1186">1186</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1187" class="pln"><span class="n"><a href="#t1187">1187</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1188" class="pln"><span class="n"><a href="#t1188">1188</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1189" class="pln"><span class="n"><a href="#t1189">1189</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> - <p id="t1190" class="pln"><span class="n"><a href="#t1190">1190</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1191" class="pln"><span class="n"><a href="#t1191">1191</a></span><span class="t"><span class="str"> goodbye cruel world</span> </span><span class="r"></span></p> - <p id="t1192" class="pln"><span class="n"><a href="#t1192">1192</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1193" class="pln"><span class="n"><a href="#t1193">1193</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1194" class="pln"><span class="n"><a href="#t1194">1194</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1195" class="pln"><span class="n"><a href="#t1195">1195</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1196" class="pln"><span class="n"><a href="#t1196">1196</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1197" class="pln"><span class="n"><a href="#t1197">1197</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> - <p id="t1198" class="pln"><span class="n"><a href="#t1198">1198</a></span><span class="t"><span class="str"> @cogfiles2.txt</span> </span><span class="r"></span></p> - <p id="t1199" class="pln"><span class="n"><a href="#t1199">1199</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1200" class="pln"><span class="n"><a href="#t1200">1200</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1201" class="pln"><span class="n"><a href="#t1201">1201</a></span><span class="t"> <span class="str">'cogfiles2.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1202" class="pln"><span class="n"><a href="#t1202">1202</a></span><span class="t"><span class="str"> # This one too, please.</span> </span><span class="r"></span></p> - <p id="t1203" class="pln"><span class="n"><a href="#t1203">1203</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> - <p id="t1204" class="pln"><span class="n"><a href="#t1204">1204</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1205" class="pln"><span class="n"><a href="#t1205">1205</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1206" class="pln"><span class="n"><a href="#t1206">1206</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1207" class="mis show_mis"><span class="n"><a href="#t1207">1207</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1208" class="mis show_mis"><span class="n"><a href="#t1208">1208</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1209" class="mis show_mis"><span class="n"><a href="#t1209">1209</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1210" class="mis show_mis"><span class="n"><a href="#t1210">1210</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1211" class="mis show_mis"><span class="n"><a href="#t1211">1211</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1212" class="mis show_mis"><span class="n"><a href="#t1212">1212</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1213" class="pln"><span class="n"><a href="#t1213">1213</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1214" class="run"><span class="n"><a href="#t1214">1214</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithArgs</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1215" class="mis show_mis"><span class="n"><a href="#t1215">1215</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1216" class="pln"><span class="n"><a href="#t1216">1216</a></span><span class="t"> <span class="str">'both.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1217" class="pln"><span class="n"><a href="#t1217">1217</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1218" class="pln"><span class="n"><a href="#t1218">1218</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> - <p id="t1219" class="pln"><span class="n"><a href="#t1219">1219</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> - <p id="t1220" class="pln"><span class="n"><a href="#t1220">1220</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1221" class="pln"><span class="n"><a href="#t1221">1221</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1222" class="pln"><span class="n"><a href="#t1222">1222</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1223" class="pln"><span class="n"><a href="#t1223">1223</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1224" class="pln"><span class="n"><a href="#t1224">1224</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1225" class="pln"><span class="n"><a href="#t1225">1225</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1226" class="pln"><span class="n"><a href="#t1226">1226</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> - <p id="t1227" class="pln"><span class="n"><a href="#t1227">1227</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> - <p id="t1228" class="pln"><span class="n"><a href="#t1228">1228</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1229" class="pln"><span class="n"><a href="#t1229">1229</a></span><span class="t"><span class="str"> one: True // ONE</span> </span><span class="r"></span></p> - <p id="t1230" class="pln"><span class="n"><a href="#t1230">1230</a></span><span class="t"><span class="str"> two: False // ONE</span> </span><span class="r"></span></p> - <p id="t1231" class="pln"><span class="n"><a href="#t1231">1231</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1232" class="pln"><span class="n"><a href="#t1232">1232</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1233" class="pln"><span class="n"><a href="#t1233">1233</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1234" class="pln"><span class="n"><a href="#t1234">1234</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1235" class="pln"><span class="n"><a href="#t1235">1235</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1236" class="pln"><span class="n"><a href="#t1236">1236</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> - <p id="t1237" class="pln"><span class="n"><a href="#t1237">1237</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> - <p id="t1238" class="pln"><span class="n"><a href="#t1238">1238</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1239" class="pln"><span class="n"><a href="#t1239">1239</a></span><span class="t"><span class="str"> one: False // TWO</span> </span><span class="r"></span></p> - <p id="t1240" class="pln"><span class="n"><a href="#t1240">1240</a></span><span class="t"><span class="str"> two: True // TWO</span> </span><span class="r"></span></p> - <p id="t1241" class="pln"><span class="n"><a href="#t1241">1241</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1242" class="pln"><span class="n"><a href="#t1242">1242</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1243" class="pln"><span class="n"><a href="#t1243">1243</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1244" class="pln"><span class="n"><a href="#t1244">1244</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1245" class="pln"><span class="n"><a href="#t1245">1245</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1246" class="pln"><span class="n"><a href="#t1246">1246</a></span><span class="t"><span class="str"> both.cog -o in/a/dir/both.one -s ' // ONE' -D one=x</span> </span><span class="r"></span></p> - <p id="t1247" class="pln"><span class="n"><a href="#t1247">1247</a></span><span class="t"><span class="str"> both.cog -o in/a/dir/both.two -s ' // TWO' -D two=x</span> </span><span class="r"></span></p> - <p id="t1248" class="pln"><span class="n"><a href="#t1248">1248</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1249" class="pln"><span class="n"><a href="#t1249">1249</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1250" class="pln"><span class="n"><a href="#t1250">1250</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1251" class="mis show_mis"><span class="n"><a href="#t1251">1251</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1252" class="mis show_mis"><span class="n"><a href="#t1252">1252</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1253" class="mis show_mis"><span class="n"><a href="#t1253">1253</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/both.one'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1254" class="mis show_mis"><span class="n"><a href="#t1254">1254</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/both.two'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1255" class="pln"><span class="n"><a href="#t1255">1255</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1256" class="run"><span class="n"><a href="#t1256">1256</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithBadArgCombo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1257" class="mis show_mis"><span class="n"><a href="#t1257">1257</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1258" class="pln"><span class="n"><a href="#t1258">1258</a></span><span class="t"> <span class="str">'both.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1259" class="pln"><span class="n"><a href="#t1259">1259</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1260" class="pln"><span class="n"><a href="#t1260">1260</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> - <p id="t1261" class="pln"><span class="n"><a href="#t1261">1261</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> - <p id="t1262" class="pln"><span class="n"><a href="#t1262">1262</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1263" class="pln"><span class="n"><a href="#t1263">1263</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1264" class="pln"><span class="n"><a href="#t1264">1264</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1265" class="pln"><span class="n"><a href="#t1265">1265</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1266" class="pln"><span class="n"><a href="#t1266">1266</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1267" class="pln"><span class="n"><a href="#t1267">1267</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1268" class="pln"><span class="n"><a href="#t1268">1268</a></span><span class="t"><span class="str"> both.cog</span> </span><span class="r"></span></p> - <p id="t1269" class="pln"><span class="n"><a href="#t1269">1269</a></span><span class="t"><span class="str"> both.cog -d # This is bad: -r and -d</span> </span><span class="r"></span></p> - <p id="t1270" class="pln"><span class="n"><a href="#t1270">1270</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1271" class="pln"><span class="n"><a href="#t1271">1271</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1272" class="pln"><span class="n"><a href="#t1272">1272</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1273" class="mis show_mis"><span class="n"><a href="#t1273">1273</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1274" class="mis show_mis"><span class="n"><a href="#t1274">1274</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -d with -r \(or you would delete all your source!\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1275" class="mis show_mis"><span class="n"><a href="#t1275">1275</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1276" class="pln"><span class="n"><a href="#t1276">1276</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1277" class="run"><span class="n"><a href="#t1277">1277</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithTrickyFilenames</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1278" class="mis show_mis"><span class="n"><a href="#t1278">1278</a></span><span class="t"> <span class="key">def</span> <span class="nam">fix_backslashes</span><span class="op">(</span><span class="nam">files_txt</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1279" class="pln"><span class="n"><a href="#t1279">1279</a></span><span class="t"> <span class="str">"""Make the contents of a files.txt sensitive to the platform."""</span> </span><span class="r"></span></p> - <p id="t1280" class="mis show_mis"><span class="n"><a href="#t1280">1280</a></span><span class="t"> <span class="key">if</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">platform</span> <span class="op">!=</span> <span class="str">"win32"</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1281" class="mis show_mis"><span class="n"><a href="#t1281">1281</a></span><span class="t"> <span class="nam">files_txt</span> <span class="op">=</span> <span class="nam">files_txt</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"\\"</span><span class="op">,</span> <span class="str">"/"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1282" class="mis show_mis"><span class="n"><a href="#t1282">1282</a></span><span class="t"> <span class="key">return</span> <span class="nam">files_txt</span> </span><span class="r"></span></p> - <p id="t1283" class="pln"><span class="n"><a href="#t1283">1283</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1284" class="mis show_mis"><span class="n"><a href="#t1284">1284</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1285" class="pln"><span class="n"><a href="#t1285">1285</a></span><span class="t"> <span class="str">'one 1.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1286" class="pln"><span class="n"><a href="#t1286">1286</a></span><span class="t"><span class="str"> //[[[cog cog.outl("hello world") ]]]</span> </span><span class="r"></span></p> - <p id="t1287" class="pln"><span class="n"><a href="#t1287">1287</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1288" class="pln"><span class="n"><a href="#t1288">1288</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1289" class="pln"><span class="n"><a href="#t1289">1289</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1290" class="pln"><span class="n"><a href="#t1290">1290</a></span><span class="t"><span class="str"> //[[[cog cog.outl("hello world") ]]]</span> </span><span class="r"></span></p> - <p id="t1291" class="pln"><span class="n"><a href="#t1291">1291</a></span><span class="t"><span class="str"> hello world //xxx</span> </span><span class="r"></span></p> - <p id="t1292" class="pln"><span class="n"><a href="#t1292">1292</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1293" class="pln"><span class="n"><a href="#t1293">1293</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1294" class="pln"><span class="n"><a href="#t1294">1294</a></span><span class="t"> <span class="str">'subdir'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1295" class="pln"><span class="n"><a href="#t1295">1295</a></span><span class="t"> <span class="str">'subback.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1296" class="pln"><span class="n"><a href="#t1296">1296</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with backslashes") ]]]</span> </span><span class="r"></span></p> - <p id="t1297" class="pln"><span class="n"><a href="#t1297">1297</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1298" class="pln"><span class="n"><a href="#t1298">1298</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1299" class="pln"><span class="n"><a href="#t1299">1299</a></span><span class="t"> <span class="str">'subfwd.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1300" class="pln"><span class="n"><a href="#t1300">1300</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with slashes") ]]]</span> </span><span class="r"></span></p> - <p id="t1301" class="pln"><span class="n"><a href="#t1301">1301</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1302" class="pln"><span class="n"><a href="#t1302">1302</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1303" class="pln"><span class="n"><a href="#t1303">1303</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1304" class="pln"><span class="n"><a href="#t1304">1304</a></span><span class="t"> <span class="str">'subback.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1305" class="pln"><span class="n"><a href="#t1305">1305</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with backslashes") ]]]</span> </span><span class="r"></span></p> - <p id="t1306" class="pln"><span class="n"><a href="#t1306">1306</a></span><span class="t"><span class="str"> down deep with backslashes //yyy</span> </span><span class="r"></span></p> - <p id="t1307" class="pln"><span class="n"><a href="#t1307">1307</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1308" class="pln"><span class="n"><a href="#t1308">1308</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1309" class="pln"><span class="n"><a href="#t1309">1309</a></span><span class="t"> <span class="str">'subfwd.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1310" class="pln"><span class="n"><a href="#t1310">1310</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with slashes") ]]]</span> </span><span class="r"></span></p> - <p id="t1311" class="pln"><span class="n"><a href="#t1311">1311</a></span><span class="t"><span class="str"> down deep with slashes //zzz</span> </span><span class="r"></span></p> - <p id="t1312" class="pln"><span class="n"><a href="#t1312">1312</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1313" class="pln"><span class="n"><a href="#t1313">1313</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1314" class="pln"><span class="n"><a href="#t1314">1314</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="nam">fix_backslashes</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1315" class="pln"><span class="n"><a href="#t1315">1315</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1316" class="pln"><span class="n"><a href="#t1316">1316</a></span><span class="t"><span class="str"> 'one 1.cog' -s ' //xxx'</span> </span><span class="r"></span></p> - <p id="t1317" class="pln"><span class="n"><a href="#t1317">1317</a></span><span class="t"><span class="str"> subdir\\subback.cog -s ' //yyy'</span> </span><span class="r"></span></p> - <p id="t1318" class="pln"><span class="n"><a href="#t1318">1318</a></span><span class="t"><span class="str"> subdir/subfwd.cog -s ' //zzz'</span> </span><span class="r"></span></p> - <p id="t1319" class="pln"><span class="n"><a href="#t1319">1319</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1320" class="pln"><span class="n"><a href="#t1320">1320</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1321" class="pln"><span class="n"><a href="#t1321">1321</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1322" class="mis show_mis"><span class="n"><a href="#t1322">1322</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1323" class="mis show_mis"><span class="n"><a href="#t1323">1323</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1324" class="mis show_mis"><span class="n"><a href="#t1324">1324</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one 1.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1325" class="mis show_mis"><span class="n"><a href="#t1325">1325</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'subdir/subback.cog'</span><span class="op">,</span> <span class="str">'subback.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1326" class="mis show_mis"><span class="n"><a href="#t1326">1326</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'subdir/subfwd.cog'</span><span class="op">,</span> <span class="str">'subfwd.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1327" class="pln"><span class="n"><a href="#t1327">1327</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1328" class="run"><span class="n"><a href="#t1328">1328</a></span><span class="t"> <span class="key">def</span> <span class="nam">run_with_verbosity</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">verbosity</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1329" class="mis show_mis"><span class="n"><a href="#t1329">1329</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1330" class="pln"><span class="n"><a href="#t1330">1330</a></span><span class="t"> <span class="str">'unchanged.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1331" class="pln"><span class="n"><a href="#t1331">1331</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1332" class="pln"><span class="n"><a href="#t1332">1332</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1333" class="pln"><span class="n"><a href="#t1333">1333</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1334" class="pln"><span class="n"><a href="#t1334">1334</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> - <p id="t1335" class="pln"><span class="n"><a href="#t1335">1335</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1336" class="pln"><span class="n"><a href="#t1336">1336</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1337" class="pln"><span class="n"><a href="#t1337">1337</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1338" class="pln"><span class="n"><a href="#t1338">1338</a></span><span class="t"> <span class="str">'changed.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1339" class="pln"><span class="n"><a href="#t1339">1339</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1340" class="pln"><span class="n"><a href="#t1340">1340</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> - <p id="t1341" class="pln"><span class="n"><a href="#t1341">1341</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1342" class="pln"><span class="n"><a href="#t1342">1342</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1343" class="pln"><span class="n"><a href="#t1343">1343</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1344" class="pln"><span class="n"><a href="#t1344">1344</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1345" class="pln"><span class="n"><a href="#t1345">1345</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1346" class="pln"><span class="n"><a href="#t1346">1346</a></span><span class="t"><span class="str"> unchanged.cog</span> </span><span class="r"></span></p> - <p id="t1347" class="pln"><span class="n"><a href="#t1347">1347</a></span><span class="t"><span class="str"> changed.cog</span> </span><span class="r"></span></p> - <p id="t1348" class="pln"><span class="n"><a href="#t1348">1348</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1349" class="pln"><span class="n"><a href="#t1349">1349</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1350" class="pln"><span class="n"><a href="#t1350">1350</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1351" class="mis show_mis"><span class="n"><a href="#t1351">1351</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1352" class="mis show_mis"><span class="n"><a href="#t1352">1352</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'--verbosity='</span><span class="op">+</span><span class="nam">verbosity</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1353" class="mis show_mis"><span class="n"><a href="#t1353">1353</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1354" class="mis show_mis"><span class="n"><a href="#t1354">1354</a></span><span class="t"> <span class="key">return</span> <span class="nam">output</span> </span><span class="r"></span></p> - <p id="t1355" class="pln"><span class="n"><a href="#t1355">1355</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1356" class="run"><span class="n"><a href="#t1356">1356</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity0</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1357" class="mis show_mis"><span class="n"><a href="#t1357">1357</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"0"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1358" class="mis show_mis"><span class="n"><a href="#t1358">1358</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1359" class="pln"><span class="n"><a href="#t1359">1359</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1360" class="run"><span class="n"><a href="#t1360">1360</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity1</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1361" class="mis show_mis"><span class="n"><a href="#t1361">1361</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"1"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1362" class="mis show_mis"><span class="n"><a href="#t1362">1362</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging changed.cog (changed)\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1363" class="pln"><span class="n"><a href="#t1363">1363</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1364" class="run"><span class="n"><a href="#t1364">1364</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1365" class="mis show_mis"><span class="n"><a href="#t1365">1365</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"2"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1366" class="mis show_mis"><span class="n"><a href="#t1366">1366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging unchanged.cog\nCogging changed.cog (changed)\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1367" class="pln"><span class="n"><a href="#t1367">1367</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1368" class="pln"><span class="n"><a href="#t1368">1368</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1369" class="run"><span class="n"><a href="#t1369">1369</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestLineEndings</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1370" class="pln"><span class="n"><a href="#t1370">1370</a></span><span class="t"> <span class="str">"""Tests for -U option (force LF line-endings in output)."""</span> </span><span class="r"></span></p> - <p id="t1371" class="pln"><span class="n"><a href="#t1371">1371</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1372" class="run"><span class="n"><a href="#t1372">1372</a></span><span class="t"> <span class="nam">lines_in</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Some text.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1373" class="pln"><span class="n"><a href="#t1373">1373</a></span><span class="t"> <span class="str">'//[[[cog'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1374" class="pln"><span class="n"><a href="#t1374">1374</a></span><span class="t"> <span class="str">'cog.outl("Cog text")'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1375" class="pln"><span class="n"><a href="#t1375">1375</a></span><span class="t"> <span class="str">'//]]]'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1376" class="pln"><span class="n"><a href="#t1376">1376</a></span><span class="t"> <span class="str">'gobbledegook.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1377" class="pln"><span class="n"><a href="#t1377">1377</a></span><span class="t"> <span class="str">'//[[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1378" class="pln"><span class="n"><a href="#t1378">1378</a></span><span class="t"> <span class="str">'epilogue.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1379" class="pln"><span class="n"><a href="#t1379">1379</a></span><span class="t"> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t1380" class="pln"><span class="n"><a href="#t1380">1380</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1381" class="run"><span class="n"><a href="#t1381">1381</a></span><span class="t"> <span class="nam">lines_out</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Some text.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1382" class="pln"><span class="n"><a href="#t1382">1382</a></span><span class="t"> <span class="str">'//[[[cog'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1383" class="pln"><span class="n"><a href="#t1383">1383</a></span><span class="t"> <span class="str">'cog.outl("Cog text")'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1384" class="pln"><span class="n"><a href="#t1384">1384</a></span><span class="t"> <span class="str">'//]]]'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1385" class="pln"><span class="n"><a href="#t1385">1385</a></span><span class="t"> <span class="str">'Cog text'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1386" class="pln"><span class="n"><a href="#t1386">1386</a></span><span class="t"> <span class="str">'//[[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1387" class="pln"><span class="n"><a href="#t1387">1387</a></span><span class="t"> <span class="str">'epilogue.'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1388" class="pln"><span class="n"><a href="#t1388">1388</a></span><span class="t"> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t1389" class="pln"><span class="n"><a href="#t1389">1389</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1390" class="run"><span class="n"><a href="#t1390">1390</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputNativeEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1391" class="mis show_mis"><span class="n"><a href="#t1391">1391</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'infile'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1392" class="mis show_mis"><span class="n"><a href="#t1392">1392</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'outfile'</span><span class="op">,</span> <span class="str">'infile'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1393" class="mis show_mis"><span class="n"><a href="#t1393">1393</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'outfile'</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1394" class="pln"><span class="n"><a href="#t1394">1394</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1395" class="run"><span class="n"><a href="#t1395">1395</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputLfEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1396" class="mis show_mis"><span class="n"><a href="#t1396">1396</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'infile'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1397" class="mis show_mis"><span class="n"><a href="#t1397">1397</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-U'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'outfile'</span><span class="op">,</span> <span class="str">'infile'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1398" class="mis show_mis"><span class="n"><a href="#t1398">1398</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'outfile'</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1399" class="pln"><span class="n"><a href="#t1399">1399</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1400" class="run"><span class="n"><a href="#t1400">1400</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReplaceNativeEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1401" class="mis show_mis"><span class="n"><a href="#t1401">1401</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'test.cog'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1402" class="mis show_mis"><span class="n"><a href="#t1402">1402</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1403" class="mis show_mis"><span class="n"><a href="#t1403">1403</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1404" class="pln"><span class="n"><a href="#t1404">1404</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1405" class="run"><span class="n"><a href="#t1405">1405</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReplaceLfEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1406" class="mis show_mis"><span class="n"><a href="#t1406">1406</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'test.cog'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1407" class="mis show_mis"><span class="n"><a href="#t1407">1407</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-U'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1408" class="mis show_mis"><span class="n"><a href="#t1408">1408</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1409" class="pln"><span class="n"><a href="#t1409">1409</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1410" class="pln"><span class="n"><a href="#t1410">1410</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1411" class="run"><span class="n"><a href="#t1411">1411</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestCharacterEncoding</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1412" class="pln"><span class="n"><a href="#t1412">1412</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1413" class="run"><span class="n"><a href="#t1413">1413</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1414" class="mis show_mis"><span class="n"><a href="#t1414">1414</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1415" class="pln"><span class="n"><a href="#t1415">1415</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> - <p id="t1416" class="pln"><span class="n"><a href="#t1416">1416</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1417" class="pln"><span class="n"><a href="#t1417">1417</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1418" class="pln"><span class="n"><a href="#t1418">1418</a></span><span class="t"><span class="str"> cog.outl("// Unicode: \xe1\x88\xb4 (U+1234)")</span> </span><span class="r"></span></p> - <p id="t1419" class="pln"><span class="n"><a href="#t1419">1419</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1420" class="pln"><span class="n"><a href="#t1420">1420</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1421" class="pln"><span class="n"><a href="#t1421">1421</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1422" class="pln"><span class="n"><a href="#t1422">1422</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1423" class="pln"><span class="n"><a href="#t1423">1423</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> - <p id="t1424" class="pln"><span class="n"><a href="#t1424">1424</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t1425" class="pln"><span class="n"><a href="#t1425">1425</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1426" class="pln"><span class="n"><a href="#t1426">1426</a></span><span class="t"><span class="str"> cog.outl("// Unicode: \xe1\x88\xb4 (U+1234)")</span> </span><span class="r"></span></p> - <p id="t1427" class="pln"><span class="n"><a href="#t1427">1427</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1428" class="pln"><span class="n"><a href="#t1428">1428</a></span><span class="t"><span class="str"> // Unicode: \xe1\x88\xb4 (U+1234)</span> </span><span class="r"></span></p> - <p id="t1429" class="pln"><span class="n"><a href="#t1429">1429</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1430" class="pln"><span class="n"><a href="#t1430">1430</a></span><span class="t"><span class="str"> """</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">b"\n"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1431" class="pln"><span class="n"><a href="#t1431">1431</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1432" class="pln"><span class="n"><a href="#t1432">1432</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1433" class="mis show_mis"><span class="n"><a href="#t1433">1433</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1434" class="mis show_mis"><span class="n"><a href="#t1434">1434</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1435" class="mis show_mis"><span class="n"><a href="#t1435">1435</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1436" class="mis show_mis"><span class="n"><a href="#t1436">1436</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1437" class="mis show_mis"><span class="n"><a href="#t1437">1437</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1438" class="pln"><span class="n"><a href="#t1438">1438</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1439" class="run"><span class="n"><a href="#t1439">1439</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFileEncodingOption</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1440" class="mis show_mis"><span class="n"><a href="#t1440">1440</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1441" class="pln"><span class="n"><a href="#t1441">1441</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> - <p id="t1442" class="pln"><span class="n"><a href="#t1442">1442</a></span><span class="t"><span class="str"> // \xca\xee\xe4\xe8\xf0\xe2\xea\xe0 Windows</span> </span><span class="r"></span></p> - <p id="t1443" class="pln"><span class="n"><a href="#t1443">1443</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1444" class="pln"><span class="n"><a href="#t1444">1444</a></span><span class="t"><span class="str"> cog.outl("\xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe")</span> </span><span class="r"></span></p> - <p id="t1445" class="pln"><span class="n"><a href="#t1445">1445</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1446" class="pln"><span class="n"><a href="#t1446">1446</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1447" class="pln"><span class="n"><a href="#t1447">1447</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1448" class="pln"><span class="n"><a href="#t1448">1448</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1449" class="pln"><span class="n"><a href="#t1449">1449</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> - <p id="t1450" class="pln"><span class="n"><a href="#t1450">1450</a></span><span class="t"><span class="str"> // \xca\xee\xe4\xe8\xf0\xe2\xea\xe0 Windows</span> </span><span class="r"></span></p> - <p id="t1451" class="pln"><span class="n"><a href="#t1451">1451</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1452" class="pln"><span class="n"><a href="#t1452">1452</a></span><span class="t"><span class="str"> cog.outl("\xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe")</span> </span><span class="r"></span></p> - <p id="t1453" class="pln"><span class="n"><a href="#t1453">1453</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1454" class="pln"><span class="n"><a href="#t1454">1454</a></span><span class="t"><span class="str"> \xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe</span> </span><span class="r"></span></p> - <p id="t1455" class="pln"><span class="n"><a href="#t1455">1455</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1456" class="pln"><span class="n"><a href="#t1456">1456</a></span><span class="t"><span class="str"> """</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">b"\n"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1457" class="pln"><span class="n"><a href="#t1457">1457</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1458" class="pln"><span class="n"><a href="#t1458">1458</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1459" class="mis show_mis"><span class="n"><a href="#t1459">1459</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1460" class="mis show_mis"><span class="n"><a href="#t1460">1460</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-n'</span><span class="op">,</span> <span class="str">'cp1251'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1461" class="mis show_mis"><span class="n"><a href="#t1461">1461</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1462" class="mis show_mis"><span class="n"><a href="#t1462">1462</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1463" class="mis show_mis"><span class="n"><a href="#t1463">1463</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1464" class="pln"><span class="n"><a href="#t1464">1464</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1465" class="pln"><span class="n"><a href="#t1465">1465</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1466" class="run"><span class="n"><a href="#t1466">1466</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCaseWithImports</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1467" class="pln"><span class="n"><a href="#t1467">1467</a></span><span class="t"> <span class="str">""" When running tests which import modules, the sys.modules list</span> </span><span class="r"></span></p> - <p id="t1468" class="pln"><span class="n"><a href="#t1468">1468</a></span><span class="t"><span class="str"> leaks from one test to the next. This test case class scrubs</span> </span><span class="r"></span></p> - <p id="t1469" class="pln"><span class="n"><a href="#t1469">1469</a></span><span class="t"><span class="str"> the list after each run to keep the tests isolated from each other.</span> </span><span class="r"></span></p> - <p id="t1470" class="pln"><span class="n"><a href="#t1470">1470</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1471" class="pln"><span class="n"><a href="#t1471">1471</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1472" class="run"><span class="n"><a href="#t1472">1472</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1473" class="mis show_mis"><span class="n"><a href="#t1473">1473</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1474" class="mis show_mis"><span class="n"><a href="#t1474">1474</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sysmodulekeys</span> <span class="op">=</span> <span class="nam">list</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1475" class="pln"><span class="n"><a href="#t1475">1475</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1476" class="run"><span class="n"><a href="#t1476">1476</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1477" class="mis show_mis"><span class="n"><a href="#t1477">1477</a></span><span class="t"> <span class="nam">modstoscrub</span> <span class="op">=</span> <span class="op">[</span> </span><span class="r"></span></p> - <p id="t1478" class="pln"><span class="n"><a href="#t1478">1478</a></span><span class="t"> <span class="nam">modname</span> </span><span class="r"></span></p> - <p id="t1479" class="pln"><span class="n"><a href="#t1479">1479</a></span><span class="t"> <span class="key">for</span> <span class="nam">modname</span> <span class="key">in</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span> </span><span class="r"></span></p> - <p id="t1480" class="pln"><span class="n"><a href="#t1480">1480</a></span><span class="t"> <span class="key">if</span> <span class="nam">modname</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sysmodulekeys</span> </span><span class="r"></span></p> - <p id="t1481" class="pln"><span class="n"><a href="#t1481">1481</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> - <p id="t1482" class="mis show_mis"><span class="n"><a href="#t1482">1482</a></span><span class="t"> <span class="key">for</span> <span class="nam">modname</span> <span class="key">in</span> <span class="nam">modstoscrub</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1483" class="mis show_mis"><span class="n"><a href="#t1483">1483</a></span><span class="t"> <span class="key">del</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="nam">modname</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t1484" class="mis show_mis"><span class="n"><a href="#t1484">1484</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1485" class="pln"><span class="n"><a href="#t1485">1485</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1486" class="pln"><span class="n"><a href="#t1486">1486</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1487" class="run"><span class="n"><a href="#t1487">1487</a></span><span class="t"><span class="key">class</span> <span class="nam">CogIncludeTests</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1488" class="run"><span class="n"><a href="#t1488">1488</a></span><span class="t"> <span class="nam">dincludes</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1489" class="pln"><span class="n"><a href="#t1489">1489</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1490" class="pln"><span class="n"><a href="#t1490">1490</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1491" class="pln"><span class="n"><a href="#t1491">1491</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> - <p id="t1492" class="pln"><span class="n"><a href="#t1492">1492</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1493" class="pln"><span class="n"><a href="#t1493">1493</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1494" class="pln"><span class="n"><a href="#t1494">1494</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1495" class="pln"><span class="n"><a href="#t1495">1495</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1496" class="pln"><span class="n"><a href="#t1496">1496</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1497" class="pln"><span class="n"><a href="#t1497">1497</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1498" class="pln"><span class="n"><a href="#t1498">1498</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> - <p id="t1499" class="pln"><span class="n"><a href="#t1499">1499</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1500" class="pln"><span class="n"><a href="#t1500">1500</a></span><span class="t"><span class="str"> Hello from mymodule</span> </span><span class="r"></span></p> - <p id="t1501" class="pln"><span class="n"><a href="#t1501">1501</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1502" class="pln"><span class="n"><a href="#t1502">1502</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1503" class="pln"><span class="n"><a href="#t1503">1503</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1504" class="pln"><span class="n"><a href="#t1504">1504</a></span><span class="t"> <span class="str">'test2.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1505" class="pln"><span class="n"><a href="#t1505">1505</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1506" class="pln"><span class="n"><a href="#t1506">1506</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> - <p id="t1507" class="pln"><span class="n"><a href="#t1507">1507</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1508" class="pln"><span class="n"><a href="#t1508">1508</a></span><span class="t"><span class="str"> Hello from mymodule in inc2</span> </span><span class="r"></span></p> - <p id="t1509" class="pln"><span class="n"><a href="#t1509">1509</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1510" class="pln"><span class="n"><a href="#t1510">1510</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1511" class="pln"><span class="n"><a href="#t1511">1511</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1512" class="pln"><span class="n"><a href="#t1512">1512</a></span><span class="t"> <span class="str">'include'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1513" class="pln"><span class="n"><a href="#t1513">1513</a></span><span class="t"> <span class="str">'mymodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1514" class="pln"><span class="n"><a href="#t1514">1514</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t1515" class="pln"><span class="n"><a href="#t1515">1515</a></span><span class="t"><span class="str"> cog.outl("Hello from mymodule")</span> </span><span class="r"></span></p> - <p id="t1516" class="pln"><span class="n"><a href="#t1516">1516</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1517" class="pln"><span class="n"><a href="#t1517">1517</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1518" class="pln"><span class="n"><a href="#t1518">1518</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1519" class="pln"><span class="n"><a href="#t1519">1519</a></span><span class="t"> <span class="str">'inc2'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1520" class="pln"><span class="n"><a href="#t1520">1520</a></span><span class="t"> <span class="str">'mymodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1521" class="pln"><span class="n"><a href="#t1521">1521</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t1522" class="pln"><span class="n"><a href="#t1522">1522</a></span><span class="t"><span class="str"> cog.outl("Hello from mymodule in inc2")</span> </span><span class="r"></span></p> - <p id="t1523" class="pln"><span class="n"><a href="#t1523">1523</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1524" class="pln"><span class="n"><a href="#t1524">1524</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1525" class="pln"><span class="n"><a href="#t1525">1525</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1526" class="pln"><span class="n"><a href="#t1526">1526</a></span><span class="t"> <span class="str">'inc3'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1527" class="pln"><span class="n"><a href="#t1527">1527</a></span><span class="t"> <span class="str">'someothermodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1528" class="pln"><span class="n"><a href="#t1528">1528</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t1529" class="pln"><span class="n"><a href="#t1529">1529</a></span><span class="t"><span class="str"> cog.outl("This is some other module.")</span> </span><span class="r"></span></p> - <p id="t1530" class="pln"><span class="n"><a href="#t1530">1530</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1531" class="pln"><span class="n"><a href="#t1531">1531</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1532" class="pln"><span class="n"><a href="#t1532">1532</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1533" class="pln"><span class="n"><a href="#t1533">1533</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1534" class="run"><span class="n"><a href="#t1534">1534</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNeedIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1535" class="pln"><span class="n"><a href="#t1535">1535</a></span><span class="t"> <span class="com"># Try it without the -I, to see that an ImportError happens.</span> </span><span class="r"></span></p> - <p id="t1536" class="mis show_mis"><span class="n"><a href="#t1536">1536</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1537" class="mis show_mis"><span class="n"><a href="#t1537">1537</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">"(ImportError|ModuleNotFoundError): No module named '?mymodule'?"</span> </span><span class="r"></span></p> - <p id="t1538" class="mis show_mis"><span class="n"><a href="#t1538">1538</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUserException</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1539" class="mis show_mis"><span class="n"><a href="#t1539">1539</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1540" class="pln"><span class="n"><a href="#t1540">1540</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1541" class="run"><span class="n"><a href="#t1541">1541</a></span><span class="t"> <span class="key">def</span> <span class="nam">testIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1542" class="pln"><span class="n"><a href="#t1542">1542</a></span><span class="t"> <span class="com"># Test that -I adds include directories properly.</span> </span><span class="r"></span></p> - <p id="t1543" class="mis show_mis"><span class="n"><a href="#t1543">1543</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1544" class="mis show_mis"><span class="n"><a href="#t1544">1544</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1545" class="mis show_mis"><span class="n"><a href="#t1545">1545</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1546" class="pln"><span class="n"><a href="#t1546">1546</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1547" class="run"><span class="n"><a href="#t1547">1547</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoIncludePaths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1548" class="pln"><span class="n"><a href="#t1548">1548</a></span><span class="t"> <span class="com"># Test that two -I's add include directories properly.</span> </span><span class="r"></span></p> - <p id="t1549" class="mis show_mis"><span class="n"><a href="#t1549">1549</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1550" class="mis show_mis"><span class="n"><a href="#t1550">1550</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc2'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1551" class="mis show_mis"><span class="n"><a href="#t1551">1551</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1552" class="pln"><span class="n"><a href="#t1552">1552</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1553" class="run"><span class="n"><a href="#t1553">1553</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoIncludePaths2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1554" class="pln"><span class="n"><a href="#t1554">1554</a></span><span class="t"> <span class="com"># Test that two -I's add include directories properly.</span> </span><span class="r"></span></p> - <p id="t1555" class="mis show_mis"><span class="n"><a href="#t1555">1555</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1556" class="mis show_mis"><span class="n"><a href="#t1556">1556</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc2'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1557" class="mis show_mis"><span class="n"><a href="#t1557">1557</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test2.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1558" class="pln"><span class="n"><a href="#t1558">1558</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1559" class="run"><span class="n"><a href="#t1559">1559</a></span><span class="t"> <span class="key">def</span> <span class="nam">testUselessIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1560" class="pln"><span class="n"><a href="#t1560">1560</a></span><span class="t"> <span class="com"># Test that the search will continue past the first directory.</span> </span><span class="r"></span></p> - <p id="t1561" class="mis show_mis"><span class="n"><a href="#t1561">1561</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1562" class="mis show_mis"><span class="n"><a href="#t1562">1562</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc3'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1563" class="mis show_mis"><span class="n"><a href="#t1563">1563</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1564" class="pln"><span class="n"><a href="#t1564">1564</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1565" class="run"><span class="n"><a href="#t1565">1565</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSysPathIsUnchanged</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1566" class="mis show_mis"><span class="n"><a href="#t1566">1566</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1567" class="pln"><span class="n"><a href="#t1567">1567</a></span><span class="t"> <span class="str">'bad.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1568" class="pln"><span class="n"><a href="#t1568">1568</a></span><span class="t"><span class="str"> //[[[cog cog.error("Oh no!") ]]]</span> </span><span class="r"></span></p> - <p id="t1569" class="pln"><span class="n"><a href="#t1569">1569</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1570" class="pln"><span class="n"><a href="#t1570">1570</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1571" class="pln"><span class="n"><a href="#t1571">1571</a></span><span class="t"> <span class="str">'good.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1572" class="pln"><span class="n"><a href="#t1572">1572</a></span><span class="t"><span class="str"> //[[[cog cog.outl("Oh yes!") ]]]</span> </span><span class="r"></span></p> - <p id="t1573" class="pln"><span class="n"><a href="#t1573">1573</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1574" class="pln"><span class="n"><a href="#t1574">1574</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1575" class="pln"><span class="n"><a href="#t1575">1575</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1576" class="pln"><span class="n"><a href="#t1576">1576</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1577" class="mis show_mis"><span class="n"><a href="#t1577">1577</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1578" class="pln"><span class="n"><a href="#t1578">1578</a></span><span class="t"> <span class="com"># Is it unchanged just by creating a cog engine?</span> </span><span class="r"></span></p> - <p id="t1579" class="mis show_mis"><span class="n"><a href="#t1579">1579</a></span><span class="t"> <span class="nam">oldsyspath</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t1580" class="mis show_mis"><span class="n"><a href="#t1580">1580</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1581" class="mis show_mis"><span class="n"><a href="#t1581">1581</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1582" class="pln"><span class="n"><a href="#t1582">1582</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run?</span> </span><span class="r"></span></p> - <p id="t1583" class="mis show_mis"><span class="n"><a href="#t1583">1583</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1584" class="mis show_mis"><span class="n"><a href="#t1584">1584</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1585" class="mis show_mis"><span class="n"><a href="#t1585">1585</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1586" class="pln"><span class="n"><a href="#t1586">1586</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run with includes?</span> </span><span class="r"></span></p> - <p id="t1587" class="mis show_mis"><span class="n"><a href="#t1587">1587</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1588" class="mis show_mis"><span class="n"><a href="#t1588">1588</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1589" class="mis show_mis"><span class="n"><a href="#t1589">1589</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1590" class="pln"><span class="n"><a href="#t1590">1590</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run with two includes?</span> </span><span class="r"></span></p> - <p id="t1591" class="mis show_mis"><span class="n"><a href="#t1591">1591</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1592" class="mis show_mis"><span class="n"><a href="#t1592">1592</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'quux'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1593" class="mis show_mis"><span class="n"><a href="#t1593">1593</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1594" class="pln"><span class="n"><a href="#t1594">1594</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run?</span> </span><span class="r"></span></p> - <p id="t1595" class="mis show_mis"><span class="n"><a href="#t1595">1595</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1596" class="mis show_mis"><span class="n"><a href="#t1596">1596</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1597" class="mis show_mis"><span class="n"><a href="#t1597">1597</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1598" class="mis show_mis"><span class="n"><a href="#t1598">1598</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1599" class="pln"><span class="n"><a href="#t1599">1599</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run with includes?</span> </span><span class="r"></span></p> - <p id="t1600" class="mis show_mis"><span class="n"><a href="#t1600">1600</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1601" class="mis show_mis"><span class="n"><a href="#t1601">1601</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1602" class="mis show_mis"><span class="n"><a href="#t1602">1602</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1603" class="mis show_mis"><span class="n"><a href="#t1603">1603</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1604" class="pln"><span class="n"><a href="#t1604">1604</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run with two includes?</span> </span><span class="r"></span></p> - <p id="t1605" class="mis show_mis"><span class="n"><a href="#t1605">1605</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1606" class="mis show_mis"><span class="n"><a href="#t1606">1606</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1607" class="mis show_mis"><span class="n"><a href="#t1607">1607</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'quux'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1608" class="mis show_mis"><span class="n"><a href="#t1608">1608</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1609" class="pln"><span class="n"><a href="#t1609">1609</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1610" class="run"><span class="n"><a href="#t1610">1610</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSubDirectories</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1611" class="pln"><span class="n"><a href="#t1611">1611</a></span><span class="t"> <span class="com"># Test that relative paths on the command line work, with includes.</span> </span><span class="r"></span></p> - <p id="t1612" class="pln"><span class="n"><a href="#t1612">1612</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1613" class="mis show_mis"><span class="n"><a href="#t1613">1613</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1614" class="pln"><span class="n"><a href="#t1614">1614</a></span><span class="t"> <span class="str">'code'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1615" class="pln"><span class="n"><a href="#t1615">1615</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1616" class="pln"><span class="n"><a href="#t1616">1616</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1617" class="pln"><span class="n"><a href="#t1617">1617</a></span><span class="t"><span class="str"> import mysubmodule</span> </span><span class="r"></span></p> - <p id="t1618" class="pln"><span class="n"><a href="#t1618">1618</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1619" class="pln"><span class="n"><a href="#t1619">1619</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1620" class="pln"><span class="n"><a href="#t1620">1620</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1621" class="pln"><span class="n"><a href="#t1621">1621</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1622" class="pln"><span class="n"><a href="#t1622">1622</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1623" class="pln"><span class="n"><a href="#t1623">1623</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1624" class="pln"><span class="n"><a href="#t1624">1624</a></span><span class="t"><span class="str"> import mysubmodule</span> </span><span class="r"></span></p> - <p id="t1625" class="pln"><span class="n"><a href="#t1625">1625</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1626" class="pln"><span class="n"><a href="#t1626">1626</a></span><span class="t"><span class="str"> Hello from mysubmodule</span> </span><span class="r"></span></p> - <p id="t1627" class="pln"><span class="n"><a href="#t1627">1627</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1628" class="pln"><span class="n"><a href="#t1628">1628</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1629" class="pln"><span class="n"><a href="#t1629">1629</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1630" class="pln"><span class="n"><a href="#t1630">1630</a></span><span class="t"> <span class="str">'mysubmodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1631" class="pln"><span class="n"><a href="#t1631">1631</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> - <p id="t1632" class="pln"><span class="n"><a href="#t1632">1632</a></span><span class="t"><span class="str"> cog.outl("Hello from mysubmodule")</span> </span><span class="r"></span></p> - <p id="t1633" class="pln"><span class="n"><a href="#t1633">1633</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1634" class="pln"><span class="n"><a href="#t1634">1634</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1635" class="pln"><span class="n"><a href="#t1635">1635</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1636" class="pln"><span class="n"><a href="#t1636">1636</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1637" class="mis show_mis"><span class="n"><a href="#t1637">1637</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1638" class="pln"><span class="n"><a href="#t1638">1638</a></span><span class="t"> <span class="com"># We should be able to invoke cog without the -I switch, and it will</span> </span><span class="r"></span></p> - <p id="t1639" class="pln"><span class="n"><a href="#t1639">1639</a></span><span class="t"> <span class="com"># auto-include the current directory</span> </span><span class="r"></span></p> - <p id="t1640" class="mis show_mis"><span class="n"><a href="#t1640">1640</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'code/test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1641" class="mis show_mis"><span class="n"><a href="#t1641">1641</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'code/test.cog'</span><span class="op">,</span> <span class="str">'code/test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1642" class="pln"><span class="n"><a href="#t1642">1642</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1643" class="pln"><span class="n"><a href="#t1643">1643</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1644" class="run"><span class="n"><a href="#t1644">1644</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestsInFiles</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1645" class="pln"><span class="n"><a href="#t1645">1645</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1646" class="run"><span class="n"><a href="#t1646">1646</a></span><span class="t"> <span class="key">def</span> <span class="nam">testWarnIfNoCogCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1647" class="pln"><span class="n"><a href="#t1647">1647</a></span><span class="t"> <span class="com"># Test that the -e switch warns if there is no Cog code.</span> </span><span class="r"></span></p> - <p id="t1648" class="mis show_mis"><span class="n"><a href="#t1648">1648</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1649" class="pln"><span class="n"><a href="#t1649">1649</a></span><span class="t"> <span class="str">'with.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1650" class="pln"><span class="n"><a href="#t1650">1650</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1651" class="pln"><span class="n"><a href="#t1651">1651</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> - <p id="t1652" class="pln"><span class="n"><a href="#t1652">1652</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1653" class="pln"><span class="n"><a href="#t1653">1653</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> - <p id="t1654" class="pln"><span class="n"><a href="#t1654">1654</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1655" class="pln"><span class="n"><a href="#t1655">1655</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1656" class="pln"><span class="n"><a href="#t1656">1656</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1657" class="pln"><span class="n"><a href="#t1657">1657</a></span><span class="t"> <span class="str">'without.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1658" class="pln"><span class="n"><a href="#t1658">1658</a></span><span class="t"><span class="str"> There's no cog</span> </span><span class="r"></span></p> - <p id="t1659" class="pln"><span class="n"><a href="#t1659">1659</a></span><span class="t"><span class="str"> code in this file.</span> </span><span class="r"></span></p> - <p id="t1660" class="pln"><span class="n"><a href="#t1660">1660</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1661" class="pln"><span class="n"><a href="#t1661">1661</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1662" class="pln"><span class="n"><a href="#t1662">1662</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1663" class="mis show_mis"><span class="n"><a href="#t1663">1663</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1664" class="mis show_mis"><span class="n"><a href="#t1664">1664</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-e'</span><span class="op">,</span> <span class="str">'with.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1665" class="mis show_mis"><span class="n"><a href="#t1665">1665</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1666" class="mis show_mis"><span class="n"><a href="#t1666">1666</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotIn</span><span class="op">(</span><span class="str">"Warning"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1667" class="mis show_mis"><span class="n"><a href="#t1667">1667</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1668" class="mis show_mis"><span class="n"><a href="#t1668">1668</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-e'</span><span class="op">,</span> <span class="str">'without.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1669" class="mis show_mis"><span class="n"><a href="#t1669">1669</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1670" class="mis show_mis"><span class="n"><a href="#t1670">1670</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"Warning: no cog code found in without.cog"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1671" class="mis show_mis"><span class="n"><a href="#t1671">1671</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1672" class="mis show_mis"><span class="n"><a href="#t1672">1672</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'without.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1673" class="mis show_mis"><span class="n"><a href="#t1673">1673</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1674" class="mis show_mis"><span class="n"><a href="#t1674">1674</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotIn</span><span class="op">(</span><span class="str">"Warning"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1675" class="pln"><span class="n"><a href="#t1675">1675</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1676" class="run"><span class="n"><a href="#t1676">1676</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFileNameProps</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1677" class="mis show_mis"><span class="n"><a href="#t1677">1677</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1678" class="pln"><span class="n"><a href="#t1678">1678</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1679" class="pln"><span class="n"><a href="#t1679">1679</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1680" class="pln"><span class="n"><a href="#t1680">1680</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> - <p id="t1681" class="pln"><span class="n"><a href="#t1681">1681</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1682" class="pln"><span class="n"><a href="#t1682">1682</a></span><span class="t"><span class="str"> this is cog1.txt in, cog1.txt out</span> </span><span class="r"></span></p> - <p id="t1683" class="pln"><span class="n"><a href="#t1683">1683</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t1684" class="pln"><span class="n"><a href="#t1684">1684</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1685" class="pln"><span class="n"><a href="#t1685">1685</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1686" class="pln"><span class="n"><a href="#t1686">1686</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1687" class="pln"><span class="n"><a href="#t1687">1687</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1688" class="pln"><span class="n"><a href="#t1688">1688</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> - <p id="t1689" class="pln"><span class="n"><a href="#t1689">1689</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1690" class="pln"><span class="n"><a href="#t1690">1690</a></span><span class="t"><span class="str"> This is cog1.txt in, cog1.txt out</span> </span><span class="r"></span></p> - <p id="t1691" class="pln"><span class="n"><a href="#t1691">1691</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t1692" class="pln"><span class="n"><a href="#t1692">1692</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1693" class="pln"><span class="n"><a href="#t1693">1693</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1694" class="pln"><span class="n"><a href="#t1694">1694</a></span><span class="t"> <span class="str">'cog1out.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1695" class="pln"><span class="n"><a href="#t1695">1695</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1696" class="pln"><span class="n"><a href="#t1696">1696</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> - <p id="t1697" class="pln"><span class="n"><a href="#t1697">1697</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1698" class="pln"><span class="n"><a href="#t1698">1698</a></span><span class="t"><span class="str"> This is cog1.txt in, cog1out.txt out</span> </span><span class="r"></span></p> - <p id="t1699" class="pln"><span class="n"><a href="#t1699">1699</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> - <p id="t1700" class="pln"><span class="n"><a href="#t1700">1700</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1701" class="pln"><span class="n"><a href="#t1701">1701</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1702" class="pln"><span class="n"><a href="#t1702">1702</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1703" class="mis show_mis"><span class="n"><a href="#t1703">1703</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1704" class="mis show_mis"><span class="n"><a href="#t1704">1704</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1705" class="mis show_mis"><span class="n"><a href="#t1705">1705</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1706" class="mis show_mis"><span class="n"><a href="#t1706">1706</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1707" class="mis show_mis"><span class="n"><a href="#t1707">1707</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'cog1out.txt'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1708" class="mis show_mis"><span class="n"><a href="#t1708">1708</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1out.txt'</span><span class="op">,</span> <span class="str">'cog1out.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1709" class="pln"><span class="n"><a href="#t1709">1709</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1710" class="run"><span class="n"><a href="#t1710">1710</a></span><span class="t"> <span class="key">def</span> <span class="nam">testGlobalsDontCrossFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1711" class="pln"><span class="n"><a href="#t1711">1711</a></span><span class="t"> <span class="com"># Make sure that global values don't get shared between files.</span> </span><span class="r"></span></p> - <p id="t1712" class="mis show_mis"><span class="n"><a href="#t1712">1712</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1713" class="pln"><span class="n"><a href="#t1713">1713</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1714" class="pln"><span class="n"><a href="#t1714">1714</a></span><span class="t"><span class="str"> //[[[cog s = "This was set in one.cog" ]]]</span> </span><span class="r"></span></p> - <p id="t1715" class="pln"><span class="n"><a href="#t1715">1715</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1716" class="pln"><span class="n"><a href="#t1716">1716</a></span><span class="t"><span class="str"> //[[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> - <p id="t1717" class="pln"><span class="n"><a href="#t1717">1717</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1718" class="pln"><span class="n"><a href="#t1718">1718</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1719" class="pln"><span class="n"><a href="#t1719">1719</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1720" class="pln"><span class="n"><a href="#t1720">1720</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1721" class="pln"><span class="n"><a href="#t1721">1721</a></span><span class="t"><span class="str"> //[[[cog s = "This was set in one.cog" ]]]</span> </span><span class="r"></span></p> - <p id="t1722" class="pln"><span class="n"><a href="#t1722">1722</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1723" class="pln"><span class="n"><a href="#t1723">1723</a></span><span class="t"><span class="str"> //[[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> - <p id="t1724" class="pln"><span class="n"><a href="#t1724">1724</a></span><span class="t"><span class="str"> This was set in one.cog</span> </span><span class="r"></span></p> - <p id="t1725" class="pln"><span class="n"><a href="#t1725">1725</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1726" class="pln"><span class="n"><a href="#t1726">1726</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1727" class="pln"><span class="n"><a href="#t1727">1727</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1728" class="pln"><span class="n"><a href="#t1728">1728</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1729" class="pln"><span class="n"><a href="#t1729">1729</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1730" class="pln"><span class="n"><a href="#t1730">1730</a></span><span class="t"><span class="str"> try:</span> </span><span class="r"></span></p> - <p id="t1731" class="pln"><span class="n"><a href="#t1731">1731</a></span><span class="t"><span class="str"> cog.outl(s)</span> </span><span class="r"></span></p> - <p id="t1732" class="pln"><span class="n"><a href="#t1732">1732</a></span><span class="t"><span class="str"> except NameError:</span> </span><span class="r"></span></p> - <p id="t1733" class="pln"><span class="n"><a href="#t1733">1733</a></span><span class="t"><span class="str"> cog.outl("s isn't set!")</span> </span><span class="r"></span></p> - <p id="t1734" class="pln"><span class="n"><a href="#t1734">1734</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1735" class="pln"><span class="n"><a href="#t1735">1735</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1736" class="pln"><span class="n"><a href="#t1736">1736</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1737" class="pln"><span class="n"><a href="#t1737">1737</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1738" class="pln"><span class="n"><a href="#t1738">1738</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1739" class="pln"><span class="n"><a href="#t1739">1739</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1740" class="pln"><span class="n"><a href="#t1740">1740</a></span><span class="t"><span class="str"> try:</span> </span><span class="r"></span></p> - <p id="t1741" class="pln"><span class="n"><a href="#t1741">1741</a></span><span class="t"><span class="str"> cog.outl(s)</span> </span><span class="r"></span></p> - <p id="t1742" class="pln"><span class="n"><a href="#t1742">1742</a></span><span class="t"><span class="str"> except NameError:</span> </span><span class="r"></span></p> - <p id="t1743" class="pln"><span class="n"><a href="#t1743">1743</a></span><span class="t"><span class="str"> cog.outl("s isn't set!")</span> </span><span class="r"></span></p> - <p id="t1744" class="pln"><span class="n"><a href="#t1744">1744</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1745" class="pln"><span class="n"><a href="#t1745">1745</a></span><span class="t"><span class="str"> s isn't set!</span> </span><span class="r"></span></p> - <p id="t1746" class="pln"><span class="n"><a href="#t1746">1746</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1747" class="pln"><span class="n"><a href="#t1747">1747</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1748" class="pln"><span class="n"><a href="#t1748">1748</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1749" class="pln"><span class="n"><a href="#t1749">1749</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1750" class="pln"><span class="n"><a href="#t1750">1750</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> - <p id="t1751" class="pln"><span class="n"><a href="#t1751">1751</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> - <p id="t1752" class="pln"><span class="n"><a href="#t1752">1752</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1753" class="pln"><span class="n"><a href="#t1753">1753</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> - <p id="t1754" class="pln"><span class="n"><a href="#t1754">1754</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1755" class="pln"><span class="n"><a href="#t1755">1755</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1756" class="pln"><span class="n"><a href="#t1756">1756</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1757" class="mis show_mis"><span class="n"><a href="#t1757">1757</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1758" class="mis show_mis"><span class="n"><a href="#t1758">1758</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1759" class="mis show_mis"><span class="n"><a href="#t1759">1759</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1760" class="mis show_mis"><span class="n"><a href="#t1760">1760</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1761" class="mis show_mis"><span class="n"><a href="#t1761">1761</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1762" class="mis show_mis"><span class="n"><a href="#t1762">1762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1763" class="pln"><span class="n"><a href="#t1763">1763</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1764" class="run"><span class="n"><a href="#t1764">1764</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRemoveGeneratedOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1765" class="mis show_mis"><span class="n"><a href="#t1765">1765</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1766" class="pln"><span class="n"><a href="#t1766">1766</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1767" class="pln"><span class="n"><a href="#t1767">1767</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1768" class="pln"><span class="n"><a href="#t1768">1768</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> - <p id="t1769" class="pln"><span class="n"><a href="#t1769">1769</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1770" class="pln"><span class="n"><a href="#t1770">1770</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t1771" class="pln"><span class="n"><a href="#t1771">1771</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1772" class="pln"><span class="n"><a href="#t1772">1772</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> - <p id="t1773" class="pln"><span class="n"><a href="#t1773">1773</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1774" class="pln"><span class="n"><a href="#t1774">1774</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1775" class="pln"><span class="n"><a href="#t1775">1775</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1776" class="pln"><span class="n"><a href="#t1776">1776</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1777" class="pln"><span class="n"><a href="#t1777">1777</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> - <p id="t1778" class="pln"><span class="n"><a href="#t1778">1778</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1779" class="pln"><span class="n"><a href="#t1779">1779</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1780" class="pln"><span class="n"><a href="#t1780">1780</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> - <p id="t1781" class="pln"><span class="n"><a href="#t1781">1781</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1782" class="pln"><span class="n"><a href="#t1782">1782</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1783" class="pln"><span class="n"><a href="#t1783">1783</a></span><span class="t"> <span class="str">'cog1.out2'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1784" class="pln"><span class="n"><a href="#t1784">1784</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1785" class="pln"><span class="n"><a href="#t1785">1785</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> - <p id="t1786" class="pln"><span class="n"><a href="#t1786">1786</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1787" class="pln"><span class="n"><a href="#t1787">1787</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t1788" class="pln"><span class="n"><a href="#t1788">1788</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1789" class="pln"><span class="n"><a href="#t1789">1789</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> - <p id="t1790" class="pln"><span class="n"><a href="#t1790">1790</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1791" class="pln"><span class="n"><a href="#t1791">1791</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1792" class="pln"><span class="n"><a href="#t1792">1792</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1793" class="mis show_mis"><span class="n"><a href="#t1793">1793</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1794" class="pln"><span class="n"><a href="#t1794">1794</a></span><span class="t"> <span class="com"># Remove generated output.</span> </span><span class="r"></span></p> - <p id="t1795" class="mis show_mis"><span class="n"><a href="#t1795">1795</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-x'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1796" class="mis show_mis"><span class="n"><a href="#t1796">1796</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1797" class="mis show_mis"><span class="n"><a href="#t1797">1797</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1798" class="pln"><span class="n"><a href="#t1798">1798</a></span><span class="t"> <span class="com"># Regenerate the generated output.</span> </span><span class="r"></span></p> - <p id="t1799" class="mis show_mis"><span class="n"><a href="#t1799">1799</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1800" class="mis show_mis"><span class="n"><a href="#t1800">1800</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out2'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1801" class="mis show_mis"><span class="n"><a href="#t1801">1801</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1802" class="pln"><span class="n"><a href="#t1802">1802</a></span><span class="t"> <span class="com"># Remove the generated output again.</span> </span><span class="r"></span></p> - <p id="t1803" class="mis show_mis"><span class="n"><a href="#t1803">1803</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-x'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1804" class="mis show_mis"><span class="n"><a href="#t1804">1804</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1805" class="pln"><span class="n"><a href="#t1805">1805</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1806" class="run"><span class="n"><a href="#t1806">1806</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMsgCall</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1807" class="mis show_mis"><span class="n"><a href="#t1807">1807</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1808" class="pln"><span class="n"><a href="#t1808">1808</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> - <p id="t1809" class="pln"><span class="n"><a href="#t1809">1809</a></span><span class="t"><span class="str"> cog.msg("Hello there!")</span> </span><span class="r"></span></p> - <p id="t1810" class="pln"><span class="n"><a href="#t1810">1810</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> - <p id="t1811" class="pln"><span class="n"><a href="#t1811">1811</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1812" class="pln"><span class="n"><a href="#t1812">1812</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1813" class="mis show_mis"><span class="n"><a href="#t1813">1813</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1814" class="mis show_mis"><span class="n"><a href="#t1814">1814</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1815" class="mis show_mis"><span class="n"><a href="#t1815">1815</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1816" class="mis show_mis"><span class="n"><a href="#t1816">1816</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Message: Hello there!\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1817" class="pln"><span class="n"><a href="#t1817">1817</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1818" class="run"><span class="n"><a href="#t1818">1818</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorMessageHasNoTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1819" class="pln"><span class="n"><a href="#t1819">1819</a></span><span class="t"> <span class="com"># Test that a Cog error is printed to stderr with no traceback.</span> </span><span class="r"></span></p> - <p id="t1820" class="pln"><span class="n"><a href="#t1820">1820</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1821" class="mis show_mis"><span class="n"><a href="#t1821">1821</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1822" class="pln"><span class="n"><a href="#t1822">1822</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1823" class="pln"><span class="n"><a href="#t1823">1823</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t1824" class="pln"><span class="n"><a href="#t1824">1824</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t1825" class="pln"><span class="n"><a href="#t1825">1825</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t1826" class="pln"><span class="n"><a href="#t1826">1826</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t1827" class="pln"><span class="n"><a href="#t1827">1827</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t1828" class="pln"><span class="n"><a href="#t1828">1828</a></span><span class="t"><span class="str"> Xhis line was newly</span> </span><span class="r"></span></p> - <p id="t1829" class="pln"><span class="n"><a href="#t1829">1829</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t1830" class="pln"><span class="n"><a href="#t1830">1830</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t1831" class="pln"><span class="n"><a href="#t1831">1831</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t1832" class="pln"><span class="n"><a href="#t1832">1832</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1833" class="pln"><span class="n"><a href="#t1833">1833</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1834" class="pln"><span class="n"><a href="#t1834">1834</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1835" class="mis show_mis"><span class="n"><a href="#t1835">1835</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1836" class="mis show_mis"><span class="n"><a href="#t1836">1836</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1837" class="mis show_mis"><span class="n"><a href="#t1837">1837</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1838" class="mis show_mis"><span class="n"><a href="#t1838">1838</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">"cog1.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1839" class="mis show_mis"><span class="n"><a href="#t1839">1839</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">"Cogging cog1.txt\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1840" class="mis show_mis"><span class="n"><a href="#t1840">1840</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">"cog1.txt(9): Output has been edited! Delete old checksum to unprotect.\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1841" class="pln"><span class="n"><a href="#t1841">1841</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1842" class="run"><span class="n"><a href="#t1842">1842</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashD</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1843" class="mis show_mis"><span class="n"><a href="#t1843">1843</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1844" class="pln"><span class="n"><a href="#t1844">1844</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1845" class="pln"><span class="n"><a href="#t1845">1845</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> - <p id="t1846" class="pln"><span class="n"><a href="#t1846">1846</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1847" class="pln"><span class="n"><a href="#t1847">1847</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1848" class="pln"><span class="n"><a href="#t1848">1848</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1849" class="pln"><span class="n"><a href="#t1849">1849</a></span><span class="t"> <span class="str">'test.kablooey'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1850" class="pln"><span class="n"><a href="#t1850">1850</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> - <p id="t1851" class="pln"><span class="n"><a href="#t1851">1851</a></span><span class="t"><span class="str"> Defined fooey as kablooey</span> </span><span class="r"></span></p> - <p id="t1852" class="pln"><span class="n"><a href="#t1852">1852</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1853" class="pln"><span class="n"><a href="#t1853">1853</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1854" class="pln"><span class="n"><a href="#t1854">1854</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1855" class="pln"><span class="n"><a href="#t1855">1855</a></span><span class="t"> <span class="str">'test.einstein'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1856" class="pln"><span class="n"><a href="#t1856">1856</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> - <p id="t1857" class="pln"><span class="n"><a href="#t1857">1857</a></span><span class="t"><span class="str"> Defined fooey as e=mc2</span> </span><span class="r"></span></p> - <p id="t1858" class="pln"><span class="n"><a href="#t1858">1858</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1859" class="pln"><span class="n"><a href="#t1859">1859</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1860" class="pln"><span class="n"><a href="#t1860">1860</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1861" class="pln"><span class="n"><a href="#t1861">1861</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1862" class="mis show_mis"><span class="n"><a href="#t1862">1862</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1863" class="mis show_mis"><span class="n"><a href="#t1863">1863</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'fooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1864" class="mis show_mis"><span class="n"><a href="#t1864">1864</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1865" class="mis show_mis"><span class="n"><a href="#t1865">1865</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1866" class="mis show_mis"><span class="n"><a href="#t1866">1866</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1867" class="mis show_mis"><span class="n"><a href="#t1867">1867</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1868" class="mis show_mis"><span class="n"><a href="#t1868">1868</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1869" class="mis show_mis"><span class="n"><a href="#t1869">1869</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=e=mc2'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1870" class="mis show_mis"><span class="n"><a href="#t1870">1870</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.einstein'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1871" class="mis show_mis"><span class="n"><a href="#t1871">1871</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1872" class="mis show_mis"><span class="n"><a href="#t1872">1872</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dbar=quux'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1873" class="mis show_mis"><span class="n"><a href="#t1873">1873</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1874" class="mis show_mis"><span class="n"><a href="#t1874">1874</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1875" class="mis show_mis"><span class="n"><a href="#t1875">1875</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'-Dbar=quux'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1876" class="mis show_mis"><span class="n"><a href="#t1876">1876</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1877" class="mis show_mis"><span class="n"><a href="#t1877">1877</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1878" class="mis show_mis"><span class="n"><a href="#t1878">1878</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=gooey'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1879" class="mis show_mis"><span class="n"><a href="#t1879">1879</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1880" class="pln"><span class="n"><a href="#t1880">1880</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1881" class="run"><span class="n"><a href="#t1881">1881</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputToStdout</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1882" class="mis show_mis"><span class="n"><a href="#t1882">1882</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1883" class="pln"><span class="n"><a href="#t1883">1883</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1884" class="pln"><span class="n"><a href="#t1884">1884</a></span><span class="t"><span class="str"> --[[[cog cog.outl('Hey there!') ]]]</span> </span><span class="r"></span></p> - <p id="t1885" class="pln"><span class="n"><a href="#t1885">1885</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1886" class="pln"><span class="n"><a href="#t1886">1886</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t1887" class="pln"><span class="n"><a href="#t1887">1887</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1888" class="pln"><span class="n"><a href="#t1888">1888</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1889" class="mis show_mis"><span class="n"><a href="#t1889">1889</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1890" class="mis show_mis"><span class="n"><a href="#t1890">1890</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1891" class="mis show_mis"><span class="n"><a href="#t1891">1891</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1892" class="mis show_mis"><span class="n"><a href="#t1892">1892</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1893" class="mis show_mis"><span class="n"><a href="#t1893">1893</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1894" class="mis show_mis"><span class="n"><a href="#t1894">1894</a></span><span class="t"> <span class="nam">outerr</span> <span class="op">=</span> <span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1895" class="mis show_mis"><span class="n"><a href="#t1895">1895</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"--[[[cog cog.outl('Hey there!') ]]]\nHey there!\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1896" class="mis show_mis"><span class="n"><a href="#t1896">1896</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">outerr</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1897" class="pln"><span class="n"><a href="#t1897">1897</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1898" class="run"><span class="n"><a href="#t1898">1898</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadFromStdin</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1899" class="mis show_mis"><span class="n"><a href="#t1899">1899</a></span><span class="t"> <span class="nam">stdin</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="str">"--[[[cog cog.outl('Wow') ]]]\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1900" class="mis show_mis"><span class="n"><a href="#t1900">1900</a></span><span class="t"> <span class="key">def</span> <span class="nam">restore_stdin</span><span class="op">(</span><span class="nam">old_stdin</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1901" class="mis show_mis"><span class="n"><a href="#t1901">1901</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> <span class="op">=</span> <span class="nam">old_stdin</span> </span><span class="r"></span></p> - <p id="t1902" class="mis show_mis"><span class="n"><a href="#t1902">1902</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addCleanup</span><span class="op">(</span><span class="nam">restore_stdin</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1903" class="mis show_mis"><span class="n"><a href="#t1903">1903</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> <span class="op">=</span> <span class="nam">stdin</span> </span><span class="r"></span></p> - <p id="t1904" class="pln"><span class="n"><a href="#t1904">1904</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1905" class="mis show_mis"><span class="n"><a href="#t1905">1905</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1906" class="mis show_mis"><span class="n"><a href="#t1906">1906</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1907" class="mis show_mis"><span class="n"><a href="#t1907">1907</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1908" class="mis show_mis"><span class="n"><a href="#t1908">1908</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1909" class="mis show_mis"><span class="n"><a href="#t1909">1909</a></span><span class="t"> <span class="nam">outerr</span> <span class="op">=</span> <span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1910" class="mis show_mis"><span class="n"><a href="#t1910">1910</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"--[[[cog cog.outl('Wow') ]]]\nWow\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1911" class="mis show_mis"><span class="n"><a href="#t1911">1911</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">outerr</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1912" class="pln"><span class="n"><a href="#t1912">1912</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1913" class="run"><span class="n"><a href="#t1913">1913</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSuffixOutputLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1914" class="mis show_mis"><span class="n"><a href="#t1914">1914</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1915" class="pln"><span class="n"><a href="#t1915">1915</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1916" class="pln"><span class="n"><a href="#t1916">1916</a></span><span class="t"><span class="str"> Hey there.</span> </span><span class="r"></span></p> - <p id="t1917" class="pln"><span class="n"><a href="#t1917">1917</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span> </span><span class="r"></span></p> - <p id="t1918" class="pln"><span class="n"><a href="#t1918">1918</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1919" class="pln"><span class="n"><a href="#t1919">1919</a></span><span class="t"><span class="str"> Good bye.</span> </span><span class="r"></span></p> - <p id="t1920" class="pln"><span class="n"><a href="#t1920">1920</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1921" class="pln"><span class="n"><a href="#t1921">1921</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1922" class="pln"><span class="n"><a href="#t1922">1922</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1923" class="pln"><span class="n"><a href="#t1923">1923</a></span><span class="t"><span class="str"> Hey there.</span> </span><span class="r"></span></p> - <p id="t1924" class="pln"><span class="n"><a href="#t1924">1924</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span> </span><span class="r"></span></p> - <p id="t1925" class="pln"><span class="n"><a href="#t1925">1925</a></span><span class="t"><span class="str"> a (foo)</span> </span><span class="r"></span></p> - <p id="t1926" class="pln"><span class="n"><a href="#t1926">1926</a></span><span class="t"><span class="str"> b (foo)</span> </span><span class="r"></span></p> - <p id="t1927" class="pln"><span class="n"><a href="#t1927">1927</a></span><span class="t"><span class="str"> """</span> <span class="com"># These three trailing spaces are important.</span> </span><span class="r"></span></p> - <p id="t1928" class="pln"><span class="n"><a href="#t1928">1928</a></span><span class="t"> <span class="com"># The suffix is not applied to completely blank lines.</span> </span><span class="r"></span></p> - <p id="t1929" class="pln"><span class="n"><a href="#t1929">1929</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p> - <p id="t1930" class="pln"><span class="n"><a href="#t1930">1930</a></span><span class="t"><span class="str"> c (foo)</span> </span><span class="r"></span></p> - <p id="t1931" class="pln"><span class="n"><a href="#t1931">1931</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1932" class="pln"><span class="n"><a href="#t1932">1932</a></span><span class="t"><span class="str"> Good bye.</span> </span><span class="r"></span></p> - <p id="t1933" class="pln"><span class="n"><a href="#t1933">1933</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1934" class="pln"><span class="n"><a href="#t1934">1934</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1935" class="pln"><span class="n"><a href="#t1935">1935</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1936" class="mis show_mis"><span class="n"><a href="#t1936">1936</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1937" class="mis show_mis"><span class="n"><a href="#t1937">1937</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' (foo)'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1938" class="mis show_mis"><span class="n"><a href="#t1938">1938</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1939" class="pln"><span class="n"><a href="#t1939">1939</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1940" class="run"><span class="n"><a href="#t1940">1940</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptySuffix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1941" class="mis show_mis"><span class="n"><a href="#t1941">1941</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1942" class="pln"><span class="n"><a href="#t1942">1942</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1943" class="pln"><span class="n"><a href="#t1943">1943</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span> </span><span class="r"></span></p> - <p id="t1944" class="pln"><span class="n"><a href="#t1944">1944</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1945" class="pln"><span class="n"><a href="#t1945">1945</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1946" class="pln"><span class="n"><a href="#t1946">1946</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1947" class="pln"><span class="n"><a href="#t1947">1947</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1948" class="pln"><span class="n"><a href="#t1948">1948</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span> </span><span class="r"></span></p> - <p id="t1949" class="pln"><span class="n"><a href="#t1949">1949</a></span><span class="t"><span class="str"> a</span> </span><span class="r"></span></p> - <p id="t1950" class="pln"><span class="n"><a href="#t1950">1950</a></span><span class="t"><span class="str"> b</span> </span><span class="r"></span></p> - <p id="t1951" class="pln"><span class="n"><a href="#t1951">1951</a></span><span class="t"><span class="str"> c</span> </span><span class="r"></span></p> - <p id="t1952" class="pln"><span class="n"><a href="#t1952">1952</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1953" class="pln"><span class="n"><a href="#t1953">1953</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1954" class="pln"><span class="n"><a href="#t1954">1954</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1955" class="pln"><span class="n"><a href="#t1955">1955</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1956" class="mis show_mis"><span class="n"><a href="#t1956">1956</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1957" class="mis show_mis"><span class="n"><a href="#t1957">1957</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1958" class="mis show_mis"><span class="n"><a href="#t1958">1958</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1959" class="pln"><span class="n"><a href="#t1959">1959</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1960" class="run"><span class="n"><a href="#t1960">1960</a></span><span class="t"> <span class="key">def</span> <span class="nam">testHellishSuffix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1961" class="mis show_mis"><span class="n"><a href="#t1961">1961</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1962" class="pln"><span class="n"><a href="#t1962">1962</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1963" class="pln"><span class="n"><a href="#t1963">1963</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\n\\nb') ]]]</span> </span><span class="r"></span></p> - <p id="t1964" class="pln"><span class="n"><a href="#t1964">1964</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1965" class="pln"><span class="n"><a href="#t1965">1965</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1966" class="pln"><span class="n"><a href="#t1966">1966</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1967" class="pln"><span class="n"><a href="#t1967">1967</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\n\\nb') ]]]</span> </span><span class="r"></span></p> - <p id="t1968" class="pln"><span class="n"><a href="#t1968">1968</a></span><span class="t"><span class="str"> a /\\n*+([)]><</span> </span><span class="r"></span></p> - <p id="t1969" class="pln"><span class="n"><a href="#t1969">1969</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1970" class="pln"><span class="n"><a href="#t1970">1970</a></span><span class="t"><span class="str"> b /\\n*+([)]><</span> </span><span class="r"></span></p> - <p id="t1971" class="pln"><span class="n"><a href="#t1971">1971</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1972" class="pln"><span class="n"><a href="#t1972">1972</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1973" class="pln"><span class="n"><a href="#t1973">1973</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1974" class="mis show_mis"><span class="n"><a href="#t1974">1974</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1975" class="mis show_mis"><span class="n"><a href="#t1975">1975</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">r' /\n*+([)]><'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1976" class="mis show_mis"><span class="n"><a href="#t1976">1976</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1977" class="pln"><span class="n"><a href="#t1977">1977</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1978" class="run"><span class="n"><a href="#t1978">1978</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t1979" class="mis show_mis"><span class="n"><a href="#t1979">1979</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t1980" class="pln"><span class="n"><a href="#t1980">1980</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1981" class="pln"><span class="n"><a href="#t1981">1981</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> - <p id="t1982" class="pln"><span class="n"><a href="#t1982">1982</a></span><span class="t"><span class="str"> //[[[cog cog.outl(str(math.sqrt(2))[:12])]]]</span> </span><span class="r"></span></p> - <p id="t1983" class="pln"><span class="n"><a href="#t1983">1983</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1984" class="pln"><span class="n"><a href="#t1984">1984</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> - <p id="t1985" class="pln"><span class="n"><a href="#t1985">1985</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1986" class="pln"><span class="n"><a href="#t1986">1986</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1987" class="pln"><span class="n"><a href="#t1987">1987</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t1988" class="pln"><span class="n"><a href="#t1988">1988</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> - <p id="t1989" class="pln"><span class="n"><a href="#t1989">1989</a></span><span class="t"><span class="str"> //[[[cog cog.outl(str(math.sqrt(2))[:12])]]]</span> </span><span class="r"></span></p> - <p id="t1990" class="pln"><span class="n"><a href="#t1990">1990</a></span><span class="t"><span class="str"> 1.4142135623</span> </span><span class="r"></span></p> - <p id="t1991" class="pln"><span class="n"><a href="#t1991">1991</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t1992" class="pln"><span class="n"><a href="#t1992">1992</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> - <p id="t1993" class="pln"><span class="n"><a href="#t1993">1993</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t1994" class="pln"><span class="n"><a href="#t1994">1994</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t1995" class="pln"><span class="n"><a href="#t1995">1995</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t1996" class="mis show_mis"><span class="n"><a href="#t1996">1996</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1997" class="mis show_mis"><span class="n"><a href="#t1997">1997</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-p'</span><span class="op">,</span> <span class="str">'import math'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1998" class="mis show_mis"><span class="n"><a href="#t1998">1998</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t1999" class="pln"><span class="n"><a href="#t1999">1999</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2000" class="run"><span class="n"><a href="#t2000">2000</a></span><span class="t"> <span class="key">def</span> <span class="nam">testThreads</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2001" class="pln"><span class="n"><a href="#t2001">2001</a></span><span class="t"> <span class="com"># Test that the implicitly imported cog module is actually different for</span> </span><span class="r"></span></p> - <p id="t2002" class="pln"><span class="n"><a href="#t2002">2002</a></span><span class="t"> <span class="com"># different threads.</span> </span><span class="r"></span></p> - <p id="t2003" class="mis show_mis"><span class="n"><a href="#t2003">2003</a></span><span class="t"> <span class="nam">numthreads</span> <span class="op">=</span> <span class="num">20</span> </span><span class="r"></span></p> - <p id="t2004" class="pln"><span class="n"><a href="#t2004">2004</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2005" class="mis show_mis"><span class="n"><a href="#t2005">2005</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t2006" class="mis show_mis"><span class="n"><a href="#t2006">2006</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">numthreads</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2007" class="mis show_mis"><span class="n"><a href="#t2007">2007</a></span><span class="t"> <span class="nam">d</span><span class="op">[</span><span class="str">'f{}.cog'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">i</span><span class="op">)</span><span class="op">]</span> <span class="op">=</span> <span class="op">(</span> </span><span class="r"></span></p> - <p id="t2008" class="pln"><span class="n"><a href="#t2008">2008</a></span><span class="t"> <span class="str">"x\n"</span> <span class="op">*</span> <span class="nam">i</span> <span class="op">+</span> </span><span class="r"></span></p> - <p id="t2009" class="pln"><span class="n"><a href="#t2009">2009</a></span><span class="t"> <span class="str">"[[[cog\n"</span> <span class="op">+</span> </span><span class="r"></span></p> - <p id="t2010" class="pln"><span class="n"><a href="#t2010">2010</a></span><span class="t"> <span class="str">"assert cog.firstLineNum == int(FIRST) == {}\n"</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">i</span><span class="op">+</span><span class="num">1</span><span class="op">)</span> <span class="op">+</span> </span><span class="r"></span></p> - <p id="t2011" class="pln"><span class="n"><a href="#t2011">2011</a></span><span class="t"> <span class="str">"]]]\n"</span> <span class="op">+</span> </span><span class="r"></span></p> - <p id="t2012" class="pln"><span class="n"><a href="#t2012">2012</a></span><span class="t"> <span class="str">"[[[end]]]\n"</span> </span><span class="r"></span></p> - <p id="t2013" class="pln"><span class="n"><a href="#t2013">2013</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> - <p id="t2014" class="mis show_mis"><span class="n"><a href="#t2014">2014</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2015" class="pln"><span class="n"><a href="#t2015">2015</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2016" class="mis show_mis"><span class="n"><a href="#t2016">2016</a></span><span class="t"> <span class="nam">results</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2017" class="pln"><span class="n"><a href="#t2017">2017</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2018" class="mis show_mis"><span class="n"><a href="#t2018">2018</a></span><span class="t"> <span class="key">def</span> <span class="nam">thread_main</span><span class="op">(</span><span class="nam">num</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2019" class="mis show_mis"><span class="n"><a href="#t2019">2019</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2020" class="mis show_mis"><span class="n"><a href="#t2020">2020</a></span><span class="t"> <span class="nam">ret</span> <span class="op">=</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span> </span><span class="r"></span></p> - <p id="t2021" class="pln"><span class="n"><a href="#t2021">2021</a></span><span class="t"> <span class="op">[</span><span class="str">'cog.py'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'FIRST={}'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">num</span><span class="op">+</span><span class="num">1</span><span class="op">)</span><span class="op">,</span> <span class="str">'f{}.cog'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">num</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2022" class="pln"><span class="n"><a href="#t2022">2022</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> - <p id="t2023" class="mis show_mis"><span class="n"><a href="#t2023">2023</a></span><span class="t"> <span class="key">assert</span> <span class="nam">ret</span> <span class="op">==</span> <span class="num">0</span> </span><span class="r"></span></p> - <p id="t2024" class="exc show_exc"><span class="n"><a href="#t2024">2024</a></span><span class="t"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">exc</span><span class="op">:</span> <span class="com"># pragma: no cover (only happens on test failure)</span> </span><span class="r"></span></p> - <p id="t2025" class="exc show_exc"><span class="n"><a href="#t2025">2025</a></span><span class="t"> <span class="nam">results</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">exc</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2026" class="pln"><span class="n"><a href="#t2026">2026</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2027" class="mis show_mis"><span class="n"><a href="#t2027">2027</a></span><span class="t"> <span class="nam">results</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="key">None</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2028" class="pln"><span class="n"><a href="#t2028">2028</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2029" class="mis show_mis"><span class="n"><a href="#t2029">2029</a></span><span class="t"> <span class="nam">ts</span> <span class="op">=</span> <span class="op">[</span><span class="nam">threading</span><span class="op">.</span><span class="nam">Thread</span><span class="op">(</span><span class="nam">target</span><span class="op">=</span><span class="nam">thread_main</span><span class="op">,</span> <span class="nam">args</span><span class="op">=</span><span class="op">(</span><span class="nam">i</span><span class="op">,</span><span class="op">)</span><span class="op">)</span> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">numthreads</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2030" class="mis show_mis"><span class="n"><a href="#t2030">2030</a></span><span class="t"> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">ts</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2031" class="mis show_mis"><span class="n"><a href="#t2031">2031</a></span><span class="t"> <span class="nam">t</span><span class="op">.</span><span class="nam">start</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2032" class="mis show_mis"><span class="n"><a href="#t2032">2032</a></span><span class="t"> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">ts</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2033" class="mis show_mis"><span class="n"><a href="#t2033">2033</a></span><span class="t"> <span class="nam">t</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2034" class="mis show_mis"><span class="n"><a href="#t2034">2034</a></span><span class="t"> <span class="key">assert</span> <span class="nam">results</span> <span class="op">==</span> <span class="op">[</span><span class="key">None</span><span class="op">]</span> <span class="op">*</span> <span class="nam">numthreads</span> </span><span class="r"></span></p> - <p id="t2035" class="pln"><span class="n"><a href="#t2035">2035</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2036" class="pln"><span class="n"><a href="#t2036">2036</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2037" class="run"><span class="n"><a href="#t2037">2037</a></span><span class="t"><span class="key">class</span> <span class="nam">WritabilityTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2038" class="pln"><span class="n"><a href="#t2038">2038</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2039" class="run"><span class="n"><a href="#t2039">2039</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2040" class="pln"><span class="n"><a href="#t2040">2040</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2041" class="pln"><span class="n"><a href="#t2041">2041</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2042" class="pln"><span class="n"><a href="#t2042">2042</a></span><span class="t"><span class="str"> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span> </span><span class="r"></span></p> - <p id="t2043" class="pln"><span class="n"><a href="#t2043">2043</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t2044" class="pln"><span class="n"><a href="#t2044">2044</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2045" class="pln"><span class="n"><a href="#t2045">2045</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2046" class="pln"><span class="n"><a href="#t2046">2046</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2047" class="pln"><span class="n"><a href="#t2047">2047</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2048" class="pln"><span class="n"><a href="#t2048">2048</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2049" class="pln"><span class="n"><a href="#t2049">2049</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2050" class="pln"><span class="n"><a href="#t2050">2050</a></span><span class="t"><span class="str"> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span> </span><span class="r"></span></p> - <p id="t2051" class="pln"><span class="n"><a href="#t2051">2051</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t2052" class="pln"><span class="n"><a href="#t2052">2052</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2053" class="pln"><span class="n"><a href="#t2053">2053</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t2054" class="pln"><span class="n"><a href="#t2054">2054</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t2055" class="pln"><span class="n"><a href="#t2055">2055</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t2056" class="pln"><span class="n"><a href="#t2056">2056</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2057" class="pln"><span class="n"><a href="#t2057">2057</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2058" class="pln"><span class="n"><a href="#t2058">2058</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2059" class="pln"><span class="n"><a href="#t2059">2059</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2060" class="exc show_exc"><span class="n"><a href="#t2060">2060</a></span><span class="t"> <span class="key">if</span> <span class="nam">os</span><span class="op">.</span><span class="nam">name</span> <span class="op">==</span> <span class="str">'nt'</span><span class="op">:</span> <span class="com">#pragma: no cover</span> </span><span class="r"></span></p> - <p id="t2061" class="pln"><span class="n"><a href="#t2061">2061</a></span><span class="t"> <span class="com"># for Windows</span> </span><span class="r"></span></p> - <p id="t2062" class="exc show_exc"><span class="n"><a href="#t2062">2062</a></span><span class="t"> <span class="nam">cmd_w_args</span> <span class="op">=</span> <span class="str">'attrib -R %s'</span> </span><span class="r"></span></p> - <p id="t2063" class="exc show_exc"><span class="n"><a href="#t2063">2063</a></span><span class="t"> <span class="nam">cmd_w_asterisk</span> <span class="op">=</span> <span class="str">'attrib -R *'</span> </span><span class="r"></span></p> - <p id="t2064" class="exc show_exc"><span class="n"><a href="#t2064">2064</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> <span class="com">#pragma: no cover</span> </span><span class="r"></span></p> - <p id="t2065" class="pln"><span class="n"><a href="#t2065">2065</a></span><span class="t"> <span class="com"># for unix-like</span> </span><span class="r"></span></p> - <p id="t2066" class="exc show_exc"><span class="n"><a href="#t2066">2066</a></span><span class="t"> <span class="nam">cmd_w_args</span> <span class="op">=</span> <span class="str">'chmod +w %s'</span> </span><span class="r"></span></p> - <p id="t2067" class="exc show_exc"><span class="n"><a href="#t2067">2067</a></span><span class="t"> <span class="nam">cmd_w_asterisk</span> <span class="op">=</span> <span class="str">'chmod +w *'</span> </span><span class="r"></span></p> - <p id="t2068" class="pln"><span class="n"><a href="#t2068">2068</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2069" class="run"><span class="n"><a href="#t2069">2069</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2070" class="mis show_mis"><span class="n"><a href="#t2070">2070</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">WritabilityTests</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2071" class="mis show_mis"><span class="n"><a href="#t2071">2071</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2072" class="mis show_mis"><span class="n"><a href="#t2072">2072</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2073" class="mis show_mis"><span class="n"><a href="#t2073">2073</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chmod</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">stat</span><span class="op">.</span><span class="nam">S_IREAD</span><span class="op">)</span> <span class="com"># Make the file readonly.</span> </span><span class="r"></span></p> - <p id="t2074" class="mis show_mis"><span class="n"><a href="#t2074">2074</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2075" class="pln"><span class="n"><a href="#t2075">2075</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2076" class="run"><span class="n"><a href="#t2076">2076</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2077" class="mis show_mis"><span class="n"><a href="#t2077">2077</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chmod</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">stat</span><span class="op">.</span><span class="nam">S_IWRITE</span><span class="op">)</span> <span class="com"># Make the file writable again.</span> </span><span class="r"></span></p> - <p id="t2078" class="mis show_mis"><span class="n"><a href="#t2078">2078</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">WritabilityTests</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2079" class="pln"><span class="n"><a href="#t2079">2079</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2080" class="run"><span class="n"><a href="#t2080">2080</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyNoCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2081" class="mis show_mis"><span class="n"><a href="#t2081">2081</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^Can't overwrite test.cog$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2082" class="mis show_mis"><span class="n"><a href="#t2082">2082</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2083" class="mis show_mis"><span class="n"><a href="#t2083">2083</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2084" class="pln"><span class="n"><a href="#t2084">2084</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2085" class="run"><span class="n"><a href="#t2085">2085</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2086" class="mis show_mis"><span class="n"><a href="#t2086">2086</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cmd_w_args</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2087" class="mis show_mis"><span class="n"><a href="#t2087">2087</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2088" class="mis show_mis"><span class="n"><a href="#t2088">2088</a></span><span class="t"> <span class="key">assert</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2089" class="pln"><span class="n"><a href="#t2089">2089</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2090" class="run"><span class="n"><a href="#t2090">2090</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithCommandWithNoSlot</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2091" class="mis show_mis"><span class="n"><a href="#t2091">2091</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cmd_w_asterisk</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2092" class="mis show_mis"><span class="n"><a href="#t2092">2092</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2093" class="mis show_mis"><span class="n"><a href="#t2093">2093</a></span><span class="t"> <span class="key">assert</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2094" class="pln"><span class="n"><a href="#t2094">2094</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2095" class="run"><span class="n"><a href="#t2095">2095</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithIneffectualCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2096" class="mis show_mis"><span class="n"><a href="#t2096">2096</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^Couldn't make test.cog writable$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2097" class="mis show_mis"><span class="n"><a href="#t2097">2097</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="str">'echo %s'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2098" class="mis show_mis"><span class="n"><a href="#t2098">2098</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2099" class="pln"><span class="n"><a href="#t2099">2099</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2100" class="pln"><span class="n"><a href="#t2100">2100</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2101" class="run"><span class="n"><a href="#t2101">2101</a></span><span class="t"><span class="key">class</span> <span class="nam">ChecksumTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2102" class="pln"><span class="n"><a href="#t2102">2102</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2103" class="run"><span class="n"><a href="#t2103">2103</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCreateChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2104" class="mis show_mis"><span class="n"><a href="#t2104">2104</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2105" class="pln"><span class="n"><a href="#t2105">2105</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2106" class="pln"><span class="n"><a href="#t2106">2106</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2107" class="pln"><span class="n"><a href="#t2107">2107</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> - <p id="t2108" class="pln"><span class="n"><a href="#t2108">2108</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2109" class="pln"><span class="n"><a href="#t2109">2109</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t2110" class="pln"><span class="n"><a href="#t2110">2110</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2111" class="pln"><span class="n"><a href="#t2111">2111</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> - <p id="t2112" class="pln"><span class="n"><a href="#t2112">2112</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2113" class="pln"><span class="n"><a href="#t2113">2113</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2114" class="pln"><span class="n"><a href="#t2114">2114</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2115" class="pln"><span class="n"><a href="#t2115">2115</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2116" class="pln"><span class="n"><a href="#t2116">2116</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> - <p id="t2117" class="pln"><span class="n"><a href="#t2117">2117</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2118" class="pln"><span class="n"><a href="#t2118">2118</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t2119" class="pln"><span class="n"><a href="#t2119">2119</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span> </span><span class="r"></span></p> - <p id="t2120" class="pln"><span class="n"><a href="#t2120">2120</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> - <p id="t2121" class="pln"><span class="n"><a href="#t2121">2121</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2122" class="pln"><span class="n"><a href="#t2122">2122</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2123" class="pln"><span class="n"><a href="#t2123">2123</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2124" class="mis show_mis"><span class="n"><a href="#t2124">2124</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2125" class="mis show_mis"><span class="n"><a href="#t2125">2125</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2126" class="mis show_mis"><span class="n"><a href="#t2126">2126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2127" class="pln"><span class="n"><a href="#t2127">2127</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2128" class="run"><span class="n"><a href="#t2128">2128</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCheckChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2129" class="mis show_mis"><span class="n"><a href="#t2129">2129</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2130" class="pln"><span class="n"><a href="#t2130">2130</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2131" class="pln"><span class="n"><a href="#t2131">2131</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2132" class="pln"><span class="n"><a href="#t2132">2132</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2133" class="pln"><span class="n"><a href="#t2133">2133</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2134" class="pln"><span class="n"><a href="#t2134">2134</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2135" class="pln"><span class="n"><a href="#t2135">2135</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2136" class="pln"><span class="n"><a href="#t2136">2136</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t2137" class="pln"><span class="n"><a href="#t2137">2137</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span> </span><span class="r"></span></p> - <p id="t2138" class="pln"><span class="n"><a href="#t2138">2138</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2139" class="pln"><span class="n"><a href="#t2139">2139</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2140" class="pln"><span class="n"><a href="#t2140">2140</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2141" class="pln"><span class="n"><a href="#t2141">2141</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2142" class="pln"><span class="n"><a href="#t2142">2142</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2143" class="pln"><span class="n"><a href="#t2143">2143</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2144" class="pln"><span class="n"><a href="#t2144">2144</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2145" class="pln"><span class="n"><a href="#t2145">2145</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2146" class="pln"><span class="n"><a href="#t2146">2146</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2147" class="pln"><span class="n"><a href="#t2147">2147</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2148" class="pln"><span class="n"><a href="#t2148">2148</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t2149" class="pln"><span class="n"><a href="#t2149">2149</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2150" class="pln"><span class="n"><a href="#t2150">2150</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2151" class="pln"><span class="n"><a href="#t2151">2151</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2152" class="pln"><span class="n"><a href="#t2152">2152</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2153" class="mis show_mis"><span class="n"><a href="#t2153">2153</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2154" class="mis show_mis"><span class="n"><a href="#t2154">2154</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2155" class="mis show_mis"><span class="n"><a href="#t2155">2155</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2156" class="pln"><span class="n"><a href="#t2156">2156</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2157" class="run"><span class="n"><a href="#t2157">2157</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRemoveChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2158" class="mis show_mis"><span class="n"><a href="#t2158">2158</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2159" class="pln"><span class="n"><a href="#t2159">2159</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2160" class="pln"><span class="n"><a href="#t2160">2160</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2161" class="pln"><span class="n"><a href="#t2161">2161</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2162" class="pln"><span class="n"><a href="#t2162">2162</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2163" class="pln"><span class="n"><a href="#t2163">2163</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2164" class="pln"><span class="n"><a href="#t2164">2164</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2165" class="pln"><span class="n"><a href="#t2165">2165</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> - <p id="t2166" class="pln"><span class="n"><a href="#t2166">2166</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893) fooey</span> </span><span class="r"></span></p> - <p id="t2167" class="pln"><span class="n"><a href="#t2167">2167</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2168" class="pln"><span class="n"><a href="#t2168">2168</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2169" class="pln"><span class="n"><a href="#t2169">2169</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2170" class="pln"><span class="n"><a href="#t2170">2170</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2171" class="pln"><span class="n"><a href="#t2171">2171</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2172" class="pln"><span class="n"><a href="#t2172">2172</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2173" class="pln"><span class="n"><a href="#t2173">2173</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2174" class="pln"><span class="n"><a href="#t2174">2174</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2175" class="pln"><span class="n"><a href="#t2175">2175</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2176" class="pln"><span class="n"><a href="#t2176">2176</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2177" class="pln"><span class="n"><a href="#t2177">2177</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t2178" class="pln"><span class="n"><a href="#t2178">2178</a></span><span class="t"><span class="str"> //[[[end]]] fooey</span> </span><span class="r"></span></p> - <p id="t2179" class="pln"><span class="n"><a href="#t2179">2179</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2180" class="pln"><span class="n"><a href="#t2180">2180</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2181" class="pln"><span class="n"><a href="#t2181">2181</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2182" class="mis show_mis"><span class="n"><a href="#t2182">2182</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2183" class="mis show_mis"><span class="n"><a href="#t2183">2183</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2184" class="mis show_mis"><span class="n"><a href="#t2184">2184</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2185" class="pln"><span class="n"><a href="#t2185">2185</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2186" class="run"><span class="n"><a href="#t2186">2186</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTamperedChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2187" class="mis show_mis"><span class="n"><a href="#t2187">2187</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2188" class="pln"><span class="n"><a href="#t2188">2188</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2189" class="pln"><span class="n"><a href="#t2189">2189</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2190" class="pln"><span class="n"><a href="#t2190">2190</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2191" class="pln"><span class="n"><a href="#t2191">2191</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2192" class="pln"><span class="n"><a href="#t2192">2192</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2193" class="pln"><span class="n"><a href="#t2193">2193</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2194" class="pln"><span class="n"><a href="#t2194">2194</a></span><span class="t"><span class="str"> Xhis line was newly</span> </span><span class="r"></span></p> - <p id="t2195" class="pln"><span class="n"><a href="#t2195">2195</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2196" class="pln"><span class="n"><a href="#t2196">2196</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t2197" class="pln"><span class="n"><a href="#t2197">2197</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2198" class="pln"><span class="n"><a href="#t2198">2198</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2199" class="pln"><span class="n"><a href="#t2199">2199</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2200" class="pln"><span class="n"><a href="#t2200">2200</a></span><span class="t"> <span class="str">'cog2.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2201" class="pln"><span class="n"><a href="#t2201">2201</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2202" class="pln"><span class="n"><a href="#t2202">2202</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2203" class="pln"><span class="n"><a href="#t2203">2203</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2204" class="pln"><span class="n"><a href="#t2204">2204</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2205" class="pln"><span class="n"><a href="#t2205">2205</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2206" class="pln"><span class="n"><a href="#t2206">2206</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2207" class="pln"><span class="n"><a href="#t2207">2207</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2208" class="pln"><span class="n"><a href="#t2208">2208</a></span><span class="t"><span class="str"> blah blah!</span> </span><span class="r"></span></p> - <p id="t2209" class="pln"><span class="n"><a href="#t2209">2209</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2210" class="pln"><span class="n"><a href="#t2210">2210</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2211" class="pln"><span class="n"><a href="#t2211">2211</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2212" class="pln"><span class="n"><a href="#t2212">2212</a></span><span class="t"> <span class="str">'cog3.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2213" class="pln"><span class="n"><a href="#t2213">2213</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2214" class="pln"><span class="n"><a href="#t2214">2214</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2215" class="pln"><span class="n"><a href="#t2215">2215</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2216" class="pln"><span class="n"><a href="#t2216">2216</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2217" class="pln"><span class="n"><a href="#t2217">2217</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2218" class="pln"><span class="n"><a href="#t2218">2218</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2219" class="pln"><span class="n"><a href="#t2219">2219</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2220" class="pln"><span class="n"><a href="#t2220">2220</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2221" class="pln"><span class="n"><a href="#t2221">2221</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t2222" class="pln"><span class="n"><a href="#t2222">2222</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2223" class="pln"><span class="n"><a href="#t2223">2223</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2224" class="pln"><span class="n"><a href="#t2224">2224</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2225" class="pln"><span class="n"><a href="#t2225">2225</a></span><span class="t"> <span class="str">'cog4.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2226" class="pln"><span class="n"><a href="#t2226">2226</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2227" class="pln"><span class="n"><a href="#t2227">2227</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2228" class="pln"><span class="n"><a href="#t2228">2228</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2229" class="pln"><span class="n"><a href="#t2229">2229</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2230" class="pln"><span class="n"><a href="#t2230">2230</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2231" class="pln"><span class="n"><a href="#t2231">2231</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2232" class="pln"><span class="n"><a href="#t2232">2232</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2233" class="pln"><span class="n"><a href="#t2233">2233</a></span><span class="t"><span class="str"> blah blah..</span> </span><span class="r"></span></p> - <p id="t2234" class="pln"><span class="n"><a href="#t2234">2234</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2235" class="pln"><span class="n"><a href="#t2235">2235</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2236" class="pln"><span class="n"><a href="#t2236">2236</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2237" class="pln"><span class="n"><a href="#t2237">2237</a></span><span class="t"> <span class="str">'cog5.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2238" class="pln"><span class="n"><a href="#t2238">2238</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2239" class="pln"><span class="n"><a href="#t2239">2239</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2240" class="pln"><span class="n"><a href="#t2240">2240</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2241" class="pln"><span class="n"><a href="#t2241">2241</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2242" class="pln"><span class="n"><a href="#t2242">2242</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2243" class="pln"><span class="n"><a href="#t2243">2243</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> - <p id="t2244" class="pln"><span class="n"><a href="#t2244">2244</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> - <p id="t2245" class="pln"><span class="n"><a href="#t2245">2245</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> - <p id="t2246" class="pln"><span class="n"><a href="#t2246">2246</a></span><span class="t"><span class="str"> extra</span> </span><span class="r"></span></p> - <p id="t2247" class="pln"><span class="n"><a href="#t2247">2247</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2248" class="pln"><span class="n"><a href="#t2248">2248</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2249" class="pln"><span class="n"><a href="#t2249">2249</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2250" class="pln"><span class="n"><a href="#t2250">2250</a></span><span class="t"> <span class="str">'cog6.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2251" class="pln"><span class="n"><a href="#t2251">2251</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2252" class="pln"><span class="n"><a href="#t2252">2252</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> - <p id="t2253" class="pln"><span class="n"><a href="#t2253">2253</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> - <p id="t2254" class="pln"><span class="n"><a href="#t2254">2254</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> - <p id="t2255" class="pln"><span class="n"><a href="#t2255">2255</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2256" class="pln"><span class="n"><a href="#t2256">2256</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> - <p id="t2257" class="pln"><span class="n"><a href="#t2257">2257</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2258" class="pln"><span class="n"><a href="#t2258">2258</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2259" class="pln"><span class="n"><a href="#t2259">2259</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2260" class="mis show_mis"><span class="n"><a href="#t2260">2260</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2261" class="mis show_mis"><span class="n"><a href="#t2261">2261</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2262" class="pln"><span class="n"><a href="#t2262">2262</a></span><span class="t"> <span class="str">r"^cog1.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2263" class="mis show_mis"><span class="n"><a href="#t2263">2263</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog1.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2264" class="mis show_mis"><span class="n"><a href="#t2264">2264</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2265" class="pln"><span class="n"><a href="#t2265">2265</a></span><span class="t"> <span class="str">r"^cog2.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2266" class="mis show_mis"><span class="n"><a href="#t2266">2266</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog2.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2267" class="mis show_mis"><span class="n"><a href="#t2267">2267</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2268" class="pln"><span class="n"><a href="#t2268">2268</a></span><span class="t"> <span class="str">r"^cog3.txt\(10\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2269" class="mis show_mis"><span class="n"><a href="#t2269">2269</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog3.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2270" class="mis show_mis"><span class="n"><a href="#t2270">2270</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2271" class="pln"><span class="n"><a href="#t2271">2271</a></span><span class="t"> <span class="str">r"^cog4.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2272" class="mis show_mis"><span class="n"><a href="#t2272">2272</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog4.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2273" class="mis show_mis"><span class="n"><a href="#t2273">2273</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2274" class="pln"><span class="n"><a href="#t2274">2274</a></span><span class="t"> <span class="str">r"^cog5.txt\(10\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2275" class="mis show_mis"><span class="n"><a href="#t2275">2275</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog5.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2276" class="mis show_mis"><span class="n"><a href="#t2276">2276</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2277" class="pln"><span class="n"><a href="#t2277">2277</a></span><span class="t"> <span class="str">r"^cog6.txt\(6\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2278" class="mis show_mis"><span class="n"><a href="#t2278">2278</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog6.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2279" class="pln"><span class="n"><a href="#t2279">2279</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2280" class="run"><span class="n"><a href="#t2280">2280</a></span><span class="t"> <span class="key">def</span> <span class="nam">testArgvIsntModified</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2281" class="mis show_mis"><span class="n"><a href="#t2281">2281</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-v'</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2282" class="mis show_mis"><span class="n"><a href="#t2282">2282</a></span><span class="t"> <span class="nam">orig_argv</span> <span class="op">=</span> <span class="nam">argv</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2283" class="mis show_mis"><span class="n"><a href="#t2283">2283</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2284" class="mis show_mis"><span class="n"><a href="#t2284">2284</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">argv</span><span class="op">,</span> <span class="nam">orig_argv</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2285" class="pln"><span class="n"><a href="#t2285">2285</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2286" class="pln"><span class="n"><a href="#t2286">2286</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2287" class="run"><span class="n"><a href="#t2287">2287</a></span><span class="t"><span class="key">class</span> <span class="nam">CustomMarkerTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2288" class="pln"><span class="n"><a href="#t2288">2288</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2289" class="run"><span class="n"><a href="#t2289">2289</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCustomerMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2290" class="mis show_mis"><span class="n"><a href="#t2290">2290</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2291" class="pln"><span class="n"><a href="#t2291">2291</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2292" class="pln"><span class="n"><a href="#t2292">2292</a></span><span class="t"><span class="str"> //{{</span> </span><span class="r"></span></p> - <p id="t2293" class="pln"><span class="n"><a href="#t2293">2293</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2294" class="pln"><span class="n"><a href="#t2294">2294</a></span><span class="t"><span class="str"> //}}</span> </span><span class="r"></span></p> - <p id="t2295" class="pln"><span class="n"><a href="#t2295">2295</a></span><span class="t"><span class="str"> //{{end}}</span> </span><span class="r"></span></p> - <p id="t2296" class="pln"><span class="n"><a href="#t2296">2296</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2297" class="pln"><span class="n"><a href="#t2297">2297</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2298" class="pln"><span class="n"><a href="#t2298">2298</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2299" class="pln"><span class="n"><a href="#t2299">2299</a></span><span class="t"><span class="str"> //{{</span> </span><span class="r"></span></p> - <p id="t2300" class="pln"><span class="n"><a href="#t2300">2300</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2301" class="pln"><span class="n"><a href="#t2301">2301</a></span><span class="t"><span class="str"> //}}</span> </span><span class="r"></span></p> - <p id="t2302" class="pln"><span class="n"><a href="#t2302">2302</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> - <p id="t2303" class="pln"><span class="n"><a href="#t2303">2303</a></span><span class="t"><span class="str"> //{{end}}</span> </span><span class="r"></span></p> - <p id="t2304" class="pln"><span class="n"><a href="#t2304">2304</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2305" class="pln"><span class="n"><a href="#t2305">2305</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2306" class="pln"><span class="n"><a href="#t2306">2306</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2307" class="mis show_mis"><span class="n"><a href="#t2307">2307</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2308" class="mis show_mis"><span class="n"><a href="#t2308">2308</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> - <p id="t2309" class="pln"><span class="n"><a href="#t2309">2309</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2310" class="pln"><span class="n"><a href="#t2310">2310</a></span><span class="t"> <span class="str">'--markers={{ }} {{end}}'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2311" class="pln"><span class="n"><a href="#t2311">2311</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> - <p id="t2312" class="pln"><span class="n"><a href="#t2312">2312</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2313" class="mis show_mis"><span class="n"><a href="#t2313">2313</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2314" class="pln"><span class="n"><a href="#t2314">2314</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2315" class="run"><span class="n"><a href="#t2315">2315</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrulyWackyMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2316" class="pln"><span class="n"><a href="#t2316">2316</a></span><span class="t"> <span class="com"># Make sure the markers are properly re-escaped.</span> </span><span class="r"></span></p> - <p id="t2317" class="mis show_mis"><span class="n"><a href="#t2317">2317</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2318" class="pln"><span class="n"><a href="#t2318">2318</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2319" class="pln"><span class="n"><a href="#t2319">2319</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> - <p id="t2320" class="pln"><span class="n"><a href="#t2320">2320</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2321" class="pln"><span class="n"><a href="#t2321">2321</a></span><span class="t"><span class="str"> //**)</span> </span><span class="r"></span></p> - <p id="t2322" class="pln"><span class="n"><a href="#t2322">2322</a></span><span class="t"><span class="str"> //**(end)**</span> </span><span class="r"></span></p> - <p id="t2323" class="pln"><span class="n"><a href="#t2323">2323</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2324" class="pln"><span class="n"><a href="#t2324">2324</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2325" class="pln"><span class="n"><a href="#t2325">2325</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2326" class="pln"><span class="n"><a href="#t2326">2326</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> - <p id="t2327" class="pln"><span class="n"><a href="#t2327">2327</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2328" class="pln"><span class="n"><a href="#t2328">2328</a></span><span class="t"><span class="str"> //**)</span> </span><span class="r"></span></p> - <p id="t2329" class="pln"><span class="n"><a href="#t2329">2329</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> - <p id="t2330" class="pln"><span class="n"><a href="#t2330">2330</a></span><span class="t"><span class="str"> //**(end)**</span> </span><span class="r"></span></p> - <p id="t2331" class="pln"><span class="n"><a href="#t2331">2331</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2332" class="pln"><span class="n"><a href="#t2332">2332</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2333" class="pln"><span class="n"><a href="#t2333">2333</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2334" class="mis show_mis"><span class="n"><a href="#t2334">2334</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2335" class="mis show_mis"><span class="n"><a href="#t2335">2335</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> - <p id="t2336" class="pln"><span class="n"><a href="#t2336">2336</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2337" class="pln"><span class="n"><a href="#t2337">2337</a></span><span class="t"> <span class="str">'--markers=**( **) **(end)**'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2338" class="pln"><span class="n"><a href="#t2338">2338</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> - <p id="t2339" class="pln"><span class="n"><a href="#t2339">2339</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2340" class="mis show_mis"><span class="n"><a href="#t2340">2340</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2341" class="pln"><span class="n"><a href="#t2341">2341</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2342" class="run"><span class="n"><a href="#t2342">2342</a></span><span class="t"> <span class="key">def</span> <span class="nam">testChangeJustOneMarker</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2343" class="mis show_mis"><span class="n"><a href="#t2343">2343</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2344" class="pln"><span class="n"><a href="#t2344">2344</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2345" class="pln"><span class="n"><a href="#t2345">2345</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> - <p id="t2346" class="pln"><span class="n"><a href="#t2346">2346</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2347" class="pln"><span class="n"><a href="#t2347">2347</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2348" class="pln"><span class="n"><a href="#t2348">2348</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2349" class="pln"><span class="n"><a href="#t2349">2349</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2350" class="pln"><span class="n"><a href="#t2350">2350</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2351" class="pln"><span class="n"><a href="#t2351">2351</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2352" class="pln"><span class="n"><a href="#t2352">2352</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> - <p id="t2353" class="pln"><span class="n"><a href="#t2353">2353</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> - <p id="t2354" class="pln"><span class="n"><a href="#t2354">2354</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2355" class="pln"><span class="n"><a href="#t2355">2355</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> - <p id="t2356" class="pln"><span class="n"><a href="#t2356">2356</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2357" class="pln"><span class="n"><a href="#t2357">2357</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2358" class="pln"><span class="n"><a href="#t2358">2358</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2359" class="pln"><span class="n"><a href="#t2359">2359</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2360" class="mis show_mis"><span class="n"><a href="#t2360">2360</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2361" class="mis show_mis"><span class="n"><a href="#t2361">2361</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> - <p id="t2362" class="pln"><span class="n"><a href="#t2362">2362</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2363" class="pln"><span class="n"><a href="#t2363">2363</a></span><span class="t"> <span class="str">'--markers=**( ]]] [[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2364" class="pln"><span class="n"><a href="#t2364">2364</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> - <p id="t2365" class="pln"><span class="n"><a href="#t2365">2365</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2366" class="mis show_mis"><span class="n"><a href="#t2366">2366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2367" class="pln"><span class="n"><a href="#t2367">2367</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2368" class="pln"><span class="n"><a href="#t2368">2368</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2369" class="run"><span class="n"><a href="#t2369">2369</a></span><span class="t"><span class="key">class</span> <span class="nam">BlakeTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2370" class="pln"><span class="n"><a href="#t2370">2370</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2371" class="pln"><span class="n"><a href="#t2371">2371</a></span><span class="t"> <span class="com"># Blake Winton's contributions.</span> </span><span class="r"></span></p> - <p id="t2372" class="run"><span class="n"><a href="#t2372">2372</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDeleteCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2373" class="pln"><span class="n"><a href="#t2373">2373</a></span><span class="t"> <span class="com"># -o sets the output file.</span> </span><span class="r"></span></p> - <p id="t2374" class="mis show_mis"><span class="n"><a href="#t2374">2374</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2375" class="pln"><span class="n"><a href="#t2375">2375</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2376" class="pln"><span class="n"><a href="#t2376">2376</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t2377" class="pln"><span class="n"><a href="#t2377">2377</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2378" class="pln"><span class="n"><a href="#t2378">2378</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> - <p id="t2379" class="pln"><span class="n"><a href="#t2379">2379</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t2380" class="pln"><span class="n"><a href="#t2380">2380</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t2381" class="pln"><span class="n"><a href="#t2381">2381</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2382" class="pln"><span class="n"><a href="#t2382">2382</a></span><span class="t"><span class="str"> Some Sample Code Here</span> </span><span class="r"></span></p> - <p id="t2383" class="pln"><span class="n"><a href="#t2383">2383</a></span><span class="t"><span class="str"> //[[[end]]]Data Data</span> </span><span class="r"></span></p> - <p id="t2384" class="pln"><span class="n"><a href="#t2384">2384</a></span><span class="t"><span class="str"> And Some More</span> </span><span class="r"></span></p> - <p id="t2385" class="pln"><span class="n"><a href="#t2385">2385</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2386" class="pln"><span class="n"><a href="#t2386">2386</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2387" class="pln"><span class="n"><a href="#t2387">2387</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2388" class="pln"><span class="n"><a href="#t2388">2388</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t2389" class="pln"><span class="n"><a href="#t2389">2389</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> - <p id="t2390" class="pln"><span class="n"><a href="#t2390">2390</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> - <p id="t2391" class="pln"><span class="n"><a href="#t2391">2391</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> - <p id="t2392" class="pln"><span class="n"><a href="#t2392">2392</a></span><span class="t"><span class="str"> And Some More</span> </span><span class="r"></span></p> - <p id="t2393" class="pln"><span class="n"><a href="#t2393">2393</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2394" class="pln"><span class="n"><a href="#t2394">2394</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2395" class="pln"><span class="n"><a href="#t2395">2395</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2396" class="mis show_mis"><span class="n"><a href="#t2396">2396</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2397" class="mis show_mis"><span class="n"><a href="#t2397">2397</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-d'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2398" class="mis show_mis"><span class="n"><a href="#t2398">2398</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2399" class="pln"><span class="n"><a href="#t2399">2399</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2400" class="run"><span class="n"><a href="#t2400">2400</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDeleteCodeWithDashRFails</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2401" class="mis show_mis"><span class="n"><a href="#t2401">2401</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2402" class="pln"><span class="n"><a href="#t2402">2402</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2403" class="pln"><span class="n"><a href="#t2403">2403</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t2404" class="pln"><span class="n"><a href="#t2404">2404</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t2405" class="pln"><span class="n"><a href="#t2405">2405</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2406" class="pln"><span class="n"><a href="#t2406">2406</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2407" class="mis show_mis"><span class="n"><a href="#t2407">2407</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2408" class="mis show_mis"><span class="n"><a href="#t2408">2408</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -d with -r \(or you would delete all your source!\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2409" class="mis show_mis"><span class="n"><a href="#t2409">2409</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-d'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2410" class="pln"><span class="n"><a href="#t2410">2410</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2411" class="run"><span class="n"><a href="#t2411">2411</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSettingGlobals</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2412" class="pln"><span class="n"><a href="#t2412">2412</a></span><span class="t"> <span class="com"># Blake Winton contributed a way to set the globals that will be used in</span> </span><span class="r"></span></p> - <p id="t2413" class="pln"><span class="n"><a href="#t2413">2413</a></span><span class="t"> <span class="com"># processFile().</span> </span><span class="r"></span></p> - <p id="t2414" class="mis show_mis"><span class="n"><a href="#t2414">2414</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2415" class="pln"><span class="n"><a href="#t2415">2415</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2416" class="pln"><span class="n"><a href="#t2416">2416</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t2417" class="pln"><span class="n"><a href="#t2417">2417</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2418" class="pln"><span class="n"><a href="#t2418">2418</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> - <p id="t2419" class="pln"><span class="n"><a href="#t2419">2419</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> - <p id="t2420" class="pln"><span class="n"><a href="#t2420">2420</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2421" class="pln"><span class="n"><a href="#t2421">2421</a></span><span class="t"><span class="str"> Some Sample Code Here</span> </span><span class="r"></span></p> - <p id="t2422" class="pln"><span class="n"><a href="#t2422">2422</a></span><span class="t"><span class="str"> //[[[end]]]"""</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2423" class="pln"><span class="n"><a href="#t2423">2423</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2424" class="pln"><span class="n"><a href="#t2424">2424</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2425" class="pln"><span class="n"><a href="#t2425">2425</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> - <p id="t2426" class="pln"><span class="n"><a href="#t2426">2426</a></span><span class="t"><span class="str"> void DoBlake();</span> </span><span class="r"></span></p> - <p id="t2427" class="pln"><span class="n"><a href="#t2427">2427</a></span><span class="t"><span class="str"> void DoWinton();</span> </span><span class="r"></span></p> - <p id="t2428" class="pln"><span class="n"><a href="#t2428">2428</a></span><span class="t"><span class="str"> void DoContribution();</span> </span><span class="r"></span></p> - <p id="t2429" class="pln"><span class="n"><a href="#t2429">2429</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2430" class="pln"><span class="n"><a href="#t2430">2430</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2431" class="pln"><span class="n"><a href="#t2431">2431</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2432" class="mis show_mis"><span class="n"><a href="#t2432">2432</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2433" class="mis show_mis"><span class="n"><a href="#t2433">2433</a></span><span class="t"> <span class="nam">globals</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> - <p id="t2434" class="mis show_mis"><span class="n"><a href="#t2434">2434</a></span><span class="t"> <span class="nam">globals</span><span class="op">[</span><span class="str">'fnames'</span><span class="op">]</span> <span class="op">=</span> <span class="op">[</span><span class="str">'DoBlake'</span><span class="op">,</span> <span class="str">'DoWinton'</span><span class="op">,</span> <span class="str">'DoContribution'</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t2435" class="mis show_mis"><span class="n"><a href="#t2435">2435</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> - <p id="t2436" class="mis show_mis"><span class="n"><a href="#t2436">2436</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.cogged'</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="nam">globals</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2437" class="mis show_mis"><span class="n"><a href="#t2437">2437</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2438" class="pln"><span class="n"><a href="#t2438">2438</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2439" class="pln"><span class="n"><a href="#t2439">2439</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2440" class="run"><span class="n"><a href="#t2440">2440</a></span><span class="t"><span class="key">class</span> <span class="nam">ErrorCallTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2441" class="pln"><span class="n"><a href="#t2441">2441</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2442" class="run"><span class="n"><a href="#t2442">2442</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorCallHasNoTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2443" class="pln"><span class="n"><a href="#t2443">2443</a></span><span class="t"> <span class="com"># Test that cog.error() doesn't show a traceback.</span> </span><span class="r"></span></p> - <p id="t2444" class="mis show_mis"><span class="n"><a href="#t2444">2444</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2445" class="pln"><span class="n"><a href="#t2445">2445</a></span><span class="t"> <span class="str">'error.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2446" class="pln"><span class="n"><a href="#t2446">2446</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2447" class="pln"><span class="n"><a href="#t2447">2447</a></span><span class="t"><span class="str"> cog.error("Something Bad!")</span> </span><span class="r"></span></p> - <p id="t2448" class="pln"><span class="n"><a href="#t2448">2448</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2449" class="pln"><span class="n"><a href="#t2449">2449</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2450" class="pln"><span class="n"><a href="#t2450">2450</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2451" class="pln"><span class="n"><a href="#t2451">2451</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2452" class="pln"><span class="n"><a href="#t2452">2452</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2453" class="mis show_mis"><span class="n"><a href="#t2453">2453</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2454" class="mis show_mis"><span class="n"><a href="#t2454">2454</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'error.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2455" class="mis show_mis"><span class="n"><a href="#t2455">2455</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2456" class="mis show_mis"><span class="n"><a href="#t2456">2456</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging error.cog\nError: Something Bad!\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2457" class="pln"><span class="n"><a href="#t2457">2457</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2458" class="run"><span class="n"><a href="#t2458">2458</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRealErrorHasTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t2459" class="pln"><span class="n"><a href="#t2459">2459</a></span><span class="t"> <span class="com"># Test that a genuine error does show a traceback.</span> </span><span class="r"></span></p> - <p id="t2460" class="mis show_mis"><span class="n"><a href="#t2460">2460</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t2461" class="pln"><span class="n"><a href="#t2461">2461</a></span><span class="t"> <span class="str">'error.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t2462" class="pln"><span class="n"><a href="#t2462">2462</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> - <p id="t2463" class="pln"><span class="n"><a href="#t2463">2463</a></span><span class="t"><span class="str"> raise RuntimeError("Hey!")</span> </span><span class="r"></span></p> - <p id="t2464" class="pln"><span class="n"><a href="#t2464">2464</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> - <p id="t2465" class="pln"><span class="n"><a href="#t2465">2465</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> - <p id="t2466" class="pln"><span class="n"><a href="#t2466">2466</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t2467" class="pln"><span class="n"><a href="#t2467">2467</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t2468" class="pln"><span class="n"><a href="#t2468">2468</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2469" class="mis show_mis"><span class="n"><a href="#t2469">2469</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2470" class="mis show_mis"><span class="n"><a href="#t2470">2470</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'error.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2471" class="mis show_mis"><span class="n"><a href="#t2471">2471</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2472" class="mis show_mis"><span class="n"><a href="#t2472">2472</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">'Actual output:\n'</span> <span class="op">+</span> <span class="nam">output</span> </span><span class="r"></span></p> - <p id="t2473" class="mis show_mis"><span class="n"><a href="#t2473">2473</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertTrue</span><span class="op">(</span><span class="nam">output</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">"Cogging error.cog\nTraceback (most recent"</span><span class="op">)</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2474" class="mis show_mis"><span class="n"><a href="#t2474">2474</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"RuntimeError: Hey!"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t2475" class="pln"><span class="n"><a href="#t2475">2475</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2476" class="pln"><span class="n"><a href="#t2476">2476</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t2477" class="pln"><span class="n"><a href="#t2477">2477</a></span><span class="t"><span class="com"># Things not yet tested:</span> </span><span class="r"></span></p> - <p id="t2478" class="pln"><span class="n"><a href="#t2478">2478</a></span><span class="t"><span class="com"># - A bad -w command (currently fails silently).</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Test cogapp.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">random</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">import</span> <span class="nam">shutil</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"><span class="key">import</span> <span class="nam">stat</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"><span class="key">import</span> <span class="nam">tempfile</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"><span class="key">import</span> <span class="nam">threading</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">StringIO</span><span class="op">,</span> <span class="nam">to_bytes</span><span class="op">,</span> <span class="nam">TestCase</span><span class="op">,</span> <span class="nam">PY3</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">Cog</span><span class="op">,</span> <span class="nam">CogOptions</span><span class="op">,</span> <span class="nam">CogGenerator</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">CogError</span><span class="op">,</span> <span class="nam">CogUsageError</span><span class="op">,</span> <span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="nam">CogUserException</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">cogapp</span> <span class="key">import</span> <span class="nam">usage</span><span class="op">,</span> <span class="nam">__version__</span><span class="op">,</span> <span class="nam">main</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">makefiles</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="nam">reindentBlock</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestsInMemory</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> <span class="str">""" Test cases for cogapp.Cog()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="nam">strings</span> <span class="op">=</span> <span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> <span class="str">''</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"> <span class="str">' '</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> <span class="str">' \t \t \tx'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="str">'hello'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"> <span class="str">'the cat\nin the\nhat.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"> <span class="str">'Horton\n\tHears A\n\t\tWho'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"><span class="str"> cog.outl("This is line one\\n")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"><span class="str"> cog.outl("This is line two")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"><span class="str"> gobbledegook.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"><span class="str"> cog.outl("This is line one\\n")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"><span class="str"> cog.outl("This is line two")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">outfile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptyCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> <span class="com"># The cog clause can be totally empty. Not sure why you'd want it,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t74" href="#t74">74</a></span><span class="t"> <span class="com"># but it works.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t75" href="#t75">75</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t76" href="#t76">76</a></span><span class="t"><span class="str"> hello</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t77" href="#t77">77</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t78" href="#t78">78</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t79" href="#t79">79</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t80" href="#t80">80</a></span><span class="t"><span class="str"> goodbye</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t81" href="#t81">81</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t82" href="#t82">82</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t83" href="#t83">83</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t84" href="#t84">84</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t85" href="#t85">85</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t86" href="#t86">86</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMultipleCogs</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t87" href="#t87">87</a></span><span class="t"> <span class="com"># One file can have many cog chunks, even abutting each other.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t88" href="#t88">88</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t89" href="#t89">89</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t90" href="#t90">90</a></span><span class="t"><span class="str"> cog.out("chunk1")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t91" href="#t91">91</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t92" href="#t92">92</a></span><span class="t"><span class="str"> chunk1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t93" href="#t93">93</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t94" href="#t94">94</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t95" href="#t95">95</a></span><span class="t"><span class="str"> cog.out("chunk2")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t96" href="#t96">96</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t97" href="#t97">97</a></span><span class="t"><span class="str"> chunk2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t98" href="#t98">98</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t99" href="#t99">99</a></span><span class="t"><span class="str"> between chunks</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t100" href="#t100">100</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t101" href="#t101">101</a></span><span class="t"><span class="str"> cog.out("chunk3")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t102" href="#t102">102</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t103" href="#t103">103</a></span><span class="t"><span class="str"> chunk3</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t104" href="#t104">104</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t105" href="#t105">105</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t106" href="#t106">106</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t107" href="#t107">107</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t108" href="#t108">108</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t109" href="#t109">109</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t110" href="#t110">110</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimBlankLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t111" href="#t111">111</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t112" href="#t112">112</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t113" href="#t113">113</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t114" href="#t114">114</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t115" href="#t115">115</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t116" href="#t116">116</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t117" href="#t117">117</a></span><span class="t"><span class="str"> cog.outl("This is line three", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t118" href="#t118">118</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t119" href="#t119">119</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t120" href="#t120">120</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t121" href="#t121">121</a></span><span class="t"><span class="str"> This is line three</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t122" href="#t122">122</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t123" href="#t123">123</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t124" href="#t124">124</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t125" href="#t125">125</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t126" href="#t126">126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t127" href="#t127">127</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t128" href="#t128">128</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimEmptyBlankLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t129" href="#t129">129</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t130" href="#t130">130</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t131" href="#t131">131</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t132" href="#t132">132</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t133" href="#t133">133</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t134" href="#t134">134</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t135" href="#t135">135</a></span><span class="t"><span class="str"> cog.out('', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t136" href="#t136">136</a></span><span class="t"><span class="str"> cog.outl("This is line three", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t137" href="#t137">137</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t138" href="#t138">138</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t139" href="#t139">139</a></span><span class="t"><span class="str"> This is line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t140" href="#t140">140</a></span><span class="t"><span class="str"> This is line three</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t141" href="#t141">141</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t142" href="#t142">142</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t143" href="#t143">143</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t144" href="#t144">144</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t145" href="#t145">145</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t146" href="#t146">146</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t147" href="#t147">147</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrimBlankLinesWithLastPartial</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t148" href="#t148">148</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t149" href="#t149">149</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t150" href="#t150">150</a></span><span class="t"><span class="str"> cog.out("This is line one\\n", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t151" href="#t151">151</a></span><span class="t"><span class="str"> cog.out("\\nLine two\\nLine three", trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t152" href="#t152">152</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t153" href="#t153">153</a></span><span class="t"><span class="str"> This is line one</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t154" href="#t154">154</a></span><span class="t"><span class="str"> Line two</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t155" href="#t155">155</a></span><span class="t"><span class="str"> Line three</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t156" href="#t156">156</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t157" href="#t157">157</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t158" href="#t158">158</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t159" href="#t159">159</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t160" href="#t160">160</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t161" href="#t161">161</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t162" href="#t162">162</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCogOutDedent</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t163" href="#t163">163</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t164" href="#t164">164</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t165" href="#t165">165</a></span><span class="t"><span class="str"> cog.out("This is the first line\\n")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t166" href="#t166">166</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t167" href="#t167">167</a></span><span class="t"><span class="str"> This is dedent=True 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t168" href="#t168">168</a></span><span class="t"><span class="str"> This is dedent=True 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t169" href="#t169">169</a></span><span class="t"><span class="str"> ''', dedent=True, trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t170" href="#t170">170</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t171" href="#t171">171</a></span><span class="t"><span class="str"> This is dedent=False 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t172" href="#t172">172</a></span><span class="t"><span class="str"> This is dedent=False 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t173" href="#t173">173</a></span><span class="t"><span class="str"> ''', dedent=False, trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t174" href="#t174">174</a></span><span class="t"><span class="str"> cog.out('''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t175" href="#t175">175</a></span><span class="t"><span class="str"> This is dedent=default 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t176" href="#t176">176</a></span><span class="t"><span class="str"> This is dedent=default 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t177" href="#t177">177</a></span><span class="t"><span class="str"> ''', trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t178" href="#t178">178</a></span><span class="t"><span class="str"> cog.out("This is the last line\\n")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t179" href="#t179">179</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t180" href="#t180">180</a></span><span class="t"><span class="str"> This is the first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t181" href="#t181">181</a></span><span class="t"><span class="str"> This is dedent=True 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t182" href="#t182">182</a></span><span class="t"><span class="str"> This is dedent=True 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t183" href="#t183">183</a></span><span class="t"><span class="str"> This is dedent=False 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t184" href="#t184">184</a></span><span class="t"><span class="str"> This is dedent=False 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t185" href="#t185">185</a></span><span class="t"><span class="str"> This is dedent=default 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t186" href="#t186">186</a></span><span class="t"><span class="str"> This is dedent=default 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t187" href="#t187">187</a></span><span class="t"><span class="str"> This is the last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t188" href="#t188">188</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t189" href="#t189">189</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t190" href="#t190">190</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t191" href="#t191">191</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t192" href="#t192">192</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t193" href="#t193">193</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t194" href="#t194">194</a></span><span class="t"> <span class="key">def</span> <span class="nam">test22EndOfLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t195" href="#t195">195</a></span><span class="t"> <span class="com"># In Python 2.2, this cog file was not parsing because the</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t196" href="#t196">196</a></span><span class="t"> <span class="com"># last line is indented but didn't end with a newline.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t197" href="#t197">197</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t198" href="#t198">198</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t199" href="#t199">199</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t200" href="#t200">200</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t201" href="#t201">201</a></span><span class="t"><span class="str"> cog.out("%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t202" href="#t202">202</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t203" href="#t203">203</a></span><span class="t"><span class="str"> 0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t204" href="#t204">204</a></span><span class="t"><span class="str"> 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t205" href="#t205">205</a></span><span class="t"><span class="str"> 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t206" href="#t206">206</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t207" href="#t207">207</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t208" href="#t208">208</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t209" href="#t209">209</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t210" href="#t210">210</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t211" href="#t211">211</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t212" href="#t212">212</a></span><span class="t"> <span class="key">def</span> <span class="nam">testIndentedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t213" href="#t213">213</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t214" href="#t214">214</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t215" href="#t215">215</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t216" href="#t216">216</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t217" href="#t217">217</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t218" href="#t218">218</a></span><span class="t"><span class="str"> cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t219" href="#t219">219</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t220" href="#t220">220</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t221" href="#t221">221</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t222" href="#t222">222</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t223" href="#t223">223</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t224" href="#t224">224</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t225" href="#t225">225</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t226" href="#t226">226</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t227" href="#t227">227</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t228" href="#t228">228</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t229" href="#t229">229</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t230" href="#t230">230</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrefixedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t231" href="#t231">231</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t232" href="#t232">232</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t233" href="#t233">233</a></span><span class="t"><span class="str"> --import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t234" href="#t234">234</a></span><span class="t"><span class="str"> --for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t235" href="#t235">235</a></span><span class="t"><span class="str"> -- cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t236" href="#t236">236</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t237" href="#t237">237</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t238" href="#t238">238</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t239" href="#t239">239</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t240" href="#t240">240</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t241" href="#t241">241</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t242" href="#t242">242</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t243" href="#t243">243</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t244" href="#t244">244</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t245" href="#t245">245</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t246" href="#t246">246</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrefixedIndentedCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t247" href="#t247">247</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t248" href="#t248">248</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t249" href="#t249">249</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t250" href="#t250">250</a></span><span class="t"><span class="str"> -- import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t251" href="#t251">251</a></span><span class="t"><span class="str"> -- for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t252" href="#t252">252</a></span><span class="t"><span class="str"> -- cog.out("xy%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t253" href="#t253">253</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t254" href="#t254">254</a></span><span class="t"><span class="str"> xy0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t255" href="#t255">255</a></span><span class="t"><span class="str"> xy1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t256" href="#t256">256</a></span><span class="t"><span class="str"> xy2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t257" href="#t257">257</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t258" href="#t258">258</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t259" href="#t259">259</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t260" href="#t260">260</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t261" href="#t261">261</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t262" href="#t262">262</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t263" href="#t263">263</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBogusPrefixMatch</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t264" href="#t264">264</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t265" href="#t265">265</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t266" href="#t266">266</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t267" href="#t267">267</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t268" href="#t268">268</a></span><span class="t"><span class="str"> # This comment should not be clobbered by removing the pound sign.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t269" href="#t269">269</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t270" href="#t270">270</a></span><span class="t"><span class="str"> cog.out("xy%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t271" href="#t271">271</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t272" href="#t272">272</a></span><span class="t"><span class="str"> xy0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t273" href="#t273">273</a></span><span class="t"><span class="str"> xy1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t274" href="#t274">274</a></span><span class="t"><span class="str"> xy2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t275" href="#t275">275</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t276" href="#t276">276</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t277" href="#t277">277</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t278" href="#t278">278</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t279" href="#t279">279</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t280" href="#t280">280</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t281" href="#t281">281</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoFinalNewline</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t282" href="#t282">282</a></span><span class="t"> <span class="com"># If the cog'ed output has no final newline,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t283" href="#t283">283</a></span><span class="t"> <span class="com"># it shouldn't eat up the cog terminator.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t284" href="#t284">284</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t285" href="#t285">285</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t286" href="#t286">286</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t287" href="#t287">287</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t288" href="#t288">288</a></span><span class="t"><span class="str"> for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t289" href="#t289">289</a></span><span class="t"><span class="str"> cog.out("%d" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t290" href="#t290">290</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t291" href="#t291">291</a></span><span class="t"><span class="str"> 012</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t292" href="#t292">292</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t293" href="#t293">293</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t294" href="#t294">294</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t295" href="#t295">295</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t296" href="#t296">296</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t297" href="#t297">297</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t298" href="#t298">298</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t299" href="#t299">299</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoOutputAtAll</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t300" href="#t300">300</a></span><span class="t"> <span class="com"># If there is absolutely no cog output, that's ok.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t301" href="#t301">301</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t302" href="#t302">302</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t303" href="#t303">303</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t304" href="#t304">304</a></span><span class="t"><span class="str"> i = 1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t305" href="#t305">305</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t306" href="#t306">306</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t307" href="#t307">307</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t308" href="#t308">308</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t309" href="#t309">309</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t310" href="#t310">310</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t311" href="#t311">311</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t312" href="#t312">312</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t313" href="#t313">313</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPurelyBlankLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t314" href="#t314">314</a></span><span class="t"> <span class="com"># If there is a blank line in the cog code with no whitespace</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t315" href="#t315">315</a></span><span class="t"> <span class="com"># prefix, that should be OK.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t316" href="#t316">316</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t317" href="#t317">317</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t318" href="#t318">318</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t319" href="#t319">319</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t320" href="#t320">320</a></span><span class="t"><span class="str"> import sys</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t321" href="#t321">321</a></span><span class="t"><span class="str"> cog.out("Hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t322" href="#t322">322</a></span><span class="t"><span class="str"> $</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t323" href="#t323">323</a></span><span class="t"><span class="str"> cog.out("There")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t324" href="#t324">324</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t325" href="#t325">325</a></span><span class="t"><span class="str"> HelloThere</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t326" href="#t326">326</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t327" href="#t327">327</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t328" href="#t328">328</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t329" href="#t329">329</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t330" href="#t330">330</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'$'</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t331" href="#t331">331</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t332" href="#t332">332</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t333" href="#t333">333</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptyOutl</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t334" href="#t334">334</a></span><span class="t"> <span class="com"># Alexander Belchenko suggested the string argument to outl should</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t335" href="#t335">335</a></span><span class="t"> <span class="com"># be optional. Does it work?</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t336" href="#t336">336</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t337" href="#t337">337</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t338" href="#t338">338</a></span><span class="t"><span class="str"> prologue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t339" href="#t339">339</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t340" href="#t340">340</a></span><span class="t"><span class="str"> cog.outl("x")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t341" href="#t341">341</a></span><span class="t"><span class="str"> cog.outl()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t342" href="#t342">342</a></span><span class="t"><span class="str"> cog.outl("y")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t343" href="#t343">343</a></span><span class="t"><span class="str"> cog.out() # Also optional, a complete no-op.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t344" href="#t344">344</a></span><span class="t"><span class="str"> cog.outl(trimblanklines=True)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t345" href="#t345">345</a></span><span class="t"><span class="str"> cog.outl("z")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t346" href="#t346">346</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t347" href="#t347">347</a></span><span class="t"><span class="str"> x</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t348" href="#t348">348</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t349" href="#t349">349</a></span><span class="t"><span class="str"> y</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t350" href="#t350">350</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t351" href="#t351">351</a></span><span class="t"><span class="str"> z</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t352" href="#t352">352</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t353" href="#t353">353</a></span><span class="t"><span class="str"> epilogue</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t354" href="#t354">354</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t355" href="#t355">355</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t356" href="#t356">356</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t357" href="#t357">357</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t358" href="#t358">358</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t359" href="#t359">359</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFirstLineNum</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t360" href="#t360">360</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t361" href="#t361">361</a></span><span class="t"><span class="str"> fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t362" href="#t362">362</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t363" href="#t363">363</a></span><span class="t"><span class="str"> cog.outl("started at line number %d" % cog.firstLineNum)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t364" href="#t364">364</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t365" href="#t365">365</a></span><span class="t"><span class="str"> started at line number 2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t366" href="#t366">366</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t367" href="#t367">367</a></span><span class="t"><span class="str"> blah blah</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t368" href="#t368">368</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t369" href="#t369">369</a></span><span class="t"><span class="str"> cog.outl("and again at line %d" % cog.firstLineNum)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t370" href="#t370">370</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t371" href="#t371">371</a></span><span class="t"><span class="str"> and again at line 8</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t372" href="#t372">372</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t373" href="#t373">373</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t374" href="#t374">374</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t375" href="#t375">375</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t376" href="#t376">376</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t377" href="#t377">377</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t378" href="#t378">378</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompactOneLineCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t379" href="#t379">379</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t380" href="#t380">380</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t381" href="#t381">381</a></span><span class="t"><span class="str"> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t382" href="#t382">382</a></span><span class="t"><span class="str"> get rid of this!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t383" href="#t383">383</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t384" href="#t384">384</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t385" href="#t385">385</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t386" href="#t386">386</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t387" href="#t387">387</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t388" href="#t388">388</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t389" href="#t389">389</a></span><span class="t"><span class="str"> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t390" href="#t390">390</a></span><span class="t"><span class="str"> hello 81</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t391" href="#t391">391</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t392" href="#t392">392</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t393" href="#t393">393</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t394" href="#t394">394</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t395" href="#t395">395</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t396" href="#t396">396</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t397" href="#t397">397</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t398" href="#t398">398</a></span><span class="t"> <span class="key">def</span> <span class="nam">testInsideOutCompact</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t399" href="#t399">399</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t400" href="#t400">400</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t401" href="#t401">401</a></span><span class="t"><span class="str"> hey?: ]]] what is this? [[[cog strange!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t402" href="#t402">402</a></span><span class="t"><span class="str"> get rid of this!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t403" href="#t403">403</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t404" href="#t404">404</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t405" href="#t405">405</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t406" href="#t406">406</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^infile.txt\(2\): Cog code markers inverted$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t407" href="#t407">407</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="str">"infile.txt"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t408" href="#t408">408</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t409" href="#t409">409</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSharingGlobals</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t410" href="#t410">410</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t411" href="#t411">411</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t412" href="#t412">412</a></span><span class="t"><span class="str"> hey: [[[cog s="hey there" ]]] looky!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t413" href="#t413">413</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t414" href="#t414">414</a></span><span class="t"><span class="str"> more literal junk.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t415" href="#t415">415</a></span><span class="t"><span class="str"> [[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t416" href="#t416">416</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t417" href="#t417">417</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t418" href="#t418">418</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t419" href="#t419">419</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t420" href="#t420">420</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t421" href="#t421">421</a></span><span class="t"><span class="str"> first line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t422" href="#t422">422</a></span><span class="t"><span class="str"> hey: [[[cog s="hey there" ]]] looky!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t423" href="#t423">423</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t424" href="#t424">424</a></span><span class="t"><span class="str"> more literal junk.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t425" href="#t425">425</a></span><span class="t"><span class="str"> [[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t426" href="#t426">426</a></span><span class="t"><span class="str"> hey there</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t427" href="#t427">427</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t428" href="#t428">428</a></span><span class="t"><span class="str"> last line</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t429" href="#t429">429</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t430" href="#t430">430</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t431" href="#t431">431</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t432" href="#t432">432</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t433" href="#t433">433</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t434" href="#t434">434</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAssertInCogCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t435" href="#t435">435</a></span><span class="t"> <span class="com"># Check that we can test assertions in cog code in the test framework.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t436" href="#t436">436</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t437" href="#t437">437</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t438" href="#t438">438</a></span><span class="t"><span class="str"> assert 1 == 2, "Oops"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t439" href="#t439">439</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t440" href="#t440">440</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t441" href="#t441">441</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t442" href="#t442">442</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t443" href="#t443">443</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUserException</span><span class="op">,</span> <span class="str">"AssertionError: Oops"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t444" href="#t444">444</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t445" href="#t445">445</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t446" href="#t446">446</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCogPrevious</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t447" href="#t447">447</a></span><span class="t"> <span class="com"># Check that we can access the previous run's output.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t448" href="#t448">448</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t449" href="#t449">449</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t450" href="#t450">450</a></span><span class="t"><span class="str"> assert cog.previous == "Hello there!\\n", "WTF??"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t451" href="#t451">451</a></span><span class="t"><span class="str"> cog.out(cog.previous)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t452" href="#t452">452</a></span><span class="t"><span class="str"> cog.outl("Ran again!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t453" href="#t453">453</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t454" href="#t454">454</a></span><span class="t"><span class="str"> Hello there!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t455" href="#t455">455</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t456" href="#t456">456</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t457" href="#t457">457</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t458" href="#t458">458</a></span><span class="t"> <span class="nam">outfile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t459" href="#t459">459</a></span><span class="t"><span class="str"> [[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t460" href="#t460">460</a></span><span class="t"><span class="str"> assert cog.previous == "Hello there!\\n", "WTF??"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t461" href="#t461">461</a></span><span class="t"><span class="str"> cog.out(cog.previous)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t462" href="#t462">462</a></span><span class="t"><span class="str"> cog.outl("Ran again!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t463" href="#t463">463</a></span><span class="t"><span class="str"> ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t464" href="#t464">464</a></span><span class="t"><span class="str"> Hello there!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t465" href="#t465">465</a></span><span class="t"><span class="str"> Ran again!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t466" href="#t466">466</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t467" href="#t467">467</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t468" href="#t468">468</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t469" href="#t469">469</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t470" href="#t470">470</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">outfile</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t471" href="#t471">471</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t472" href="#t472">472</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t473" href="#t473">473</a></span><span class="t"><span class="key">class</span> <span class="nam">CogOptionsTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t474" href="#t474">474</a></span><span class="t"> <span class="str">""" Test the CogOptions class.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t475" href="#t475">475</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t476" href="#t476">476</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t477" href="#t477">477</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEquality</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t478" href="#t478">478</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t479" href="#t479">479</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t480" href="#t480">480</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t481" href="#t481">481</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-r'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t482" href="#t482">482</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t483" href="#t483">483</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-r'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t484" href="#t484">484</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t485" href="#t485">485</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t486" href="#t486">486</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCloning</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t487" href="#t487">487</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t488" href="#t488">488</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'booey'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' /*x*/'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t489" href="#t489">489</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">o</span><span class="op">.</span><span class="nam">clone</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t490" href="#t490">490</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t491" href="#t491">491</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'huey'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'foo=quux'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t492" href="#t492">492</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t493" href="#t493">493</a></span><span class="t"> <span class="nam">q</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t494" href="#t494">494</a></span><span class="t"> <span class="nam">q</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-I'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'booey'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' /*x*/'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'huey'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'foo=quux'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t495" href="#t495">495</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">p</span><span class="op">,</span> <span class="nam">q</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t496" href="#t496">496</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t497" href="#t497">497</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCombiningFlags</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t498" href="#t498">498</a></span><span class="t"> <span class="com"># Single-character flags can be combined.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t499" href="#t499">499</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t500" href="#t500">500</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-e'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t501" href="#t501">501</a></span><span class="t"> <span class="nam">p</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t502" href="#t502">502</a></span><span class="t"> <span class="nam">p</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'-erz'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t503" href="#t503">503</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">o</span><span class="op">,</span> <span class="nam">p</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t504" href="#t504">504</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t505" href="#t505">505</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t506" href="#t506">506</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t507" href="#t507">507</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">_parse_markers</span><span class="op">(</span><span class="str">'a b c'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t508" href="#t508">508</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'a'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t509" href="#t509">509</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'b'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t510" href="#t510">510</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'c'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t511" href="#t511">511</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t512" href="#t512">512</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMarkersSwitch</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t513" href="#t513">513</a></span><span class="t"> <span class="nam">o</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t514" href="#t514">514</a></span><span class="t"> <span class="nam">o</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="op">[</span><span class="str">'--markers'</span><span class="op">,</span> <span class="str">'a b c'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t515" href="#t515">515</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'a'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t516" href="#t516">516</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'b'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t517" href="#t517">517</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'c'</span><span class="op">,</span> <span class="nam">o</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t518" href="#t518">518</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t519" href="#t519">519</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t520" href="#t520">520</a></span><span class="t"><span class="key">class</span> <span class="nam">FileStructureTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t521" href="#t521">521</a></span><span class="t"> <span class="str">""" Test cases to check that we're properly strict about the structure</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t522" href="#t522">522</a></span><span class="t"><span class="str"> of files.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t523" href="#t523">523</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t524" href="#t524">524</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t525" href="#t525">525</a></span><span class="t"> <span class="key">def</span> <span class="nam">isBad</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">infile</span><span class="op">,</span> <span class="nam">msg</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t526" href="#t526">526</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t527" href="#t527">527</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^"</span><span class="op">+</span><span class="nam">re</span><span class="op">.</span><span class="nam">escape</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span><span class="op">+</span><span class="str">"$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t528" href="#t528">528</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">'infile.txt'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t529" href="#t529">529</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t530" href="#t530">530</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBeginNoEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t531" href="#t531">531</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t532" href="#t532">532</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t533" href="#t533">533</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t534" href="#t534">534</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t535" href="#t535">535</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t536" href="#t536">536</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(2): Cog block begun but never ended."</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t537" href="#t537">537</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t538" href="#t538">538</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoEoo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t539" href="#t539">539</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t540" href="#t540">540</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t541" href="#t541">541</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t542" href="#t542">542</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t543" href="#t543">543</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t544" href="#t544">544</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t545" href="#t545">545</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(4): Missing '[[[end]]]' before end of file."</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t546" href="#t546">546</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t547" href="#t547">547</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t548" href="#t548">548</a></span><span class="t"><span class="str"> Fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t549" href="#t549">549</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t550" href="#t550">550</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t551" href="#t551">551</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t552" href="#t552">552</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t553" href="#t553">553</a></span><span class="t"><span class="str"> cog.outl('goodbye')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t554" href="#t554">554</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t555" href="#t555">555</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t556" href="#t556">556</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t557" href="#t557">557</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t558" href="#t558">558</a></span><span class="t"> <span class="key">def</span> <span class="nam">testStartWithEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t559" href="#t559">559</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t560" href="#t560">560</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t561" href="#t561">561</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t562" href="#t562">562</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(1): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t563" href="#t563">563</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t564" href="#t564">564</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t565" href="#t565">565</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t566" href="#t566">566</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t567" href="#t567">567</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t568" href="#t568">568</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t569" href="#t569">569</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t570" href="#t570">570</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t571" href="#t571">571</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t572" href="#t572">572</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t573" href="#t573">573</a></span><span class="t"> <span class="key">def</span> <span class="nam">testStartWithEoo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t574" href="#t574">574</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t575" href="#t575">575</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t576" href="#t576">576</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t577" href="#t577">577</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(1): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t578" href="#t578">578</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t579" href="#t579">579</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t580" href="#t580">580</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t581" href="#t581">581</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t582" href="#t582">582</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t583" href="#t583">583</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t584" href="#t584">584</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t585" href="#t585">585</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t586" href="#t586">586</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(5): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t587" href="#t587">587</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t588" href="#t588">588</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoEnd</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t589" href="#t589">589</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t590" href="#t590">590</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t591" href="#t591">591</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t592" href="#t592">592</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t593" href="#t593">593</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t594" href="#t594">594</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(3): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t595" href="#t595">595</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t596" href="#t596">596</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t597" href="#t597">597</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t598" href="#t598">598</a></span><span class="t"><span class="str"> cog.outl('hello')</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t599" href="#t599">599</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t600" href="#t600">600</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t601" href="#t601">601</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t602" href="#t602">602</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t603" href="#t603">603</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t604" href="#t604">604</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t605" href="#t605">605</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(7): Unexpected '[[[end]]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t606" href="#t606">606</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t607" href="#t607">607</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoBegins</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t608" href="#t608">608</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t609" href="#t609">609</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t610" href="#t610">610</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t611" href="#t611">611</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t612" href="#t612">612</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t613" href="#t613">613</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t614" href="#t614">614</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t615" href="#t615">615</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(2): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t616" href="#t616">616</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t617" href="#t617">617</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t618" href="#t618">618</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t619" href="#t619">619</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t620" href="#t620">620</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t621" href="#t621">621</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t622" href="#t622">622</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t623" href="#t623">623</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t624" href="#t624">624</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t625" href="#t625">625</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t626" href="#t626">626</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t627" href="#t627">627</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t628" href="#t628">628</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(6): Unexpected '[[[cog'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t629" href="#t629">629</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t630" href="#t630">630</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoEnds</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t631" href="#t631">631</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t632" href="#t632">632</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t633" href="#t633">633</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t634" href="#t634">634</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t635" href="#t635">635</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t636" href="#t636">636</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t637" href="#t637">637</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t638" href="#t638">638</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile</span><span class="op">,</span> <span class="str">"infile.txt(4): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t639" href="#t639">639</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t640" href="#t640">640</a></span><span class="t"> <span class="nam">infile2</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t641" href="#t641">641</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t642" href="#t642">642</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t643" href="#t643">643</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t644" href="#t644">644</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t645" href="#t645">645</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t646" href="#t646">646</a></span><span class="t"><span class="str"> cog.outl("hello")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t647" href="#t647">647</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t648" href="#t648">648</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t649" href="#t649">649</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t650" href="#t650">650</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t651" href="#t651">651</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">isBad</span><span class="op">(</span><span class="nam">infile2</span><span class="op">,</span> <span class="str">"infile.txt(8): Unexpected ']]]'"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t652" href="#t652">652</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t653" href="#t653">653</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t654" href="#t654">654</a></span><span class="t"><span class="key">class</span> <span class="nam">CogErrorTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t655" href="#t655">655</a></span><span class="t"> <span class="str">""" Test cases for cog.error().</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t656" href="#t656">656</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t657" href="#t657">657</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t658" href="#t658">658</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorMsg</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t659" href="#t659">659</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t660" href="#t660">660</a></span><span class="t"><span class="str"> [[[cog cog.error("This ain't right!")]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t661" href="#t661">661</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t662" href="#t662">662</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t663" href="#t663">663</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t664" href="#t664">664</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t665" href="#t665">665</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="str">"^This ain't right!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t666" href="#t666">666</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t667" href="#t667">667</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t668" href="#t668">668</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorNoMsg</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t669" href="#t669">669</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t670" href="#t670">670</a></span><span class="t"><span class="str"> [[[cog cog.error()]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t671" href="#t671">671</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t672" href="#t672">672</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t673" href="#t673">673</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t674" href="#t674">674</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t675" href="#t675">675</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogGeneratedError</span><span class="op">,</span> <span class="str">"^Error raised by cog generator.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t676" href="#t676">676</a></span><span class="t"> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t677" href="#t677">677</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t678" href="#t678">678</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoErrorIfErrorNotCalled</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t679" href="#t679">679</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t680" href="#t680">680</a></span><span class="t"><span class="str"> --[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t681" href="#t681">681</a></span><span class="t"><span class="str"> --import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t682" href="#t682">682</a></span><span class="t"><span class="str"> --for i in range(3):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t683" href="#t683">683</a></span><span class="t"><span class="str"> -- if i > 10:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t684" href="#t684">684</a></span><span class="t"><span class="str"> -- cog.error("Something is amiss!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t685" href="#t685">685</a></span><span class="t"><span class="str"> -- cog.out("xx%d\\n" % i)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t686" href="#t686">686</a></span><span class="t"><span class="str"> --]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t687" href="#t687">687</a></span><span class="t"><span class="str"> xx0</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t688" href="#t688">688</a></span><span class="t"><span class="str"> xx1</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t689" href="#t689">689</a></span><span class="t"><span class="str"> xx2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t690" href="#t690">690</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t691" href="#t691">691</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t692" href="#t692">692</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t693" href="#t693">693</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t694" href="#t694">694</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t695" href="#t695">695</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t696" href="#t696">696</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t697" href="#t697">697</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGeneratorGetCodeTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t698" href="#t698">698</a></span><span class="t"> <span class="str">""" Unit tests against CogGenerator to see if its getCode() method works</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t699" href="#t699">699</a></span><span class="t"><span class="str"> properly.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t700" href="#t700">700</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t701" href="#t701">701</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t702" href="#t702">702</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t703" href="#t703">703</a></span><span class="t"> <span class="str">""" All tests get a generator to use, and short same-length names for</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t704" href="#t704">704</a></span><span class="t"><span class="str"> the functions we're going to use.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t705" href="#t705">705</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t706" href="#t706">706</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span> <span class="op">=</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t707" href="#t707">707</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t708" href="#t708">708</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t709" href="#t709">709</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t710" href="#t710">710</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmpty</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t711" href="#t711">711</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t712" href="#t712">712</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t713" href="#t713">713</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t714" href="#t714">714</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t715" href="#t715">715</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t716" href="#t716">716</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t717" href="#t717">717</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">' print "hello"'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t718" href="#t718">718</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">' print "bye"'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t719" href="#t719">719</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t720" href="#t720">720</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'print "hello"\nprint "bye"'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t721" href="#t721">721</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t722" href="#t722">722</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed1</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t723" href="#t723">723</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t724" href="#t724">724</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t725" href="#t725">725</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'// hello'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t726" href="#t726">726</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'// bye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t727" href="#t727">727</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t728" href="#t728">728</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t729" href="#t729">729</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t730" href="#t730">730</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t731" href="#t731">731</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t732" href="#t732">732</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t733" href="#t733">733</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'hello'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t734" href="#t734">734</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t735" href="#t735">735</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t736" href="#t736">736</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t737" href="#t737">737</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t738" href="#t738">738</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed3</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t739" href="#t739">739</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t740" href="#t740">740</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t741" href="#t741">741</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'print """hello'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t742" href="#t742">742</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t743" href="#t743">743</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// """)]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t744" href="#t744">744</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'print """hello\nbye'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t745" href="#t745">745</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t746" href="#t746">746</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCompressed4</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t747" href="#t747">747</a></span><span class="t"> <span class="com"># For a while, I supported compressed code blocks, but no longer.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t748" href="#t748">748</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// [[[cog: print """'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t749" href="#t749">749</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'hello'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t750" href="#t750">750</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'bye""")'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t751" href="#t751">751</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'// ]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t752" href="#t752">752</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'hello\nbye""")'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t753" href="#t753">753</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t754" href="#t754">754</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCommonPrefixForMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t755" href="#t755">755</a></span><span class="t"> <span class="com"># It's important to be able to use #if 0 to hide lines from a</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t756" href="#t756">756</a></span><span class="t"> <span class="com"># C++ compiler.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t757" href="#t757">757</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'#if 0 //[[[cog'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t758" href="#t758">758</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'\timport cog, sys'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t759" href="#t759">759</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t760" href="#t760">760</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">l</span><span class="op">(</span><span class="str">'\tprint sys.argv'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t761" href="#t761">761</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">m</span><span class="op">(</span><span class="str">'#endif //]]]'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t762" href="#t762">762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">gen</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'import cog, sys\n\nprint sys.argv'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t763" href="#t763">763</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t764" href="#t764">764</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t765" href="#t765">765</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCaseWithTempDir</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t766" href="#t766">766</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t767" href="#t767">767</a></span><span class="t"> <span class="key">def</span> <span class="nam">newCog</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t768" href="#t768">768</a></span><span class="t"> <span class="str">""" Initialize the cog members for another run.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t769" href="#t769">769</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t770" href="#t770">770</a></span><span class="t"> <span class="com"># Create a cog engine, and catch its output.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t771" href="#t771">771</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span> <span class="op">=</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t772" href="#t772">772</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t773" href="#t773">773</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stdout</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">,</span> <span class="nam">stderr</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t774" href="#t774">774</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t775" href="#t775">775</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t776" href="#t776">776</a></span><span class="t"> <span class="com"># Create a temporary directory.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t777" href="#t777">777</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">tempfile</span><span class="op">.</span><span class="nam">gettempdir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'testcog_tempdir_'</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">random</span><span class="op">.</span><span class="nam">random</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">[</span><span class="num">2</span><span class="op">:</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t778" href="#t778">778</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t779" href="#t779">779</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">olddir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">getcwd</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t780" href="#t780">780</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t781" href="#t781">781</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t782" href="#t782">782</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t783" href="#t783">783</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t784" href="#t784">784</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">olddir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t785" href="#t785">785</a></span><span class="t"> <span class="com"># Get rid of the temporary directory.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t786" href="#t786">786</a></span><span class="t"> <span class="nam">shutil</span><span class="op">.</span><span class="nam">rmtree</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t787" href="#t787">787</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t788" href="#t788">788</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertFilesSame</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFName1</span><span class="op">,</span> <span class="nam">sFName2</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t789" href="#t789">789</a></span><span class="t"> <span class="nam">text1</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName1</span><span class="op">)</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t790" href="#t790">790</a></span><span class="t"> <span class="nam">text2</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName2</span><span class="op">)</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t791" href="#t791">791</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">text1</span><span class="op">,</span> <span class="nam">text2</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t792" href="#t792">792</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t793" href="#t793">793</a></span><span class="t"> <span class="key">def</span> <span class="nam">assertFileContent</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFName</span><span class="op">,</span> <span class="nam">sContent</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t794" href="#t794">794</a></span><span class="t"> <span class="nam">sAbsName</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">sFName</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t795" href="#t795">795</a></span><span class="t"> <span class="nam">f</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">sAbsName</span><span class="op">,</span> <span class="str">'rb'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t796" href="#t796">796</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t797" href="#t797">797</a></span><span class="t"> <span class="nam">sFileContent</span> <span class="op">=</span> <span class="nam">f</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t798" href="#t798">798</a></span><span class="t"> <span class="key">finally</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t799" href="#t799">799</a></span><span class="t"> <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t800" href="#t800">800</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">sFileContent</span><span class="op">,</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">sContent</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t801" href="#t801">801</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t802" href="#t802">802</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t803" href="#t803">803</a></span><span class="t"><span class="key">class</span> <span class="nam">ArgumentHandlingTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t804" href="#t804">804</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t805" href="#t805">805</a></span><span class="t"> <span class="key">def</span> <span class="nam">testArgumentFailure</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t806" href="#t806">806</a></span><span class="t"> <span class="com"># Return value 2 means usage problem.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t807" href="#t807">807</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-j'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="num">2</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t808" href="#t808">808</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t809" href="#t809">809</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"option -j not recognized"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t810" href="#t810">810</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^No files to process$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t811" href="#t811">811</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t812" href="#t812">812</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^option -j not recognized$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t813" href="#t813">813</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-j'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t814" href="#t814">814</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t815" href="#t815">815</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoDashOAndAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t816" href="#t816">816</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t817" href="#t817">817</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t818" href="#t818">818</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t819" href="#t819">819</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t820" href="#t820">820</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t821" href="#t821">821</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t822" href="#t822">822</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t823" href="#t823">823</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -o with @file$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t824" href="#t824">824</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'foo'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t825" href="#t825">825</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t826" href="#t826">826</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashV</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t827" href="#t827">827</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-v'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t828" href="#t828">828</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t829" href="#t829">829</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="str">'Cog version %s\n'</span> <span class="op">%</span> <span class="nam">__version__</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t830" href="#t830">830</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t831" href="#t831">831</a></span><span class="t"> <span class="key">def</span> <span class="nam">producesHelp</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t832" href="#t832">832</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t833" href="#t833">833</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">'argv0'</span><span class="op">]</span> <span class="op">+</span> <span class="nam">args</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t834" href="#t834">834</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t835" href="#t835">835</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">usage</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t836" href="#t836">836</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t837" href="#t837">837</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashH</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t838" href="#t838">838</a></span><span class="t"> <span class="com"># -h or -? anywhere on the command line should just print help.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t839" href="#t839">839</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-h"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t840" href="#t840">840</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-?"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t841" href="#t841">841</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"fooey.txt -h"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t842" href="#t842">842</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">producesHelp</span><span class="op">(</span><span class="str">"-o -r @fooey.txt -? @booey.txt"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t843" href="#t843">843</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t844" href="#t844">844</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashOAndDashR</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t845" href="#t845">845</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t846" href="#t846">846</a></span><span class="t"> <span class="str">'cogfile.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t847" href="#t847">847</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t848" href="#t848">848</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t849" href="#t849">849</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t850" href="#t850">850</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t851" href="#t851">851</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t852" href="#t852">852</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -o with -r \(they are opposites\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t853" href="#t853">853</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'foo'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cogfile.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t854" href="#t854">854</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t855" href="#t855">855</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashZ</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t856" href="#t856">856</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t857" href="#t857">857</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t858" href="#t858">858</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t859" href="#t859">859</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t860" href="#t860">860</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t861" href="#t861">861</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t862" href="#t862">862</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t863" href="#t863">863</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t864" href="#t864">864</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t865" href="#t865">865</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t866" href="#t866">866</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t867" href="#t867">867</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t868" href="#t868">868</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t869" href="#t869">869</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t870" href="#t870">870</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t871" href="#t871">871</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t872" href="#t872">872</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t873" href="#t873">873</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t874" href="#t874">874</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t875" href="#t875">875</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t876" href="#t876">876</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t877" href="#t877">877</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t878" href="#t878">878</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t879" href="#t879">879</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t880" href="#t880">880</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^test.cog\(6\): Missing '\[\[\[end\]\]\]' before end of file.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t881" href="#t881">881</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t882" href="#t882">882</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t883" href="#t883">883</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t884" href="#t884">884</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t885" href="#t885">885</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t886" href="#t886">886</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBadDashD</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t887" href="#t887">887</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^-D takes a name=value argument$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t888" href="#t888">888</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-Dfooey'</span><span class="op">,</span> <span class="str">'cog.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t889" href="#t889">889</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^-D takes a name=value argument$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t890" href="#t890">890</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'fooey'</span><span class="op">,</span> <span class="str">'cog.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t891" href="#t891">891</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t892" href="#t892">892</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBadMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t893" href="#t893">893</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^--markers requires 3 values separated by spaces, could not parse 'X'$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t894" href="#t894">894</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'--markers=X'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t895" href="#t895">895</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^--markers requires 3 values separated by spaces, could not parse 'A B C D'$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t896" href="#t896">896</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'--markers=A B C D'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t897" href="#t897">897</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t898" href="#t898">898</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t899" href="#t899">899</a></span><span class="t"><span class="key">class</span> <span class="nam">TestMain</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t900" href="#t900">900</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t901" href="#t901">901</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestMain</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t902" href="#t902">902</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">old_argv</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t903" href="#t903">903</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">old_stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t904" href="#t904">904</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t905" href="#t905">905</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t906" href="#t906">906</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t907" href="#t907">907</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">old_stderr</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t908" href="#t908">908</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">old_argv</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t909" href="#t909">909</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">.</span><span class="nam">pop</span><span class="op">(</span><span class="str">'mycode'</span><span class="op">,</span> <span class="key">None</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t910" href="#t910">910</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestMain</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t911" href="#t911">911</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t912" href="#t912">912</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_main_function</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t913" href="#t913">913</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">,</span> <span class="str">"-Z"</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t914" href="#t914">914</a></span><span class="t"> <span class="nam">ret</span> <span class="op">=</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t915" href="#t915">915</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">ret</span><span class="op">,</span> <span class="num">2</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t916" href="#t916">916</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t917" href="#t917">917</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">stderr</span><span class="op">,</span> <span class="str">'option -Z not recognized\n(for help use -?)\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t918" href="#t918">918</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t919" href="#t919">919</a></span><span class="t"> <span class="nam">files</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t920" href="#t920">920</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t921" href="#t921">921</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t922" href="#t922">922</a></span><span class="t"><span class="str"> def func():</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t923" href="#t923">923</a></span><span class="t"><span class="str"> import mycode</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t924" href="#t924">924</a></span><span class="t"><span class="str"> mycode.boom()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t925" href="#t925">925</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t926" href="#t926">926</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t927" href="#t927">927</a></span><span class="t"><span class="str"> -----</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t928" href="#t928">928</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t929" href="#t929">929</a></span><span class="t"><span class="str"> func()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t930" href="#t930">930</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t931" href="#t931">931</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t932" href="#t932">932</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t933" href="#t933">933</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t934" href="#t934">934</a></span><span class="t"> <span class="str">'mycode.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t935" href="#t935">935</a></span><span class="t"><span class="str"> def boom():</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t936" href="#t936">936</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t937" href="#t937">937</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t938" href="#t938">938</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t939" href="#t939">939</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t940" href="#t940">940</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_report</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t941" href="#t941">941</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">check_error_report</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t942" href="#t942">942</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t943" href="#t943">943</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_report_with_prologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t944" href="#t944">944</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">check_error_report</span><span class="op">(</span><span class="str">"-p"</span><span class="op">,</span> <span class="str">"#1\n#2"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t945" href="#t945">945</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t946" href="#t946">946</a></span><span class="t"> <span class="key">def</span> <span class="nam">check_error_report</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="op">*</span><span class="nam">args</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t947" href="#t947">947</a></span><span class="t"> <span class="str">"""Check that the error report is right."""</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t948" href="#t948">948</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">files</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t949" href="#t949">949</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">]</span> <span class="op">+</span> <span class="nam">list</span><span class="op">(</span><span class="nam">args</span><span class="op">)</span> <span class="op">+</span> <span class="op">[</span><span class="str">"-r"</span><span class="op">,</span> <span class="str">"test.cog"</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t950" href="#t950">950</a></span><span class="t"> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t951" href="#t951">951</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t952" href="#t952">952</a></span><span class="t"><span class="str"> Traceback (most recent call last):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t953" href="#t953">953</a></span><span class="t"><span class="str"> File "test.cog", line 9, in <module></span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t954" href="#t954">954</a></span><span class="t"><span class="str"> func()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t955" href="#t955">955</a></span><span class="t"><span class="str"> File "test.cog", line 4, in func</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t956" href="#t956">956</a></span><span class="t"><span class="str"> mycode.boom()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t957" href="#t957">957</a></span><span class="t"><span class="str"> File "MYCODE", line 2, in boom</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t958" href="#t958">958</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t959" href="#t959">959</a></span><span class="t"><span class="str"> IndexError: list index out of range</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t960" href="#t960">960</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t961" href="#t961">961</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t962" href="#t962">962</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="str">"mycode.py"</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t963" href="#t963">963</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t964" href="#t964">964</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="str">"mycode.py"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t965" href="#t965">965</a></span><span class="t"> <span class="key">assert</span> <span class="nam">expected</span> <span class="op">==</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t966" href="#t966">966</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t967" href="#t967">967</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_error_in_prologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t968" href="#t968">968</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">files</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t969" href="#t969">969</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">"argv0"</span><span class="op">,</span> <span class="str">"-p"</span><span class="op">,</span> <span class="str">"import mycode; mycode.boom()"</span><span class="op">,</span> <span class="str">"-r"</span><span class="op">,</span> <span class="str">"test.cog"</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t970" href="#t970">970</a></span><span class="t"> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t971" href="#t971">971</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t972" href="#t972">972</a></span><span class="t"><span class="str"> Traceback (most recent call last):</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t973" href="#t973">973</a></span><span class="t"><span class="str"> File "<prologue>", line 1, in <module></span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t974" href="#t974">974</a></span><span class="t"><span class="str"> import mycode; mycode.boom()</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t975" href="#t975">975</a></span><span class="t"><span class="str"> File "MYCODE", line 2, in boom</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t976" href="#t976">976</a></span><span class="t"><span class="str"> [][0]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t977" href="#t977">977</a></span><span class="t"><span class="str"> IndexError: list index out of range</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t978" href="#t978">978</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t979" href="#t979">979</a></span><span class="t"> <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t980" href="#t980">980</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="str">"mycode.py"</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t981" href="#t981">981</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t982" href="#t982">982</a></span><span class="t"> <span class="nam">expected</span> <span class="op">=</span> <span class="nam">expected</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"MYCODE"</span><span class="op">,</span> <span class="str">"mycode.py"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t983" href="#t983">983</a></span><span class="t"> <span class="key">assert</span> <span class="nam">expected</span> <span class="op">==</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t984" href="#t984">984</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t985" href="#t985">985</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t986" href="#t986">986</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t987" href="#t987">987</a></span><span class="t"><span class="key">class</span> <span class="nam">TestFileHandling</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t988" href="#t988">988</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t989" href="#t989">989</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t990" href="#t990">990</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t991" href="#t991">991</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t992" href="#t992">992</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t993" href="#t993">993</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t994" href="#t994">994</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t995" href="#t995">995</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t996" href="#t996">996</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t997" href="#t997">997</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t998" href="#t998">998</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t999" href="#t999">999</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1000" href="#t1000">1000</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1001" href="#t1001">1001</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1002" href="#t1002">1002</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1003" href="#t1003">1003</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1004" href="#t1004">1004</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1005" href="#t1005">1005</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1006" href="#t1006">1006</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1007" href="#t1007">1007</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1008" href="#t1008">1008</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1009" href="#t1009">1009</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1010" href="#t1010">1010</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1011" href="#t1011">1011</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1012" href="#t1012">1012</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1013" href="#t1013">1013</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1014" href="#t1014">1014</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1015" href="#t1015">1015</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1016" href="#t1016">1016</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1017" href="#t1017">1017</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1018" href="#t1018">1018</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1019" href="#t1019">1019</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1020" href="#t1020">1020</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1021" href="#t1021">1021</a></span><span class="t"> <span class="key">def</span> <span class="nam">testWildcards</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1022" href="#t1022">1022</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1023" href="#t1023">1023</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1024" href="#t1024">1024</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1025" href="#t1025">1025</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1026" href="#t1026">1026</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1027" href="#t1027">1027</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1028" href="#t1028">1028</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1029" href="#t1029">1029</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1030" href="#t1030">1030</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1031" href="#t1031">1031</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1032" href="#t1032">1032</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1033" href="#t1033">1033</a></span><span class="t"> <span class="str">'test2.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1034" href="#t1034">1034</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1035" href="#t1035">1035</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1036" href="#t1036">1036</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1037" href="#t1037">1037</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1038" href="#t1038">1038</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1039" href="#t1039">1039</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1040" href="#t1040">1040</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1041" href="#t1041">1041</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1042" href="#t1042">1042</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1043" href="#t1043">1043</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1044" href="#t1044">1044</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1045" href="#t1045">1045</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1046" href="#t1046">1046</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1047" href="#t1047">1047</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1048" href="#t1048">1048</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1049" href="#t1049">1049</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1050" href="#t1050">1050</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1051" href="#t1051">1051</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1052" href="#t1052">1052</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1053" href="#t1053">1053</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1054" href="#t1054">1054</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1055" href="#t1055">1055</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1056" href="#t1056">1056</a></span><span class="t"> <span class="str">'not_this_one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1057" href="#t1057">1057</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1058" href="#t1058">1058</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1059" href="#t1059">1059</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1060" href="#t1060">1060</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1061" href="#t1061">1061</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1062" href="#t1062">1062</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1063" href="#t1063">1063</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1064" href="#t1064">1064</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1065" href="#t1065">1065</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1066" href="#t1066">1066</a></span><span class="t"> <span class="str">'not_this_one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1067" href="#t1067">1067</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1068" href="#t1068">1068</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1069" href="#t1069">1069</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1070" href="#t1070">1070</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1071" href="#t1071">1071</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1072" href="#t1072">1072</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1073" href="#t1073">1073</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1074" href="#t1074">1074</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1075" href="#t1075">1075</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1076" href="#t1076">1076</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1077" href="#t1077">1077</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1078" href="#t1078">1078</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'t*.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1079" href="#t1079">1079</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1080" href="#t1080">1080</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test2.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1081" href="#t1081">1081</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'not_this_one.cog'</span><span class="op">,</span> <span class="str">'not_this_one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1082" href="#t1082">1082</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1083" href="#t1083">1083</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1084" href="#t1084">1084</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1085" href="#t1085">1085</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1086" href="#t1086">1086</a></span><span class="t"> <span class="com"># -o sets the output file.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1087" href="#t1087">1087</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1088" href="#t1088">1088</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1089" href="#t1089">1089</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1090" href="#t1090">1090</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1091" href="#t1091">1091</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1092" href="#t1092">1092</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1093" href="#t1093">1093</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1094" href="#t1094">1094</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1095" href="#t1095">1095</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1096" href="#t1096">1096</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1097" href="#t1097">1097</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1098" href="#t1098">1098</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1099" href="#t1099">1099</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1100" href="#t1100">1100</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1101" href="#t1101">1101</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1102" href="#t1102">1102</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1103" href="#t1103">1103</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1104" href="#t1104">1104</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1105" href="#t1105">1105</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1106" href="#t1106">1106</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1107" href="#t1107">1107</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1108" href="#t1108">1108</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1109" href="#t1109">1109</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1110" href="#t1110">1110</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1111" href="#t1111">1111</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1112" href="#t1112">1112</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1113" href="#t1113">1113</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'in/a/dir/test.cogged'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1114" href="#t1114">1114</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1115" href="#t1115">1115</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1116" href="#t1116">1116</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1117" href="#t1117">1117</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1118" href="#t1118">1118</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1119" href="#t1119">1119</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1120" href="#t1120">1120</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1121" href="#t1121">1121</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1122" href="#t1122">1122</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1123" href="#t1123">1123</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1124" href="#t1124">1124</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1125" href="#t1125">1125</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1126" href="#t1126">1126</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1127" href="#t1127">1127</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1128" href="#t1128">1128</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1129" href="#t1129">1129</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1130" href="#t1130">1130</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1131" href="#t1131">1131</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1132" href="#t1132">1132</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1133" href="#t1133">1133</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1134" href="#t1134">1134</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1135" href="#t1135">1135</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1136" href="#t1136">1136</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1137" href="#t1137">1137</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1138" href="#t1138">1138</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1139" href="#t1139">1139</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1140" href="#t1140">1140</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1141" href="#t1141">1141</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1142" href="#t1142">1142</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1143" href="#t1143">1143</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1144" href="#t1144">1144</a></span><span class="t"><span class="str"> goodbye cruel world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1145" href="#t1145">1145</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1146" href="#t1146">1146</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1147" href="#t1147">1147</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1148" href="#t1148">1148</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1149" href="#t1149">1149</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1150" href="#t1150">1150</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1151" href="#t1151">1151</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1152" href="#t1152">1152</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1153" href="#t1153">1153</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1154" href="#t1154">1154</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1155" href="#t1155">1155</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1156" href="#t1156">1156</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1157" href="#t1157">1157</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1158" href="#t1158">1158</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1159" href="#t1159">1159</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1160" href="#t1160">1160</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1161" href="#t1161">1161</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1162" href="#t1162">1162</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1163" href="#t1163">1163</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNestedAtFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1164" href="#t1164">1164</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1165" href="#t1165">1165</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1166" href="#t1166">1166</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1167" href="#t1167">1167</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1168" href="#t1168">1168</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1169" href="#t1169">1169</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1170" href="#t1170">1170</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1171" href="#t1171">1171</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1172" href="#t1172">1172</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1173" href="#t1173">1173</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1174" href="#t1174">1174</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1175" href="#t1175">1175</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1176" href="#t1176">1176</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1177" href="#t1177">1177</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1178" href="#t1178">1178</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1179" href="#t1179">1179</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1180" href="#t1180">1180</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1181" href="#t1181">1181</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1182" href="#t1182">1182</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1183" href="#t1183">1183</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1184" href="#t1184">1184</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1185" href="#t1185">1185</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1186" href="#t1186">1186</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1187" href="#t1187">1187</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1188" href="#t1188">1188</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1189" href="#t1189">1189</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1190" href="#t1190">1190</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1191" href="#t1191">1191</a></span><span class="t"><span class="str"> goodbye cruel world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1192" href="#t1192">1192</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1193" href="#t1193">1193</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1194" href="#t1194">1194</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1195" href="#t1195">1195</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1196" href="#t1196">1196</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1197" href="#t1197">1197</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1198" href="#t1198">1198</a></span><span class="t"><span class="str"> @cogfiles2.txt</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1199" href="#t1199">1199</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1200" href="#t1200">1200</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1201" href="#t1201">1201</a></span><span class="t"> <span class="str">'cogfiles2.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1202" href="#t1202">1202</a></span><span class="t"><span class="str"> # This one too, please.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1203" href="#t1203">1203</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1204" href="#t1204">1204</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1205" href="#t1205">1205</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1206" href="#t1206">1206</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1207" href="#t1207">1207</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1208" href="#t1208">1208</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1209" href="#t1209">1209</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1210" href="#t1210">1210</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1211" href="#t1211">1211</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1212" href="#t1212">1212</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1213" href="#t1213">1213</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1214" href="#t1214">1214</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithArgs</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1215" href="#t1215">1215</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1216" href="#t1216">1216</a></span><span class="t"> <span class="str">'both.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1217" href="#t1217">1217</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1218" href="#t1218">1218</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1219" href="#t1219">1219</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1220" href="#t1220">1220</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1221" href="#t1221">1221</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1222" href="#t1222">1222</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1223" href="#t1223">1223</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1224" href="#t1224">1224</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1225" href="#t1225">1225</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1226" href="#t1226">1226</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1227" href="#t1227">1227</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1228" href="#t1228">1228</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1229" href="#t1229">1229</a></span><span class="t"><span class="str"> one: True // ONE</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1230" href="#t1230">1230</a></span><span class="t"><span class="str"> two: False // ONE</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1231" href="#t1231">1231</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1232" href="#t1232">1232</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1233" href="#t1233">1233</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1234" href="#t1234">1234</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1235" href="#t1235">1235</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1236" href="#t1236">1236</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1237" href="#t1237">1237</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1238" href="#t1238">1238</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1239" href="#t1239">1239</a></span><span class="t"><span class="str"> one: False // TWO</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1240" href="#t1240">1240</a></span><span class="t"><span class="str"> two: True // TWO</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1241" href="#t1241">1241</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1242" href="#t1242">1242</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1243" href="#t1243">1243</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1244" href="#t1244">1244</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1245" href="#t1245">1245</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1246" href="#t1246">1246</a></span><span class="t"><span class="str"> both.cog -o in/a/dir/both.one -s ' // ONE' -D one=x</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1247" href="#t1247">1247</a></span><span class="t"><span class="str"> both.cog -o in/a/dir/both.two -s ' // TWO' -D two=x</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1248" href="#t1248">1248</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1249" href="#t1249">1249</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1250" href="#t1250">1250</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1251" href="#t1251">1251</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1252" href="#t1252">1252</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1253" href="#t1253">1253</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/both.one'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1254" href="#t1254">1254</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'in/a/dir/both.two'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1255" href="#t1255">1255</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1256" href="#t1256">1256</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithBadArgCombo</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1257" href="#t1257">1257</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1258" href="#t1258">1258</a></span><span class="t"> <span class="str">'both.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1259" href="#t1259">1259</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1260" href="#t1260">1260</a></span><span class="t"><span class="str"> cog.outl("one: %s" % ('one' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1261" href="#t1261">1261</a></span><span class="t"><span class="str"> cog.outl("two: %s" % ('two' in globals()))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1262" href="#t1262">1262</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1263" href="#t1263">1263</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1264" href="#t1264">1264</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1265" href="#t1265">1265</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1266" href="#t1266">1266</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1267" href="#t1267">1267</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1268" href="#t1268">1268</a></span><span class="t"><span class="str"> both.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1269" href="#t1269">1269</a></span><span class="t"><span class="str"> both.cog -d # This is bad: -r and -d</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1270" href="#t1270">1270</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1271" href="#t1271">1271</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1272" href="#t1272">1272</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1273" href="#t1273">1273</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1274" href="#t1274">1274</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -d with -r \(or you would delete all your source!\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1275" href="#t1275">1275</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1276" href="#t1276">1276</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1277" href="#t1277">1277</a></span><span class="t"> <span class="key">def</span> <span class="nam">testAtFileWithTrickyFilenames</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1278" href="#t1278">1278</a></span><span class="t"> <span class="key">def</span> <span class="nam">fix_backslashes</span><span class="op">(</span><span class="nam">files_txt</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1279" href="#t1279">1279</a></span><span class="t"> <span class="str">"""Make the contents of a files.txt sensitive to the platform."""</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1280" href="#t1280">1280</a></span><span class="t"> <span class="key">if</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">platform</span> <span class="op">!=</span> <span class="str">"win32"</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1281" href="#t1281">1281</a></span><span class="t"> <span class="nam">files_txt</span> <span class="op">=</span> <span class="nam">files_txt</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">"\\"</span><span class="op">,</span> <span class="str">"/"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1282" href="#t1282">1282</a></span><span class="t"> <span class="key">return</span> <span class="nam">files_txt</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1283" href="#t1283">1283</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1284" href="#t1284">1284</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1285" href="#t1285">1285</a></span><span class="t"> <span class="str">'one 1.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1286" href="#t1286">1286</a></span><span class="t"><span class="str"> //[[[cog cog.outl("hello world") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1287" href="#t1287">1287</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1288" href="#t1288">1288</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1289" href="#t1289">1289</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1290" href="#t1290">1290</a></span><span class="t"><span class="str"> //[[[cog cog.outl("hello world") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1291" href="#t1291">1291</a></span><span class="t"><span class="str"> hello world //xxx</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1292" href="#t1292">1292</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1293" href="#t1293">1293</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1294" href="#t1294">1294</a></span><span class="t"> <span class="str">'subdir'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1295" href="#t1295">1295</a></span><span class="t"> <span class="str">'subback.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1296" href="#t1296">1296</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with backslashes") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1297" href="#t1297">1297</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1298" href="#t1298">1298</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1299" href="#t1299">1299</a></span><span class="t"> <span class="str">'subfwd.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1300" href="#t1300">1300</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with slashes") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1301" href="#t1301">1301</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1302" href="#t1302">1302</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1303" href="#t1303">1303</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1304" href="#t1304">1304</a></span><span class="t"> <span class="str">'subback.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1305" href="#t1305">1305</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with backslashes") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1306" href="#t1306">1306</a></span><span class="t"><span class="str"> down deep with backslashes //yyy</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1307" href="#t1307">1307</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1308" href="#t1308">1308</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1309" href="#t1309">1309</a></span><span class="t"> <span class="str">'subfwd.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1310" href="#t1310">1310</a></span><span class="t"><span class="str"> //[[[cog cog.outl("down deep with slashes") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1311" href="#t1311">1311</a></span><span class="t"><span class="str"> down deep with slashes //zzz</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1312" href="#t1312">1312</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1313" href="#t1313">1313</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1314" href="#t1314">1314</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="nam">fix_backslashes</span><span class="op">(</span><span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1315" href="#t1315">1315</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1316" href="#t1316">1316</a></span><span class="t"><span class="str"> 'one 1.cog' -s ' //xxx'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1317" href="#t1317">1317</a></span><span class="t"><span class="str"> subdir\\subback.cog -s ' //yyy'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1318" href="#t1318">1318</a></span><span class="t"><span class="str"> subdir/subfwd.cog -s ' //zzz'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1319" href="#t1319">1319</a></span><span class="t"><span class="str"> """</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1320" href="#t1320">1320</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1321" href="#t1321">1321</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1322" href="#t1322">1322</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1323" href="#t1323">1323</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1324" href="#t1324">1324</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one 1.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1325" href="#t1325">1325</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'subdir/subback.cog'</span><span class="op">,</span> <span class="str">'subback.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1326" href="#t1326">1326</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'subdir/subfwd.cog'</span><span class="op">,</span> <span class="str">'subfwd.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1327" href="#t1327">1327</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1328" href="#t1328">1328</a></span><span class="t"> <span class="key">def</span> <span class="nam">run_with_verbosity</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">verbosity</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1329" href="#t1329">1329</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1330" href="#t1330">1330</a></span><span class="t"> <span class="str">'unchanged.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1331" href="#t1331">1331</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1332" href="#t1332">1332</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1333" href="#t1333">1333</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1334" href="#t1334">1334</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1335" href="#t1335">1335</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1336" href="#t1336">1336</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1337" href="#t1337">1337</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1338" href="#t1338">1338</a></span><span class="t"> <span class="str">'changed.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1339" href="#t1339">1339</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1340" href="#t1340">1340</a></span><span class="t"><span class="str"> cog.outl("goodbye cruel world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1341" href="#t1341">1341</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1342" href="#t1342">1342</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1343" href="#t1343">1343</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1344" href="#t1344">1344</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1345" href="#t1345">1345</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1346" href="#t1346">1346</a></span><span class="t"><span class="str"> unchanged.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1347" href="#t1347">1347</a></span><span class="t"><span class="str"> changed.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1348" href="#t1348">1348</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1349" href="#t1349">1349</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1350" href="#t1350">1350</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1351" href="#t1351">1351</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1352" href="#t1352">1352</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'--verbosity='</span><span class="op">+</span><span class="nam">verbosity</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1353" href="#t1353">1353</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1354" href="#t1354">1354</a></span><span class="t"> <span class="key">return</span> <span class="nam">output</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1355" href="#t1355">1355</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1356" href="#t1356">1356</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity0</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1357" href="#t1357">1357</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"0"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1358" href="#t1358">1358</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1359" href="#t1359">1359</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1360" href="#t1360">1360</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity1</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1361" href="#t1361">1361</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"1"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1362" href="#t1362">1362</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging changed.cog (changed)\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1363" href="#t1363">1363</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1364" href="#t1364">1364</a></span><span class="t"> <span class="key">def</span> <span class="nam">test_verbosity2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1365" href="#t1365">1365</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">run_with_verbosity</span><span class="op">(</span><span class="str">"2"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1366" href="#t1366">1366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging unchanged.cog\nCogging changed.cog (changed)\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1367" href="#t1367">1367</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1368" href="#t1368">1368</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1369" href="#t1369">1369</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestLineEndings</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1370" href="#t1370">1370</a></span><span class="t"> <span class="str">"""Tests for -U option (force LF line-endings in output)."""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1371" href="#t1371">1371</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1372" href="#t1372">1372</a></span><span class="t"> <span class="nam">lines_in</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Some text.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1373" href="#t1373">1373</a></span><span class="t"> <span class="str">'//[[[cog'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1374" href="#t1374">1374</a></span><span class="t"> <span class="str">'cog.outl("Cog text")'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1375" href="#t1375">1375</a></span><span class="t"> <span class="str">'//]]]'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1376" href="#t1376">1376</a></span><span class="t"> <span class="str">'gobbledegook.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1377" href="#t1377">1377</a></span><span class="t"> <span class="str">'//[[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1378" href="#t1378">1378</a></span><span class="t"> <span class="str">'epilogue.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1379" href="#t1379">1379</a></span><span class="t"> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1380" href="#t1380">1380</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1381" href="#t1381">1381</a></span><span class="t"> <span class="nam">lines_out</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Some text.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1382" href="#t1382">1382</a></span><span class="t"> <span class="str">'//[[[cog'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1383" href="#t1383">1383</a></span><span class="t"> <span class="str">'cog.outl("Cog text")'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1384" href="#t1384">1384</a></span><span class="t"> <span class="str">'//]]]'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1385" href="#t1385">1385</a></span><span class="t"> <span class="str">'Cog text'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1386" href="#t1386">1386</a></span><span class="t"> <span class="str">'//[[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1387" href="#t1387">1387</a></span><span class="t"> <span class="str">'epilogue.'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1388" href="#t1388">1388</a></span><span class="t"> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1389" href="#t1389">1389</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1390" href="#t1390">1390</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputNativeEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1391" href="#t1391">1391</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'infile'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1392" href="#t1392">1392</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'outfile'</span><span class="op">,</span> <span class="str">'infile'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1393" href="#t1393">1393</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'outfile'</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1394" href="#t1394">1394</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1395" href="#t1395">1395</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputLfEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1396" href="#t1396">1396</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'infile'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1397" href="#t1397">1397</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-U'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'outfile'</span><span class="op">,</span> <span class="str">'infile'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1398" href="#t1398">1398</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'outfile'</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1399" href="#t1399">1399</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1400" href="#t1400">1400</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReplaceNativeEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1401" href="#t1401">1401</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'test.cog'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1402" href="#t1402">1402</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1403" href="#t1403">1403</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1404" href="#t1404">1404</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1405" href="#t1405">1405</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReplaceLfEol</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1406" href="#t1406">1406</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="op">{</span><span class="str">'test.cog'</span><span class="op">:</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_in</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1407" href="#t1407">1407</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-U'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1408" href="#t1408">1408</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFileContent</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines_out</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1409" href="#t1409">1409</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1410" href="#t1410">1410</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1411" href="#t1411">1411</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestCharacterEncoding</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1412" href="#t1412">1412</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1413" href="#t1413">1413</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSimple</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1414" href="#t1414">1414</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1415" href="#t1415">1415</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1416" href="#t1416">1416</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1417" href="#t1417">1417</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1418" href="#t1418">1418</a></span><span class="t"><span class="str"> cog.outl("// Unicode: \xe1\x88\xb4 (U+1234)")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1419" href="#t1419">1419</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1420" href="#t1420">1420</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1421" href="#t1421">1421</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1422" href="#t1422">1422</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1423" href="#t1423">1423</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1424" href="#t1424">1424</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1425" href="#t1425">1425</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1426" href="#t1426">1426</a></span><span class="t"><span class="str"> cog.outl("// Unicode: \xe1\x88\xb4 (U+1234)")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1427" href="#t1427">1427</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1428" href="#t1428">1428</a></span><span class="t"><span class="str"> // Unicode: \xe1\x88\xb4 (U+1234)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1429" href="#t1429">1429</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1430" href="#t1430">1430</a></span><span class="t"><span class="str"> """</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">b"\n"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1431" href="#t1431">1431</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1432" href="#t1432">1432</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1433" href="#t1433">1433</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1434" href="#t1434">1434</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1435" href="#t1435">1435</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1436" href="#t1436">1436</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1437" href="#t1437">1437</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1438" href="#t1438">1438</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1439" href="#t1439">1439</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFileEncodingOption</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1440" href="#t1440">1440</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1441" href="#t1441">1441</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1442" href="#t1442">1442</a></span><span class="t"><span class="str"> // \xca\xee\xe4\xe8\xf0\xe2\xea\xe0 Windows</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1443" href="#t1443">1443</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1444" href="#t1444">1444</a></span><span class="t"><span class="str"> cog.outl("\xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1445" href="#t1445">1445</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1446" href="#t1446">1446</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1447" href="#t1447">1447</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1448" href="#t1448">1448</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1449" href="#t1449">1449</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">b"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1450" href="#t1450">1450</a></span><span class="t"><span class="str"> // \xca\xee\xe4\xe8\xf0\xe2\xea\xe0 Windows</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1451" href="#t1451">1451</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1452" href="#t1452">1452</a></span><span class="t"><span class="str"> cog.outl("\xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1453" href="#t1453">1453</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1454" href="#t1454">1454</a></span><span class="t"><span class="str"> \xd1\xfa\xe5\xf8\xfc \xe5\xf9\xb8 \xfd\xf2\xe8\xf5 \xec\xff\xe3\xea\xe8\xf5 \xf4\xf0\xe0\xed\xf6\xf3\xe7\xf1\xea\xe8\xf5 \xe1\xf3\xeb\xee\xea \xe4\xe0 \xe2\xfb\xef\xe5\xe9 \xf7\xe0\xfe</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1455" href="#t1455">1455</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1456" href="#t1456">1456</a></span><span class="t"><span class="str"> """</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">b"\n"</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">linesep</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1457" href="#t1457">1457</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1458" href="#t1458">1458</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1459" href="#t1459">1459</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">bytes</span><span class="op">=</span><span class="key">True</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1460" href="#t1460">1460</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-n'</span><span class="op">,</span> <span class="str">'cp1251'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1461" href="#t1461">1461</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1462" href="#t1462">1462</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1463" href="#t1463">1463</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1464" href="#t1464">1464</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1465" href="#t1465">1465</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1466" href="#t1466">1466</a></span><span class="t"><span class="key">class</span> <span class="nam">TestCaseWithImports</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1467" href="#t1467">1467</a></span><span class="t"> <span class="str">""" When running tests which import modules, the sys.modules list</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1468" href="#t1468">1468</a></span><span class="t"><span class="str"> leaks from one test to the next. This test case class scrubs</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1469" href="#t1469">1469</a></span><span class="t"><span class="str"> the list after each run to keep the tests isolated from each other.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1470" href="#t1470">1470</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1471" href="#t1471">1471</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1472" href="#t1472">1472</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1473" href="#t1473">1473</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1474" href="#t1474">1474</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">sysmodulekeys</span> <span class="op">=</span> <span class="nam">list</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1475" href="#t1475">1475</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1476" href="#t1476">1476</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1477" href="#t1477">1477</a></span><span class="t"> <span class="nam">modstoscrub</span> <span class="op">=</span> <span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1478" href="#t1478">1478</a></span><span class="t"> <span class="nam">modname</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1479" href="#t1479">1479</a></span><span class="t"> <span class="key">for</span> <span class="nam">modname</span> <span class="key">in</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1480" href="#t1480">1480</a></span><span class="t"> <span class="key">if</span> <span class="nam">modname</span> <span class="key">not</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sysmodulekeys</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1481" href="#t1481">1481</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1482" href="#t1482">1482</a></span><span class="t"> <span class="key">for</span> <span class="nam">modname</span> <span class="key">in</span> <span class="nam">modstoscrub</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1483" href="#t1483">1483</a></span><span class="t"> <span class="key">del</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="nam">modname</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1484" href="#t1484">1484</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1485" href="#t1485">1485</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1486" href="#t1486">1486</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1487" href="#t1487">1487</a></span><span class="t"><span class="key">class</span> <span class="nam">CogIncludeTests</span><span class="op">(</span><span class="nam">TestCaseWithImports</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1488" href="#t1488">1488</a></span><span class="t"> <span class="nam">dincludes</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1489" href="#t1489">1489</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1490" href="#t1490">1490</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1491" href="#t1491">1491</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1492" href="#t1492">1492</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1493" href="#t1493">1493</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1494" href="#t1494">1494</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1495" href="#t1495">1495</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1496" href="#t1496">1496</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1497" href="#t1497">1497</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1498" href="#t1498">1498</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1499" href="#t1499">1499</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1500" href="#t1500">1500</a></span><span class="t"><span class="str"> Hello from mymodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1501" href="#t1501">1501</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1502" href="#t1502">1502</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1503" href="#t1503">1503</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1504" href="#t1504">1504</a></span><span class="t"> <span class="str">'test2.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1505" href="#t1505">1505</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1506" href="#t1506">1506</a></span><span class="t"><span class="str"> import mymodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1507" href="#t1507">1507</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1508" href="#t1508">1508</a></span><span class="t"><span class="str"> Hello from mymodule in inc2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1509" href="#t1509">1509</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1510" href="#t1510">1510</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1511" href="#t1511">1511</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1512" href="#t1512">1512</a></span><span class="t"> <span class="str">'include'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1513" href="#t1513">1513</a></span><span class="t"> <span class="str">'mymodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1514" href="#t1514">1514</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1515" href="#t1515">1515</a></span><span class="t"><span class="str"> cog.outl("Hello from mymodule")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1516" href="#t1516">1516</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1517" href="#t1517">1517</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1518" href="#t1518">1518</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1519" href="#t1519">1519</a></span><span class="t"> <span class="str">'inc2'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1520" href="#t1520">1520</a></span><span class="t"> <span class="str">'mymodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1521" href="#t1521">1521</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1522" href="#t1522">1522</a></span><span class="t"><span class="str"> cog.outl("Hello from mymodule in inc2")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1523" href="#t1523">1523</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1524" href="#t1524">1524</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1525" href="#t1525">1525</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1526" href="#t1526">1526</a></span><span class="t"> <span class="str">'inc3'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1527" href="#t1527">1527</a></span><span class="t"> <span class="str">'someothermodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1528" href="#t1528">1528</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1529" href="#t1529">1529</a></span><span class="t"><span class="str"> cog.outl("This is some other module.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1530" href="#t1530">1530</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1531" href="#t1531">1531</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1532" href="#t1532">1532</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1533" href="#t1533">1533</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1534" href="#t1534">1534</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNeedIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1535" href="#t1535">1535</a></span><span class="t"> <span class="com"># Try it without the -I, to see that an ImportError happens.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1536" href="#t1536">1536</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1537" href="#t1537">1537</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">"(ImportError|ModuleNotFoundError): No module named '?mymodule'?"</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1538" href="#t1538">1538</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUserException</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1539" href="#t1539">1539</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1540" href="#t1540">1540</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1541" href="#t1541">1541</a></span><span class="t"> <span class="key">def</span> <span class="nam">testIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1542" href="#t1542">1542</a></span><span class="t"> <span class="com"># Test that -I adds include directories properly.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1543" href="#t1543">1543</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1544" href="#t1544">1544</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1545" href="#t1545">1545</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1546" href="#t1546">1546</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1547" href="#t1547">1547</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoIncludePaths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1548" href="#t1548">1548</a></span><span class="t"> <span class="com"># Test that two -I's add include directories properly.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1549" href="#t1549">1549</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1550" href="#t1550">1550</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc2'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1551" href="#t1551">1551</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1552" href="#t1552">1552</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1553" href="#t1553">1553</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTwoIncludePaths2</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1554" href="#t1554">1554</a></span><span class="t"> <span class="com"># Test that two -I's add include directories properly.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1555" href="#t1555">1555</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1556" href="#t1556">1556</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc2'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1557" href="#t1557">1557</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test2.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1558" href="#t1558">1558</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1559" href="#t1559">1559</a></span><span class="t"> <span class="key">def</span> <span class="nam">testUselessIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1560" href="#t1560">1560</a></span><span class="t"> <span class="com"># Test that the search will continue past the first directory.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1561" href="#t1561">1561</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">dincludes</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1562" href="#t1562">1562</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'inc3'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'include'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1563" href="#t1563">1563</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1564" href="#t1564">1564</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1565" href="#t1565">1565</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSysPathIsUnchanged</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1566" href="#t1566">1566</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1567" href="#t1567">1567</a></span><span class="t"> <span class="str">'bad.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1568" href="#t1568">1568</a></span><span class="t"><span class="str"> //[[[cog cog.error("Oh no!") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1569" href="#t1569">1569</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1570" href="#t1570">1570</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1571" href="#t1571">1571</a></span><span class="t"> <span class="str">'good.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1572" href="#t1572">1572</a></span><span class="t"><span class="str"> //[[[cog cog.outl("Oh yes!") ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1573" href="#t1573">1573</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1574" href="#t1574">1574</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1575" href="#t1575">1575</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1576" href="#t1576">1576</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1577" href="#t1577">1577</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1578" href="#t1578">1578</a></span><span class="t"> <span class="com"># Is it unchanged just by creating a cog engine?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1579" href="#t1579">1579</a></span><span class="t"> <span class="nam">oldsyspath</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1580" href="#t1580">1580</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1581" href="#t1581">1581</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1582" href="#t1582">1582</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1583" href="#t1583">1583</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1584" href="#t1584">1584</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1585" href="#t1585">1585</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1586" href="#t1586">1586</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run with includes?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1587" href="#t1587">1587</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1588" href="#t1588">1588</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1589" href="#t1589">1589</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1590" href="#t1590">1590</a></span><span class="t"> <span class="com"># Is it unchanged for a successful run with two includes?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1591" href="#t1591">1591</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1592" href="#t1592">1592</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'quux'</span><span class="op">,</span> <span class="str">'good.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1593" href="#t1593">1593</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1594" href="#t1594">1594</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1595" href="#t1595">1595</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1596" href="#t1596">1596</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1597" href="#t1597">1597</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1598" href="#t1598">1598</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1599" href="#t1599">1599</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run with includes?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1600" href="#t1600">1600</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1601" href="#t1601">1601</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1602" href="#t1602">1602</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1603" href="#t1603">1603</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1604" href="#t1604">1604</a></span><span class="t"> <span class="com"># Is it unchanged for a failed run with two includes?</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1605" href="#t1605">1605</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1606" href="#t1606">1606</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">r"^Oh no!$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1607" href="#t1607">1607</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'xyzzy'</span><span class="op">,</span> <span class="str">'-I'</span><span class="op">,</span> <span class="str">'quux'</span><span class="op">,</span> <span class="str">'bad.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1608" href="#t1608">1608</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">oldsyspath</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1609" href="#t1609">1609</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1610" href="#t1610">1610</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSubDirectories</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1611" href="#t1611">1611</a></span><span class="t"> <span class="com"># Test that relative paths on the command line work, with includes.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1612" href="#t1612">1612</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1613" href="#t1613">1613</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1614" href="#t1614">1614</a></span><span class="t"> <span class="str">'code'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1615" href="#t1615">1615</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1616" href="#t1616">1616</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1617" href="#t1617">1617</a></span><span class="t"><span class="str"> import mysubmodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1618" href="#t1618">1618</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1619" href="#t1619">1619</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1620" href="#t1620">1620</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1621" href="#t1621">1621</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1622" href="#t1622">1622</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1623" href="#t1623">1623</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1624" href="#t1624">1624</a></span><span class="t"><span class="str"> import mysubmodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1625" href="#t1625">1625</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1626" href="#t1626">1626</a></span><span class="t"><span class="str"> Hello from mysubmodule</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1627" href="#t1627">1627</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1628" href="#t1628">1628</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1629" href="#t1629">1629</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1630" href="#t1630">1630</a></span><span class="t"> <span class="str">'mysubmodule.py'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1631" href="#t1631">1631</a></span><span class="t"><span class="str"> import cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1632" href="#t1632">1632</a></span><span class="t"><span class="str"> cog.outl("Hello from mysubmodule")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1633" href="#t1633">1633</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1634" href="#t1634">1634</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1635" href="#t1635">1635</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1636" href="#t1636">1636</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1637" href="#t1637">1637</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1638" href="#t1638">1638</a></span><span class="t"> <span class="com"># We should be able to invoke cog without the -I switch, and it will</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1639" href="#t1639">1639</a></span><span class="t"> <span class="com"># auto-include the current directory</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1640" href="#t1640">1640</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'code/test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1641" href="#t1641">1641</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'code/test.cog'</span><span class="op">,</span> <span class="str">'code/test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1642" href="#t1642">1642</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1643" href="#t1643">1643</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1644" href="#t1644">1644</a></span><span class="t"><span class="key">class</span> <span class="nam">CogTestsInFiles</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1645" href="#t1645">1645</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1646" href="#t1646">1646</a></span><span class="t"> <span class="key">def</span> <span class="nam">testWarnIfNoCogCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1647" href="#t1647">1647</a></span><span class="t"> <span class="com"># Test that the -e switch warns if there is no Cog code.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1648" href="#t1648">1648</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1649" href="#t1649">1649</a></span><span class="t"> <span class="str">'with.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1650" href="#t1650">1650</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1651" href="#t1651">1651</a></span><span class="t"><span class="str"> cog.outl("hello world")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1652" href="#t1652">1652</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1653" href="#t1653">1653</a></span><span class="t"><span class="str"> hello world</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1654" href="#t1654">1654</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1655" href="#t1655">1655</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1656" href="#t1656">1656</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1657" href="#t1657">1657</a></span><span class="t"> <span class="str">'without.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1658" href="#t1658">1658</a></span><span class="t"><span class="str"> There's no cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1659" href="#t1659">1659</a></span><span class="t"><span class="str"> code in this file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1660" href="#t1660">1660</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1661" href="#t1661">1661</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1662" href="#t1662">1662</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1663" href="#t1663">1663</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1664" href="#t1664">1664</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-e'</span><span class="op">,</span> <span class="str">'with.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1665" href="#t1665">1665</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1666" href="#t1666">1666</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotIn</span><span class="op">(</span><span class="str">"Warning"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1667" href="#t1667">1667</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1668" href="#t1668">1668</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-e'</span><span class="op">,</span> <span class="str">'without.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1669" href="#t1669">1669</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1670" href="#t1670">1670</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"Warning: no cog code found in without.cog"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1671" href="#t1671">1671</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1672" href="#t1672">1672</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'without.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1673" href="#t1673">1673</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1674" href="#t1674">1674</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertNotIn</span><span class="op">(</span><span class="str">"Warning"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1675" href="#t1675">1675</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1676" href="#t1676">1676</a></span><span class="t"> <span class="key">def</span> <span class="nam">testFileNameProps</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1677" href="#t1677">1677</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1678" href="#t1678">1678</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1679" href="#t1679">1679</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1680" href="#t1680">1680</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1681" href="#t1681">1681</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1682" href="#t1682">1682</a></span><span class="t"><span class="str"> this is cog1.txt in, cog1.txt out</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1683" href="#t1683">1683</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1684" href="#t1684">1684</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1685" href="#t1685">1685</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1686" href="#t1686">1686</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1687" href="#t1687">1687</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1688" href="#t1688">1688</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1689" href="#t1689">1689</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1690" href="#t1690">1690</a></span><span class="t"><span class="str"> This is cog1.txt in, cog1.txt out</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1691" href="#t1691">1691</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1692" href="#t1692">1692</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1693" href="#t1693">1693</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1694" href="#t1694">1694</a></span><span class="t"> <span class="str">'cog1out.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1695" href="#t1695">1695</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1696" href="#t1696">1696</a></span><span class="t"><span class="str"> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1697" href="#t1697">1697</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1698" href="#t1698">1698</a></span><span class="t"><span class="str"> This is cog1.txt in, cog1out.txt out</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1699" href="#t1699">1699</a></span><span class="t"><span class="str"> [[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1700" href="#t1700">1700</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1701" href="#t1701">1701</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1702" href="#t1702">1702</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1703" href="#t1703">1703</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1704" href="#t1704">1704</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1705" href="#t1705">1705</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1706" href="#t1706">1706</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1707" href="#t1707">1707</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'cog1out.txt'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1708" href="#t1708">1708</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1out.txt'</span><span class="op">,</span> <span class="str">'cog1out.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1709" href="#t1709">1709</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1710" href="#t1710">1710</a></span><span class="t"> <span class="key">def</span> <span class="nam">testGlobalsDontCrossFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1711" href="#t1711">1711</a></span><span class="t"> <span class="com"># Make sure that global values don't get shared between files.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1712" href="#t1712">1712</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1713" href="#t1713">1713</a></span><span class="t"> <span class="str">'one.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1714" href="#t1714">1714</a></span><span class="t"><span class="str"> //[[[cog s = "This was set in one.cog" ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1715" href="#t1715">1715</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1716" href="#t1716">1716</a></span><span class="t"><span class="str"> //[[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1717" href="#t1717">1717</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1718" href="#t1718">1718</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1719" href="#t1719">1719</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1720" href="#t1720">1720</a></span><span class="t"> <span class="str">'one.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1721" href="#t1721">1721</a></span><span class="t"><span class="str"> //[[[cog s = "This was set in one.cog" ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1722" href="#t1722">1722</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1723" href="#t1723">1723</a></span><span class="t"><span class="str"> //[[[cog cog.outl(s) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1724" href="#t1724">1724</a></span><span class="t"><span class="str"> This was set in one.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1725" href="#t1725">1725</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1726" href="#t1726">1726</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1727" href="#t1727">1727</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1728" href="#t1728">1728</a></span><span class="t"> <span class="str">'two.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1729" href="#t1729">1729</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1730" href="#t1730">1730</a></span><span class="t"><span class="str"> try:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1731" href="#t1731">1731</a></span><span class="t"><span class="str"> cog.outl(s)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1732" href="#t1732">1732</a></span><span class="t"><span class="str"> except NameError:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1733" href="#t1733">1733</a></span><span class="t"><span class="str"> cog.outl("s isn't set!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1734" href="#t1734">1734</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1735" href="#t1735">1735</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1736" href="#t1736">1736</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1737" href="#t1737">1737</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1738" href="#t1738">1738</a></span><span class="t"> <span class="str">'two.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1739" href="#t1739">1739</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1740" href="#t1740">1740</a></span><span class="t"><span class="str"> try:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1741" href="#t1741">1741</a></span><span class="t"><span class="str"> cog.outl(s)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1742" href="#t1742">1742</a></span><span class="t"><span class="str"> except NameError:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1743" href="#t1743">1743</a></span><span class="t"><span class="str"> cog.outl("s isn't set!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1744" href="#t1744">1744</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1745" href="#t1745">1745</a></span><span class="t"><span class="str"> s isn't set!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1746" href="#t1746">1746</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1747" href="#t1747">1747</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1748" href="#t1748">1748</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1749" href="#t1749">1749</a></span><span class="t"> <span class="str">'cogfiles.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1750" href="#t1750">1750</a></span><span class="t"><span class="str"> # Please run cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1751" href="#t1751">1751</a></span><span class="t"><span class="str"> one.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1752" href="#t1752">1752</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1753" href="#t1753">1753</a></span><span class="t"><span class="str"> two.cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1754" href="#t1754">1754</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1755" href="#t1755">1755</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1756" href="#t1756">1756</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1757" href="#t1757">1757</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1758" href="#t1758">1758</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'@cogfiles.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1759" href="#t1759">1759</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'one.cog'</span><span class="op">,</span> <span class="str">'one.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1760" href="#t1760">1760</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'two.cog'</span><span class="op">,</span> <span class="str">'two.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1761" href="#t1761">1761</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1762" href="#t1762">1762</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"(changed)"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1763" href="#t1763">1763</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1764" href="#t1764">1764</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRemoveGeneratedOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1765" href="#t1765">1765</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1766" href="#t1766">1766</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1767" href="#t1767">1767</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1768" href="#t1768">1768</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1769" href="#t1769">1769</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1770" href="#t1770">1770</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1771" href="#t1771">1771</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1772" href="#t1772">1772</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1773" href="#t1773">1773</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1774" href="#t1774">1774</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1775" href="#t1775">1775</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1776" href="#t1776">1776</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1777" href="#t1777">1777</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1778" href="#t1778">1778</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1779" href="#t1779">1779</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1780" href="#t1780">1780</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1781" href="#t1781">1781</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1782" href="#t1782">1782</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1783" href="#t1783">1783</a></span><span class="t"> <span class="str">'cog1.out2'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1784" href="#t1784">1784</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1785" href="#t1785">1785</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1786" href="#t1786">1786</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1787" href="#t1787">1787</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1788" href="#t1788">1788</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1789" href="#t1789">1789</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1790" href="#t1790">1790</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1791" href="#t1791">1791</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1792" href="#t1792">1792</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1793" href="#t1793">1793</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1794" href="#t1794">1794</a></span><span class="t"> <span class="com"># Remove generated output.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1795" href="#t1795">1795</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-x'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1796" href="#t1796">1796</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1797" href="#t1797">1797</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1798" href="#t1798">1798</a></span><span class="t"> <span class="com"># Regenerate the generated output.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1799" href="#t1799">1799</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1800" href="#t1800">1800</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out2'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1801" href="#t1801">1801</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">newCog</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1802" href="#t1802">1802</a></span><span class="t"> <span class="com"># Remove the generated output again.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1803" href="#t1803">1803</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-x'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1804" href="#t1804">1804</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1805" href="#t1805">1805</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1806" href="#t1806">1806</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMsgCall</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1807" href="#t1807">1807</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1808" href="#t1808">1808</a></span><span class="t"><span class="str"> #[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1809" href="#t1809">1809</a></span><span class="t"><span class="str"> cog.msg("Hello there!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1810" href="#t1810">1810</a></span><span class="t"><span class="str"> #]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1811" href="#t1811">1811</a></span><span class="t"><span class="str"> #[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1812" href="#t1812">1812</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1813" href="#t1813">1813</a></span><span class="t"> <span class="nam">infile</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1814" href="#t1814">1814</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">infile</span><span class="op">)</span><span class="op">,</span> <span class="nam">infile</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1815" href="#t1815">1815</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1816" href="#t1816">1816</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Message: Hello there!\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1817" href="#t1817">1817</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1818" href="#t1818">1818</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorMessageHasNoTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1819" href="#t1819">1819</a></span><span class="t"> <span class="com"># Test that a Cog error is printed to stderr with no traceback.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1820" href="#t1820">1820</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1821" href="#t1821">1821</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1822" href="#t1822">1822</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1823" href="#t1823">1823</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1824" href="#t1824">1824</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1825" href="#t1825">1825</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1826" href="#t1826">1826</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1827" href="#t1827">1827</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1828" href="#t1828">1828</a></span><span class="t"><span class="str"> Xhis line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1829" href="#t1829">1829</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1830" href="#t1830">1830</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1831" href="#t1831">1831</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1832" href="#t1832">1832</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1833" href="#t1833">1833</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1834" href="#t1834">1834</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1835" href="#t1835">1835</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1836" href="#t1836">1836</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1837" href="#t1837">1837</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1838" href="#t1838">1838</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">"cog1.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1839" href="#t1839">1839</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">"Cogging cog1.txt\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1840" href="#t1840">1840</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">"cog1.txt(9): Output has been edited! Delete old checksum to unprotect.\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1841" href="#t1841">1841</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1842" href="#t1842">1842</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDashD</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1843" href="#t1843">1843</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1844" href="#t1844">1844</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1845" href="#t1845">1845</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1846" href="#t1846">1846</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1847" href="#t1847">1847</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1848" href="#t1848">1848</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1849" href="#t1849">1849</a></span><span class="t"> <span class="str">'test.kablooey'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1850" href="#t1850">1850</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1851" href="#t1851">1851</a></span><span class="t"><span class="str"> Defined fooey as kablooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1852" href="#t1852">1852</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1853" href="#t1853">1853</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1854" href="#t1854">1854</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1855" href="#t1855">1855</a></span><span class="t"> <span class="str">'test.einstein'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1856" href="#t1856">1856</a></span><span class="t"><span class="str"> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1857" href="#t1857">1857</a></span><span class="t"><span class="str"> Defined fooey as e=mc2</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1858" href="#t1858">1858</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1859" href="#t1859">1859</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1860" href="#t1860">1860</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1861" href="#t1861">1861</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1862" href="#t1862">1862</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1863" href="#t1863">1863</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'fooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1864" href="#t1864">1864</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1865" href="#t1865">1865</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1866" href="#t1866">1866</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1867" href="#t1867">1867</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1868" href="#t1868">1868</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1869" href="#t1869">1869</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=e=mc2'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1870" href="#t1870">1870</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.einstein'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1871" href="#t1871">1871</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1872" href="#t1872">1872</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dbar=quux'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1873" href="#t1873">1873</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1874" href="#t1874">1874</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1875" href="#t1875">1875</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'-Dbar=quux'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1876" href="#t1876">1876</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1877" href="#t1877">1877</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1878" href="#t1878">1878</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-Dfooey=gooey'</span><span class="op">,</span> <span class="str">'-Dfooey=kablooey'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1879" href="#t1879">1879</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.kablooey'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1880" href="#t1880">1880</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1881" href="#t1881">1881</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOutputToStdout</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1882" href="#t1882">1882</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1883" href="#t1883">1883</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1884" href="#t1884">1884</a></span><span class="t"><span class="str"> --[[[cog cog.outl('Hey there!') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1885" href="#t1885">1885</a></span><span class="t"><span class="str"> --[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1886" href="#t1886">1886</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1887" href="#t1887">1887</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1888" href="#t1888">1888</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1889" href="#t1889">1889</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1890" href="#t1890">1890</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1891" href="#t1891">1891</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1892" href="#t1892">1892</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1893" href="#t1893">1893</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1894" href="#t1894">1894</a></span><span class="t"> <span class="nam">outerr</span> <span class="op">=</span> <span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1895" href="#t1895">1895</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"--[[[cog cog.outl('Hey there!') ]]]\nHey there!\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1896" href="#t1896">1896</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">outerr</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1897" href="#t1897">1897</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1898" href="#t1898">1898</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadFromStdin</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1899" href="#t1899">1899</a></span><span class="t"> <span class="nam">stdin</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="str">"--[[[cog cog.outl('Wow') ]]]\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1900" href="#t1900">1900</a></span><span class="t"> <span class="key">def</span> <span class="nam">restore_stdin</span><span class="op">(</span><span class="nam">old_stdin</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1901" href="#t1901">1901</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> <span class="op">=</span> <span class="nam">old_stdin</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1902" href="#t1902">1902</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">addCleanup</span><span class="op">(</span><span class="nam">restore_stdin</span><span class="op">,</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1903" href="#t1903">1903</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span> <span class="op">=</span> <span class="nam">stdin</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1904" href="#t1904">1904</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1905" href="#t1905">1905</a></span><span class="t"> <span class="nam">stderr</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1906" href="#t1906">1906</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stderr</span><span class="op">=</span><span class="nam">stderr</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1907" href="#t1907">1907</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1908" href="#t1908">1908</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1909" href="#t1909">1909</a></span><span class="t"> <span class="nam">outerr</span> <span class="op">=</span> <span class="nam">stderr</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1910" href="#t1910">1910</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"--[[[cog cog.outl('Wow') ]]]\nWow\n--[[[end]]]\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1911" href="#t1911">1911</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">outerr</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1912" href="#t1912">1912</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1913" href="#t1913">1913</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSuffixOutputLines</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1914" href="#t1914">1914</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1915" href="#t1915">1915</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1916" href="#t1916">1916</a></span><span class="t"><span class="str"> Hey there.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1917" href="#t1917">1917</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1918" href="#t1918">1918</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1919" href="#t1919">1919</a></span><span class="t"><span class="str"> Good bye.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1920" href="#t1920">1920</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1921" href="#t1921">1921</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1922" href="#t1922">1922</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1923" href="#t1923">1923</a></span><span class="t"><span class="str"> Hey there.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1924" href="#t1924">1924</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1925" href="#t1925">1925</a></span><span class="t"><span class="str"> a (foo)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1926" href="#t1926">1926</a></span><span class="t"><span class="str"> b (foo)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1927" href="#t1927">1927</a></span><span class="t"><span class="str"> """</span> <span class="com"># These three trailing spaces are important.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1928" href="#t1928">1928</a></span><span class="t"> <span class="com"># The suffix is not applied to completely blank lines.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1929" href="#t1929">1929</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1930" href="#t1930">1930</a></span><span class="t"><span class="str"> c (foo)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1931" href="#t1931">1931</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1932" href="#t1932">1932</a></span><span class="t"><span class="str"> Good bye.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1933" href="#t1933">1933</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1934" href="#t1934">1934</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1935" href="#t1935">1935</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1936" href="#t1936">1936</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1937" href="#t1937">1937</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">' (foo)'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1938" href="#t1938">1938</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1939" href="#t1939">1939</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1940" href="#t1940">1940</a></span><span class="t"> <span class="key">def</span> <span class="nam">testEmptySuffix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1941" href="#t1941">1941</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1942" href="#t1942">1942</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1943" href="#t1943">1943</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1944" href="#t1944">1944</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1945" href="#t1945">1945</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1946" href="#t1946">1946</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1947" href="#t1947">1947</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1948" href="#t1948">1948</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1949" href="#t1949">1949</a></span><span class="t"><span class="str"> a</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1950" href="#t1950">1950</a></span><span class="t"><span class="str"> b</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1951" href="#t1951">1951</a></span><span class="t"><span class="str"> c</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1952" href="#t1952">1952</a></span><span class="t"><span class="str"> ;[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1953" href="#t1953">1953</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1954" href="#t1954">1954</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1955" href="#t1955">1955</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1956" href="#t1956">1956</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1957" href="#t1957">1957</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1958" href="#t1958">1958</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1959" href="#t1959">1959</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1960" href="#t1960">1960</a></span><span class="t"> <span class="key">def</span> <span class="nam">testHellishSuffix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1961" href="#t1961">1961</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1962" href="#t1962">1962</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1963" href="#t1963">1963</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\n\\nb') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1964" href="#t1964">1964</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1965" href="#t1965">1965</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1966" href="#t1966">1966</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1967" href="#t1967">1967</a></span><span class="t"><span class="str"> ;[[[cog cog.outl('a\\n\\nb') ]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1968" href="#t1968">1968</a></span><span class="t"><span class="str"> a /\\n*+([)]><</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1969" href="#t1969">1969</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1970" href="#t1970">1970</a></span><span class="t"><span class="str"> b /\\n*+([)]><</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1971" href="#t1971">1971</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1972" href="#t1972">1972</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1973" href="#t1973">1973</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1974" href="#t1974">1974</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1975" href="#t1975">1975</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-z'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-s'</span><span class="op">,</span> <span class="str">r' /\n*+([)]><'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1976" href="#t1976">1976</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1977" href="#t1977">1977</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t1978" href="#t1978">1978</a></span><span class="t"> <span class="key">def</span> <span class="nam">testPrologue</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1979" href="#t1979">1979</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1980" href="#t1980">1980</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1981" href="#t1981">1981</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1982" href="#t1982">1982</a></span><span class="t"><span class="str"> //[[[cog cog.outl(str(math.sqrt(2))[:12])]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1983" href="#t1983">1983</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1984" href="#t1984">1984</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1985" href="#t1985">1985</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1986" href="#t1986">1986</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1987" href="#t1987">1987</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1988" href="#t1988">1988</a></span><span class="t"><span class="str"> Some text.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1989" href="#t1989">1989</a></span><span class="t"><span class="str"> //[[[cog cog.outl(str(math.sqrt(2))[:12])]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1990" href="#t1990">1990</a></span><span class="t"><span class="str"> 1.4142135623</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1991" href="#t1991">1991</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1992" href="#t1992">1992</a></span><span class="t"><span class="str"> epilogue.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1993" href="#t1993">1993</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1994" href="#t1994">1994</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1995" href="#t1995">1995</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1996" href="#t1996">1996</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1997" href="#t1997">1997</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-p'</span><span class="op">,</span> <span class="str">'import math'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t1998" href="#t1998">1998</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t1999" href="#t1999">1999</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2000" href="#t2000">2000</a></span><span class="t"> <span class="key">def</span> <span class="nam">testThreads</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2001" href="#t2001">2001</a></span><span class="t"> <span class="com"># Test that the implicitly imported cog module is actually different for</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2002" href="#t2002">2002</a></span><span class="t"> <span class="com"># different threads.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2003" href="#t2003">2003</a></span><span class="t"> <span class="nam">numthreads</span> <span class="op">=</span> <span class="num">20</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2004" href="#t2004">2004</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2005" href="#t2005">2005</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2006" href="#t2006">2006</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">numthreads</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2007" href="#t2007">2007</a></span><span class="t"> <span class="nam">d</span><span class="op">[</span><span class="str">'f{}.cog'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">i</span><span class="op">)</span><span class="op">]</span> <span class="op">=</span> <span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2008" href="#t2008">2008</a></span><span class="t"> <span class="str">"x\n"</span> <span class="op">*</span> <span class="nam">i</span> <span class="op">+</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2009" href="#t2009">2009</a></span><span class="t"> <span class="str">"[[[cog\n"</span> <span class="op">+</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2010" href="#t2010">2010</a></span><span class="t"> <span class="str">"assert cog.firstLineNum == int(FIRST) == {}\n"</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">i</span><span class="op">+</span><span class="num">1</span><span class="op">)</span> <span class="op">+</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2011" href="#t2011">2011</a></span><span class="t"> <span class="str">"]]]\n"</span> <span class="op">+</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2012" href="#t2012">2012</a></span><span class="t"> <span class="str">"[[[end]]]\n"</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2013" href="#t2013">2013</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2014" href="#t2014">2014</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2015" href="#t2015">2015</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2016" href="#t2016">2016</a></span><span class="t"> <span class="nam">results</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2017" href="#t2017">2017</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2018" href="#t2018">2018</a></span><span class="t"> <span class="key">def</span> <span class="nam">thread_main</span><span class="op">(</span><span class="nam">num</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2019" href="#t2019">2019</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2020" href="#t2020">2020</a></span><span class="t"> <span class="nam">ret</span> <span class="op">=</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2021" href="#t2021">2021</a></span><span class="t"> <span class="op">[</span><span class="str">'cog.py'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-D'</span><span class="op">,</span> <span class="str">'FIRST={}'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">num</span><span class="op">+</span><span class="num">1</span><span class="op">)</span><span class="op">,</span> <span class="str">'f{}.cog'</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">num</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2022" href="#t2022">2022</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2023" href="#t2023">2023</a></span><span class="t"> <span class="key">assert</span> <span class="nam">ret</span> <span class="op">==</span> <span class="num">0</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2024" href="#t2024">2024</a></span><span class="t"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">exc</span><span class="op">:</span> <span class="com"># pragma: no cover (only happens on test failure)</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2025" href="#t2025">2025</a></span><span class="t"> <span class="nam">results</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">exc</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2026" href="#t2026">2026</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2027" href="#t2027">2027</a></span><span class="t"> <span class="nam">results</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="key">None</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2028" href="#t2028">2028</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2029" href="#t2029">2029</a></span><span class="t"> <span class="nam">ts</span> <span class="op">=</span> <span class="op">[</span><span class="nam">threading</span><span class="op">.</span><span class="nam">Thread</span><span class="op">(</span><span class="nam">target</span><span class="op">=</span><span class="nam">thread_main</span><span class="op">,</span> <span class="nam">args</span><span class="op">=</span><span class="op">(</span><span class="nam">i</span><span class="op">,</span><span class="op">)</span><span class="op">)</span> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">numthreads</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2030" href="#t2030">2030</a></span><span class="t"> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">ts</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2031" href="#t2031">2031</a></span><span class="t"> <span class="nam">t</span><span class="op">.</span><span class="nam">start</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2032" href="#t2032">2032</a></span><span class="t"> <span class="key">for</span> <span class="nam">t</span> <span class="key">in</span> <span class="nam">ts</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2033" href="#t2033">2033</a></span><span class="t"> <span class="nam">t</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2034" href="#t2034">2034</a></span><span class="t"> <span class="key">assert</span> <span class="nam">results</span> <span class="op">==</span> <span class="op">[</span><span class="key">None</span><span class="op">]</span> <span class="op">*</span> <span class="nam">numthreads</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2035" href="#t2035">2035</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2036" href="#t2036">2036</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2037" href="#t2037">2037</a></span><span class="t"><span class="key">class</span> <span class="nam">WritabilityTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2038" href="#t2038">2038</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2039" href="#t2039">2039</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2040" href="#t2040">2040</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2041" href="#t2041">2041</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2042" href="#t2042">2042</a></span><span class="t"><span class="str"> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2043" href="#t2043">2043</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2044" href="#t2044">2044</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2045" href="#t2045">2045</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2046" href="#t2046">2046</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2047" href="#t2047">2047</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2048" href="#t2048">2048</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2049" href="#t2049">2049</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2050" href="#t2050">2050</a></span><span class="t"><span class="str"> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2051" href="#t2051">2051</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2052" href="#t2052">2052</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2053" href="#t2053">2053</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2054" href="#t2054">2054</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2055" href="#t2055">2055</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2056" href="#t2056">2056</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2057" href="#t2057">2057</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2058" href="#t2058">2058</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2059" href="#t2059">2059</a></span><span class="t"> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2060" href="#t2060">2060</a></span><span class="t"> <span class="key">if</span> <span class="nam">os</span><span class="op">.</span><span class="nam">name</span> <span class="op">==</span> <span class="str">'nt'</span><span class="op">:</span> <span class="com">#pragma: no cover</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2061" href="#t2061">2061</a></span><span class="t"> <span class="com"># for Windows</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2062" href="#t2062">2062</a></span><span class="t"> <span class="nam">cmd_w_args</span> <span class="op">=</span> <span class="str">'attrib -R %s'</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2063" href="#t2063">2063</a></span><span class="t"> <span class="nam">cmd_w_asterisk</span> <span class="op">=</span> <span class="str">'attrib -R *'</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2064" href="#t2064">2064</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> <span class="com">#pragma: no cover</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2065" href="#t2065">2065</a></span><span class="t"> <span class="com"># for unix-like</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2066" href="#t2066">2066</a></span><span class="t"> <span class="nam">cmd_w_args</span> <span class="op">=</span> <span class="str">'chmod +w %s'</span> </span><span class="r"></span></p> + <p class="exc show_exc"><span class="n"><a id="t2067" href="#t2067">2067</a></span><span class="t"> <span class="nam">cmd_w_asterisk</span> <span class="op">=</span> <span class="str">'chmod +w *'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2068" href="#t2068">2068</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2069" href="#t2069">2069</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2070" href="#t2070">2070</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">WritabilityTests</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">setUp</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2071" href="#t2071">2071</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2072" href="#t2072">2072</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2073" href="#t2073">2073</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chmod</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">stat</span><span class="op">.</span><span class="nam">S_IREAD</span><span class="op">)</span> <span class="com"># Make the file readonly.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2074" href="#t2074">2074</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2075" href="#t2075">2075</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2076" href="#t2076">2076</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2077" href="#t2077">2077</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">chmod</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">stat</span><span class="op">.</span><span class="nam">S_IWRITE</span><span class="op">)</span> <span class="com"># Make the file writable again.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2078" href="#t2078">2078</a></span><span class="t"> <span class="nam">super</span><span class="op">(</span><span class="nam">WritabilityTests</span><span class="op">,</span> <span class="nam">self</span><span class="op">)</span><span class="op">.</span><span class="nam">tearDown</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2079" href="#t2079">2079</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2080" href="#t2080">2080</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyNoCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2081" href="#t2081">2081</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^Can't overwrite test.cog$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2082" href="#t2082">2082</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2083" href="#t2083">2083</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2084" href="#t2084">2084</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2085" href="#t2085">2085</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2086" href="#t2086">2086</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cmd_w_args</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2087" href="#t2087">2087</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2088" href="#t2088">2088</a></span><span class="t"> <span class="key">assert</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2089" href="#t2089">2089</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2090" href="#t2090">2090</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithCommandWithNoSlot</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2091" href="#t2091">2091</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cmd_w_asterisk</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2092" href="#t2092">2092</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2093" href="#t2093">2093</a></span><span class="t"> <span class="key">assert</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2094" href="#t2094">2094</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2095" href="#t2095">2095</a></span><span class="t"> <span class="key">def</span> <span class="nam">testReadonlyWithIneffectualCommand</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2096" href="#t2096">2096</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> <span class="str">"^Couldn't make test.cog writable$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2097" href="#t2097">2097</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-w'</span><span class="op">,</span> <span class="str">'echo %s'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2098" href="#t2098">2098</a></span><span class="t"> <span class="key">assert</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">testcog</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2099" href="#t2099">2099</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2100" href="#t2100">2100</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2101" href="#t2101">2101</a></span><span class="t"><span class="key">class</span> <span class="nam">ChecksumTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2102" href="#t2102">2102</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2103" href="#t2103">2103</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCreateChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2104" href="#t2104">2104</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2105" href="#t2105">2105</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2106" href="#t2106">2106</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2107" href="#t2107">2107</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2108" href="#t2108">2108</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2109" href="#t2109">2109</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2110" href="#t2110">2110</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2111" href="#t2111">2111</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2112" href="#t2112">2112</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2113" href="#t2113">2113</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2114" href="#t2114">2114</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2115" href="#t2115">2115</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2116" href="#t2116">2116</a></span><span class="t"><span class="str"> cog.outl("This line was generated.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2117" href="#t2117">2117</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2118" href="#t2118">2118</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2119" href="#t2119">2119</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2120" href="#t2120">2120</a></span><span class="t"><span class="str"> This line was not.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2121" href="#t2121">2121</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2122" href="#t2122">2122</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2123" href="#t2123">2123</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2124" href="#t2124">2124</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2125" href="#t2125">2125</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2126" href="#t2126">2126</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2127" href="#t2127">2127</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2128" href="#t2128">2128</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCheckChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2129" href="#t2129">2129</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2130" href="#t2130">2130</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2131" href="#t2131">2131</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2132" href="#t2132">2132</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2133" href="#t2133">2133</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2134" href="#t2134">2134</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2135" href="#t2135">2135</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2136" href="#t2136">2136</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2137" href="#t2137">2137</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2138" href="#t2138">2138</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2139" href="#t2139">2139</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2140" href="#t2140">2140</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2141" href="#t2141">2141</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2142" href="#t2142">2142</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2143" href="#t2143">2143</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2144" href="#t2144">2144</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2145" href="#t2145">2145</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2146" href="#t2146">2146</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2147" href="#t2147">2147</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2148" href="#t2148">2148</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2149" href="#t2149">2149</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2150" href="#t2150">2150</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2151" href="#t2151">2151</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2152" href="#t2152">2152</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2153" href="#t2153">2153</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2154" href="#t2154">2154</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2155" href="#t2155">2155</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2156" href="#t2156">2156</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2157" href="#t2157">2157</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRemoveChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2158" href="#t2158">2158</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2159" href="#t2159">2159</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2160" href="#t2160">2160</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2161" href="#t2161">2161</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2162" href="#t2162">2162</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2163" href="#t2163">2163</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2164" href="#t2164">2164</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2165" href="#t2165">2165</a></span><span class="t"><span class="str"> This line was generated.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2166" href="#t2166">2166</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893) fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2167" href="#t2167">2167</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2168" href="#t2168">2168</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2169" href="#t2169">2169</a></span><span class="t"> <span class="str">'cog1.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2170" href="#t2170">2170</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2171" href="#t2171">2171</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2172" href="#t2172">2172</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2173" href="#t2173">2173</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2174" href="#t2174">2174</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2175" href="#t2175">2175</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2176" href="#t2176">2176</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2177" href="#t2177">2177</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2178" href="#t2178">2178</a></span><span class="t"><span class="str"> //[[[end]]] fooey</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2179" href="#t2179">2179</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2180" href="#t2180">2180</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2181" href="#t2181">2181</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2182" href="#t2182">2182</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2183" href="#t2183">2183</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'cog1.txt'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2184" href="#t2184">2184</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'cog1.txt'</span><span class="op">,</span> <span class="str">'cog1.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2185" href="#t2185">2185</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2186" href="#t2186">2186</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTamperedChecksumOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2187" href="#t2187">2187</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2188" href="#t2188">2188</a></span><span class="t"> <span class="str">'cog1.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2189" href="#t2189">2189</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2190" href="#t2190">2190</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2191" href="#t2191">2191</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2192" href="#t2192">2192</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2193" href="#t2193">2193</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2194" href="#t2194">2194</a></span><span class="t"><span class="str"> Xhis line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2195" href="#t2195">2195</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2196" href="#t2196">2196</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2197" href="#t2197">2197</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2198" href="#t2198">2198</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2199" href="#t2199">2199</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2200" href="#t2200">2200</a></span><span class="t"> <span class="str">'cog2.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2201" href="#t2201">2201</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2202" href="#t2202">2202</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2203" href="#t2203">2203</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2204" href="#t2204">2204</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2205" href="#t2205">2205</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2206" href="#t2206">2206</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2207" href="#t2207">2207</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2208" href="#t2208">2208</a></span><span class="t"><span class="str"> blah blah!</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2209" href="#t2209">2209</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2210" href="#t2210">2210</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2211" href="#t2211">2211</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2212" href="#t2212">2212</a></span><span class="t"> <span class="str">'cog3.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2213" href="#t2213">2213</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2214" href="#t2214">2214</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2215" href="#t2215">2215</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2216" href="#t2216">2216</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2217" href="#t2217">2217</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2218" href="#t2218">2218</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2219" href="#t2219">2219</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2220" href="#t2220">2220</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2221" href="#t2221">2221</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2222" href="#t2222">2222</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2223" href="#t2223">2223</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2224" href="#t2224">2224</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2225" href="#t2225">2225</a></span><span class="t"> <span class="str">'cog4.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2226" href="#t2226">2226</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2227" href="#t2227">2227</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2228" href="#t2228">2228</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2229" href="#t2229">2229</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2230" href="#t2230">2230</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2231" href="#t2231">2231</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2232" href="#t2232">2232</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2233" href="#t2233">2233</a></span><span class="t"><span class="str"> blah blah..</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2234" href="#t2234">2234</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2235" href="#t2235">2235</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2236" href="#t2236">2236</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2237" href="#t2237">2237</a></span><span class="t"> <span class="str">'cog5.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2238" href="#t2238">2238</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2239" href="#t2239">2239</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2240" href="#t2240">2240</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2241" href="#t2241">2241</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2242" href="#t2242">2242</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2243" href="#t2243">2243</a></span><span class="t"><span class="str"> This line was newly</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2244" href="#t2244">2244</a></span><span class="t"><span class="str"> generated by cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2245" href="#t2245">2245</a></span><span class="t"><span class="str"> blah blah.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2246" href="#t2246">2246</a></span><span class="t"><span class="str"> extra</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2247" href="#t2247">2247</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2248" href="#t2248">2248</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2249" href="#t2249">2249</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2250" href="#t2250">2250</a></span><span class="t"> <span class="str">'cog6.txt'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2251" href="#t2251">2251</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2252" href="#t2252">2252</a></span><span class="t"><span class="str"> cog.outl("This line was newly")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2253" href="#t2253">2253</a></span><span class="t"><span class="str"> cog.outl("generated by cog")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2254" href="#t2254">2254</a></span><span class="t"><span class="str"> cog.outl("blah blah.")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2255" href="#t2255">2255</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2256" href="#t2256">2256</a></span><span class="t"><span class="str"> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2257" href="#t2257">2257</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2258" href="#t2258">2258</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2259" href="#t2259">2259</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2260" href="#t2260">2260</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2261" href="#t2261">2261</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2262" href="#t2262">2262</a></span><span class="t"> <span class="str">r"^cog1.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2263" href="#t2263">2263</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog1.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2264" href="#t2264">2264</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2265" href="#t2265">2265</a></span><span class="t"> <span class="str">r"^cog2.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2266" href="#t2266">2266</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog2.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2267" href="#t2267">2267</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2268" href="#t2268">2268</a></span><span class="t"> <span class="str">r"^cog3.txt\(10\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2269" href="#t2269">2269</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog3.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2270" href="#t2270">2270</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2271" href="#t2271">2271</a></span><span class="t"> <span class="str">r"^cog4.txt\(9\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2272" href="#t2272">2272</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog4.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2273" href="#t2273">2273</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2274" href="#t2274">2274</a></span><span class="t"> <span class="str">r"^cog5.txt\(10\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2275" href="#t2275">2275</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog5.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2276" href="#t2276">2276</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogError</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2277" href="#t2277">2277</a></span><span class="t"> <span class="str">r"^cog6.txt\(6\): Output has been edited! Delete old checksum to unprotect.$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2278" href="#t2278">2278</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-c'</span><span class="op">,</span> <span class="str">"cog6.txt"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2279" href="#t2279">2279</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2280" href="#t2280">2280</a></span><span class="t"> <span class="key">def</span> <span class="nam">testArgvIsntModified</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2281" href="#t2281">2281</a></span><span class="t"> <span class="nam">argv</span> <span class="op">=</span> <span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-v'</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2282" href="#t2282">2282</a></span><span class="t"> <span class="nam">orig_argv</span> <span class="op">=</span> <span class="nam">argv</span><span class="op">[</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2283" href="#t2283">2283</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2284" href="#t2284">2284</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">argv</span><span class="op">,</span> <span class="nam">orig_argv</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2285" href="#t2285">2285</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2286" href="#t2286">2286</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2287" href="#t2287">2287</a></span><span class="t"><span class="key">class</span> <span class="nam">CustomMarkerTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2288" href="#t2288">2288</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2289" href="#t2289">2289</a></span><span class="t"> <span class="key">def</span> <span class="nam">testCustomerMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2290" href="#t2290">2290</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2291" href="#t2291">2291</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2292" href="#t2292">2292</a></span><span class="t"><span class="str"> //{{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2293" href="#t2293">2293</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2294" href="#t2294">2294</a></span><span class="t"><span class="str"> //}}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2295" href="#t2295">2295</a></span><span class="t"><span class="str"> //{{end}}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2296" href="#t2296">2296</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2297" href="#t2297">2297</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2298" href="#t2298">2298</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2299" href="#t2299">2299</a></span><span class="t"><span class="str"> //{{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2300" href="#t2300">2300</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2301" href="#t2301">2301</a></span><span class="t"><span class="str"> //}}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2302" href="#t2302">2302</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2303" href="#t2303">2303</a></span><span class="t"><span class="str"> //{{end}}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2304" href="#t2304">2304</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2305" href="#t2305">2305</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2306" href="#t2306">2306</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2307" href="#t2307">2307</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2308" href="#t2308">2308</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2309" href="#t2309">2309</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2310" href="#t2310">2310</a></span><span class="t"> <span class="str">'--markers={{ }} {{end}}'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2311" href="#t2311">2311</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2312" href="#t2312">2312</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2313" href="#t2313">2313</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2314" href="#t2314">2314</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2315" href="#t2315">2315</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTrulyWackyMarkers</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2316" href="#t2316">2316</a></span><span class="t"> <span class="com"># Make sure the markers are properly re-escaped.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2317" href="#t2317">2317</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2318" href="#t2318">2318</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2319" href="#t2319">2319</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2320" href="#t2320">2320</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2321" href="#t2321">2321</a></span><span class="t"><span class="str"> //**)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2322" href="#t2322">2322</a></span><span class="t"><span class="str"> //**(end)**</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2323" href="#t2323">2323</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2324" href="#t2324">2324</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2325" href="#t2325">2325</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2326" href="#t2326">2326</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2327" href="#t2327">2327</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2328" href="#t2328">2328</a></span><span class="t"><span class="str"> //**)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2329" href="#t2329">2329</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2330" href="#t2330">2330</a></span><span class="t"><span class="str"> //**(end)**</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2331" href="#t2331">2331</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2332" href="#t2332">2332</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2333" href="#t2333">2333</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2334" href="#t2334">2334</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2335" href="#t2335">2335</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2336" href="#t2336">2336</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2337" href="#t2337">2337</a></span><span class="t"> <span class="str">'--markers=**( **) **(end)**'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2338" href="#t2338">2338</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2339" href="#t2339">2339</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2340" href="#t2340">2340</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2341" href="#t2341">2341</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2342" href="#t2342">2342</a></span><span class="t"> <span class="key">def</span> <span class="nam">testChangeJustOneMarker</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2343" href="#t2343">2343</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2344" href="#t2344">2344</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2345" href="#t2345">2345</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2346" href="#t2346">2346</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2347" href="#t2347">2347</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2348" href="#t2348">2348</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2349" href="#t2349">2349</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2350" href="#t2350">2350</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2351" href="#t2351">2351</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2352" href="#t2352">2352</a></span><span class="t"><span class="str"> //**(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2353" href="#t2353">2353</a></span><span class="t"><span class="str"> cog.outl("void %s();" % "MyFunction")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2354" href="#t2354">2354</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2355" href="#t2355">2355</a></span><span class="t"><span class="str"> void MyFunction();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2356" href="#t2356">2356</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2357" href="#t2357">2357</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2358" href="#t2358">2358</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2359" href="#t2359">2359</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2360" href="#t2360">2360</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2361" href="#t2361">2361</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2362" href="#t2362">2362</a></span><span class="t"> <span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2363" href="#t2363">2363</a></span><span class="t"> <span class="str">'--markers=**( ]]] [[[end]]]'</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2364" href="#t2364">2364</a></span><span class="t"> <span class="str">'test.cog'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2365" href="#t2365">2365</a></span><span class="t"> <span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2366" href="#t2366">2366</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2367" href="#t2367">2367</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2368" href="#t2368">2368</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2369" href="#t2369">2369</a></span><span class="t"><span class="key">class</span> <span class="nam">BlakeTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2370" href="#t2370">2370</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2371" href="#t2371">2371</a></span><span class="t"> <span class="com"># Blake Winton's contributions.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2372" href="#t2372">2372</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDeleteCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2373" href="#t2373">2373</a></span><span class="t"> <span class="com"># -o sets the output file.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2374" href="#t2374">2374</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2375" href="#t2375">2375</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2376" href="#t2376">2376</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2377" href="#t2377">2377</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2378" href="#t2378">2378</a></span><span class="t"><span class="str"> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2379" href="#t2379">2379</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2380" href="#t2380">2380</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2381" href="#t2381">2381</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2382" href="#t2382">2382</a></span><span class="t"><span class="str"> Some Sample Code Here</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2383" href="#t2383">2383</a></span><span class="t"><span class="str"> //[[[end]]]Data Data</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2384" href="#t2384">2384</a></span><span class="t"><span class="str"> And Some More</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2385" href="#t2385">2385</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2386" href="#t2386">2386</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2387" href="#t2387">2387</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2388" href="#t2388">2388</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2389" href="#t2389">2389</a></span><span class="t"><span class="str"> void DoSomething();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2390" href="#t2390">2390</a></span><span class="t"><span class="str"> void DoAnotherThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2391" href="#t2391">2391</a></span><span class="t"><span class="str"> void DoLastThing();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2392" href="#t2392">2392</a></span><span class="t"><span class="str"> And Some More</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2393" href="#t2393">2393</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2394" href="#t2394">2394</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2395" href="#t2395">2395</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2396" href="#t2396">2396</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2397" href="#t2397">2397</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-d'</span><span class="op">,</span> <span class="str">'-o'</span><span class="op">,</span> <span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2398" href="#t2398">2398</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2399" href="#t2399">2399</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2400" href="#t2400">2400</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDeleteCodeWithDashRFails</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2401" href="#t2401">2401</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2402" href="#t2402">2402</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2403" href="#t2403">2403</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2404" href="#t2404">2404</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2405" href="#t2405">2405</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2406" href="#t2406">2406</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2407" href="#t2407">2407</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2408" href="#t2408">2408</a></span><span class="t"> <span class="key">with</span> <span class="nam">self</span><span class="op">.</span><span class="nam">assertRaisesRegex</span><span class="op">(</span><span class="nam">CogUsageError</span><span class="op">,</span> <span class="str">r"^Can't use -d with -r \(or you would delete all your source!\)$"</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2409" href="#t2409">2409</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'-d'</span><span class="op">,</span> <span class="str">'test.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2410" href="#t2410">2410</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2411" href="#t2411">2411</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSettingGlobals</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2412" href="#t2412">2412</a></span><span class="t"> <span class="com"># Blake Winton contributed a way to set the globals that will be used in</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2413" href="#t2413">2413</a></span><span class="t"> <span class="com"># processFile().</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2414" href="#t2414">2414</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2415" href="#t2415">2415</a></span><span class="t"> <span class="str">'test.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2416" href="#t2416">2416</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2417" href="#t2417">2417</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2418" href="#t2418">2418</a></span><span class="t"><span class="str"> for fn in fnames:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2419" href="#t2419">2419</a></span><span class="t"><span class="str"> cog.outl("void %s();" % fn)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2420" href="#t2420">2420</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2421" href="#t2421">2421</a></span><span class="t"><span class="str"> Some Sample Code Here</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2422" href="#t2422">2422</a></span><span class="t"><span class="str"> //[[[end]]]"""</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2423" href="#t2423">2423</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2424" href="#t2424">2424</a></span><span class="t"> <span class="str">'test.out'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2425" href="#t2425">2425</a></span><span class="t"><span class="str"> // This is my C++ file.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2426" href="#t2426">2426</a></span><span class="t"><span class="str"> void DoBlake();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2427" href="#t2427">2427</a></span><span class="t"><span class="str"> void DoWinton();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2428" href="#t2428">2428</a></span><span class="t"><span class="str"> void DoContribution();</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2429" href="#t2429">2429</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2430" href="#t2430">2430</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2431" href="#t2431">2431</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2432" href="#t2432">2432</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2433" href="#t2433">2433</a></span><span class="t"> <span class="nam">globals</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2434" href="#t2434">2434</a></span><span class="t"> <span class="nam">globals</span><span class="op">[</span><span class="str">'fnames'</span><span class="op">]</span> <span class="op">=</span> <span class="op">[</span><span class="str">'DoBlake'</span><span class="op">,</span> <span class="str">'DoWinton'</span><span class="op">,</span> <span class="str">'DoContribution'</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2435" href="#t2435">2435</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">True</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2436" href="#t2436">2436</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="str">'test.cog'</span><span class="op">,</span> <span class="str">'test.cogged'</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="nam">globals</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2437" href="#t2437">2437</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertFilesSame</span><span class="op">(</span><span class="str">'test.cogged'</span><span class="op">,</span> <span class="str">'test.out'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2438" href="#t2438">2438</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2439" href="#t2439">2439</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2440" href="#t2440">2440</a></span><span class="t"><span class="key">class</span> <span class="nam">ErrorCallTests</span><span class="op">(</span><span class="nam">TestCaseWithTempDir</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2441" href="#t2441">2441</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2442" href="#t2442">2442</a></span><span class="t"> <span class="key">def</span> <span class="nam">testErrorCallHasNoTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2443" href="#t2443">2443</a></span><span class="t"> <span class="com"># Test that cog.error() doesn't show a traceback.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2444" href="#t2444">2444</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2445" href="#t2445">2445</a></span><span class="t"> <span class="str">'error.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2446" href="#t2446">2446</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2447" href="#t2447">2447</a></span><span class="t"><span class="str"> cog.error("Something Bad!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2448" href="#t2448">2448</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2449" href="#t2449">2449</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2450" href="#t2450">2450</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2451" href="#t2451">2451</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2452" href="#t2452">2452</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2453" href="#t2453">2453</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2454" href="#t2454">2454</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'error.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2455" href="#t2455">2455</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2456" href="#t2456">2456</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">output</span><span class="op">,</span> <span class="str">"Cogging error.cog\nError: Something Bad!\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2457" href="#t2457">2457</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t2458" href="#t2458">2458</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRealErrorHasTraceback</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2459" href="#t2459">2459</a></span><span class="t"> <span class="com"># Test that a genuine error does show a traceback.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2460" href="#t2460">2460</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2461" href="#t2461">2461</a></span><span class="t"> <span class="str">'error.cog'</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2462" href="#t2462">2462</a></span><span class="t"><span class="str"> //[[[cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2463" href="#t2463">2463</a></span><span class="t"><span class="str"> raise RuntimeError("Hey!")</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2464" href="#t2464">2464</a></span><span class="t"><span class="str"> //]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2465" href="#t2465">2465</a></span><span class="t"><span class="str"> //[[[end]]]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2466" href="#t2466">2466</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2467" href="#t2467">2467</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2468" href="#t2468">2468</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2469" href="#t2469">2469</a></span><span class="t"> <span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2470" href="#t2470">2470</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">cog</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="op">[</span><span class="str">'argv0'</span><span class="op">,</span> <span class="str">'-r'</span><span class="op">,</span> <span class="str">'error.cog'</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2471" href="#t2471">2471</a></span><span class="t"> <span class="nam">output</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">output</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2472" href="#t2472">2472</a></span><span class="t"> <span class="nam">msg</span> <span class="op">=</span> <span class="str">'Actual output:\n'</span> <span class="op">+</span> <span class="nam">output</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2473" href="#t2473">2473</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertTrue</span><span class="op">(</span><span class="nam">output</span><span class="op">.</span><span class="nam">startswith</span><span class="op">(</span><span class="str">"Cogging error.cog\nTraceback (most recent"</span><span class="op">)</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t2474" href="#t2474">2474</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIn</span><span class="op">(</span><span class="str">"RuntimeError: Hey!"</span><span class="op">,</span> <span class="nam">output</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2475" href="#t2475">2475</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2476" href="#t2476">2476</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2477" href="#t2477">2477</a></span><span class="t"><span class="com"># Things not yet tested:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2478" href="#t2478">2478</a></span><span class="t"><span class="com"># - A bad -w command (currently fails silently).</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html b/doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html index 3d9602b6..da37bdf0 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html @@ -6,183 +6,188 @@ <title>Coverage for cogapp/test_makefiles.py: 23.38%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/test_makefiles.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/test_makefiles.py</b>: <span class="pc_cov">23.38%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 71 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">18 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">53 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">71 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">18<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">53<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Test the cogapp.makefiles modules</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">shutil</span> </span><span class="r"></span></p> - <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">random</span> </span><span class="r"></span></p> - <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">tempfile</span> </span><span class="r"></span></p> - <p id="t13" class="pln"><span class="n"><a href="#t13">13</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">makefiles</span> </span><span class="r"></span></p> - <p id="t15" class="run"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">TestCase</span> </span><span class="r"></span></p> - <p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t18" class="run"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="key">class</span> <span class="nam">SimpleTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t21" class="pln"><span class="n"><a href="#t21">21</a></span><span class="t"> <span class="com"># Create a temporary directory.</span> </span><span class="r"></span></p> - <p id="t22" class="mis show_mis"><span class="n"><a href="#t22">22</a></span><span class="t"> <span class="nam">my_dir</span> <span class="op">=</span> <span class="str">'testmakefiles_tempdir_'</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">random</span><span class="op">.</span><span class="nam">random</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">[</span><span class="num">2</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">tempfile</span><span class="op">.</span><span class="nam">gettempdir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">my_dir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t24" class="mis show_mis"><span class="n"><a href="#t24">24</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t25" class="pln"><span class="n"><a href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t26" class="run"><span class="n"><a href="#t26">26</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t27" class="pln"><span class="n"><a href="#t27">27</a></span><span class="t"> <span class="com"># Get rid of the temporary directory.</span> </span><span class="r"></span></p> - <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t"> <span class="nam">shutil</span><span class="op">.</span><span class="nam">rmtree</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t30" class="run"><span class="n"><a href="#t30">30</a></span><span class="t"> <span class="key">def</span> <span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t31" class="mis show_mis"><span class="n"><a href="#t31">31</a></span><span class="t"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t32" class="pln"><span class="n"><a href="#t32">32</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t33" class="run"><span class="n"><a href="#t33">33</a></span><span class="t"> <span class="key">def</span> <span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">d</span><span class="op">,</span> <span class="nam">dname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t34" class="mis show_mis"><span class="n"><a href="#t34">34</a></span><span class="t"> <span class="key">for</span> <span class="nam">fname</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t35" class="mis show_mis"><span class="n"><a href="#t35">35</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t36" class="mis show_mis"><span class="n"><a href="#t36">36</a></span><span class="t"> <span class="key">if</span> <span class="nam">type</span><span class="op">(</span><span class="nam">d</span><span class="op">[</span><span class="nam">fname</span><span class="op">]</span><span class="op">)</span> <span class="op">==</span> <span class="nam">type</span><span class="op">(</span><span class="op">{</span><span class="op">}</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t37" class="mis show_mis"><span class="n"><a href="#t37">37</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d</span><span class="op">[</span><span class="nam">fname</span><span class="op">]</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t39" class="run"><span class="n"><a href="#t39">39</a></span><span class="t"> <span class="key">def</span> <span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">d</span><span class="op">,</span> <span class="nam">dname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t40" class="mis show_mis"><span class="n"><a href="#t40">40</a></span><span class="t"> <span class="key">for</span> <span class="nam">fname</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t41" class="mis show_mis"><span class="n"><a href="#t41">41</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t43" class="run"><span class="n"><a href="#t43">43</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOneFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t44" class="mis show_mis"><span class="n"><a href="#t44">44</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'foo.txt'</span> </span><span class="r"></span></p> - <p id="t45" class="mis show_mis"><span class="n"><a href="#t45">45</a></span><span class="t"> <span class="nam">notfname</span> <span class="op">=</span> <span class="str">'not_here.txt'</span> </span><span class="r"></span></p> - <p id="t46" class="mis show_mis"><span class="n"><a href="#t46">46</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> <span class="nam">fname</span><span class="op">:</span> <span class="str">"howdy"</span> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t47" class="mis show_mis"><span class="n"><a href="#t47">47</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t48" class="mis show_mis"><span class="n"><a href="#t48">48</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t50" class="mis show_mis"><span class="n"><a href="#t50">50</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t51" class="mis show_mis"><span class="n"><a href="#t51">51</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t52" class="mis show_mis"><span class="n"><a href="#t52">52</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t53" class="pln"><span class="n"><a href="#t53">53</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t54" class="mis show_mis"><span class="n"><a href="#t54">54</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t55" class="mis show_mis"><span class="n"><a href="#t55">55</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t56" class="mis show_mis"><span class="n"><a href="#t56">56</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t58" class="run"><span class="n"><a href="#t58">58</a></span><span class="t"> <span class="key">def</span> <span class="nam">testManyFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t59" class="mis show_mis"><span class="n"><a href="#t59">59</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t60" class="pln"><span class="n"><a href="#t60">60</a></span><span class="t"> <span class="str">'top1.txt'</span><span class="op">:</span> <span class="str">"howdy"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t61" class="pln"><span class="n"><a href="#t61">61</a></span><span class="t"> <span class="str">'top2.txt'</span><span class="op">:</span> <span class="str">"hello"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t62" class="pln"><span class="n"><a href="#t62">62</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t"> <span class="str">'sub1.txt'</span><span class="op">:</span> <span class="str">"inside"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t"> <span class="str">'sub2.txt'</span><span class="op">:</span> <span class="str">"inside2"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t65" class="pln"><span class="n"><a href="#t65">65</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t66" class="pln"><span class="n"><a href="#t66">66</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t67" class="pln"><span class="n"><a href="#t67">67</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t68" class="mis show_mis"><span class="n"><a href="#t68">68</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t69" class="mis show_mis"><span class="n"><a href="#t69">69</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t70" class="mis show_mis"><span class="n"><a href="#t70">70</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t71" class="mis show_mis"><span class="n"><a href="#t71">71</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t72" class="mis show_mis"><span class="n"><a href="#t72">72</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t73" class="pln"><span class="n"><a href="#t73">73</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t74" class="run"><span class="n"><a href="#t74">74</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOverlapping</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t75" class="mis show_mis"><span class="n"><a href="#t75">75</a></span><span class="t"> <span class="nam">d1</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t"> <span class="str">'top1.txt'</span><span class="op">:</span> <span class="str">"howdy"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t77" class="pln"><span class="n"><a href="#t77">77</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t78" class="pln"><span class="n"><a href="#t78">78</a></span><span class="t"> <span class="str">'sub1.txt'</span><span class="op">:</span> <span class="str">"inside"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t80" class="pln"><span class="n"><a href="#t80">80</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t81" class="pln"><span class="n"><a href="#t81">81</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t82" class="mis show_mis"><span class="n"><a href="#t82">82</a></span><span class="t"> <span class="nam">d2</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t83" class="pln"><span class="n"><a href="#t83">83</a></span><span class="t"> <span class="str">'top2.txt'</span><span class="op">:</span> <span class="str">"hello"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t84" class="pln"><span class="n"><a href="#t84">84</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t85" class="pln"><span class="n"><a href="#t85">85</a></span><span class="t"> <span class="str">'sub2.txt'</span><span class="op">:</span> <span class="str">"inside2"</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t86" class="pln"><span class="n"><a href="#t86">86</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t87" class="pln"><span class="n"><a href="#t87">87</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t88" class="pln"><span class="n"><a href="#t88">88</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t89" class="mis show_mis"><span class="n"><a href="#t89">89</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t90" class="mis show_mis"><span class="n"><a href="#t90">90</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t91" class="mis show_mis"><span class="n"><a href="#t91">91</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t92" class="mis show_mis"><span class="n"><a href="#t92">92</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t93" class="mis show_mis"><span class="n"><a href="#t93">93</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t94" class="mis show_mis"><span class="n"><a href="#t94">94</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t95" class="mis show_mis"><span class="n"><a href="#t95">95</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t96" class="mis show_mis"><span class="n"><a href="#t96">96</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t97" class="mis show_mis"><span class="n"><a href="#t97">97</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t98" class="mis show_mis"><span class="n"><a href="#t98">98</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t100" class="run"><span class="n"><a href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">testContents</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t101" class="mis show_mis"><span class="n"><a href="#t101">101</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'bar.txt'</span> </span><span class="r"></span></p> - <p id="t102" class="mis show_mis"><span class="n"><a href="#t102">102</a></span><span class="t"> <span class="nam">cont0</span> <span class="op">=</span> <span class="str">"I am bar.txt"</span> </span><span class="r"></span></p> - <p id="t103" class="mis show_mis"><span class="n"><a href="#t103">103</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> <span class="nam">fname</span><span class="op">:</span> <span class="nam">cont0</span> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t104" class="mis show_mis"><span class="n"><a href="#t104">104</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t105" class="mis show_mis"><span class="n"><a href="#t105">105</a></span><span class="t"> <span class="nam">fcont1</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t106" class="mis show_mis"><span class="n"><a href="#t106">106</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">fcont1</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="nam">cont0</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t107" class="mis show_mis"><span class="n"><a href="#t107">107</a></span><span class="t"> <span class="nam">fcont1</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t108" class="pln"><span class="n"><a href="#t108">108</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t109" class="run"><span class="n"><a href="#t109">109</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDedent</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t110" class="mis show_mis"><span class="n"><a href="#t110">110</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'dedent.txt'</span> </span><span class="r"></span></p> - <p id="t111" class="mis show_mis"><span class="n"><a href="#t111">111</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> - <p id="t112" class="pln"><span class="n"><a href="#t112">112</a></span><span class="t"> <span class="nam">fname</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> - <p id="t113" class="pln"><span class="n"><a href="#t113">113</a></span><span class="t"><span class="str"> This is dedent.txt</span> </span><span class="r"></span></p> - <p id="t114" class="pln"><span class="n"><a href="#t114">114</a></span><span class="t"><span class="str"> \tTabbed in.</span> </span><span class="r"></span></p> - <p id="t115" class="pln"><span class="n"><a href="#t115">115</a></span><span class="t"><span class="str"> spaced in.</span> </span><span class="r"></span></p> - <p id="t116" class="pln"><span class="n"><a href="#t116">116</a></span><span class="t"><span class="str"> OK.</span> </span><span class="r"></span></p> - <p id="t117" class="pln"><span class="n"><a href="#t117">117</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t118" class="pln"><span class="n"><a href="#t118">118</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> - <p id="t119" class="mis show_mis"><span class="n"><a href="#t119">119</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t120" class="mis show_mis"><span class="n"><a href="#t120">120</a></span><span class="t"> <span class="nam">fcont</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t121" class="mis show_mis"><span class="n"><a href="#t121">121</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">fcont</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">"This is dedent.txt\n\tTabbed in.\n spaced in.\nOK.\n"</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t122" class="mis show_mis"><span class="n"><a href="#t122">122</a></span><span class="t"> <span class="nam">fcont</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Test the cogapp.makefiles modules</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">shutil</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">random</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">tempfile</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">makefiles</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">TestCase</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"><span class="key">class</span> <span class="nam">SimpleTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> <span class="key">def</span> <span class="nam">setUp</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"> <span class="com"># Create a temporary directory.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> <span class="nam">my_dir</span> <span class="op">=</span> <span class="str">'testmakefiles_tempdir_'</span> <span class="op">+</span> <span class="nam">str</span><span class="op">(</span><span class="nam">random</span><span class="op">.</span><span class="nam">random</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">[</span><span class="num">2</span><span class="op">:</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">tempfile</span><span class="op">.</span><span class="nam">gettempdir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">my_dir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> <span class="nam">os</span><span class="op">.</span><span class="nam">mkdir</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> <span class="key">def</span> <span class="nam">tearDown</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="com"># Get rid of the temporary directory.</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> <span class="nam">shutil</span><span class="op">.</span><span class="nam">rmtree</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> <span class="key">def</span> <span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> <span class="key">def</span> <span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">d</span><span class="op">,</span> <span class="nam">dname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"> <span class="key">for</span> <span class="nam">fname</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="key">if</span> <span class="nam">type</span><span class="op">(</span><span class="nam">d</span><span class="op">[</span><span class="nam">fname</span><span class="op">]</span><span class="op">)</span> <span class="op">==</span> <span class="nam">type</span><span class="op">(</span><span class="op">{</span><span class="op">}</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d</span><span class="op">[</span><span class="nam">fname</span><span class="op">]</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="key">def</span> <span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">d</span><span class="op">,</span> <span class="nam">dname</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="key">for</span> <span class="nam">fname</span> <span class="key">in</span> <span class="nam">d</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">dname</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOneFile</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'foo.txt'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"> <span class="nam">notfname</span> <span class="op">=</span> <span class="str">'not_here.txt'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> <span class="nam">fname</span><span class="op">:</span> <span class="str">"howdy"</span> <span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">notfname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"> <span class="key">def</span> <span class="nam">testManyFiles</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"> <span class="str">'top1.txt'</span><span class="op">:</span> <span class="str">"howdy"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"> <span class="str">'top2.txt'</span><span class="op">:</span> <span class="str">"hello"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"> <span class="str">'sub1.txt'</span><span class="op">:</span> <span class="str">"inside"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"> <span class="str">'sub2.txt'</span><span class="op">:</span> <span class="str">"inside2"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t74" href="#t74">74</a></span><span class="t"> <span class="key">def</span> <span class="nam">testOverlapping</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t75" href="#t75">75</a></span><span class="t"> <span class="nam">d1</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t76" href="#t76">76</a></span><span class="t"> <span class="str">'top1.txt'</span><span class="op">:</span> <span class="str">"howdy"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t77" href="#t77">77</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t78" href="#t78">78</a></span><span class="t"> <span class="str">'sub1.txt'</span><span class="op">:</span> <span class="str">"inside"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t79" href="#t79">79</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t80" href="#t80">80</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t81" href="#t81">81</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t82" href="#t82">82</a></span><span class="t"> <span class="nam">d2</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t83" href="#t83">83</a></span><span class="t"> <span class="str">'top2.txt'</span><span class="op">:</span> <span class="str">"hello"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t84" href="#t84">84</a></span><span class="t"> <span class="str">'sub'</span><span class="op">:</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t85" href="#t85">85</a></span><span class="t"> <span class="str">'sub2.txt'</span><span class="op">:</span> <span class="str">"inside2"</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t86" href="#t86">86</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t87" href="#t87">87</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t88" href="#t88">88</a></span><span class="t"> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t89" href="#t89">89</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t90" href="#t90">90</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t91" href="#t91">91</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t92" href="#t92">92</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t93" href="#t93">93</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t94" href="#t94">94</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t95" href="#t95">95</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t96" href="#t96">96</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">removeFiles</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t97" href="#t97">97</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d1</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t98" href="#t98">98</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">checkFilesDontExist</span><span class="op">(</span><span class="nam">d2</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t99" href="#t99">99</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t100" href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">testContents</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t101" href="#t101">101</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'bar.txt'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t102" href="#t102">102</a></span><span class="t"> <span class="nam">cont0</span> <span class="op">=</span> <span class="str">"I am bar.txt"</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t103" href="#t103">103</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> <span class="nam">fname</span><span class="op">:</span> <span class="nam">cont0</span> <span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t104" href="#t104">104</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t105" href="#t105">105</a></span><span class="t"> <span class="nam">fcont1</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t106" href="#t106">106</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">fcont1</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="nam">cont0</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t107" href="#t107">107</a></span><span class="t"> <span class="nam">fcont1</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t108" href="#t108">108</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t109" href="#t109">109</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDedent</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t110" href="#t110">110</a></span><span class="t"> <span class="nam">fname</span> <span class="op">=</span> <span class="str">'dedent.txt'</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t111" href="#t111">111</a></span><span class="t"> <span class="nam">d</span> <span class="op">=</span> <span class="op">{</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t112" href="#t112">112</a></span><span class="t"> <span class="nam">fname</span><span class="op">:</span> <span class="str">"""\</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t113" href="#t113">113</a></span><span class="t"><span class="str"> This is dedent.txt</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t114" href="#t114">114</a></span><span class="t"><span class="str"> \tTabbed in.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t115" href="#t115">115</a></span><span class="t"><span class="str"> spaced in.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t116" href="#t116">116</a></span><span class="t"><span class="str"> OK.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t117" href="#t117">117</a></span><span class="t"><span class="str"> """</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t118" href="#t118">118</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t119" href="#t119">119</a></span><span class="t"> <span class="nam">makefiles</span><span class="op">.</span><span class="nam">makeFiles</span><span class="op">(</span><span class="nam">d</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t120" href="#t120">120</a></span><span class="t"> <span class="nam">fcont</span> <span class="op">=</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">tempdir</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t121" href="#t121">121</a></span><span class="t"> <span class="key">assert</span><span class="op">(</span><span class="nam">fcont</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">"This is dedent.txt\n\tTabbed in.\n spaced in.\nOK.\n"</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t122" href="#t122">122</a></span><span class="t"> <span class="nam">fcont</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_test_whiteutils_py.html b/doc/sample_html/d_7b071bdc2a35fa80_test_whiteutils_py.html index c311ee37..6d8e91f1 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_test_whiteutils_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_test_whiteutils_py.html @@ -6,162 +6,167 @@ <title>Coverage for cogapp/test_whiteutils.py: 27.54%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/test_whiteutils.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/test_whiteutils.py</b>: <span class="pc_cov">27.54%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 69 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">19 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">50 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">0 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">69 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">19<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">50<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">0<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Test the cogapp.whiteutils module.</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">TestCase</span> </span><span class="r"></span></p> - <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> - <p id="t11" class="pln"><span class="n"><a href="#t11">11</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">class</span> <span class="nam">WhitePrefixTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t14" class="pln"><span class="n"><a href="#t14">14</a></span><span class="t"> <span class="str">""" Test cases for cogapp.whiteutils.</span> </span><span class="r"></span></p> - <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSingleLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t17" class="mis show_mis"><span class="n"><a href="#t17">17</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t18" class="mis show_mis"><span class="n"><a href="#t18">18</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' '</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t19" class="mis show_mis"><span class="n"><a href="#t19">19</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t20" class="mis show_mis"><span class="n"><a href="#t20">20</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t21" class="mis show_mis"><span class="n"><a href="#t21">21</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'\tx'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t22" class="mis show_mis"><span class="n"><a href="#t22">22</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t23" class="mis show_mis"><span class="n"><a href="#t23">23</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' \t \tx '</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' \t \t'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t24" class="pln"><span class="n"><a href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t25" class="run"><span class="n"><a href="#t25">25</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMultiLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t26" class="mis show_mis"><span class="n"><a href="#t26">26</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t27" class="mis show_mis"><span class="n"><a href="#t27">27</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t28" class="mis show_mis"><span class="n"><a href="#t28">28</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t30" class="run"><span class="n"><a href="#t30">30</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBlankLinesAreIgnored</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t31" class="mis show_mis"><span class="n"><a href="#t31">31</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t32" class="mis show_mis"><span class="n"><a href="#t32">32</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t33" class="mis show_mis"><span class="n"><a href="#t33">33</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t34" class="mis show_mis"><span class="n"><a href="#t34">34</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' '</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t36" class="run"><span class="n"><a href="#t36">36</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTabCharacters</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t37" class="mis show_mis"><span class="n"><a href="#t37">37</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'\timport sys'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'\tprint sys.argv'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t39" class="run"><span class="n"><a href="#t39">39</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDecreasingLengths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t40" class="mis show_mis"><span class="n"><a href="#t40">40</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t41" class="mis show_mis"><span class="n"><a href="#t41">41</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t43" class="pln"><span class="n"><a href="#t43">43</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t44" class="run"><span class="n"><a href="#t44">44</a></span><span class="t"><span class="key">class</span> <span class="nam">ReindentBlockTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t"> <span class="str">""" Test cases for cogapp.reindentBlock.</span> </span><span class="r"></span></p> - <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t47" class="run"><span class="n"><a href="#t47">47</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNonTermLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t48" class="mis show_mis"><span class="n"><a href="#t48">48</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">''</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t49" class="mis show_mis"><span class="n"><a href="#t49">49</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t50" class="mis show_mis"><span class="n"><a href="#t50">50</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t51" class="mis show_mis"><span class="n"><a href="#t51">51</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t52" class="mis show_mis"><span class="n"><a href="#t52">52</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\tx'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t53" class="mis show_mis"><span class="n"><a href="#t53">53</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t54" class="mis show_mis"><span class="n"><a href="#t54">54</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t55" class="mis show_mis"><span class="n"><a href="#t55">55</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t56" class="mis show_mis"><span class="n"><a href="#t56">56</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t57" class="mis show_mis"><span class="n"><a href="#t57">57</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t58" class="pln"><span class="n"><a href="#t58">58</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t59" class="run"><span class="n"><a href="#t59">59</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSingleLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t60" class="mis show_mis"><span class="n"><a href="#t60">60</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t61" class="mis show_mis"><span class="n"><a href="#t61">61</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t62" class="mis show_mis"><span class="n"><a href="#t62">62</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t63" class="mis show_mis"><span class="n"><a href="#t63">63</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t64" class="mis show_mis"><span class="n"><a href="#t64">64</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\tx\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t65" class="mis show_mis"><span class="n"><a href="#t65">65</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t66" class="mis show_mis"><span class="n"><a href="#t66">66</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t67" class="mis show_mis"><span class="n"><a href="#t67">67</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t68" class="mis show_mis"><span class="n"><a href="#t68">68</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t69" class="mis show_mis"><span class="n"><a href="#t69">69</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t70" class="pln"><span class="n"><a href="#t70">70</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t71" class="run"><span class="n"><a href="#t71">71</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRealBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t72" class="mis show_mis"><span class="n"><a href="#t72">72</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span> </span><span class="r"></span></p> - <p id="t73" class="pln"><span class="n"><a href="#t73">73</a></span><span class="t"> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\timport sys\n\n\tprint sys.argv\n'</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> - <p id="t74" class="pln"><span class="n"><a href="#t74">74</a></span><span class="t"> <span class="str">'import sys\n\nprint sys.argv\n'</span> </span><span class="r"></span></p> - <p id="t75" class="pln"><span class="n"><a href="#t75">75</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> - <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t77" class="pln"><span class="n"><a href="#t77">77</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t78" class="run"><span class="n"><a href="#t78">78</a></span><span class="t"><span class="key">class</span> <span class="nam">CommonPrefixTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t"> <span class="str">""" Test cases for cogapp.commonPrefix.</span> </span><span class="r"></span></p> - <p id="t80" class="pln"><span class="n"><a href="#t80">80</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t81" class="run"><span class="n"><a href="#t81">81</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDegenerateCases</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t82" class="mis show_mis"><span class="n"><a href="#t82">82</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t83" class="mis show_mis"><span class="n"><a href="#t83">83</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t84" class="mis show_mis"><span class="n"><a href="#t84">84</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t85" class="mis show_mis"><span class="n"><a href="#t85">85</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'cat in the hat'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'cat in the hat'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t86" class="pln"><span class="n"><a href="#t86">86</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t87" class="run"><span class="n"><a href="#t87">87</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCommonPrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t88" class="mis show_mis"><span class="n"><a href="#t88">88</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'b'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t89" class="mis show_mis"><span class="n"><a href="#t89">89</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'b'</span><span class="op">,</span><span class="str">'c'</span><span class="op">,</span><span class="str">'d'</span><span class="op">,</span><span class="str">'e'</span><span class="op">,</span><span class="str">'f'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t90" class="mis show_mis"><span class="n"><a href="#t90">90</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t91" class="pln"><span class="n"><a href="#t91">91</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t92" class="run"><span class="n"><a href="#t92">92</a></span><span class="t"> <span class="key">def</span> <span class="nam">testUsualCases</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t93" class="mis show_mis"><span class="n"><a href="#t93">93</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'ab'</span><span class="op">,</span> <span class="str">'ac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'a'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t94" class="mis show_mis"><span class="n"><a href="#t94">94</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'aab'</span><span class="op">,</span> <span class="str">'aac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'aa'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t95" class="mis show_mis"><span class="n"><a href="#t95">95</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'aab'</span><span class="op">,</span> <span class="str">'aab'</span><span class="op">,</span> <span class="str">'aab'</span><span class="op">,</span> <span class="str">'aac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'aa'</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t96" class="pln"><span class="n"><a href="#t96">96</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t97" class="run"><span class="n"><a href="#t97">97</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBlankLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t98" class="mis show_mis"><span class="n"><a href="#t98">98</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'abc'</span><span class="op">,</span> <span class="str">'abx'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'aby'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t100" class="run"><span class="n"><a href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDecreasingLengths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t101" class="mis show_mis"><span class="n"><a href="#t101">101</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'abcd'</span><span class="op">,</span> <span class="str">'abc'</span><span class="op">,</span> <span class="str">'ab'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'ab'</span><span class="op">)</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Test the cogapp.whiteutils module.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">TestCase</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="op">*</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">class</span> <span class="nam">WhitePrefixTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"> <span class="str">""" Test cases for cogapp.whiteutils.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSingleLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' '</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'\tx'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' \t \tx '</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' \t \t'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> <span class="key">def</span> <span class="nam">testMultiLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">,</span><span class="str">' y'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBlankLinesAreIgnored</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' '</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="key">def</span> <span class="nam">testTabCharacters</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'\timport sys'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'\tprint sys.argv'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDecreasingLengths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">whitePrefix</span><span class="op">(</span><span class="op">[</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">,</span><span class="str">' x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"><span class="key">class</span> <span class="nam">ReindentBlockTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"> <span class="str">""" Test cases for cogapp.reindentBlock.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNonTermLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">''</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\tx'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"> <span class="key">def</span> <span class="nam">testSingleLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\tx\n'</span><span class="op">)</span><span class="op">,</span> <span class="str">'x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'x\n'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">'\t'</span><span class="op">)</span><span class="op">,</span> <span class="str">'\tx\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">reindentBlock</span><span class="op">(</span><span class="str">' x\n'</span><span class="op">,</span> <span class="str">' '</span><span class="op">)</span><span class="op">,</span> <span class="str">' x\n'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> <span class="key">def</span> <span class="nam">testRealBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> <span class="nam">reindentBlock</span><span class="op">(</span><span class="str">'\timport sys\n\n\tprint sys.argv\n'</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t74" href="#t74">74</a></span><span class="t"> <span class="str">'import sys\n\nprint sys.argv\n'</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t75" href="#t75">75</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t76" href="#t76">76</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t77" href="#t77">77</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t78" href="#t78">78</a></span><span class="t"><span class="key">class</span> <span class="nam">CommonPrefixTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t79" href="#t79">79</a></span><span class="t"> <span class="str">""" Test cases for cogapp.commonPrefix.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t80" href="#t80">80</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t81" href="#t81">81</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDegenerateCases</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t82" href="#t82">82</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t83" href="#t83">83</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t84" href="#t84">84</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">,</span><span class="str">''</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t85" href="#t85">85</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'cat in the hat'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'cat in the hat'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t86" href="#t86">86</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t87" href="#t87">87</a></span><span class="t"> <span class="key">def</span> <span class="nam">testNoCommonPrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t88" href="#t88">88</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'b'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t89" href="#t89">89</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'b'</span><span class="op">,</span><span class="str">'c'</span><span class="op">,</span><span class="str">'d'</span><span class="op">,</span><span class="str">'e'</span><span class="op">,</span><span class="str">'f'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t90" href="#t90">90</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'a'</span><span class="op">,</span><span class="str">'x'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t91" href="#t91">91</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t92" href="#t92">92</a></span><span class="t"> <span class="key">def</span> <span class="nam">testUsualCases</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t93" href="#t93">93</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'ab'</span><span class="op">,</span> <span class="str">'ac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'a'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t94" href="#t94">94</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'aab'</span><span class="op">,</span> <span class="str">'aac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'aa'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t95" href="#t95">95</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'aab'</span><span class="op">,</span> <span class="str">'aab'</span><span class="op">,</span> <span class="str">'aab'</span><span class="op">,</span> <span class="str">'aac'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'aa'</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t96" href="#t96">96</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t97" href="#t97">97</a></span><span class="t"> <span class="key">def</span> <span class="nam">testBlankLine</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t98" href="#t98">98</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'abc'</span><span class="op">,</span> <span class="str">'abx'</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="str">'aby'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t99" href="#t99">99</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t100" href="#t100">100</a></span><span class="t"> <span class="key">def</span> <span class="nam">testDecreasingLengths</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t101" href="#t101">101</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEqual</span><span class="op">(</span><span class="nam">commonPrefix</span><span class="op">(</span><span class="op">[</span><span class="str">'abcd'</span><span class="op">,</span> <span class="str">'abc'</span><span class="op">,</span> <span class="str">'ab'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span> <span class="str">'ab'</span><span class="op">)</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html b/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html index 8be3ebd6..6c784697 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html @@ -6,134 +6,139 @@ <title>Coverage for cogapp/whiteutils.py: 88.61%</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="jquery.isonscreen.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.pyfile_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="pyfile"> -<div id="header"> +<header> <div class="content"> - <h1>Coverage for <b>cogapp/whiteutils.py</b> : + <h1> + <span class="text">Coverage for </span><b>cogapp/whiteutils.py</b>: <span class="pc_cov">88.61%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> - <h2 class="stats"> - 45 statements - <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">40 run</button> - <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">5 missing</button> - <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">0 excluded</button> - <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">4 partial</button> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>r</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>p</kbd> toggle line displays + </p> + <p class="keyhelp"> + <kbd>j</kbd> + <kbd>k</kbd> next/prev highlighted chunk + </p> + <p class="keyhelp"> + <kbd>0</kbd> (zero) top of page + </p> + <p class="keyhelp"> + <kbd>1</kbd> (one) first highlighted chunk + </p> + </div> + </div> + </div> + <h2> + <span class="text">45 statements </span> + <button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">40<span class="text"> run</span></button> + <button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">5<span class="text"> missing</span></button> + <button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button> + <button type="button" class="par run show_par button_toggle_par" value="par" data-shortcut="p" title="Toggle lines partially run">4<span class="text"> partial</span></button> </h2> + <div style="display: none;"> + <button type="button" class="button_next_chunk" data-shortcut="j">Next highlighted chunk</button> + <button type="button" class="button_prev_chunk" data-shortcut="k">Previous highlighted chunk</button> + <button type="button" class="button_top_of_page" data-shortcut="0">Goto top of page</button> + <button type="button" class="button_first_chunk" data-shortcut="1">Goto first highlighted chunk</button> + </div> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">r</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">p</span> toggle line displays - </p> - <p class="keyhelp"> - <span class="key">j</span> - <span class="key">k</span> next/prev highlighted chunk - </p> - <p class="keyhelp"> - <span class="key">0</span> (zero) top of page - </p> - <p class="keyhelp"> - <span class="key">1</span> (one) first highlighted chunk - </p> - </div> -</div> -<div id="source"> - <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="str">""" Indentation utilities for Cog.</span> </span><span class="r"></span></p> - <p id="t2" class="pln"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> - <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> - <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> - <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t7" class="run"><span class="n"><a href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> - <p id="t8" class="pln"><span class="n"><a href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t9" class="run"><span class="n"><a href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> - <p id="t10" class="pln"><span class="n"><a href="#t10">10</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">,</span> <span class="nam">to_bytes</span> </span><span class="r"></span></p> - <p id="t12" class="pln"><span class="n"><a href="#t12">12</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">def</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">strings</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t14" class="pln"><span class="n"><a href="#t14">14</a></span><span class="t"> <span class="str">""" Determine the whitespace prefix common to all non-blank lines</span> </span><span class="r"></span></p> - <p id="t15" class="pln"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="str"> in the argument list.</span> </span><span class="r"></span></p> - <p id="t16" class="pln"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t17" class="pln"><span class="n"><a href="#t17">17</a></span><span class="t"> <span class="com"># Remove all blank lines from the list</span> </span><span class="r"></span></p> - <p id="t18" class="run"><span class="n"><a href="#t18">18</a></span><span class="t"> <span class="nam">strings</span> <span class="op">=</span> <span class="op">[</span><span class="nam">s</span> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span> <span class="key">if</span> <span class="nam">s</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">!=</span> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t19" class="pln"><span class="n"><a href="#t19">19</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">strings</span><span class="op">:</span> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t21" class="pln"><span class="n"><a href="#t21">21</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t22" class="pln"><span class="n"><a href="#t22">22</a></span><span class="t"> <span class="com"># Find initial whitespace chunk in the first line.</span> </span><span class="r"></span></p> - <p id="t23" class="pln"><span class="n"><a href="#t23">23</a></span><span class="t"> <span class="com"># This is the best prefix we can hope for.</span> </span><span class="r"></span></p> - <p id="t24" class="run"><span class="n"><a href="#t24">24</a></span><span class="t"> <span class="nam">pat</span> <span class="op">=</span> <span class="str">r'\s*'</span> </span><span class="r"></span></p> - <p id="t25" class="par run show_par"><span class="n"><a href="#t25">25</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">25 ↛ 26</span><span class="annotate long">line 25 didn't jump to line 26, because the condition on line 25 was never true</span></span></p> - <p id="t26" class="mis show_mis"><span class="n"><a href="#t26">26</a></span><span class="t"> <span class="nam">pat</span> <span class="op">=</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">pat</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t27" class="run"><span class="n"><a href="#t27">27</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">match</span><span class="op">(</span><span class="nam">pat</span><span class="op">,</span> <span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">.</span><span class="nam">group</span><span class="op">(</span><span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t28" class="pln"><span class="n"><a href="#t28">28</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"> <span class="com"># Loop over the other strings, keeping only as much of</span> </span><span class="r"></span></p> - <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t"> <span class="com"># the prefix as matches each string.</span> </span><span class="r"></span></p> - <p id="t31" class="run"><span class="n"><a href="#t31">31</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t32" class="run"><span class="n"><a href="#t32">32</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t33" class="par run show_par"><span class="n"><a href="#t33">33</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefix</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span> <span class="op">!=</span> <span class="nam">s</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">:</span> </span><span class="r"><span class="annotate short">33 ↛ 34</span><span class="annotate long">line 33 didn't jump to line 34, because the condition on line 33 was never true</span></span></p> - <p id="t34" class="mis show_mis"><span class="n"><a href="#t34">34</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">i</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t35" class="mis show_mis"><span class="n"><a href="#t35">35</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> - <p id="t36" class="run"><span class="n"><a href="#t36">36</a></span><span class="t"> <span class="key">return</span> <span class="nam">prefix</span> </span><span class="r"></span></p> - <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t38" class="run"><span class="n"><a href="#t38">38</a></span><span class="t"><span class="key">def</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">newIndent</span><span class="op">=</span><span class="str">''</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t"> <span class="str">""" Take a block of text as a string or list of lines.</span> </span><span class="r"></span></p> - <p id="t40" class="pln"><span class="n"><a href="#t40">40</a></span><span class="t"><span class="str"> Remove any common whitespace indentation.</span> </span><span class="r"></span></p> - <p id="t41" class="pln"><span class="n"><a href="#t41">41</a></span><span class="t"><span class="str"> Re-indent using newIndent, and return it as a single string.</span> </span><span class="r"></span></p> - <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t43" class="run"><span class="n"><a href="#t43">43</a></span><span class="t"> <span class="nam">sep</span><span class="op">,</span> <span class="nam">nothing</span> <span class="op">=</span> <span class="str">'\n'</span><span class="op">,</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t44" class="par run show_par"><span class="n"><a href="#t44">44</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">44 ↛ 45</span><span class="annotate long">line 44 didn't jump to line 45, because the condition on line 44 was never true</span></span></p> - <p id="t45" class="mis show_mis"><span class="n"><a href="#t45">45</a></span><span class="t"> <span class="nam">sep</span><span class="op">,</span> <span class="nam">nothing</span> <span class="op">=</span> <span class="str">b'\n'</span><span class="op">,</span> <span class="str">b''</span> </span><span class="r"></span></p> - <p id="t46" class="run"><span class="n"><a href="#t46">46</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t47" class="run"><span class="n"><a href="#t47">47</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">lines</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">sep</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t48" class="run"><span class="n"><a href="#t48">48</a></span><span class="t"> <span class="nam">oldIndent</span> <span class="op">=</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">lines</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t49" class="run"><span class="n"><a href="#t49">49</a></span><span class="t"> <span class="nam">outLines</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t50" class="run"><span class="n"><a href="#t50">50</a></span><span class="t"> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">lines</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t51" class="run"><span class="n"><a href="#t51">51</a></span><span class="t"> <span class="key">if</span> <span class="nam">oldIndent</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t52" class="run"><span class="n"><a href="#t52">52</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">oldIndent</span><span class="op">,</span> <span class="nam">nothing</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t53" class="run"><span class="n"><a href="#t53">53</a></span><span class="t"> <span class="key">if</span> <span class="nam">l</span> <span class="key">and</span> <span class="nam">newIndent</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t54" class="run"><span class="n"><a href="#t54">54</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">newIndent</span> <span class="op">+</span> <span class="nam">l</span> </span><span class="r"></span></p> - <p id="t55" class="run"><span class="n"><a href="#t55">55</a></span><span class="t"> <span class="nam">outLines</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t56" class="run"><span class="n"><a href="#t56">56</a></span><span class="t"> <span class="key">return</span> <span class="nam">sep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">outLines</span><span class="op">)</span> </span><span class="r"></span></p> - <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t"> </span><span class="r"></span></p> - <p id="t58" class="run"><span class="n"><a href="#t58">58</a></span><span class="t"><span class="key">def</span> <span class="nam">commonPrefix</span><span class="op">(</span><span class="nam">strings</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t59" class="pln"><span class="n"><a href="#t59">59</a></span><span class="t"> <span class="str">""" Find the longest string that is a prefix of all the strings.</span> </span><span class="r"></span></p> - <p id="t60" class="pln"><span class="n"><a href="#t60">60</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> - <p id="t61" class="par run show_par"><span class="n"><a href="#t61">61</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"><span class="annotate short">61 ↛ 62</span><span class="annotate long">line 61 didn't jump to line 62, because the condition on line 61 was never true</span></span></p> - <p id="t62" class="mis show_mis"><span class="n"><a href="#t62">62</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t63" class="run"><span class="n"><a href="#t63">63</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t64" class="run"><span class="n"><a href="#t64">64</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t65" class="run"><span class="n"><a href="#t65">65</a></span><span class="t"> <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span> <span class="op"><</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t66" class="run"><span class="n"><a href="#t66">66</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">len</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t67" class="run"><span class="n"><a href="#t67">67</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">prefix</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t68" class="run"><span class="n"><a href="#t68">68</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> - <p id="t69" class="run"><span class="n"><a href="#t69">69</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t70" class="run"><span class="n"><a href="#t70">70</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefix</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span> <span class="op">!=</span> <span class="nam">s</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p> - <p id="t71" class="run"><span class="n"><a href="#t71">71</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">i</span><span class="op">]</span> </span><span class="r"></span></p> - <p id="t72" class="run"><span class="n"><a href="#t72">72</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> - <p id="t73" class="run"><span class="n"><a href="#t73">73</a></span><span class="t"> <span class="key">return</span> <span class="nam">prefix</span> </span><span class="r"></span></p> -</div> -<div id="footer"> +</header> +<main id="source"> + <p class="pln"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="str">""" Indentation utilities for Cog.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="str"> http://nedbatchelder.com/code/cog</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="str"> Copyright 2004-2019, Ned Batchelder.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="str">"""</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">,</span> <span class="nam">to_bytes</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">def</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">strings</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"> <span class="str">""" Determine the whitespace prefix common to all non-blank lines</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"><span class="str"> in the argument list.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"> <span class="com"># Remove all blank lines from the list</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"> <span class="nam">strings</span> <span class="op">=</span> <span class="op">[</span><span class="nam">s</span> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span> <span class="key">if</span> <span class="nam">s</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">!=</span> <span class="str">''</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">strings</span><span class="op">:</span> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> <span class="com"># Find initial whitespace chunk in the first line.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"> <span class="com"># This is the best prefix we can hope for.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"> <span class="nam">pat</span> <span class="op">=</span> <span class="str">r'\s*'</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">25 ↛ 26</span><span class="annotate long">line 25 didn't jump to line 26, because the condition on line 25 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> <span class="nam">pat</span> <span class="op">=</span> <span class="nam">to_bytes</span><span class="op">(</span><span class="nam">pat</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">match</span><span class="op">(</span><span class="nam">pat</span><span class="op">,</span> <span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">.</span><span class="nam">group</span><span class="op">(</span><span class="num">0</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> <span class="com"># Loop over the other strings, keeping only as much of</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"> <span class="com"># the prefix as matches each string.</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefix</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span> <span class="op">!=</span> <span class="nam">s</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">:</span> </span><span class="r"><span class="annotate short">33 ↛ 34</span><span class="annotate long">line 33 didn't jump to line 34, because the condition on line 33 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">i</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="mis show_mis"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="key">return</span> <span class="nam">prefix</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"><span class="key">def</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">newIndent</span><span class="op">=</span><span class="str">''</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="str">""" Take a block of text as a string or list of lines.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"><span class="str"> Remove any common whitespace indentation.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"><span class="str"> Re-indent using newIndent, and return it as a single string.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"> <span class="nam">sep</span><span class="op">,</span> <span class="nam">nothing</span> <span class="op">=</span> <span class="str">'\n'</span><span class="op">,</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">bytes_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"><span class="annotate short">44 ↛ 45</span><span class="annotate long">line 44 didn't jump to line 45, because the condition on line 44 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"> <span class="nam">sep</span><span class="op">,</span> <span class="nam">nothing</span> <span class="op">=</span> <span class="str">b'\n'</span><span class="op">,</span> <span class="str">b''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"> <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">lines</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"> <span class="nam">lines</span> <span class="op">=</span> <span class="nam">lines</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">sep</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"> <span class="nam">oldIndent</span> <span class="op">=</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">lines</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"> <span class="nam">outLines</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">lines</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"> <span class="key">if</span> <span class="nam">oldIndent</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">oldIndent</span><span class="op">,</span> <span class="nam">nothing</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"> <span class="key">if</span> <span class="nam">l</span> <span class="key">and</span> <span class="nam">newIndent</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"> <span class="nam">l</span> <span class="op">=</span> <span class="nam">newIndent</span> <span class="op">+</span> <span class="nam">l</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"> <span class="nam">outLines</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"> <span class="key">return</span> <span class="nam">sep</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">outLines</span><span class="op">)</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"><span class="key">def</span> <span class="nam">commonPrefix</span><span class="op">(</span><span class="nam">strings</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"> <span class="str">""" Find the longest string that is a prefix of all the strings.</span> </span><span class="r"></span></p> + <p class="pln"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p> + <p class="par run show_par"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"><span class="annotate short">61 ↛ 62</span><span class="annotate long">line 61 didn't jump to line 62, because the condition on line 61 was never true</span></span></p> + <p class="mis show_mis"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">strings</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"> <span class="key">for</span> <span class="nam">s</span> <span class="key">in</span> <span class="nam">strings</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"> <span class="key">if</span> <span class="nam">len</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span> <span class="op"><</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">len</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">prefix</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"> <span class="key">return</span> <span class="str">''</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">prefix</span><span class="op">)</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> <span class="key">if</span> <span class="nam">prefix</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span> <span class="op">!=</span> <span class="nam">s</span><span class="op">[</span><span class="nam">i</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> <span class="nam">prefix</span> <span class="op">=</span> <span class="nam">prefix</span><span class="op">[</span><span class="op">:</span><span class="nam">i</span><span class="op">]</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="key">break</span> </span><span class="r"></span></p> + <p class="run"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> <span class="key">return</span> <span class="nam">prefix</span> </span><span class="r"></span></p> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="index.html">« index</a> <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/index.html b/doc/sample_html/index.html index 7a7a63f1..a43f85e3 100644 --- a/doc/sample_html/index.html +++ b/doc/sample_html/index.html @@ -5,66 +5,52 @@ <title>Coverage report</title> <link rel="icon" sizes="32x32" href="favicon_32.png"> <link rel="stylesheet" href="style.css" type="text/css"> - <script type="text/javascript" src="jquery.min.js"></script> - <script type="text/javascript" src="jquery.ba-throttle-debounce.min.js"></script> - <script type="text/javascript" src="jquery.tablesorter.min.js"></script> - <script type="text/javascript" src="jquery.hotkeys.js"></script> - <script type="text/javascript" src="coverage_html.js"></script> - <script type="text/javascript"> - jQuery(document).ready(coverage.index_ready); - </script> + <script type="text/javascript" src="coverage_html.js" defer></script> </head> <body class="indexfile"> -<div id="header"> +<header> <div class="content"> <h1>Coverage report: <span class="pc_cov">39.98%</span> </h1> - <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" /> + <div id="help_panel_wrapper"> + <input id="help_panel_state" type="checkbox"> + <label for="help_panel_state"> + <img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" /> + </label> + <div id="help_panel"> + <p class="legend">Shortcuts on this page</p> + <div> + <p class="keyhelp"> + <kbd>n</kbd> + <kbd>s</kbd> + <kbd>m</kbd> + <kbd>x</kbd> + <kbd>b</kbd> + <kbd>p</kbd> + <kbd>c</kbd> change column sorting + </p> + </div> + </div> + </div> <form id="filter_container"> <input id="filter" type="text" value="" placeholder="filter..." /> </form> </div> -</div> -<div class="help_panel"> - <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" /> - <p class="legend">Hot-keys on this page</p> - <div> - <p class="keyhelp"> - <span class="key">n</span> - <span class="key">s</span> - <span class="key">m</span> - <span class="key">x</span> - <span class="key">b</span> - <span class="key">p</span> - <span class="key">c</span> change column sorting - </p> - </div> -</div> -<div id="index"> - <table class="index"> +</header> +<main id="index"> + <table class="index" data-sortable> <thead> <tr class="tablehead" title="Click to sort"> - <th class="name left headerSortDown shortkey_n">Module</th> - <th class="shortkey_s">statements</th> - <th class="shortkey_m">missing</th> - <th class="shortkey_x">excluded</th> - <th class="shortkey_b">branches</th> - <th class="shortkey_p">partial</th> - <th class="right shortkey_c">coverage</th> + <th class="name left" aria-sort="none" data-shortcut="n">Module</th> + <th aria-sort="none" data-default-sort-order="descending" data-shortcut="s">statements</th> + <th aria-sort="none" data-default-sort-order="descending" data-shortcut="m">missing</th> + <th aria-sort="none" data-default-sort-order="descending" data-shortcut="x">excluded</th> + <th aria-sort="none" data-default-sort-order="descending" data-shortcut="b">branches</th> + <th aria-sort="none" data-default-sort-order="descending" data-shortcut="p">partial</th> + <th class="right" aria-sort="none" data-shortcut="c">coverage</th> </tr> </thead> - <tfoot> - <tr class="total"> - <td class="name left">Total</td> - <td>1513</td> - <td>899</td> - <td>9</td> - <td>278</td> - <td>34</td> - <td class="right" data-ratio="716 1791">39.98%</td> - </tr> - </tfoot> <tbody> <tr class="file"> <td class="name left"><a href="d_7b071bdc2a35fa80___init___py.html">cogapp/__init__.py</a></td> @@ -148,18 +134,29 @@ <td class="right" data-ratio="70 79">88.61%</td> </tr> </tbody> + <tfoot> + <tr class="total"> + <td class="name left">Total</td> + <td>1513</td> + <td>899</td> + <td>9</td> + <td>278</td> + <td>34</td> + <td class="right" data-ratio="716 1791">39.98%</td> + </tr> + </tfoot> </table> <p id="no_rows"> No items found using the specified filter. </p> -</div> -<div id="footer"> +</main> +<footer> <div class="content"> <p> - <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.0.2</a>, - created at 2021-10-11 16:57 -0400 + <a class="nav" href="https://coverage.readthedocs.io">coverage.py v6.1</a>, + created at 2021-10-29 22:41 -0400 </p> </div> -</div> +</footer> </body> </html> diff --git a/doc/sample_html/jquery.ba-throttle-debounce.min.js b/doc/sample_html/jquery.ba-throttle-debounce.min.js deleted file mode 100644 index 648fe5d3..00000000 --- a/doc/sample_html/jquery.ba-throttle-debounce.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * jQuery throttle / debounce - v1.1 - 3/7/2010 - * http://benalman.com/projects/jquery-throttle-debounce-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); diff --git a/doc/sample_html/jquery.hotkeys.js b/doc/sample_html/jquery.hotkeys.js deleted file mode 100644 index 09b21e03..00000000 --- a/doc/sample_html/jquery.hotkeys.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * jQuery Hotkeys Plugin - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * - * Based upon the plugin by Tzury Bar Yochay: - * http://github.com/tzuryby/hotkeys - * - * Original idea by: - * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ -*/ - -(function(jQuery){ - - jQuery.hotkeys = { - version: "0.8", - - specialKeys: { - 8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", - 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", - 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", - 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", - 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", - 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", - 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 191: "/", 224: "meta" - }, - - shiftNums: { - "`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", - "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<", - ".": ">", "/": "?", "\\": "|" - } - }; - - function keyHandler( handleObj ) { - // Only care when a possible input has been specified - if ( typeof handleObj.data !== "string" ) { - return; - } - - var origHandler = handleObj.handler, - keys = handleObj.data.toLowerCase().split(" "); - - handleObj.handler = function( event ) { - // Don't fire in text-accepting inputs that we didn't directly bind to - if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) || - event.target.type === "text") ) { - return; - } - - // Keypress represents characters, not special keys - var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[ event.which ], - character = String.fromCharCode( event.which ).toLowerCase(), - key, modif = "", possible = {}; - - // check combinations (alt|ctrl|shift+anything) - if ( event.altKey && special !== "alt" ) { - modif += "alt+"; - } - - if ( event.ctrlKey && special !== "ctrl" ) { - modif += "ctrl+"; - } - - // TODO: Need to make sure this works consistently across platforms - if ( event.metaKey && !event.ctrlKey && special !== "meta" ) { - modif += "meta+"; - } - - if ( event.shiftKey && special !== "shift" ) { - modif += "shift+"; - } - - if ( special ) { - possible[ modif + special ] = true; - - } else { - possible[ modif + character ] = true; - possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true; - - // "$" can be triggered as "Shift+4" or "Shift+$" or just "$" - if ( modif === "shift+" ) { - possible[ jQuery.hotkeys.shiftNums[ character ] ] = true; - } - } - - for ( var i = 0, l = keys.length; i < l; i++ ) { - if ( possible[ keys[i] ] ) { - return origHandler.apply( this, arguments ); - } - } - }; - } - - jQuery.each([ "keydown", "keyup", "keypress" ], function() { - jQuery.event.special[ this ] = { add: keyHandler }; - }); - -})( jQuery ); diff --git a/doc/sample_html/jquery.isonscreen.js b/doc/sample_html/jquery.isonscreen.js deleted file mode 100644 index 28fb99bc..00000000 --- a/doc/sample_html/jquery.isonscreen.js +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2010 - * @author Laurence Wheway - * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. - * - * @version 1.2.0 - */ -(function($) { - jQuery.extend({ - isOnScreen: function(box, container) { - //ensure numbers come in as integers (not strings) and remove 'px' is it's there - for(var i in box){box[i] = parseFloat(box[i])}; - for(var i in container){container[i] = parseFloat(container[i])}; - - if(!container){ - container = { - left: $(window).scrollLeft(), - top: $(window).scrollTop(), - width: $(window).width(), - height: $(window).height() - } - } - - if( box.left+box.width-container.left > 0 && - box.left < container.width+container.left && - box.top+box.height-container.top > 0 && - box.top < container.height+container.top - ) return true; - return false; - } - }) - - - jQuery.fn.isOnScreen = function (container) { - for(var i in container){container[i] = parseFloat(container[i])}; - - if(!container){ - container = { - left: $(window).scrollLeft(), - top: $(window).scrollTop(), - width: $(window).width(), - height: $(window).height() - } - } - - if( $(this).offset().left+$(this).width()-container.left > 0 && - $(this).offset().left < container.width+container.left && - $(this).offset().top+$(this).height()-container.top > 0 && - $(this).offset().top < container.height+container.top - ) return true; - return false; - } -})(jQuery); diff --git a/doc/sample_html/jquery.min.js b/doc/sample_html/jquery.min.js deleted file mode 100644 index d1608e37..00000000 --- a/doc/sample_html/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==cb()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===cb()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ab:bb):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:bb,isPropagationStopped:bb,isImmediatePropagationStopped:bb,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ab,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ab,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ab,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=bb;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=bb),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function db(a){var b=eb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var eb="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fb=/ jQuery\d+="(?:null|\d+)"/g,gb=new RegExp("<(?:"+eb+")[\\s/>]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/<tbody/i,lb=/<|&#?\w+;/,mb=/<(?:script|style|link)/i,nb=/checked\s*(?:[^=]|=\s*.checked.)/i,ob=/^$|\/(?:java|ecma)script/i,pb=/^true\/(.*)/,qb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,rb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"<table>"!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px") -},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$b=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_b||(_b=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_b),_b=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});
\ No newline at end of file diff --git a/doc/sample_html/jquery.tablesorter.min.js b/doc/sample_html/jquery.tablesorter.min.js deleted file mode 100644 index 64c70071..00000000 --- a/doc/sample_html/jquery.tablesorter.min.js +++ /dev/null @@ -1,2 +0,0 @@ - -(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,cells[i]);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}return parsers[0];}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}return t;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false,tableHeadersRows=[];for(var i=0;i<table.tHead.rows.length;i++){tableHeadersRows[i]=0;};$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}return i;}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
\ No newline at end of file diff --git a/doc/sample_html/status.json b/doc/sample_html/status.json index 9be42a99..a67836a7 100644 --- a/doc/sample_html/status.json +++ b/doc/sample_html/status.json @@ -1 +1 @@ -{"format":2,"version":"6.0.2","globals":"6a4256e35f9798f9bb080b10ccdeeac8","files":{"d_7b071bdc2a35fa80___init___py":{"hash":"1fc4f9498f460d6c93280e8962ee0c0f","index":{"nums":[2,1,2,0,0,0,0,0],"html_filename":"d_7b071bdc2a35fa80___init___py.html","relative_filename":"cogapp/__init__.py"}},"d_7b071bdc2a35fa80___main___py":{"hash":"ffe6befa655d4d0b0b31eb0c73811311","index":{"nums":[2,1,3,0,3,0,0,0],"html_filename":"d_7b071bdc2a35fa80___main___py.html","relative_filename":"cogapp/__main__.py"}},"d_7b071bdc2a35fa80_backward_py":{"hash":"32afb71b2a11dd4b8ca4ed66b6815d42","index":{"nums":[2,1,22,0,6,4,2,2],"html_filename":"d_7b071bdc2a35fa80_backward_py.html","relative_filename":"cogapp/backward.py"}},"d_7b071bdc2a35fa80_cogapp_py":{"hash":"f3523a775c5c1d12a213eead8df82291","index":{"nums":[2,1,486,1,215,200,28,132],"html_filename":"d_7b071bdc2a35fa80_cogapp_py.html","relative_filename":"cogapp/cogapp.py"}},"d_7b071bdc2a35fa80_makefiles_py":{"hash":"85ec1064ff86d94238a8d7b76a2178a5","index":{"nums":[2,1,27,0,20,14,0,14],"html_filename":"d_7b071bdc2a35fa80_makefiles_py.html","relative_filename":"cogapp/makefiles.py"}},"d_7b071bdc2a35fa80_test_cogapp_py":{"hash":"6985a05ab5a9b347b3665136686f6fb1","index":{"nums":[2,1,788,8,547,20,0,18],"html_filename":"d_7b071bdc2a35fa80_test_cogapp_py.html","relative_filename":"cogapp/test_cogapp.py"}},"d_7b071bdc2a35fa80_test_makefiles_py":{"hash":"647f7dc911c97a6e646a91c3300a25ff","index":{"nums":[2,1,71,0,53,6,0,6],"html_filename":"d_7b071bdc2a35fa80_test_makefiles_py.html","relative_filename":"cogapp/test_makefiles.py"}},"d_7b071bdc2a35fa80_test_whiteutils_py":{"hash":"9476b26e42e6169b1857cfe7f29bf954","index":{"nums":[2,1,69,0,50,0,0,0],"html_filename":"d_7b071bdc2a35fa80_test_whiteutils_py.html","relative_filename":"cogapp/test_whiteutils.py"}},"d_7b071bdc2a35fa80_whiteutils_py":{"hash":"cf00c3e6149e4b80a2d01b6919c066a4","index":{"nums":[2,1,45,0,5,34,4,4],"html_filename":"d_7b071bdc2a35fa80_whiteutils_py.html","relative_filename":"cogapp/whiteutils.py"}}}}
\ No newline at end of file +{"format":2,"version":"6.1","globals":"e385eb185350a8ab0cefee795b10cb84","files":{"d_7b071bdc2a35fa80___init___py":{"hash":"1fc4f9498f460d6c93280e8962ee0c0f","index":{"nums":[2,1,2,0,0,0,0,0],"html_filename":"d_7b071bdc2a35fa80___init___py.html","relative_filename":"cogapp/__init__.py"}},"d_7b071bdc2a35fa80___main___py":{"hash":"ffe6befa655d4d0b0b31eb0c73811311","index":{"nums":[2,1,3,0,3,0,0,0],"html_filename":"d_7b071bdc2a35fa80___main___py.html","relative_filename":"cogapp/__main__.py"}},"d_7b071bdc2a35fa80_backward_py":{"hash":"32afb71b2a11dd4b8ca4ed66b6815d42","index":{"nums":[2,1,22,0,6,4,2,2],"html_filename":"d_7b071bdc2a35fa80_backward_py.html","relative_filename":"cogapp/backward.py"}},"d_7b071bdc2a35fa80_cogapp_py":{"hash":"f3523a775c5c1d12a213eead8df82291","index":{"nums":[2,1,486,1,215,200,28,132],"html_filename":"d_7b071bdc2a35fa80_cogapp_py.html","relative_filename":"cogapp/cogapp.py"}},"d_7b071bdc2a35fa80_makefiles_py":{"hash":"85ec1064ff86d94238a8d7b76a2178a5","index":{"nums":[2,1,27,0,20,14,0,14],"html_filename":"d_7b071bdc2a35fa80_makefiles_py.html","relative_filename":"cogapp/makefiles.py"}},"d_7b071bdc2a35fa80_test_cogapp_py":{"hash":"6985a05ab5a9b347b3665136686f6fb1","index":{"nums":[2,1,788,8,547,20,0,18],"html_filename":"d_7b071bdc2a35fa80_test_cogapp_py.html","relative_filename":"cogapp/test_cogapp.py"}},"d_7b071bdc2a35fa80_test_makefiles_py":{"hash":"647f7dc911c97a6e646a91c3300a25ff","index":{"nums":[2,1,71,0,53,6,0,6],"html_filename":"d_7b071bdc2a35fa80_test_makefiles_py.html","relative_filename":"cogapp/test_makefiles.py"}},"d_7b071bdc2a35fa80_test_whiteutils_py":{"hash":"9476b26e42e6169b1857cfe7f29bf954","index":{"nums":[2,1,69,0,50,0,0,0],"html_filename":"d_7b071bdc2a35fa80_test_whiteutils_py.html","relative_filename":"cogapp/test_whiteutils.py"}},"d_7b071bdc2a35fa80_whiteutils_py":{"hash":"cf00c3e6149e4b80a2d01b6919c066a4","index":{"nums":[2,1,45,0,5,34,4,4],"html_filename":"d_7b071bdc2a35fa80_whiteutils_py.html","relative_filename":"cogapp/whiteutils.py"}}}}
\ No newline at end of file diff --git a/doc/sample_html/style.css b/doc/sample_html/style.css index 7f8e32ab..cca6f11f 100644 --- a/doc/sample_html/style.css +++ b/doc/sample_html/style.css @@ -28,23 +28,39 @@ a.nav { text-decoration: none; color: inherit; } a.nav:hover { text-decoration: underline; color: inherit; } -#header { background: #f8f8f8; width: 100%; border-bottom: 1px solid #eee; } +header { background: #f8f8f8; width: 100%; z-index: 2; border-bottom: 1px solid #ccc; } -@media (prefers-color-scheme: dark) { #header { background: black; } } +@media (prefers-color-scheme: dark) { header { background: black; } } -@media (prefers-color-scheme: dark) { #header { border-color: #333; } } +@media (prefers-color-scheme: dark) { header { border-color: #333; } } -.indexfile #footer { margin: 1rem 3.5rem; } +header .content { padding: 1rem 3.5rem; } -.pyfile #footer { margin: 1rem 1rem; } +header h2 { margin-top: .5em; font-size: 1em; } -#footer .content { padding: 0; color: #666; font-style: italic; } +header.sticky { position: fixed; left: 0; right: 0; height: 2.5em; } -@media (prefers-color-scheme: dark) { #footer .content { color: #aaa; } } +header.sticky .text { display: none; } -#index { margin: 1rem 0 0 3.5rem; } +header.sticky h1, header.sticky h2 { font-size: 1em; margin-top: 0; display: inline-block; } + +header.sticky .content { padding: 0.5rem 3.5rem; } + +header.sticky .content p { font-size: 1em; } + +header.sticky ~ #source { padding-top: 6.5em; } + +main { position: relative; z-index: 1; } + +.indexfile footer { margin: 1rem 3.5rem; } + +.pyfile footer { margin: 1rem 1rem; } -#header .content { padding: 1rem 3.5rem; } +footer .content { padding: 0; color: #666; font-style: italic; } + +@media (prefers-color-scheme: dark) { footer .content { color: #aaa; } } + +#index { margin: 1rem 0 0 3.5rem; } h1 { font-size: 1.25em; display: inline-block; } @@ -60,67 +76,67 @@ h1 { font-size: 1.25em; display: inline-block; } #filter_container input:focus { border-color: #007acc; } -h2.stats { margin-top: .5em; font-size: 1em; } +header button { font-family: inherit; font-size: inherit; border: 1px solid; border-radius: .2em; color: inherit; padding: .1em .5em; margin: 1px calc(.1em + 1px); cursor: pointer; border-color: #ccc; } -.stats button { font-family: inherit; font-size: inherit; border: 1px solid; border-radius: .2em; color: inherit; padding: .1em .5em; margin: 1px calc(.1em + 1px); cursor: pointer; border-color: #ccc; } +@media (prefers-color-scheme: dark) { header button { border-color: #444; } } -@media (prefers-color-scheme: dark) { .stats button { border-color: #444; } } +header button:active, header button:focus { outline: 2px dashed #007acc; } -.stats button:active, .stats button:focus { outline: 2px dashed #007acc; } +header button.run { background: #eeffee; } -.stats button:active, .stats button:focus { outline: 2px dashed #007acc; } +@media (prefers-color-scheme: dark) { header button.run { background: #373d29; } } -.stats button.run { background: #eeffee; } +header button.run.show_run { background: #dfd; border: 2px solid #00dd00; margin: 0 .1em; } -@media (prefers-color-scheme: dark) { .stats button.run { background: #373d29; } } +@media (prefers-color-scheme: dark) { header button.run.show_run { background: #373d29; } } -.stats button.run.show_run { background: #dfd; border: 2px solid #00dd00; margin: 0 .1em; } +header button.mis { background: #ffeeee; } -@media (prefers-color-scheme: dark) { .stats button.run.show_run { background: #373d29; } } +@media (prefers-color-scheme: dark) { header button.mis { background: #4b1818; } } -.stats button.mis { background: #ffeeee; } +header button.mis.show_mis { background: #fdd; border: 2px solid #ff0000; margin: 0 .1em; } -@media (prefers-color-scheme: dark) { .stats button.mis { background: #4b1818; } } +@media (prefers-color-scheme: dark) { header button.mis.show_mis { background: #4b1818; } } -.stats button.mis.show_mis { background: #fdd; border: 2px solid #ff0000; margin: 0 .1em; } +header button.exc { background: #f7f7f7; } -@media (prefers-color-scheme: dark) { .stats button.mis.show_mis { background: #4b1818; } } +@media (prefers-color-scheme: dark) { header button.exc { background: #333; } } -.stats button.exc { background: #f7f7f7; } +header button.exc.show_exc { background: #eee; border: 2px solid #808080; margin: 0 .1em; } -@media (prefers-color-scheme: dark) { .stats button.exc { background: #333; } } +@media (prefers-color-scheme: dark) { header button.exc.show_exc { background: #333; } } -.stats button.exc.show_exc { background: #eee; border: 2px solid #808080; margin: 0 .1em; } +header button.par { background: #ffffd5; } -@media (prefers-color-scheme: dark) { .stats button.exc.show_exc { background: #333; } } +@media (prefers-color-scheme: dark) { header button.par { background: #650; } } -.stats button.par { background: #ffffd5; } +header button.par.show_par { background: #ffa; border: 2px solid #bbbb00; margin: 0 .1em; } -@media (prefers-color-scheme: dark) { .stats button.par { background: #650; } } +@media (prefers-color-scheme: dark) { header button.par.show_par { background: #650; } } -.stats button.par.show_par { background: #ffa; border: 2px solid #dddd00; margin: 0 .1em; } +#help_panel, #source p .annotate.long { display: none; position: absolute; z-index: 999; background: #ffffcc; border: 1px solid #888; border-radius: .2em; color: #333; padding: .25em .5em; } -@media (prefers-color-scheme: dark) { .stats button.par.show_par { background: #650; } } +#source p .annotate.long { white-space: normal; float: right; top: 1.75em; right: 1em; height: auto; } -.help_panel, #source p .annotate.long { display: none; position: absolute; z-index: 999; background: #ffffcc; border: 1px solid #888; border-radius: .2em; color: #333; padding: .25em .5em; } +#help_panel_wrapper { float: right; position: relative; } -#source p .annotate.long { white-space: normal; float: right; top: 1.75em; right: 1em; height: auto; } +#keyboard_icon { margin: 5px; } -#keyboard_icon { float: right; margin: 5px; cursor: pointer; } +#help_panel_state { display: none; } -.help_panel { padding: .75em; border: 1px solid #883; } +#help_panel { top: 25px; right: 0; padding: .75em; border: 1px solid #883; } -.help_panel .legend { font-style: italic; margin-bottom: 1em; } +#help_panel .legend { font-style: italic; margin-bottom: 1em; } -.indexfile .help_panel { width: 25em; } +.indexfile #help_panel { width: 25em; } -.pyfile .help_panel { width: 18em; } +.pyfile #help_panel { width: 18em; } -#panel_icon { float: right; cursor: pointer; } +#help_panel_state:checked ~ #help_panel { display: block; } .keyhelp { margin-top: .75em; } -.keyhelp .key { border: 1px solid black; border-color: #888 #333 #333 #888; padding: .1em .35em; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-weight: bold; background: #eee; } +kbd { border: 1px solid black; border-color: #888 #333 #333 #888; padding: .1em .35em; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-weight: bold; background: #eee; border-radius: 3px; } #source { padding: 1em 0 1em 3.5rem; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; } @@ -132,7 +148,9 @@ h2.stats { margin-top: .5em; font-size: 1em; } @media (prefers-color-scheme: dark) { #source p .n { color: #777; } } -#source p .n a { text-decoration: none; color: #999; } +#source p .n.highlight { background: #ffdd00; } + +#source p .n a { margin-top: -4em; padding-top: 4em; text-decoration: none; color: #999; } @media (prefers-color-scheme: dark) { #source p .n a { color: #777; } } @@ -140,8 +158,6 @@ h2.stats { margin-top: .5em; font-size: 1em; } @media (prefers-color-scheme: dark) { #source p .n a:hover { color: #777; } } -#source p.highlight .n { background: #ffdd00; } - #source p .t { display: inline-block; width: 100%; box-sizing: border-box; margin-left: -.5em; padding-left: 0.3em; border-left: 0.2em solid #fff; } @media (prefers-color-scheme: dark) { #source p .t { border-color: #1e1e1e; } } @@ -154,13 +170,13 @@ h2.stats { margin-top: .5em; font-size: 1em; } #source p .t .com { color: #008000; font-style: italic; line-height: 1px; } -@media (prefers-color-scheme: dark) { #source p .t .com { color: #6A9955; } } +@media (prefers-color-scheme: dark) { #source p .t .com { color: #6a9955; } } #source p .t .key { font-weight: bold; line-height: 1px; } -#source p .t .str { color: #0451A5; } +#source p .t .str { color: #0451a5; } -@media (prefers-color-scheme: dark) { #source p .t .str { color: #9CDCFE; } } +@media (prefers-color-scheme: dark) { #source p .t .str { color: #9cdcfe; } } #source p.mis .t { border-left: 0.2em solid #ff0000; } @@ -192,7 +208,7 @@ h2.stats { margin-top: .5em; font-size: 1em; } @media (prefers-color-scheme: dark) { #source p.exc.show_exc .t:hover { background: #3c3c3c; } } -#source p.par .t { border-left: 0.2em solid #dddd00; } +#source p.par .t { border-left: 0.2em solid #bbbb00; } #source p.par.show_par .t { background: #ffa; } @@ -218,13 +234,13 @@ h2.stats { margin-top: .5em; font-size: 1em; } #source p input ~ .r label.ctx::before { content: "▶ "; } -#source p input ~ .r label.ctx:hover { background: #d5f7ff; color: #666; } +#source p input ~ .r label.ctx:hover { background: #e8f4ff; color: #666; } @media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { background: #0f3a42; } } @media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { color: #aaa; } } -#source p input:checked ~ .r label.ctx { background: #aef; color: #666; border-radius: .75em .75em 0 0; padding: 0 .5em; margin: -.25em 0; } +#source p input:checked ~ .r label.ctx { background: #d0e8ff; color: #666; border-radius: .75em .75em 0 0; padding: 0 .5em; margin: -.25em 0; } @media (prefers-color-scheme: dark) { #source p input:checked ~ .r label.ctx { background: #056; } } @@ -238,7 +254,7 @@ h2.stats { margin-top: .5em; font-size: 1em; } @media (prefers-color-scheme: dark) { #source p label.ctx { color: #777; } } -#source p .ctxs { display: block; max-height: 0; overflow-y: hidden; transition: all .2s; padding: 0 .5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; white-space: nowrap; background: #aef; border-radius: .25em; margin-right: 1.75em; } +#source p .ctxs { display: block; max-height: 0; overflow-y: hidden; transition: all .2s; padding: 0 .5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; white-space: nowrap; background: #d0e8ff; border-radius: .25em; margin-right: 1.75em; } @media (prefers-color-scheme: dark) { #source p .ctxs { background: #056; } } @@ -262,13 +278,13 @@ h2.stats { margin-top: .5em; font-size: 1em; } @media (prefers-color-scheme: dark) { #index th:hover { background: #333; } } -#index th.headerSortDown, #index th.headerSortUp { white-space: nowrap; background: #eee; } +#index th[aria-sort="ascending"], #index th[aria-sort="descending"] { white-space: nowrap; background: #eee; padding-left: .5em; } -@media (prefers-color-scheme: dark) { #index th.headerSortDown, #index th.headerSortUp { background: #333; } } +@media (prefers-color-scheme: dark) { #index th[aria-sort="ascending"], #index th[aria-sort="descending"] { background: #333; } } -#index th.headerSortDown:after { content: " ↑"; } +#index th[aria-sort="ascending"]::after { font-family: sans-serif; content: " ↑"; } -#index th.headerSortUp:after { content: " ↓"; } +#index th[aria-sort="descending"]::after { font-family: sans-serif; content: " ↓"; } #index td.name a { text-decoration: none; color: inherit; } @@ -280,7 +296,7 @@ h2.stats { margin-top: .5em; font-size: 1em; } #index tr.file:hover td.name { text-decoration: underline; color: inherit; } -#scroll_marker { position: fixed; right: 0; top: 0; width: 16px; height: 100%; background: #fff; border-left: 1px solid #eee; will-change: transform; } +#scroll_marker { position: fixed; z-index: 3; right: 0; top: 0; width: 16px; height: 100%; background: #fff; border-left: 1px solid #eee; will-change: transform; } @media (prefers-color-scheme: dark) { #scroll_marker { background: #1e1e1e; } } |