def __init__(self, *args, **kwargs): self.start_idx = kwargs['start_idx'] if 'start_idx' in kwargs else 0 self.end_idx = kwargs['end_idx'] if 'end_idx' in kwargs else 0 self.env = kwargs['env'] if 'env' in kwargs else 'dev' self.conf = config[self.env] self.d = Debug(level=4, color=True) self.current_dir = os.path.dirname(os.path.abspath(__file__)) self.project_dir = os.path.abspath( os.path.join(self.current_dir, os.pardir)) self.admin_url = self.conf['url']['admin'] self._default_image_id = 2
from tools import Debug orig_prettify = BeautifulSoup.prettify r = re.compile(r'^(\s*)', re.MULTILINE) def prettify(self, encoding=None, formatter="minimal", indent_width=4): return r.sub(r'\1' * indent_width, orig_prettify(self, encoding, formatter)) BeautifulSoup.prettify = prettify if __name__ == '__main__': ## init logger d = Debug(level=4, color=True) db_conn = None try: d.info('connect to database ...') db_conn = DBConn(config['dev']['db']) d.info('[OK]\n') except Exception as e: d.error(e) exit() cursor = db_conn.get_cursor() ## init directories current_dir = os.path.dirname(os.path.abspath(__file__)) output_dir = os.path.abspath(os.path.join(current_dir, os.pardir,