def get_submission(self, url=None, submission_id=None): """Returns a Submission object for the given url or submission_id.""" if bool(url) == bool(submission_id): raise TypeError("One (and only one) of id or url is required!") if submission_id: url = urljoin(self.config["comments"], submission_id) return objects.Submission.get_info(self, url)
def get_submission(self, url=None, submission_id=None): """Returns a Submission object for the given url or submission_id.""" if bool(url) == bool(submission_id): raise TypeError('One (and only one) of id or url is required!') if submission_id: url = urljoin(self.config['comments'], submission_id) return reddit.objects.Submission.get_info(self, url)
def get_captcha(self, reddit_session, captcha_id): url = urljoin(reddit_session.config['captcha'], captcha_id + '.png') sys.stdout.write('Captcha URL: %s\nCaptcha: ' % url) sys.stdout.flush() captcha = sys.stdin.readline().strip() return {'iden': captcha_id, 'captcha': captcha}
def __init__(self, reddit_session, json_dict): super(Submission, self).__init__(reddit_session, json_dict) self.permalink = urljoin(reddit_session.config["reddit_url"], self.permalink) self._comments_by_id = {} self._all_comments = False self._comments = None self._comments_flat = None self._orphaned = {}
def _sorted(self, *args, **kw): if 'url_data' in kw and kw['url_data']: url_data = kw['url_data'] else: url_data = kw['url_data'] = {} for key, value in six.iteritems(defaults): url_data.setdefault(key, value) url = urljoin(self._url, subpath) # pylint: disable-msg=W0212 return self.reddit_session.get_content(url, *args, **kw)
def _section(self, sort='new', time='all', *args, **kw): if 'url_data' in kw and kw['url_data']: url_data = kw['url_data'] else: url_data = kw['url_data'] = {} url_data.setdefault('sort', sort) url_data.setdefault('t', time) url = urljoin(self._url, subpath) # pylint: disable-msg=W0212 return self.reddit_session.get_content(url, *args, **kw)
def _section(self, sort="new", time="all", *args, **kw): if "url_data" in kw and kw["url_data"]: url_data = kw["url_data"] else: url_data = kw["url_data"] = {} url_data.setdefault("sort", sort) url_data.setdefault("t", time) url = urljoin(self._url, subpath) # pylint: disable-msg=W0212 return self.reddit_session.get_content(url, *args, **kw)
def __init__(self, reddit_session, json_dict): super(Submission, self).__init__(reddit_session, json_dict) self.permalink = urljoin(reddit_session.config['reddit_url'], self.permalink) self._comments_by_id = {} self._all_comments = False self._comments = None self._comments_flat = None self._orphaned = {}
def __getitem__(self, key): """Return the URL for key""" if self._ssl_url and key in self.SSL_PATHS: return urljoin(self._ssl_url, self.API_PATHS[key]) return urljoin(self._site_url, self.API_PATHS[key])
def get_captcha(self, reddit_session, captcha_id): url = urljoin(reddit_session.config["captcha"], captcha_id + ".png") sys.stdout.write("Captcha URL: %s\nCaptcha: " % url) sys.stdout.flush() captcha = sys.stdin.readline().strip() return {"iden": captcha_id, "captcha": captcha}
def short_link(self): return urljoin(self.reddit_session.config.short_domain, self.id)
def permalink(self): return urljoin(self.submission.permalink, self.id)
def url(self, path): # pylint: disable-msg=W0212 return urljoin(self.r.config._site_url, path)