Write injection chisq plots to markup.page object page
543636
def write_inj_snrs(page, ifos, injList, grbtag):

    

    if injList:
        th = ['']+injList + ['OFFSOURCE']
    else:
        th= ['','OFFSOURCE']
        injList = ['OFFSOURCE']
    td = []

    ifos = [ifos[i:i+2] for i in range(0, len(ifos), 2)]
    plots = ['null_stat2']+['%s_snr' % ifo for ifo in ifos]

    for row in plots:
        pTag = row.replace('_',' ').title()
        d = [pTag]
        for inj in injList + ['OFFSOURCE']:
            plot = markup.page()
            p = "%s/plots_clustered/GRB%s_%s_vs_snr_zoom.png" % (inj, grbtag,
                                                                 row)
            plot.a(href=p, title="%s %s versus SNR" % (inj, pTag))
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    page = write_table(page, th, td)

    return page
933835
public static void renderTemplateAsExcel(String templateName, Object... args) {

		// Template datas
		Scope.RenderArgs templateBinding = Scope.RenderArgs.current();
		for (Object o : args) {
			List<String> names = LocalvariablesNamesEnhancer.LocalVariablesNamesTracer
					.getAllLocalVariableNames(o);
			for (String name : names) {
				templateBinding.put(name, o);
			}
		}
		templateBinding.put("session", Scope.Session.current());
		templateBinding.put("request", Http.Request.current());
		templateBinding.put("flash", Scope.Flash.current());
		templateBinding.put("params", Scope.Params.current());
		if (null == templateBinding.get("fileName")) {
			templateBinding.put("fileName", templateName.substring(templateName.lastIndexOf("/") + 1) + ".xls");
		}
		//Logger.trace("fileName: " + templateBinding.get("fileName"));
		try {
			templateBinding.put("errors", Validation.errors());
		} catch (Exception ex) {
			throw new UnexpectedException(ex);
		}
		try {
			throw new RenderExcelTemplate(templateName + ".xls", templateBinding.data, templateBinding.get("fileName").toString());
		} catch (TemplateNotFoundException ex) {
			if (ex.isSourceAvailable()) {
				throw ex;
			}
			StackTraceElement element = PlayException
					.getInterestingStrackTraceElement(ex);
			if (element != null) {
				throw new TemplateNotFoundException(templateName, Play.classes
						.getApplicationClass(element.getClassName()), element
						.getLineNumber());
			} else {
				throw ex;
			}
		}
	}
458816
def __get_plots_of_the_current_page(self, section, page):
        """"""
        
        plots = []
        structure = [len(x) for x in self.sections[section].pages[page].layout]
        for key in self.sections[section].pages[page].elements.keys():
            if self.sections[section].pages[page].elements[key].plot_object is None:
                plots.append(None)
            else:
                plots.append(self.sections[section].pages[page].elements[key].name)


        plots_sub = []
        for idx, i in enumerate(list(accumulate(structure))):
            if idx == 0:
                plots_sub.append(plots[0:i])
            else :
                plots_sub.append(plots[list(accumulate(structure))[idx - 1]:i])

        return plots_sub
872060
def on_page_markdown(self, markdown, page, config,
                          site_navigation=None, **kwargs):
        ""

        # the site_navigation argument has been made optional
        # (deleted in post 1.0 mkdocs, but maintained here
        # for backward compatibility)

        if not self.variables:
            return markdown

        else:

            # Create templae and get the variables
            md_template = Template(markdown)

            # Execute the jinja2 template and return
            return md_template.render(**self.variables)
