aboutsummaryrefslogtreecommitdiff
path: root/ips/config.py
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2013-04-21 23:25:55 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2013-04-21 23:25:55 -0400
commit1f2b4af32761563219eb963bf48da9ebb3a6f6e3 (patch)
tree9a5a656763d90176bea02da0af44a6e18b365dae /ips/config.py
parent60ad0c3fd1c55be857ea902ff431db8d958efc64 (diff)
downloadipsutils-1f2b4af32761563219eb963bf48da9ebb3a6f6e3.tar.gz
* Created IPS package
* Major overhaul in progress
Diffstat (limited to 'ips/config.py')
-rw-r--r--ips/config.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/ips/config.py b/ips/config.py
new file mode 100644
index 0000000..45aa204
--- /dev/null
+++ b/ips/config.py
@@ -0,0 +1,59 @@
+import shlex
+import string
+
+class Config(object):
+ def __init__(self, ipsfile):
+ super(Config, self).__init__()
+ key_dict = {
+ 'name': '',
+ 'version': '',
+ 'release': '',
+ 'maintainer': '',
+ 'group': '',
+ 'upstream_url': '',
+ 'source_url': '',
+ 'description': '',
+ 'summary': '',
+ 'classification': '',
+ 'arch': '',
+ 'license': ''
+ }
+
+ script_dict = {
+ 'build': [],
+ 'prep': [],
+ 'install': [],
+ 'files': []
+ }
+
+ expandable = []
+ for line in file(ipsfile).readlines():
+ parts = shlex.split(line)
+ t = string.Template(parts)
+ expandable.append(t)
+
+ for key in key_dict:
+ for line in file(ipsfile).readlines():
+ parts = shlex.split(line)
+ if key + ":" in parts:
+ key_dict[key] = parts[1]
+
+ found_data = False
+ code_section = ['%build', '%prep', '%install']
+
+ for section in code_section:
+ for line in file(ipsfile).readlines():
+ if line.startswith('#'):
+ continue
+ parts = shlex.split(line)
+ if '%end' in parts:
+ found_data = False
+ if section in parts:
+ found_data = True
+ continue
+ if found_data:
+ script_dict[section.strip('%')].append(parts)
+
+ self.key_dict = key_dict
+ self.script_dict = script_dict
+ \ No newline at end of file