Racing through config files with ConfigParser in Python #W3

Does it seem like to you sometimes when you have a lot of free time and even if you have your hands dipped, dirty, and stuck in so many other pies (projects) that would take you naturally a lot of time to eat and finish (complete), but you still want to reach out for the next big pie (New Project). That’s me in summers and oh man, the pies are piling up. FAST and FURIOUS.

I wouldn’t dare to share my pie business to you, it’s flourishing by the way as you saw the image on the top. But you like updates and here it is.

Let’s get this post started with what new I learned this past week and its ConfigParser.


So say, you have config files, INI files like the ones below we have in activities of Sugar Labs, used as a metadata file for each activity containing all information about the same. This file is used by ASLOv3 to showcase metadata about each of the activity which helps the user get more information about the activity that they are trying to download.

name = Browse
activity_version = 156
bundle_id = org.laptop.WebActivity
icon = activity-web
exec = sugar-activity webactivity.WebActivity -s
mime_types = image/png;image/gif;image/jpeg;text/html;text/uri-list;application/xhtml+xml;application/rss+xml;application/xml;text/css
license = GPLv2+
summary = Surf the world! Here you can do research, watch educational videos, take online courses, find books, connect with friends and more.
update_url =
tags = exploration;web
single_instance = no
max_participants = 4
repository =

So needless to say these files are pretty important. Now think about having about 160 of these in total, stored on GitHub or some code sharing website, in their separate repositories and you, sir need to fix all of them. Fixing here means adding, removing, editing details in and out of them. Extracting content and using it such as authentication and such. There is no one way to find what you need to fix each file. You can use the time-proven way of the mouse and ctrl+c and ctrl+v. But good luck spending your next 2 months on the job fixing them.

You, my friend, need automation. You need Python. You need ConfigParser. 

Breaking it down for you.

The What?

The configparser module in Python is used for working with configuration files. It is much similar to Windows INI files. You can use it to manage user-editable configuration files for an application. The configuration files are organized into sections, and each section can contain name-value pairs for configuration data. Config file sections are identified by looking for lines starting with [ and ending with ]. The value between the square brackets is the section name, and can contain any characters except square brackets. Options are listed one per line within a section. The line starts with the name of the option, which is separated from the value by a colon (:) or equal sign (=). Whitespace around the separator is ignored when the file is parsed.

Source: PythonForBeginners

Enjoy the docs, Read the docs

How to get started? (The How)

Applications (The Woah)

Other Parsers (.. umm)

Also, sorry. Usually I put my hyperlinks with a bit of more finesse in my blogs but with a sheer number of them this time and with my undying intent of not reinventing the wheel, I put up the links of the blogs from where I learned. For you to learn. Live in the mix guys.

Updates About Week #2 

  • Convened the 3rd meeting for GSoC and Mentors in which we shared what we did this week and what we will do in the following the week. All updates summed up here [1]
  • I am done with the community Bonding task, of setting up my development environment and figuring out my project.
  • Started writing the next blog post. All blog updates available here [2][1] – Sugar Tracker
    [2] – GSoC #2018


Written by Vipul Gupta – vipulgupta2048


One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s