當前位置: 首頁>>代碼示例>>Python>>正文


Python re.IGNORECASE屬性代碼示例

本文整理匯總了Python中re.IGNORECASE屬性的典型用法代碼示例。如果您正苦於以下問題:Python re.IGNORECASE屬性的具體用法?Python re.IGNORECASE怎麽用?Python re.IGNORECASE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在re的用法示例。


在下文中一共展示了re.IGNORECASE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read_process

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def read_process(cmd, args=''):
    fullcmd = '%s %s' % (cmd, args)
    pipeout = popen(fullcmd)
    try:
        firstline = pipeout.readline()
        cmd_not_found = re.search(
            b'(not recognized|No such file|not found)',
            firstline,
            re.IGNORECASE
        )
        if cmd_not_found:
            raise IOError('%s must be on your system path.' % cmd)
        output = firstline + pipeout.read()
    finally:
        pipeout.close()
    return output 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:18,代碼來源:_cpmodpy.py

示例2: check_paste

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def check_paste ( self, paste_id ):
        paste_url = self.PASTEBIN_URL + paste_id
        try:
            paste_txt = PyQuery ( url = paste_url )('#paste_code').text()

            for regex,file,directory in self.regexes:
                if re.match ( regex, paste_txt, re.IGNORECASE ):
                    Logger ().log ( 'Found a matching paste: ' + paste_url + ' (' + file + ')', True, 'CYAN' )
                    self.save_result ( paste_url,paste_id,file,directory )
                    return True
            Logger ().log ( 'Not matching paste: ' + paste_url )
        except KeyboardInterrupt:
            raise
        except:
            Logger ().log ( 'Error reading paste (probably a 404 or encoding issue).', True, 'YELLOW')
        return False 
開發者ID:fabiospampinato,項目名稱:pastebin-monitor,代碼行數:18,代碼來源:pastebin_crawler.py

示例3: ReqBuilder

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def ReqBuilder(self, target_BoxObject):
        filename, extension = os.path.splitext(target_BoxObject.path)
        extension = extension[1:] # removing the dot character before the extension
        result = self.templateRequest.safe_substitute(ip=target_BoxObject.ip,
                                                    port=target_BoxObject.port,
                                                    path=target_BoxObject.path,
                                                    filename=filename,
                                                    extension=extension,
                                                    hostname=target_BoxObject.hostname,
                                                    description=target_BoxObject.description)

        if self.autoContentLength:
            bodylength = len(result) - re.search("(\r\n\r\n)|(\n\n)", result).end()
            if re.search("content\\-length", result, re.IGNORECASE):
                result = re.sub(r"(?i)content\-length:\s*\d+", "Content-Length: " + str(bodylength),
                                result, 1)
            else:
                result = re.sub(r"(\r\n\r\n)|(\n\n)", "\r\nContent-Length: " + str(bodylength) + "\r\n\r\n",
                                result, 1)

        return result 
開發者ID:irsdl,項目名稱:httpninja,代碼行數:23,代碼來源:testcase_definition.py

示例4: test

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def test(self,user,password,token):
        for line in self.regexs:
            (ignore,regex) = line
            regex = regex.replace('<user>',user)
            results = None
            if ignore == True:
                results = re.search(regex,password,re.IGNORECASE)
            else:
                results = re.search(regex,password)
            if results != None:
                if self.debug:
                    print(" \- - A blacklisted term was found")
                return (20,None)
        if self.debug:
            print(" \- * No blacklisted terms were found")
        return (0,None) 
開發者ID:CboeSecurity,項目名稱:password_pwncheck,代碼行數:18,代碼來源:pwnpass.py

示例5: set_memlimit

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def set_memlimit(limit):
    global max_memuse
    global real_max_memuse
    sizes = {
        'k': 1024,
        'm': _1M,
        'g': _1G,
        't': 1024*_1G,
    }
    m = re.match(r'(\d+(\.\d+)?) (K|M|G|T)b?$', limit,
                 re.IGNORECASE | re.VERBOSE)
    if m is None:
        raise ValueError('Invalid memory limit %r' % (limit,))
    memlimit = int(float(m.group(1)) * sizes[m.group(3).lower()])
    real_max_memuse = memlimit
    if memlimit > MAX_Py_ssize_t:
        memlimit = MAX_Py_ssize_t
    if memlimit < _2G - 1:
        raise ValueError('Memory limit %r too low to be useful' % (limit,))
    max_memuse = memlimit 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:22,代碼來源:support.py

