def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age and max_age < 86400: return 0 # it cannot be shorter than one day else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None)
def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age is not None and not self.get_closest_expiration(max_age): return 0 else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None)
def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age: return 0 # expiration is not possible else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None)
def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r"[^a-zA-Z0-9=+/\s]", contents): return 0 elif max_age: return 0 # expiration is not possible else: mime = image_mime(contents, ("gif", "jpeg", "png")) return 20 * int(mime is not None)
def can_post(self, contents, title=None, public=None, max_age=None): if (public is False or re.search(r'[^a-zA-Z0-9=+/\s]', contents) or not re.search(r'[^a-zA-Z0-9=+/\s]', contents) and max_age): return 0 else: mime = image_mime(contents, ('gif', 'jpeg', 'png', 'tiff', 'xcf', 'pdf')) return 20 * int(mime is not None)
def can_post(self, contents, title=None, public=None, max_age=None): if public is False: return 0 elif re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age: return 0 else: mime = image_mime(contents, ('gif', 'jpeg', 'png', 'tiff', 'xcf', 'pdf')) return 20 * int(mime is not None)
def post_image(self, filename, contents, private=False, description=''): self.location('/') assert self.is_on_page(PageHome) mime = image_mime(contents.encode('base64')) self.select_form(nr=0) self.form.find_control('private').items[0].selected = private self.form['description'] = description or '' self.form.find_control('img').add_file(StringIO(contents), filename=filename, content_type=mime) self.submit() assert self.is_on_page(PageImage) return self.page.get_info()
def post_image(self, filename, contents, private=False, description=''): self.location('/') assert self.home.is_here() mime = image_mime(b64encode(contents)) form = self.page.get_form(nr=0) form['private'] = int(private) form['description'] = description or '' del form['img'] f = (filename, BytesIO(contents), mime) self.location(form.url, data=form, files={'img': f}) assert self.img.is_here() return self.page.get_info()
def post_image(self, filename, contents, private=False, description=''): self.location('/') assert self.is_on_page(PageHome) mime = image_mime(contents.encode('base64')) self.select_form(nr=0) self.form.find_control('private').items[0].selected = private self.form['description'] = description or '' self.form.find_control('img').add_file(BytesIO(contents), filename=filename, content_type=mime) self.submit() assert self.is_on_page(PageImage) return self.page.get_info()