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: 595
Function: getPaste

File: /home3/analyti4/public_html/nerdingout/pastetool/index.php
Line: 315
Function: require_once

Generic MultiReplace Tool/Template Builder - NerdingOut Paste Tool (Stikked)

This paste brought to you by NerdingOut Paste Tool (Stikked). View Raw

  1. import os
  2. import re
  3. import csv
  4. import string
  5. import subprocess
  6. import argparse
  7.  
  8. # TemplateBuilder.py
  9. # SCRIPT_VERSION 1.0
  10. # by JASON BLACK
  11. # last revision date 5/21/18
  12.  
  13. class TemplateBuilder(object):
  14.         def __init__(self, input,template,output):
  15.                 self.input = input
  16.                 self.CSV_DICT = {}
  17.                 self.template = template
  18.                 self.templatecontents = ''
  19.                 self.output = output
  20.                                
  21.                 # READ IN TEMPLATE
  22.                 with open(self.template) as b:
  23.                         self.templatecontents = b.read()
  24.                 self.resultstring = self.templatecontents
  25.                
  26.                 # READ IN INPUTFILE
  27.                 with open(self.input, mode='r') as csvfile:
  28.                         Detail_file = csv.reader(csvfile, delimiter=',')
  29.                         # Cycle through Each ITEM-VALUE pair in the DETAIL FILE
  30.                         for row in Detail_file:
  31.                                 # DEREFERENCE row ARRAY FOR CLARITY IN READING CODE
  32.                                 try:
  33.                                         ITEM = row[0]
  34.                                 except IndexError:
  35.                                         print "==== WARNING: ==== There is a blank line or a line that starts with comma in the CSV file"
  36.                                 try:
  37.                                         VALUE = row[1]
  38.                                 except IndexError:
  39.                                         VALUE = ''
  40.                                         print "==== WARNING: ==== " + ITEM + " is missing a comma in the CSV file, or the next line is blank"
  41.                                 # CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK BEFORE STORING IN DICTIONARY
  42.                                 if VALUE.strip()!='':
  43.                                         self.CSV_DICT[ITEM] = VALUE
  44.                                
  45.         def generateConfig(self):
  46.                 # Cycle through Each ITEM-VALUE pair in the CSV DICTIONARY
  47.                 for key in self.CSV_DICT:
  48.                         ITEM = key
  49.                         VALUE = self.CSV_DICT[key]
  50.                         self.resultstring = self.resultstring.replace(ITEM,VALUE)
  51.                 return self.resultstring
  52.        
  53.         def writeconfig(self,outputfilename,FinalOutput):
  54.                 if os.path.isfile(outputfilename):
  55.                         os.remove(outputfilename)
  56.                 with open(outputfilename, 'w') as outputFile:
  57.                         print '====   INFO:  ==== WRITING FINAL CONFIG FILE: ' + outputfilename
  58.                         outputFile.write(FinalOutput)
  59.  
  60.         def fullBuild(self):
  61.                 Config = self.generateConfig()
  62.                 FinalOutput = Config
  63.                 self.writeconfig(self.output,FinalOutput)
  64.                
  65. def main():
  66.         # usage python templatebuilder.py CSVFILE TEMPLATEFILE OUTPUTFILE
  67.         parser = argparse.ArgumentParser(description='build a config from template')
  68.         parser.add_argument('InputFile' , type=str , action='store' , nargs=1 , help='The CSV input file')
  69.         parser.add_argument('TemplateFile' , type=str , action='store' , nargs=1 , help='The Template')
  70.         parser.add_argument('OutputFile' , type=str , action='store' , nargs=1 , help='The Output File')
  71.         args = parser.parse_args()
  72.        
  73.         InputFile = " ".join(args.InputFile)
  74.         TemplateFile = " ".join(args.TemplateFile)
  75.         OutputFile = " ".join(args.OutputFile)
  76.                
  77.         myTemplateBuilder = TemplateBuilder(InputFile,TemplateFile,OutputFile)
  78.         myTemplateBuilder.fullBuild()
  79.        
  80. if __name__ == '__main__':
  81.    main()
  82.