示例6: regex

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def regex(self, response, port):
        match = False

        if re.search(b'<title>502 Bad Gateway', response):
            return match

        for pattern in SIGNS:
            pattern = pattern.split(b'|')
            if re.search(pattern[-1], response, re.IGNORECASE):
                text = response.decode('utf-8', 'ignore')
                match = True
                proto = {"server": pattern[1].decode(), "port": port, "banner": text}
                self.out.append(proto)
                break
        if not match:
            proto = {"server": get_server(port), "port": port, "banner": response.decode('utf-8', 'ignore')}
            self.out.append(proto) 
開發者ID:al0ne,項目名稱:Vxscan,代碼行數:19,代碼來源:port_scan.py

示例7: __init__

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def __init__(self, pairs, reflections={}):
        """
        Initialize the chatbot.  Pairs is a list of patterns and responses.  Each
        pattern is a regular expression matching the user's statement or question,
        e.g. r'I like (.*)'.  For each such pattern a list of possible responses
        is given, e.g. ['Why do you like %1', 'Did you ever dislike %1'].  Material
        which is matched by parenthesized sections of the patterns (e.g. .*) is mapped to
        the numbered positions in the responses, e.g. %1.

        @type pairs: C{list} of C{tuple}
        @param pairs: The patterns and responses
        @type reflections: C{dict}
        @param reflections: A mapping between first and second person expressions
        @rtype: C{None}
        """

        self._pairs = [(re.compile(x, re.IGNORECASE),y) for (x,y) in pairs]
        self._reflections = reflections

    # bug: only permits single word expressions to be mapped 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:22,代碼來源:__init__.py

示例8: __init__

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def __init__(self, pairs, reflections={}):
        """
        Initialize the chatbot.  Pairs is a list of patterns and responses.  Each
        pattern is a regular expression matching the user's statement or question,
        e.g. r'I like (.*)'.  For each such pattern a list of possible responses
        is given, e.g. ['Why do you like %1', 'Did you ever dislike %1'].  Material
        which is matched by parenthesized sections of the patterns (e.g. .*) is mapped to
        the numbered positions in the responses, e.g. %1.

        :type pairs: list of tuple
        :param pairs: The patterns and responses
        :type reflections: dict
        :param reflections: A mapping between first and second person expressions
        :rtype: None
        """

        self._pairs = [(re.compile(x, re.IGNORECASE),y) for (x,y) in pairs]
        self._reflections = reflections
        self._regex = self._compile_reflections() 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:21,代碼來源:util.py

示例9: check_juniper_rift_in_path

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def check_juniper_rift_in_path():
    if shutil.which("rift-environ") is None:
        fatal_error("Cannot find Juniper RIFT (rift-environ) in PATH")

    # run it and check version
    output = subprocess.check_output(["rift-environ",
                                      "--version"], universal_newlines=True)
    # print (output)
    regex = re.compile(r"^.hrift encoding schema: *(\d+)\.(\d+).*",
                       re.IGNORECASE  | re.MULTILINE)
    major = re.search(regex, output)

    if not major or not major.group(1):
        fatal_error("Cannot detect major version of Juniper RIFT")

    minor = major.group(2)
    major = major.group(1)

    expected_minor = protocol_minor_version
    expected_major = protocol_major_version

    if int(major) != expected_major or int(minor) != expected_minor:
        fatal_error("Wrong Major/Minor version of Juniper RIFT: (expected {}.{}, got {}.{})"
                    .format(expected_major, expected_minor, major, minor)) 
開發者ID:brunorijsman,項目名稱:rift-python,代碼行數:26,代碼來源:interop.py

