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

Replies to Configbuilder.py rss

Title Name Language When
Re: Configbuilder.py Black python 6 Years ago.

Reply to "Configbuilder.py"

Here you can reply to the paste above

captcha