def PreProcessSourceFile(cmd): HandleValue(cmd) var = cmd.params.Get('var', None) if (var): out = "" for k in var: v = var[k] if (isinstance(v, src.TableData)): out += "let " + str(k) + " = [" fr = True for r in v.ForEachRow(): first = True out += '[' if fr else ",[" fr = False for c in v.ForEachCol(): txt = v.GetCell(r, c) out += (',' if not first else "") + str( FormatText(txt)) first = False out += ']' out += "];\n" elif (isinstance(v, lst.ListData)): out += "let " + str(k) + " = [" first = True for txt in v: out += (',' if not first else "") + str(FormatText(txt)) first = False out += "];\n" elif (isinstance(v, int) or isinstance(v, float) or (isinstance(v, str) and util.numberCheck(v))): out += "let " + str(k) + " = " + str(v) + ";\n" elif (isinstance(v, str)): out += "let " + str(k) + " = \'" + str(v) + "\';\n" cmd.source = out + cmd.source
def PreProcessSourceFile(cmd): HandleValue(cmd) var = cmd.params.Get('var', None) if (var): out = "" for k in var: v = var[k] if (isinstance(v, src.TableData)): out += "set " + str(k) + "_width=" + str(v.Width()) + "\n" out += "set " + str(k) + "_height=" + str(v.Height()) + "\n" for r in v.ForEachRow(): for c in v.ForEachCol(): txt = v.GetCell(r, c) out += "set " + str(k) + "[" + str(r) + "," + str( c) + "]=" + str(FormatText(txt)) + "\n" elif (isinstance(v, lst.ListData)): out += "set " + str(k) + "_len=" + str(v.Length()) + "\n" out += "set " + str(k) + "=[" first = True for txt in v: out += (',' if not first else "") + str(FormatText(txt)) first = False out += "]\n" elif (isinstance(v, int) or isinstance(v, float) or (isinstance(v, str) and util.numberCheck(v))): out += "set /A " + str(k) + "=" + str(v) + "\n" elif (isinstance(v, str)): out += "set " + str(k) + "=" + str(v) + "\n" cmd.source = out + cmd.source print(str(cmd.source))
def PreProcessSourceFile(cmd): HandleValue(cmd) var = cmd.params.Get('var', None) if (var): out = "" for k in var: v = var[k] if (isinstance(v, src.TableData)): out += str(k) + "=$(cat <<'END_HERE_DOC'\n" for r in v.ForEachRow(): first = True for c in v.ForEachCol(): txt = v.GetCell(r, c) out += ('\t' if not first else "") + str( FormatText(txt)) first = False out += '\n' out += "END_HERE_DOC\n)\n" elif (isinstance(v, lst.ListData)): out += str(k) + "=(" first = True for txt in v: out += (' ' if not first else "") + str(FormatText(txt)) first = False out += ")\n" elif (isinstance(v, int) or isinstance(v, float) or (isinstance(v, str) and util.numberCheck(v))): out += str(k) + "=" + str(v) + "\n" elif (isinstance(v, str)): out += str(k) + "=\'" + str(v) + "\'\n" cmd.source = out + cmd.source
def PreProcessSourceFile(cmd): var = cmd.params.Get('var', None) cmd.varsDefs = [] out = "" if (var): for k in var: v = var[k] if (isinstance(v, src.TableData)): out += str(k) + " = [\n" cmd.varsDefs.append("global " + str(k)) fr = True for r in v.ForEachRow(): first = True out += '[' if fr else ",[" fr = False for c in v.ForEachCol(): txt = v.GetCell(r, c) out += (',' if not first else "") + str( FormatText(txt)) first = False out += ']' out += "]\n" if (isinstance(v, fml.TableDef)): out += str(k) + " = [\n" cmd.varsDefs.append("global " + str(k)) fr = True for r in v.ForEachRow(): first = True out += '[' if fr else ",[" fr = False for c in v.ForEachCol(): txt = fml.Cell(r, c, v).GetVal() out += (',' if not first else "") + str( FormatText(txt)) first = False out += ']' out += "]\n" elif (isinstance(v, lst.ListData)): out += str(k) + " = [\n" cmd.varsDefs.append("global " + str(k)) first = True for txt in v: out += (',' if not first else "") + str(FormatText(txt)) first = False out += "]\n" elif (isinstance(v, int) or isinstance(v, float) or (isinstance(v, str) and util.numberCheck(v))): out += str(k) + " = " + str(v) + "\n" cmd.varsDefs.append("global " + str(k)) elif (isinstance(v, str)): out += str(k) + " = \'" + str(v) + "\'\n" cmd.varsDefs.append("global " + str(k)) HandleValue(cmd) if (out != ""): cmd.source = out + cmd.source
def plot_write_table_data_to(params,table,f,r,c,first=False): txt = table.GetCellText(r,c).strip() if(first): if((r == 1 and table.StartRow() != 1) and not ("include" in params and "header" in params["include"])): f.write("#") else: f.write("\t") if(not util.numberCheck(txt) and " " in txt or "\t" in txt): f.write("\""+ txt + "\"") else: f.write(txt)
def ProcessPossibleSourceObjects(cmd, language, cmdArgs): #BuildFullParamList(cmd,language,cmdArgs) var = cmd.params.GetDict('var', None) cmd.params.Replace('var', var) cmd.deferedSources = 0 hadDeferred = False if (var): for k in var: n = var[k] if (not util.numberCheck(n)): td = tbl.LookupTableFromNamedObject(n) if (td): # I think it's better to just pass through the table here. # Each language may want to do something very different and abstracting away # What the data source actually is may actually be a disservice #var[k] = GetGeneratorForTable(td,cmd.params) var[k] = td else: l = lst.LookupNamedListInFile(n) if (l): var[k] = l else: pt = LookupNamedSourceBlockInFile(n) if (None != pt): if (not n in cmd.sourcefns): cmd.deferedSources += 1 hadDeferred = True cmd.sourcefns[n] = { 'at': pt, 'key': k, 'name': n } cmd.view.run_command( 'org_execute_source_block', { 'at': pt, 'onDoneResultsPos': evt.Make(cmd.OnDoneFunction), 'onDoneFnName': n }) return hadDeferred