A PHP Error was encountered
Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
Backtrace:
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache
File: /home3/analyti4/public_html/nerdingout/pastetool/application/libraries/Process.php
Line: 45
Function: parse_code
File: /home3/analyti4/public_html/nerdingout/pastetool/application/models/Pastes.php
Line: 517
Function: syntax
File: /home3/analyti4/public_html/nerdingout/pastetool/application/controllers/Main.php
Line: 551
Function: getPaste
File: /home3/analyti4/public_html/nerdingout/pastetool/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home3/analyti4/public_html/nerdingout/pastetool/system/core/Exceptions.php:271)
Filename: view/raw.php
Line Number: 2
Backtrace:
File: /home3/analyti4/public_html/nerdingout/pastetool/themes/default/views/view/raw.php
Line: 2
Function: header
File: /home3/analyti4/public_html/nerdingout/pastetool/application/core/MY_Loader.php
Line: 173
Function: include
File: /home3/analyti4/public_html/nerdingout/pastetool/application/core/MY_Loader.php
Line: 43
Function: _ci_load
File: /home3/analyti4/public_html/nerdingout/pastetool/application/controllers/Main.php
Line: 558
Function: view
File: /home3/analyti4/public_html/nerdingout/pastetool/index.php
Line: 315
Function: require_once
import os
import re
import csv
import string
import subprocess
import argparse
# TemplateBuilder.py
# SCRIPT_VERSION 1.0
# by JASON BLACK
# last revision date 5/21/18
class TemplateBuilder(object):
def __init__(self, input,template,output):
self.input = input
self.CSV_DICT = {}
self.template = template
self.templatecontents = ''
self.output = output
# READ IN TEMPLATE
with open(self.template) as b:
self.templatecontents = b.read()
self.resultstring = self.templatecontents
# READ IN INPUTFILE
with open(self.input, mode='r') as csvfile:
Detail_file = csv.reader(csvfile, delimiter=',')
# Cycle through Each ITEM-VALUE pair in the DETAIL FILE
for row in Detail_file:
# DEREFERENCE row ARRAY FOR CLARITY IN READING CODE
try:
ITEM = row[0]
except IndexError:
print "==== WARNING: ==== There is a blank line or a line that starts with comma in the CSV file"
try:
VALUE = row[1]
except IndexError:
VALUE = ''
print "==== WARNING: ==== " + ITEM + " is missing a comma in the CSV file, or the next line is blank"
# CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK BEFORE STORING IN DICTIONARY
if VALUE.strip()!='':
self.CSV_DICT[ITEM] = VALUE
def generateConfig(self):
# Cycle through Each ITEM-VALUE pair in the CSV DICTIONARY
for key in self.CSV_DICT:
ITEM = key
VALUE = self.CSV_DICT[key]
self.resultstring = self.resultstring.replace(ITEM,VALUE)
return self.resultstring
def writeconfig(self,outputfilename,FinalOutput):
if os.path.isfile(outputfilename):
os.remove(outputfilename)
with open(outputfilename, 'w') as outputFile:
print '==== INFO: ==== WRITING FINAL CONFIG FILE: ' + outputfilename
outputFile.write(FinalOutput)
def fullBuild(self):
Config = self.generateConfig()
FinalOutput = Config
self.writeconfig(self.output,FinalOutput)
def main():
# usage python templatebuilder.py CSVFILE TEMPLATEFILE OUTPUTFILE
parser = argparse.ArgumentParser(description='build a config from template')
parser.add_argument('InputFile' , type=str , action='store' , nargs=1 , help='The CSV input file')
parser.add_argument('TemplateFile' , type=str , action='store' , nargs=1 , help='The Template')
parser.add_argument('OutputFile' , type=str , action='store' , nargs=1 , help='The Output File')
args = parser.parse_args()
InputFile = " ".join(args.InputFile)
TemplateFile = " ".join(args.TemplateFile)
OutputFile = " ".join(args.OutputFile)
myTemplateBuilder = TemplateBuilder(InputFile,TemplateFile,OutputFile)
myTemplateBuilder.fullBuild()
if __name__ == '__main__':
main()