Best Python code snippet using lemoncheesecake
jive.py
Source:jive.py
...149 def _run_span_gamut(self, text):150 # These are all the transformations that occur *within* block-level151 # tags like paragraphs, headers, and list items.152 # Process anchor and image tags.153 text = self._do_links(text)154 text = self._do_inline_styling(text)155 # Do hard breaks:156 return re.sub(r" {2,}\n", "\n\n", text)157 def _is_auto_link(self, s):158 if ':' in s and self._auto_link_re.match(s):159 return True160 elif '@' in s and self._auto_email_link_re.match(s):161 return True162 return False163 def _unhash_html_blocks(self, text):164 for hash, html in self._blocks.items():165 text = text.replace(hash, html)166 return text167 _email_pattern = r'[-.\w]+\@[-\w]+(?:\.[-\w]+)*\.[a-z]+'168 _url_pattern = "((http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*)"169 _email_re = re.compile(_email_pattern, re.I | re.U)170 _url_re = re.compile(_url_pattern)171 _hypertext_link_re1 = re.compile(r'\[(.*?)\]')172 def _hypertext_link_sub1(self, match):173 link_bits = match.group(1).split('|')174 num_bits = len(link_bits)175 if num_bits == 0:176 return match.group(0)#return the whole thing177 elif num_bits == 1:178 link = link_bits[0]179 if self._url_re.match(link) or not self._email_re.match(link):180 return '<a href="%s">%s</a>' % (link, link)181 elif num_bits in (2, 3):182 #if self._url_re.match(link_bits[1]):183 if num_bits == 2:184 return '<a href="%s">%s</a>' % (link_bits[1], link_bits[0])185 else:186 bits = link_bits187 return '<a href="%s" title="%s">%s</a>' % (bits[1], bits[2], bits[0])188 return '[' + '|'.join(link_bits) + ']'189 _hypertext_link_re2 = re.compile(r'\[url\]%s\[/url\]' % _url_pattern)190 def _hypertext_link_sub2(self, match):191 """convert to plain autolink"""192 link = match.group(1)193 return link194 def _do_hypertext_links(self, text):195 """196 """197 #now do these:198 #[ÐÑÐ¸Ð¼ÐµÑ ÑайÑа|http://www.example.com|ÐбÑÐ°Ð·ÐµÑ Ð¿Ð¾Ð´Ñказки по ÑайÑÑ]199 #[ÐÑÐ¸Ð¼ÐµÑ ÑайÑа|http://www.example.com]200 #[http://www.example.com]201 return self._hypertext_link_re1.sub(self._hypertext_link_sub1, text)202 def _image_link_sub(self, match):203 src = match.group(1)204 return '<img src="%s"/>' % src205 _image_link_re = re.compile(r'!(.*?)!')206 def _do_image_links(self, text):207 """208 !http://../post.gif!209 !post.gif!210 """211 return self._image_link_re.sub(self._image_link_sub, text)212 def _do_links(self, text):213 """214 now do only image and href links215 todo: more link types https://community.jivesoftware.com/markuphelpfull.jspa216 """217 #do this first [url]http://...[/url] --> plain http://...218 text = self._hypertext_link_re2.sub(self._hypertext_link_sub2, text)219 text = self._do_hypertext_links(text)220 text = self._do_image_links(text)221 #now take care of plain links222 return self._do_auto_links(text)223 _h_re = re.compile(r'''224 ^h([1-6])\. # \1 = level225 [ \t]*226 (.+?) # \2 = Header text...
__init__.py
Source:__init__.py
1from __future__ import absolute_import, print_function2import sys3from fitz.fitz import *4# define the supported colorspaces for convenience5fitz.csRGB = fitz.Colorspace(fitz.CS_RGB)6fitz.csGRAY = fitz.Colorspace(fitz.CS_GRAY)7fitz.csCMYK = fitz.Colorspace(fitz.CS_CMYK)8csRGB = fitz.csRGB9csGRAY = fitz.csGRAY10csCMYK = fitz.csCMYK11# create the TOOLS object12TOOLS = fitz.Tools()13fitz.TOOLS = TOOLS14if fitz.VersionFitz != fitz.TOOLS.mupdf_version():15 v1 = fitz.VersionFitz.split(".")16 v2 = fitz.TOOLS.mupdf_version().split(".")17 if v1[:-1] != v2[:-1]:18 raise ValueError(19 "MuPDF library mismatch %s <> %s"20 % (fitz.VersionFitz, fitz.TOOLS.mupdf_version())21 )22# copy functions to their respective fitz classes23import fitz.utils24# ------------------------------------------------------------------------------25# Document26# ------------------------------------------------------------------------------27fitz.open = fitz.Document28fitz.Document.getToC = fitz.utils.getToC29fitz.Document._do_links = fitz.utils.do_links30fitz.Document.getPagePixmap = fitz.utils.getPagePixmap31fitz.Document.getPageText = fitz.utils.getPageText32fitz.Document.setMetadata = fitz.utils.setMetadata33fitz.Document.setToC = fitz.utils.setToC34fitz.Document.searchPageFor = fitz.utils.searchPageFor35fitz.Document.newPage = fitz.utils.newPage36fitz.Document.insertPage = fitz.utils.insertPage37fitz.Document.getCharWidths = fitz.utils.getCharWidths38# ------------------------------------------------------------------------------39# Page40# ------------------------------------------------------------------------------41fitz.Page.drawBezier = fitz.utils.drawBezier42fitz.Page.drawCircle = fitz.utils.drawCircle43fitz.Page.drawCurve = fitz.utils.drawCurve44fitz.Page.drawLine = fitz.utils.drawLine45fitz.Page.drawOval = fitz.utils.drawOval46fitz.Page.drawPolyline = fitz.utils.drawPolyline47fitz.Page.drawRect = fitz.utils.drawRect48fitz.Page.drawQuad = fitz.utils.drawQuad49fitz.Page.drawSector = fitz.utils.drawSector50fitz.Page.drawSquiggle = fitz.utils.drawSquiggle51fitz.Page.drawZigzag = fitz.utils.drawZigzag52fitz.Page.getImageBbox = fitz.utils.getImageBbox53fitz.Page.getTextBlocks = fitz.utils.getTextBlocks54fitz.Page.getTextWords = fitz.utils.getTextWords55fitz.Page.getLinks = fitz.utils.getLinks56fitz.Page.getText = fitz.utils.getText57fitz.Page.getPixmap = fitz.utils.getPixmap58fitz.Page.insertLink = fitz.utils.insertLink59fitz.Page.insertTextbox = fitz.utils.insertTextbox60fitz.Page.insertText = fitz.utils.insertText61fitz.Page.searchFor = fitz.utils.searchFor62fitz.Page.showPDFpage = fitz.utils.showPDFpage63fitz.Page.insertImage = fitz.utils.insertImage64fitz.Page.updateLink = fitz.utils.updateLink65fitz.Page.newShape = lambda x: fitz.utils.Shape(x)66# ------------------------------------------------------------------------------67# Rect68# ------------------------------------------------------------------------------69fitz.Rect.getRectArea = fitz.utils.getRectArea70fitz.Rect.getArea = fitz.utils.getRectArea71# ------------------------------------------------------------------------------72# IRect73# ------------------------------------------------------------------------------74fitz.IRect.getRectArea = fitz.utils.getRectArea75fitz.IRect.getArea = fitz.utils.getRectArea76fitz.__doc__ = """77PyMuPDF %s: Python bindings for the MuPDF %s library.78Version date: %s.79Built for Python %i.%i on %s (%i-bit).80""" % (81 fitz.VersionBind,82 fitz.VersionFitz,83 fitz.VersionDate,84 sys.version_info[0],85 sys.version_info[1],86 sys.platform,87 64 if sys.maxsize > 2 ** 32 else 32,...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!