431547
function PageRenderer(req, res) {
    var page = req.attrs.page;
    Object.defineProperties(this, {
        req: {
            value: req
        },
        res: {
            value: res
        },
        page: {
            value: _.clone(page)
        },
        themeDBAction: {
            value: DBActions.getInstance(req, THEME_SCHEMA)
        },
        layoutDBAction: {
            value: DBActions.getInstance(req, LAYOUT_SCHEMA)
        },
        pageInstanceDBAction: {
            value: DBActions.getAuthInstance(req, PAGE_SCHEMA, PAGE_PERMISSION_SCHEMA)
        },
        pluginInstanceDBAction: {
            value: DBActions.getInstance(req, PLUGIN_INSTANCE_SCHEMA)
        },
        pagePermissionValidator: {
            value: new PermissionValidator(req, PAGE_PERMISSION_SCHEMA, PAGE_SCHEMA)
        },
        pluginPermissionValidator: {
            value: new PermissionValidator(req, PLUGIN_PERMISSION_SCHEMA, PLUGIN_INSTANCE_SCHEMA)
        },
        isExclusive: {
            value: req.query && req.query.mode === "exclusive"
        }
    });
}
360212
def page(content, pagecallback=prompt):
    
    width = getwidth()
    height = getheight()
    pagenum = 1

    try:
        try:
            line = content.next().rstrip("\r\n")
        except AttributeError:
            # Python 3 compatibility
            line = content.__next__().rstrip("\r\n")
    except StopIteration:
        pagecallback(pagenum)
        return

    while True:     # page cycle
        linesleft = height-1 # leave the last line for the prompt callback
        while linesleft:
            linelist = [line[i:i+width] for i in range(0, len(line), width)]
            if not linelist:
                linelist = ['']
            lines2print = min(len(linelist), linesleft)
            for i in range(lines2print):
                if WINDOWS and len(line) == width:
                    # avoid extra blank line by skipping linefeed print
                    echo(linelist[i])
                else:
                    print((linelist[i]))
            linesleft -= lines2print
            linelist = linelist[lines2print:]

            if linelist: # prepare symbols left on the line for the next iteration
                line = ''.join(linelist)
                continue
            else:
                try:
                    try:
                        line = content.next().rstrip("\r\n")
                    except AttributeError:
                        # Python 3 compatibility
                        line = content.__next__().rstrip("\r\n")
                except StopIteration:
                    pagecallback(pagenum)
                    return
        if pagecallback(pagenum) == False:
            return
        pagenum += 1
235025
private static Map<String, ModelDescription> assigneModelsToViews(Map<ModelDescription, 
            XLinkConnectorView[]> modelsToViews) {
        HashMap<String, ModelDescription> viewsToModels = new HashMap<String, ModelDescription>();
        for (ModelDescription modelInfo : modelsToViews.keySet()) {
            List<XLinkConnectorView> currentViewList = Arrays.asList(modelsToViews.get(modelInfo));
            for (XLinkConnectorView view : currentViewList) {
                if (!viewsToModels.containsKey(view.getViewId())) {
                    viewsToModels.put(view.getViewId(), modelInfo);
                }
            }
        }
        return viewsToModels;
    }
1349839
def Page(QLExportable):
  '''  '''
  def __init__(self, filename, page_id):
    self.id = page_id
    super(Page, self).__init__(filename)

  def export(self, export_format=ExportFormat.PNG):
    pass
1225721
public static void renderExcel(Object... args) {
		String templateName = null;
		final Http.Request request = Http.Request.current();

		if (args.length > 0
				&& args[0] instanceof String
				&& LocalvariablesNamesEnhancer.LocalVariablesNamesTracer
						.getAllLocalVariableNames(args[0]).isEmpty()) {
			templateName = args[0].toString();
		} else {
			templateName = request.action.replace(".", "/");
		}
		if (templateName.startsWith("@")) {
			templateName = templateName.substring(1);
			if (!templateName.contains(".")) {
				templateName = request.controller + "." + templateName;
			}
			templateName = templateName.replace(".", "/");
		}
		renderTemplateAsExcel(templateName, args);
	}
1368544
def simxCopyPasteObjects(clientID, objectHandles, operationMode):
    '''
    
    '''
    c_objectHandles  = (ct.c_int*len(objectHandles))(*objectHandles)
    c_objectHandles = ct.cast(c_objectHandles,ct.POINTER(ct.c_int)) # IronPython needs this
    newObjectCount   = ct.c_int()
    newObjectHandles = ct.POINTER(ct.c_int)()
    ret = c_CopyPasteObjects(clientID, c_objectHandles, len(objectHandles), ct.byref(newObjectHandles), ct.byref(newObjectCount), operationMode)

    newobj = []
    if ret == 0:
        for i in range(newObjectCount.value):
            newobj.append(newObjectHandles[i])

    return ret, newobj
1368656
function(page) {
			var regixAll = /(<p>!FILENAME\s+([\S].+)<\/p>)\s*<pre>[\s\S]*?(<\/pre>)/g;
			var regix = /(<p>!FILENAME\s+([\S].+)<\/p>)\s*<pre>[\s\S]*?(<\/pre>)/;
			var replacer = function(filename){
				return '<div><p class="code-filename">' + filename + '</p></div>';
			}

			var tagAll = page.content.match(regixAll);

			for(var j = 0; tagAll && j < tagAll.length; j++){
				var tag = page.content.match(regix);
				var replace = tag[0].replace(tag[1], replacer(tag[2]));
				page.content = page.content.replace(tag[0], replace);
			}

			return page;
		}