示例10: render_re

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def render_re(regex):
  """Renders a repr()-style value for a compiled regular expression."""
  actual_flags = []
  if regex.flags:
    flags = [
      (re.IGNORECASE, 'IGNORECASE'),
      (re.LOCALE, 'LOCALE'),
      (re.UNICODE, 'UNICODE'),
      (re.MULTILINE, 'MULTILINE'),
      (re.DOTALL, 'DOTALL'),
      (re.VERBOSE, 'VERBOSE'),
    ]
    for val, name in flags:
      if regex.flags & val:
        actual_flags.append(name)
  if actual_flags:
    return 're.compile(%r, %s)' % (regex.pattern, '|'.join(actual_flags))
  else:
    return 're.compile(%r)' % regex.pattern 
開發者ID:luci,項目名稱:recipes-py,代碼行數:21,代碼來源:magic_check_fn.py

示例11: normalize_release_tags

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def normalize_release_tags(name, real_title):
    import re
    import xbmc
    def _normalize_name(val):
        proper = re.sub(r"[\[\(\]\)]", "", val)
        proper = re.sub(r"'", "", proper)
        proper = re.sub(r"\W", " ", proper)
        proper = re.sub(r"\s+", " ", proper)
        return proper
    name = _normalize_name(name)
    real_title = _normalize_name(real_title)
    release_tags = re.compile(real_title, re.IGNORECASE).sub("", name)
    tags = map(re.escape, VIDEO_CODECS.keys() + AUDIO_CODECS.keys() + RESOLUTIONS.keys())
    release_tags = re.compile("(%s)" % "|".join(tags), re.IGNORECASE).sub("", release_tags)
    release_tags = re.sub(r"\s+", " ", release_tags)
    return release_tags.strip() 
開發者ID:jmarth,項目名稱:plugin.video.kmediatorrent,代碼行數:18,代碼來源:utils.py

示例12: expand_windows_drive

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def expand_windows_drive(path: str) -> str:
    r"""Expand a drive-path like E: into E:\.

    Does nothing for other paths.

    Args:
        path: The path to expand.
    """
    # Usually, "E:" on Windows refers to the current working directory on drive
    # E:\. The correct way to specifify drive E: is "E:\", but most users
    # probably don't use the "multiple working directories" feature and expect
    # "E:" and "E:\" to be equal.
    if re.fullmatch(r'[A-Z]:', path, re.IGNORECASE):
        return path + "\\"
    else:
        return path 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:18,代碼來源:utils.py

示例13: transform_path

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def transform_path(path):
    r"""Do platform-specific transformations, like changing E: to E:\.

    Returns None if the path is invalid on the current platform.
    """
    if not utils.is_windows:
        return path
    path = utils.expand_windows_drive(path)
    # Drive dependent working directories are not supported, e.g.
    # E:filename is invalid
    if re.search(r'^[A-Z]:[^\\]', path, re.IGNORECASE):
        return None
    # Paths like COM1, ...
    # See https://github.com/qutebrowser/qutebrowser/issues/82
    if pathlib.Path(path).is_reserved():
        return None
    return path 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:19,代碼來源:downloads.py

示例14: query_state

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def query_state(self, query):
        """
        Query the drone current state return a dictionary of every drone state
        whose message name contains the query string
        :return: dictionary of drone state
        :param: query, the string to search for in the message received from the drone.
        """
        result = OrderedDict()
        for message in self.messages.values():
            if re.search(query, message.fullName, re.IGNORECASE):
                try:
                    result[message.fullName] = message.state()
                except RuntimeError:
                    continue
            for arg_name in message.args_name:
                name = message.fullName + "." + arg_name
                if re.search(query, name, re.IGNORECASE):
                    try:
                        result[message.fullName] = message.state()
                    except RuntimeError:
                        break
        return result 
開發者ID:Parrot-Developers,項目名稱:olympe,代碼行數:24,代碼來源:drone.py

示例15: __init__

# 需要導入模塊: import re [as 別名]
# 或者: from re import IGNORECASE [as 別名]
def __init__(self, bot: Bot):
        self.bot = bot

        self.matches = [
            (re.compile(i[0], re.IGNORECASE), i[1]) for i in self.match_strings
        ] 
開發者ID:CyberDiscovery,項目名稱:cyberdisc-bot,代碼行數:8,代碼來源:cyber.py


注:本文中的re.IGNORECASE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。