当前位置: 首页>>代码示例>>Python>>正文


Python re.DEBUG属性代码示例

本文整理汇总了Python中re.DEBUG属性的典型用法代码示例。如果您正苦于以下问题:Python re.DEBUG属性的具体用法?Python re.DEBUG怎么用?Python re.DEBUG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在re的用法示例。


在下文中一共展示了re.DEBUG属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def __init__(self, logdispatcher):
        """
        Initialize all object attributes
        @author: ekkehard j. koch
        """
        self.logdispatcher = logdispatcher
        self.command = []
        self.commandblank = True
        self.returncode = 0
        self.output = []
        self.stdout = []
        self.stderr = []
        self.shell = False
        self.setLogPriority(LogPriority.DEBUG)
        self.flags = ["DEBUG", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL",
                      "UNICODE", "VERBOSE"]
        self.flag = ""

        # set this to False if you need to run a command that has no return code
        self.wait = True
        self.cmdtimeout = 0

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:25,代码来源:CommandHelper.py

示例2: __calledBy

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def __calledBy(self):
        """
        Log the caller of the method that calls this method

        @author: Roy Nielsen
        """
        try:
            filename = inspect.stack()[3][1]
            functionName = str(inspect.stack()[3][3])
            lineNumber = str(inspect.stack()[3][2])
        except Exception as err:
            raise err
        else:
            self.logdispatcher.log(LogPriority.DEBUG, "called by: " + \
                                      filename + ": " + \
                                      functionName + " (" + \
                                      lineNumber + ")")
        return " Filename: " + str(filename) + "Line: " + str(lineNumber) + " functionName: " + str(functionName)

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:22,代码来源:CommandHelper.py

示例3: convert_bytes_to_string

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def convert_bytes_to_string(self, data):
        """

        :param data:
        :return: data
        :rtype: str|list
        """

        self.logdispatcher.log(LogPriority.DEBUG, "Converting any bytes objects into strings...")

        data_type = type(data)

        if data_type is list:
            for e in data:
                if type(e) is bytes:
                    data = [e.decode('utf-8') for e in data]
        elif data_type is bytes:
            data = data.decode('utf-8')
            data = str(data)

        return data 
开发者ID:CSD-Public,项目名称:stonix,代码行数:23,代码来源:CommandHelper.py

示例4: test_debug_flag

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def test_debug_flag(self):
        pat = r'(\.)(?:[ch]|py)(?(1)$|: )'
        with captured_stdout() as out:
            re.compile(pat, re.DEBUG)
        dump = '''\
subpattern 1
  literal 46
subpattern None
  branch
    in
      literal 99
      literal 104
  or
    literal 112
    literal 121
subpattern None
  groupref_exists 1
    at at_end
  else
    literal 58
    literal 32
'''
        self.assertEqual(out.getvalue(), dump)
        # Debug output is output again even a second time (bypassing
        # the cache -- issue #20426).
        with captured_stdout() as out:
            re.compile(pat, re.DEBUG)
        self.assertEqual(out.getvalue(), dump) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:30,代码来源:test_re.py

示例5: test_debug_flag

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def test_debug_flag(self):
        pat = r'(\.)(?:[ch]|py)(?(1)$|: )'
        with captured_stdout() as out:
            re.compile(pat, re.DEBUG)
        dump = '''\
SUBPATTERN 1
  LITERAL 46
SUBPATTERN None
  BRANCH
    IN
      LITERAL 99
      LITERAL 104
  OR
    LITERAL 112
    LITERAL 121
SUBPATTERN None
  GROUPREF_EXISTS 1
    AT AT_END
  ELSE
    LITERAL 58
    LITERAL 32
'''
        self.assertEqual(out.getvalue(), dump)
        # Debug output is output again even a second time (bypassing
        # the cache -- issue #20426).
        with captured_stdout() as out:
            re.compile(pat, re.DEBUG)
        self.assertEqual(out.getvalue(), dump) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:30,代码来源:test_re.py