972241
function injectScripts(filePath) {
  var contents = String($.fs.readFileSync(filePath));
  var fileExt = $.path.extname(filePath).substr(1);
  var fileType = fileTypes[fileExt] || fileTypes['default'];
  var returnType = /\r\n/.test(contents) ? '\r\n' : '\n';

  var newContents = contents.replace(
    fileType.block,
    replaceIncludes(filePath, fileType, returnType)
  );

  if (contents !== newContents) {
    $.fs.writeFileSync(filePath, newContents);

    config.get('on-file-updated')(filePath);
  }
}
203390
function(rm, sId, iIdx){
		rm.write("<div");
		rm.writeAttribute("id", sId + "-add" + iIdx);
		rm.addClass("sapUiRoadMapStepAdd" + iIdx);
		rm.writeClasses();
		rm.write("></div>");
	}
507973
function generatePage(output, page) {
    var book = output.getBook();
    var engine = createTemplateEngine(output);

    return timing.measure(
        'page.generate',
        Promise(page)
        .then(function(resultPage) {
            var file = resultPage.getFile();
            var filePath = file.getPath();
            var parser = file.getParser();
            var context = JSONUtils.encodeOutputWithPage(output, resultPage);

            if (!parser) {
                return Promise.reject(error.FileNotParsableError({
                    filename: filePath
                }));
            }

            // Call hook "page:before"
            return callPageHook('page:before', output, resultPage)

            // Escape code blocks with raw tags
            .then(function(currentPage) {
                return parser.preparePage(currentPage.getContent());
            })

            // Render templating syntax
            .then(function(content) {
                var absoluteFilePath = path.join(book.getContentRoot(), filePath);
                return Templating.render(engine, absoluteFilePath, content, context);
            })

            .then(function(output) {
                var content = output.getContent();

                return parser.parsePage(content)
                .then(function(result) {
                    return output.setContent(result.content);
                });
            })

            // Post processing for templating syntax
            .then(function(output) {
                return Templating.postRender(engine, output);
            })

            // Return new page
            .then(function(content) {
                return resultPage.set('content', content);
            })

            // Call final hook
            .then(function(currentPage) {
                return callPageHook('page', output, currentPage);
            });
        })
    );
}
729080
function writePages(drizzleData) {
  return Promise.all(walkPages(drizzleData.pages, drizzleData)).then(
    () => drizzleData,
    error => DrizzleError.error(error, drizzleData.options.debug)
  );
}
643435
private void encodeFooter(final FacesContext context, final ResponseWriter responseWriter, final Sheet sheet)
                throws IOException {
        // footer
        final UIComponent footer = sheet.getFacet("footer");
        if (footer != null) {
            responseWriter.startElement("div", null);
            responseWriter.writeAttribute("class", "ui-datatable-footer ui-widget-header ui-corner-bottom", null);
            footer.encodeAll(context);
            responseWriter.endElement("div");
        }
    }
343544
function(page) {
            // Get all code texts
            umls = page.content.match(/```(uml|puml|plantuml)((.*[\r\n]+)+?)?```/igm);
            // Begin replace
            if (umls instanceof Array) {
                for (var i = 0, len = umls.length; i < len; i++) {
                    page.content = page.content.replace(
                        umls[i],
                        // Parameter parser for user argument to gitbook argument
                        umls[i].replace(/```(uml|puml|plantuml)[ \t]+{(.*)}/i,
                            function(match, p1, p2) {
                                var newStr = "";
                                var modeQuote = false;
                                var modeArray = false;
                                var modeChar = false;
                                var modeEqual = false;
                                // Trim left and right space
                                var str = p2.replace(/^\s+|\s+$/g,"");

                                // Build new str
                                for(var i = 0; i < str.length; i++){
                                    if (str.charAt(i) == "\"") {
                                        modeQuote = !modeQuote;
                                        modeChar = true;
                                        newStr += str.charAt(i);
                                        continue;
                                    }
                                    if (str.charAt(i) == "[") {
                                        modeArray = true;
                                        newStr += str.charAt(i);
                                        continue;
                                    }
                                    if (str.charAt(i) == "]") {
                                        modeArray = false;
                                        newStr += str.charAt(i);
                                        continue;
                                    }
                                    if (modeQuote || modeArray) {
                                        // In quote, keep all string
                                        newStr += str.charAt(i);
                                    } else {
                                        // Out of quote, process it
                                        if (str.charAt(i).match(/[A-Za-z0-9_]/)) {
                                            modeChar = true;
                                            newStr += str.charAt(i);
                                        } else if (str.charAt(i).match(/[=]/)) {
                                            modeEqual = true;
                                            modeChar = false;
                                            newStr += str.charAt(i);
                                        } else if (modeChar && modeEqual) {
                                            modeChar = false;
                                            modeEqual = false;
                                            newStr += ",";
                                        }
                                    }
                                }

                                newStr = newStr.replace(/,$/,"");

                                return "{% uml " + newStr + " %}";
                            })
                        .replace(/```(uml|puml|plantuml)/i, '{% uml %}')
                        .replace(/```/, '{% enduml %}'));
                }
            }
            return page;
        }