From 1f2b4af32761563219eb963bf48da9ebb3a6f6e3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 21 Apr 2013 23:25:55 -0400 Subject: * Created IPS package * Major overhaul in progress --- ips/config.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 ips/config.py (limited to 'ips/config.py') 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 -- cgit