cleaning
[lori.git] / lori.py
blob5f40b35e1c0a3e7d6ffa6901b67e2379edac7d45
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 import os, sys
5 class lori(object):
6 """Simple package manager"""
7 def __init__(self, config, args):
8 #try:
9 self.dirs, self.depends, self.mirrors, self.args, self.modules, self.db_name = config.dirs, config.depends, config.mirrors, args, {}, config.db_name
10 self.prepare_cmd()
11 #except:
12 # print 'You have error in config file!'
13 # return None
15 def prepare_cmd(self):
16 try:
17 if self.args[0]:
18 self.action = [ self.args[0], self.args[1:] ]
19 try:
20 if not self.modules.has_key(self.action[0]):
21 module = __import__(self.action[0])
22 module = module.module()
23 self.modules[self.action[0]] = module
24 except:
25 print """I can't found module file!"""
26 except:
27 print """Usage lori <action> <action's args>"""
29 def do_module(self):
30 for module in self.modules:
31 getattr(self.modules[module], "install")(self, self.action[1])
33 def load_sqlite(self):
34 import sqlite
35 self.sqlite = sqlite.sqlite()
36 getattr(self.sqlite, 'install')(self)
38 def do_sql(self, cmd):
39 try:
40 getattr(self.sqlite, cmd)(self)
41 except:
42 pass