• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(70254)  |  Call(69819)  |  Derive(0)  |  Import(435)
Compile a regular expression pattern, returning a pattern object.

        def compile(pattern, flags=0):
    "Compile a regular expression pattern, returning a pattern object."
    return _compile(pattern, flags)
        


src/a/r/artie-HEAD/example/applications/scrape.py   artie(Download)
    flags = kwargs.get('flags', re.DOTALL)
    for i, param in enumerate(params):
        template = template.replace('__%d__' % i, param)
    return re.compile(template, flags)
 
def iregex(template, *params, **kwargs):
    """Compile a regular expression, substituting in any passed parameters
    return '<' + tagname_re + tagcontent_re + '>'
 
anytag_re = tag_re(r'(\?|!\w*|/?[a-zA-Z_:][\w:.-]*)')
tagpat = re.compile(anytag_re)
 
# This pattern matches a character entity reference (a decimal numeric
# references, a hexadecimal numeric reference, or a named reference).
charrefpat = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?')
def no_groups(re):
    return re.replace('(', '(?:').replace('(?:?', '(?')
 
tagsplitter = re.compile(no_groups(anytag_re))
parasplitter = re.compile(no_groups(tag_re('(p|table|form)')), re.I)
linesplitter = re.compile(no_groups(tag_re('(div|br|tr)')), re.I)
cdatapat = re.compile(r'<(!\s*--|style\b|script\b)', re.I)
endcdatapat = {'!': re.compile(r'--\s*>'),
               'script': re.compile(r'</script[^>]*>', re.I),
               'style': re.compile(r'</style[^>]*>', re.I)}
    return re.sub('\n\n+', '\n\n', '\n\n'.join(paragraphs)).strip()
 
attr_re = r'''\s*([\w:.-]+)(\s*=\s*('[^']*'|"[^"]*"|[^\s>]*))?'''
attrpat = re.compile(attr_re)
 
def parseattrs(text):
    """Turn a string of name=value pairs into an attribute dictionary."""

src/c/l/clearsilver-0.10.1/clearsilver/python/examples/trans/trans.py   clearsilver(Download)
 
 
        if Translator._HTML_TAG_RE is None:
            Translator._HTML_TAG_RE = re.compile(Translator._HTML_TAG_REGEX, re.MULTILINE | re.DOTALL)
        if Translator._HTML_CMT_RE is None:
            Translator._HTML_CMT_RE = re.compile(Translator._HTML_CMT_REGEX, re.MULTILINE | re.DOTALL)
        if Translator._CS_TAG_RE is None:
            Translator._CS_TAG_RE = re.compile(Translator._CS_TAG_REGEX, re.MULTILINE | re.DOTALL)
        #print "Found tag: %s" % tag
        results = []
        attrfind = re.compile(
            r'\s*([a-zA-Z_][-.a-zA-Z_0-9]*)(\s*=\s*'
            r'(\'[^\']*\'|"[^"]*"|[^ \t\n<>]*))?')
        k = i
        attrs = {}

src/p/o/pony-build-HEAD/examples/push-cgi-notifier/feedparser.py   pony-build(Download)
class NonXMLContentType(ThingsNobodyCaresAboutButMe): pass
class UndeclaredNamespace(Exception): pass
 
sgmllib.tagfind = re.compile('[a-zA-Z][-_.:a-zA-Z0-9]*')
sgmllib.special = re.compile('<!')
sgmllib.charref = re.compile('&#(x?[0-9A-Fa-f]+)[^0-9A-Fa-f]')
 
            ''.join(map(chr, range(256))), ''.join(map(chr, emap)))
    return s.translate(_ebcdic_to_ascii_map)
 
_urifixer = re.compile('^([A-Za-z][A-Za-z0-9+-.]*://)(/*)(.*?)')
def _urljoin(base, uri):
    uri = _urifixer.sub(r'\1\3', uri)
    return urlparse.urljoin(base, uri)
_korean_pm    = u'\uc624\ud6c4' # bfc0 c8c4 in euc-kr
 
_korean_onblog_date_re = \
    re.compile('(\d{4})%s\s+(\d{2})%s\s+(\d{2})%s\s+(\d{2}):(\d{2}):(\d{2})' % \
               (_korean_year, _korean_month, _korean_day))
_korean_nate_date_re = \
    re.compile(u'(\d{4})-(\d{2})-(\d{2})\s+(%s|%s)\s+(\d{,2}):(\d{,2}):(\d{,2})' % \
registerDateHandler(_parse_date_nate)
 
_mssql_date_re = \
    re.compile('(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})(\.\d+)?')
def _parse_date_mssql(dateString):
    '''Parse a string according to the MS SQL date format'''
    m = _mssql_date_re.match(dateString)
  }
 
_greek_date_format_re = \
    re.compile(u'([^,]+),\s+(\d{2})\s+([^\s]+)\s+(\d{4})\s+(\d{2}):(\d{2}):(\d{2})\s+([^\s]+)')
 
def _parse_date_greek(dateString):
    '''Parse a string according to a Greek 8-bit date format.'''
  }
 
_hungarian_date_format_re = \
  re.compile(u'(\d{4})-([^-]+)-(\d{,2})T(\d{,2}):(\d{2})((\+|-)(\d{,2}:\d{2}))')
 
def _parse_date_hungarian(dateString):
    '''Parse a string according to a Hungarian 8-bit date format.'''
                 '(?:(?P<julian>\d\d\d)'
                 '|(?P<month>\d\d)(?:(?P=dsep)(?P<day>\d\d))?))?')
    __tzd_re = '(?P<tzd>[-+](?P<tzdhours>\d\d)(?::?(?P<tzdminutes>\d\d))|Z)'
    __tzd_rx = re.compile(__tzd_re)
    __time_re = ('(?P<hours>\d\d)(?P<tsep>:|)(?P<minutes>\d\d)'
                 '(?:(?P=tsep)(?P<seconds>\d\d(?:[.,]\d+)?))?'
                 + __tzd_re)
    __datetime_re = '%s(?:T%s)?' % (__date_re, __time_re)
    __datetime_rx = re.compile(__datetime_re)
        data = data[4:]
    newdata = unicode(data, encoding)
    if _debug: sys.stderr.write('successfully converted %s data to unicode\n' % encoding)
    declmatch = re.compile('^<\?xml[^>]*?>')
    newdecl = '''<?xml version='1.0' encoding='utf-8'?>'''
    if declmatch.search(newdata):
        newdata = declmatch.sub(newdecl, newdata)
def _stripDoctype(data):
    '''Strips DOCTYPE from XML document, returns (rss_version, stripped_data)
 
    rss_version may be 'rss091n' or None
    stripped_data is the same XML document, minus the DOCTYPE
    '''
    entity_pattern = re.compile(r'<!ENTITY([^>]*?)>', re.MULTILINE)
    data = entity_pattern.sub('', data)
    doctype_pattern = re.compile(r'<!DOCTYPE([^>]*?)>', re.MULTILINE)

src/m/a/matplotlib-HEAD/py4science/examples/sphinx_template2/tools/sphinxext/numpydoc.py   matplotlib(Download)
def mangle_docstrings(app, what, name, obj, options, lines,
                      reference_offset=[0]):
    if what == 'module':
        # Strip top title
        title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
                              re.I|re.S)
        lines[:] = title_re.sub('', "\n".join(lines)).split("\n")

src/p/y/pyjamas-0.7/examples/libtest/ReModuleTest.py   Pyjamas(Download)
    def matchTest(self, msg, pat, flags, string, groups, span):
        r = re.compile(pat, flags)
        m = r.match(string)
        if groups is None:
            self.assertTrue(m is None, "%s: None expected" % msg)
            return
        self.assertTrue(m is not None, "%s: Unexpected None" % msg)
    def searchTest(self, msg, pat, flags, string, groups, span):
        r = re.compile(pat, flags)
        m = r.search(string)
        if groups is None:
            self.assertTrue(m is None, "%s: None expected" % msg)
            return
        self.assertTrue(m is not None, "%s: Unexpected None" % msg)
    def testSubBasics(self):
        matches = []
        def fn(m):
            matches.append(m)
            return "%s" % len(matches)
        r = re.compile('e')
        s = "Where are all these eees"
    def testSplitBasics(self):
        r = re.compile('e')
        s = "Where are all these eees"
 
        self.assertEqual(r.split(s), ['Wh', 'r', ' ar', ' all th', 's', ' ', '', '', 's'])
 
 
    def testMatchExtended(self):
        r = re.compile("ed")
        m = r.match("ed ed", 3)
        self.assertEqual(m.group(0), "ed")
 
        r = re.compile("^a.*$", re.M)
        m = r.match("a  ")
        self.assertEqual(m.group(0), "a  ")
 

src/g/o/google-app-engine-HEAD/lib/webob/docs/comment-example-code/example.py   google-app-engine(Download)
    def url_filename(self, url):
        return os.path.join(self.storage_dir, urllib.quote(url, ''))
 
    _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
 
    def add_to_end(self, html, extra_html):
        """

