class Client: def __init__(self, session=None): self.conn = Connection() self.session = None if session: self.load_session(session) #self.bm = BoardManager() def load_session(self, session): if isinstance(session, basestring): session = Session.create(session) if session: self.conn.load_session(session) self.session = session def is_logged_in(self): return IsLoggedInAction.run(client) def login(self, username, password): LogInAction.run(client, username, password) def logout(self): LogOutAction.run(client) def compose(self, board, title, body, pid=None, gid=None): ''' title can have as many as 49 ascii chars, which is 24.5 chinese chars ''' return ComposeAction.run(self, board, title, body, pid, gid) def fetch_post(self, board, pid, num): return FetchPostAction.run(self, board, pid, num) def fetch_topic(self, board, pid, idx=None): return FetchTopicAction.run(self, board, pid, idx) def fetch_page(self, board, idx=None): return FetchPageAction.run(client, board, idx) def fetch_top10(self): return FetchTopAction.run(self) def fetch_hot(self): return FetchHotAction.run(self) def fetch_subscription(self): return FetchSubscriptionAction.run(self) def fetch_all_board(self): bm = FetchBoardManagerAction.run(self) bm.dump_xml() def fetch_emoticon(self): ret = FetchEmoticonAction.run(self) fn = os.path.join(ROOT_DIR, 'assets/emoticon.json') with open(fn, 'w') as f: json.dump(ret, f)
def __init__(self, session=None): self.conn = Connection() self.session = None if session: self.load_session(session)