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

Configbuilder.py - NerdingOut Paste Tool (Stikked)

Configbuilder.py

From Black, 6 Years ago, written in Python, viewed 73 times.
URL http://nerdingout.net/pastetool/view/943ec7c2 Embed
Download Paste or View Raw
  1. import os
  2. import csv
  3. import string
  4.  
  5. class ConfigBuilder(object):
  6.         def __init__(self, CSV,basetemplatefile,vrftemplatefile):
  7.                 self.CSV = CSV
  8.                 self.basetemplatefile = basetemplatefile
  9.                 self.basetemplatecontents = ''
  10.                 with open(self.basetemplatefile) as b:
  11.                         self.basetemplatecontents = b.read()
  12.  
  13.                 self.vrftemplatefile = vrftemplatefile
  14.                 self.vrftemplatecontents = ''
  15.  
  16.                 self.baseresultstring = self.basetemplatecontents
  17.                 with open(self.vrftemplatefile) as v:
  18.                         self.vrftemplatecontents = v.read()
  19.                 self.vrfresultstring = ''
  20.  
  21.         def generateBaseConfig(self):
  22.                 # OPEN CSV CONFIG FILE AND READ INTO AN ARRAY
  23.                 with open(self.CSV, mode='r') as csvfile:
  24.                         Detail_file = csv.reader(csvfile, delimiter=',')
  25.                         # Cycle through Each ITEM-VALUE pair in the DETAIL FILE
  26.                         for row in Detail_file:
  27.                                 # DEREFERENCE row ARRAY FOR CLARITY IN READING CODE
  28.                                 ITEM = row[0]
  29.                                 VALUE = row[1]
  30.                                 # CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK
  31.                                 if VALUE.strip()!='':
  32.                                         # DO THE ACTUAL SUBSTITUTION
  33.                                         self.baseresultstring = self.baseresultstring.replace(ITEM,VALUE)
  34.                 return self.baseresultstring
  35.  
  36.         def generateAgencyVRFs(self):
  37.                 NumVRFs = self.queryitem('@NUMBER_OF_AGENCY_VRFS')
  38.                 for x in range(0, int(NumVRFs)):
  39.                         print x
  40.                         # OPEN CSV CONFIG FILE AND READ INTO AN ARRAY
  41.                         self.vrfresultstring = self.vrfresultstring + self.vrftemplatecontents
  42.                         with open(self.CSV, mode='r') as csvfile:
  43.                                 Detail_file = csv.reader(csvfile, delimiter=',')
  44.                                 # Cycle through Each ITEM-VALUE pair in the DETAIL FILE
  45.                                 for row in Detail_file:
  46.                                         # DEREFERENCE row ARRAY FOR CLARITY IN READING CODE
  47.                                         ITEM = row[0]
  48.                                         # remove VRF1, VRF2, etc in ITEM key and replace with just VRF so I can use one template for all vrfs
  49.                                         ITEM = ITEM.replace('VRF'+ str((x+1)), 'VRF')
  50.                                         VALUE = row[1]
  51.                                         print ITEM + '=' + VALUE
  52.                                         # CHECK TO MAKE SURE THE CONFIG_VALUE ISN"T BLANK
  53.                                         if VALUE.strip()!='':
  54.                                                 # DO THE ACTUAL SUBSTITUTION
  55.                                                 self.vrfresultstring = self.vrfresultstring.replace(ITEM,VALUE)
  56.                 return self.vrfresultstring
  57.  
  58.         def queryitem(self,querystring):
  59.                 # OPEN CSV CONFIG FILE AND READ INTO AN ARRAY
  60.                 with open(self.CSV, mode='r') as csvfile:
  61.                         Detail_file = csv.reader(csvfile, delimiter=',')
  62.                         # Cycle through Each ITEM-VALUE pair in the DETAIL FILE
  63.                         for row in Detail_file:
  64.                                 # DEREFERENCE row ARRAY FOR CLARITY IN READING CODE
  65.                                 ITEM = row[0]
  66.                                 VALUE = row[1]
  67.                                 if VALUE.strip()!='':
  68.                                         if ITEM == querystring:
  69.                                                 queryresult = VALUE
  70.                                                 return queryresult
  71.                                                
  72.         def writeconfig(self,outputfilename,FinalOutput):
  73.                 if os.path.isfile(outputfilename):
  74.                         os.remove(outputfilename)
  75.                 with open(outputfilename + '.txt', 'w') as outputFile:
  76.                         print '\n WRITING FINAL CONFIG FILE: ' + outputfilename + '.txt'
  77.                         outputFile.write(FinalOutput)
  78.                        
  79.         def fullbuild(self):
  80.                 baseconfig = self.generateBaseConfig()
  81.                 vrfconfig = self.generateAgencyVRFs()
  82.                 outputfilename = self.queryitem('@RTR_NAME_OF_ROUTER')
  83.                 FinalOutput = baseconfig + vrfconfig
  84.                 self.writeconfig(outputfilename,FinalOutput)
  85.  
  86. def main():
  87.         MPLSGen = ConfigBuilder('RouterDetails.csv','BaseMPLSRouter.tmpl','AgencyVRF.tmpl')
  88.         MPLSGen.fullbuild()
  89.  
  90. if __name__ == '__main__':
  91.     main()

Reply to "Configbuilder.py"

Here you can reply to the paste above

captcha