python ile basit bir kod wrapper örneği

import sys

pre = ‘out.println("‘ # satirbasi sql.append(" gibi
pst = ‘")‘            # satirsonu ") gibi
addslash = 1          # tirnaklara backslash

if len(sys.argv) == 1:
    print "kullanim: \n \t\t  wrapper.py giris.txt \n  \t\t  > cikis.txt gerekiyorsa"
    sys.exit(1)

f = open(sys.argv[1] ,’r‘)

for r in f:
    if (addslash == 1):
        r = r.replace(‘"‘,’\\"‘)
    r = r.rstrip()
    line =  "%s%s%s" % (pre , r, pst)
    print line

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by sweet Captcha