src/g/o/google_appengine-HEAD/lib/webob/docs/comment-example-code/example.py   google_appengine(Download)
    def url_filename(self, url):
        return os.path.join(self.storage_dir, urllib.quote(url, ''))
 
    _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
 
    def add_to_end(self, html, extra_html):
        """

src/m/a/matplotlib-HEAD/sampledoc_tut/sphinxext/numpydoc.py   matplotlib(Download)
def mangle_docstrings(app, what, name, obj, options, lines,
                      reference_offset=[0]):
    if what == 'module':
        # Strip top title
        title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
                              re.I|re.S)
        lines[:] = title_re.sub('', "\n".join(lines)).split("\n")

src/g/a/gaesdk-python-HEAD/lib/webob/docs/comment-example-code/example.py   gaesdk-python(Download)
    def url_filename(self, url):
        return os.path.join(self.storage_dir, urllib.quote(url, ''))
 
    _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
 
    def add_to_end(self, html, extra_html):
        """

src/b/a/badger-lib-HEAD/packages/pyparsing/docs/examples/LAparser.py   badger-lib(Download)
   writing, respectively.
   """
   pattern = r'\[\[\s*(.*?)\s*\]\]'
   eqn = re.compile(pattern,re.DOTALL)
   s = infilep.read()
   def parser(mo): 
      ccode = parse(mo.group(1))

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next