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

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

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

Generic Template Builder/MultiReplace Tool

From Jason Black, 6 Years ago, written in Python, viewed 68 times.
URL http://nerdingout.net/pastetool/view/230f0adc Embed
Download Paste or 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.                                 ITEM = row[0]
  33.                                 try:
  34.                                         VALUE = row[1]
  35.                                 except IndexError:
  36.                                         VALUE = ''
  37.                                         print "==== WARNING: ==== " + ITEM + " is missing a comma in the CSV file"
  38.                                 try:
  39.                                         REQUIRED_FIELD = bool(row[2])
  40.                                 except IndexError:
  41.                                         REQUIRED_FIELD = False
  42.                                 if (REQUIRED_FIELD == True and VALUE == ''):
  43.                                         print "==== WARNING: ==== " + ITEM + " == IS A REQUIRED FIELD!"
  44.                                 # CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK BEFORE STORING IN DICTIONARY
  45.                                 if VALUE.strip()!='':
  46.                                         self.CSV_DICT[ITEM] = VALUE
  47.                                
  48.         def generateConfig(self):
  49.                 # Cycle through Each ITEM-VALUE pair in the CSV DICTIONARY
  50.                 for key in self.CSV_DICT:
  51.                         ITEM = key
  52.                         VALUE = self.CSV_DICT[key]
  53.                         # CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK
  54.                         self.resultstring = self.resultstring.replace(ITEM,VALUE)
  55.                 return self.resultstring
  56.        
  57.         def writeconfig(self,outputfilename,FinalOutput):
  58.                 if os.path.isfile(outputfilename):
  59.                         os.remove(outputfilename)
  60.                 with open(outputfilename, 'w') as outputFile:
  61.                         print '====   INFO:  ==== WRITING FINAL CONFIG FILE: ' + outputfilename
  62.                         outputFile.write(FinalOutput)
  63.  
  64.         def fullBuild(self):
  65.                 Config = self.generateConfig()
  66.                 FinalOutput = Config
  67.                 self.writeconfig(self.output,FinalOutput)
  68.                
  69. def main():
  70.         # usage python templatebuilder.py CSVFILE TEMPLATEFILE OUTPUTFILE
  71.         parser = argparse.ArgumentParser(description='build a config from template')
  72.         parser.add_argument('InputFile' , type=str , action='store' , nargs=1 , help='The CSV input file')
  73.         parser.add_argument('TemplateFile' , type=str , action='store' , nargs=1 , help='The Template')
  74.         parser.add_argument('OutputFile' , type=str , action='store' , nargs=1 , help='The Output File')
  75.         args = parser.parse_args()
  76.        
  77.         InputFile = " ".join(args.InputFile)
  78.         TemplateFile = " ".join(args.TemplateFile)
  79.         OutputFile = " ".join(args.OutputFile)
  80.                
  81.         myTemplateBuilder = TemplateBuilder(InputFile,TemplateFile,OutputFile)
  82.         myTemplateBuilder.fullBuild()
  83.        
  84. if __name__ == '__main__':
  85.    main()
  86.  

Reply to "Generic Template Builder/MultiReplace Tool"

Here you can reply to the paste above

captcha