For example, I have a config file named rule1.conf like this:
[Basis]
user = "sunhf"
time = "2012-12-31"
[Bowtie]
path = "/usr/bin/bowtie"
index = "/mnt/Storage/sync/hg19"
And a models.py like this(using a package named magic.py
..):
from magic import Section
class Conf:
__confname__ = None
basis = Section(["user", "time"])
bowtie = Section(["path", "index"])
At last, a viewer.py like this:
from models import Conf as my_conf
my_conf.__confname__ = "rule1.conf" // bind to the config file, I have no ideas how to do this
print my_conf.basis.user // output: `sunhf`
print my_conf.bowtie.index // output: `/mnt/Storage/sync/hg19`
When I run viewer.py
in command line:
$ python viewer.py
sunhf
/mnt/Storage/sync/hg19
Does anyone have any ideas about how to implement the magic.py
?
Thanks!