示例6: test_debug_flag

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def test_debug_flag(self):
        with captured_stdout() as out:
            re.compile('foo', re.DEBUG)
        self.assertEqual(out.getvalue().splitlines(),
                         ['literal 102', 'literal 111', 'literal 111'])
        # Debug output is output again even a second time (bypassing
        # the cache -- issue #20426).
        with captured_stdout() as out:
            re.compile('foo', re.DEBUG)
        self.assertEqual(out.getvalue().splitlines(),
                         ['literal 102', 'literal 111', 'literal 111']) 
开发者ID:gcblue,项目名称:gcblue,代码行数:13,代码来源:test_re.py

示例7: getOutputString

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def getOutputString(self):
        """Get standard out in string format

        :param self: essential if you override this definition
        :returns: stdstring
        :rtype: string
@author: ekkehard j. koch
@change: Breen Malmberg - 12/3/2015

        """

        stdstring = ""

        try:

            if self.stdout:
                if not isinstance(self.stdout, list):
                    self.logdispatcher.log(LogPriority.DEBUG,
                                           "Parameter self.stdout is not a " +
                                           "list. Cannot compile stdout " +
                                           "string. Returning blank stdout " +
                                           "string...")
                    return stdstring

                for line in self.stdout:
                    stdstring += line + "\n"
            else:
                self.logdispatcher.log(LogPriority.DEBUG, "No stdout string to display")

        except Exception:
            raise
        return stdstring

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:36,代码来源:CommandHelper.py

示例8: getAllList

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def getAllList(self):
        """Get both the stdout and stderr together as one list

        :param self: essential if you override this definition
        :returns: alllist
        :rtype: list
@author: Breen Malmberg

        """

        alllist = []

        stdoutlist = self.getOutput()
        stderrlist = self.getError()

        try:

            if not isinstance(stdoutlist, list):
                self.logdispatcher.log(LogPriority.DEBUG, "Content of parameter stdoutlist is not in list format. Will not include content in output!")
                stdoutlist = []
            if not isinstance(stderrlist, list):
                self.logdispatcher.log(LogPriority.DEBUG, "Content of parameter stderrlist is not in list format. Will not include content in output!")
                stderrlist = []

            if stdoutlist:
                for line in stdoutlist:
                    alllist.append(line)
            if stderrlist:
                for line in stderrlist:
                    alllist.append(line)

            if not alllist:
                self.logdispatcher.log(LogPriority.DEBUG, "There was no output to return")

        except Exception:
            raise
        return alllist 
开发者ID:CSD-Public,项目名称:stonix,代码行数:39,代码来源:CommandHelper.py

示例9: validate_command

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def validate_command(self, command):
        """
        A valid format for a command is:
        list of non-empty strings
        -or-
        non-empty string

        :param command: the command to evaluate
        """

        self.valid_command = True

        self.logdispatcher.log(LogPriority.DEBUG, "Validating command format...")

        command_type = type(command)

        valid_types = [list, str]

        if command_type not in valid_types:
            self.logdispatcher.log(LogPriority.DEBUG, "Invalid data type for command. Expecting: str or list. Got: " + str(command_type))
            self.valid_command = False

        if command == "":
            self.logdispatcher.log(LogPriority.DEBUG, "Command was an empty string. Cannot run nothing")
            self.valid_command = False
        elif command == []:
            self.logdispatcher.log(LogPriority.DEBUG, "Command was an empty list. Cannot run nothing")
            self.valid_command = False

        if not self.valid_command:
            self.logdispatcher.log(LogPriority.DEBUG, "Command is not a valid format") 
开发者ID:CSD-Public,项目名称:stonix,代码行数:33,代码来源:CommandHelper.py

