Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Xbox Lve Generator v3
Better way to get content via jQuery $.get()
Free CarTown Blue Points Generator and CarTown Templates
Steam Wallet Hack 2012
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
PAYPAL REMOVE ACCESS LIMITED ACCOUNT 100% Working
Pastable version of
.ini file parser
<pre class='prettyprint' language='python'>import sys import re inifile = sys.argv[1] quotes = ["'", '\"'] f = file(inifile) d = {} def get_quote_char(line): for char in line: if char in quotes: return char def getkey(line): #swallow everything up to the = return line[ : line.find('=') ].strip() def getval(line): #swallow everything after the = line = line[ line.find('=') + 1 : ].strip() q = get_quote_char(line) startq = line.find(q) #start scanning the line from the quote onwards position = 0 for char in line[ startq : ]: if char not in quotes or line[ position - 1 ] == '\\': pass else: #might hit some remote corner-case with this if position > 0: return line[ startq + 1 : position ] position+=1 for line in f: line = line.strip() #skip comments and empty lines if line.startswith(';') or line=='': pass #store sections as dicts elif line.startswith('['): section_name = line[ 1 : len(line) - 1 ].strip() section_dict = { section_name : {} } d.update(section_dict) else: k = getkey(line) v = getval(line) #print k,v try: d[section_name].update( {k:v} ) except TypeError: print 'The ini file contains invalid characters' print d</pre> <pre class='prettyprint' language='python'>[foo] greeting = 'hello' ;this is a comment name = 'Eddie' [bar] lastname = 'Vedder';that's another comment; [ malformed section ] city='Prague' country="\'Czech Republic\'" whatever='this ; is nasty' [bad] dog='bau' cat = 'miao' mouse = "squeak" [tabbed section] dogname = '\Oliver' catname = 'Barbara' [one more] appliance='lcd \'monitor\'' car = "Alfa \"Romeo\" - Giulietta";"foo"</pre> <a href="http://www.refactormycode.com/codes/143-ini-file-parser" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>