示例10: setLogPriority

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def setLogPriority(self, logpriority=None):
        """Setting log priority use LogPriority.DEBUG, LogPrority.ERROR, etc.

        :param logpriority: of type LogPriority.xxx (Default value = None)
        :returns: success
        :rtype: bool
@author: ekkehard j. koch

        """

        success = True

        logprioritytype = type(logpriority)
        #print("logprioritytype: ", logprioritytype, "\n")
        if (logpriority is None):
            self.logpriority = LogPriority.DEBUG
        elif isinstance(logpriority, str):
            self.logpriority = logpriority
        else:
            self.logpriority = LogPriority.DEBUG
            success = False
            raise TypeError("LogPriority is set to '" +
                            str(self.logpriority) +
                            "'! Invalid LogPriority Object of type '" +
                            str(logprioritytype) + "' specified!")
        return success

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:30,代码来源:CommandHelper.py

示例11: getOutputGroup

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def getOutputGroup(self, expression, groupnumber, searchgroup="output"):
        """getOutputGroup (expression,groupnumber) finds an expression in the
        returns the specified group after using regular expression on output

        :param self: essential if you override this definition
        :param expression: string: expression to search for in searchgroup
        :param groupnumber: integer: number of group to return
        :param searchgroup: string: group to search in output, stdout, stderr (Default value = "output")
        :returns: returnlist
        :rtype: list
@author: rsn
@change: Breen Malmberg - 12/3/2015

        """

        returnlist = []

        try:

            if searchgroup == "output":
                searchstream = self.output
            elif searchgroup == "stdout":
                searchstream = self.stdout
            elif searchgroup == "stderr":
                searchstream = self.stderr
            else:
                searchstream = self.output
            for line in searchstream:
                reresult = re.search(expression, line)
                groupstr = reresult.group(groupnumber)
                msg = "Group(" + str(groupnumber) + ")='" + \
                groupstr + "'; line='" + line + "'"
                self.logdispatcher.log(LogPriority.DEBUG, msg)
                returnlist.append(groupstr)
            msg = "expression = " + str(expression) + ", " + \
            "groupnumber = " + str(groupnumber) + ", " + \
            "searchgroup = " + str(searchgroup) + " = " + \
            "returnlist = " + str(returnlist) + ";"
            self.logdispatcher.log(LogPriority.DEBUG, msg)
        except Exception:
            raise
        return returnlist

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:46,代码来源:CommandHelper.py

示例12: getFirstOutputGroup

# 需要导入模块: import re [as 别名]
# 或者: from re import DEBUG [as 别名]
def getFirstOutputGroup(self, expression, groupnumber, searchgroup="output"):
        """getOutputGroup (expression, groupnumber) finds an expression in the
        returns the first instance (string) of the group specified in the
        regular expression that is found in the output.

        :param str expression: expression to search for
        :param groupnumber: integer: number of group to return
        :param searchgroup: string: group to search in output, stdout, stderr (Default value = "output")

        :return: returnstring
        :rtype: bool

        """

        returnstring = ""

        try:

            if searchgroup == "output":
                searchstream = self.output
            elif searchgroup == "stdout":
                searchstream = self.stdout
            elif searchgroup == "stderr":
                searchstream = self.stderr
            else:
                searchstream = self.output
            for line in searchstream:
                reresult = re.search(expression, line)
                if reresult:
                    groupstr = reresult.group(groupnumber)
                    msg = "Group(" + str(groupnumber) + ")='" + \
                    groupstr + "'; line='" + line + "'"
                    self.logdispatcher.log(LogPriority.DEBUG, msg)
                    returnstring = groupstr
                    break
            msg = "expression = " + str(expression) + ", " + \
            "groupnumber = " + str(groupnumber) + ", " + \
            "searchgroup = " + str(searchgroup) + " = " + \
            "returnstring = " + str(returnstring) + ";"
            self.logdispatcher.log(LogPriority.DEBUG, msg)
        except Exception:
            raise
        return returnstring

############################################################################### 
开发者ID:CSD-Public,项目名称:stonix,代码行数:47,代码来源:CommandHelper.py


注:本文中的re.DEBUG属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。