コード例 #1
0
ファイル: argumentparser.py プロジェクト: superbaby11/autoOMC
 def _decode_from_file_system(self, arg):
     encoding = sys.getfilesystemencoding()
     if sys.platform.startswith('java'):
         # http://bugs.jython.org/issue1592
         from java.lang import String
         arg = String(arg)
     return unic(arg, encoding) if encoding else unic(arg)
コード例 #2
0
 def _decode_from_file_system(self, arg):
     encoding = sys.getfilesystemencoding()
     if sys.platform.startswith('java'):
         # http://bugs.jython.org/issue1592
         from java.lang import String
         arg = String(arg)
     return unic(arg, encoding) if encoding else unic(arg)
コード例 #3
0
ファイル: encoding.py プロジェクト: IlfirinPL/RIDE
def decode_from_file_system(string):
    """Decodes path from file system to Unicode."""
    encoding = sys.getfilesystemencoding()
    if sys.platform.startswith('java'):
        # http://bugs.jython.org/issue1592
        from java.lang import String
        string = String(string)
    return unic(string, encoding) if encoding else unic(string)
コード例 #4
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_python_message(exc_type, exc_value):
    # If exception is a "string exception" without a message exc_value is None
    if exc_value is None:
        return unic(exc_type)
    name = _get_name(exc_type)
    try:
        msg = unicode(exc_value)
    except UnicodeError:  # Happens if message is Unicode and version < 2.6
        msg = ' '.join(unic(a) for a in exc_value.args)
    return _format_message(name, msg)
コード例 #5
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_python_message(exc_type, exc_value):
    # If exception is a "string exception" without a message exc_value is None
    if exc_value is None:
        return unic(exc_type)
    name = _get_name(exc_type)
    try:
        msg = unicode(exc_value)
    except UnicodeError:  # Happens if message is Unicode and version < 2.6
        msg = ' '.join(unic(a) for a in exc_value.args)
    return _format_message(name, msg)
 def _escape(self, content):
     content = unic(content)
     for char in _ILLEGAL_CHARS_IN_XML:
         # Avoid bug http://ironpython.codeplex.com/workitem/29402
         if char in content:
             content = content.replace(char, '')
     return content
コード例 #7
0
ファイル: asserts.py プロジェクト: IlfirinPL/RIDE
def fail_unless_raises_with_msg(exc_class, expected_msg, callable_obj, *args,
                                **kwargs):
    """Similar to fail_unless_raises but also checks the exception message."""
    try:
        callable_obj(*args, **kwargs)
    except exc_class, err:
        assert_equal(expected_msg, unic(err), 'Correct exception but wrong message')
コード例 #8
0
ファイル: misc.py プロジェクト: EnochManohar/RIDE
def getdoc(item):
    doc = inspect.getdoc(item) or u''
    if isinstance(doc, unicode):
        return doc
    try:
        return doc.decode('UTF-8')
    except UnicodeDecodeError:
        return unic(doc)
コード例 #9
0
ファイル: asserts.py プロジェクト: superbaby11/autoOMC
def fail_unless_raises_with_msg(exc_class, expected_msg, callable_obj, *args,
                                **kwargs):
    """Similar to fail_unless_raises but also checks the exception message."""
    try:
        callable_obj(*args, **kwargs)
    except exc_class, err:
        assert_equal(expected_msg, unic(err),
                     'Correct exception but wrong message')
コード例 #10
0
 def _format_message(self, name, message):
     message = unic(message or '')
     message = self._clean_up_message(message, name)
     name = name.split('.')[-1]  # Use only last part of the name
     if message == '':
         return name
     if name in _generic_exceptions:
         return message
     return '%s: %s' % (name, message)
コード例 #11
0
ファイル: misc.py プロジェクト: EnochManohar/RIDE
def seq2str(sequence, quote="'", sep=', ', lastsep=' and '):
    """Returns sequence in format 'item 1', 'item 2' and 'item 3'"""
    quote_elem = lambda string: quote + unic(string) + quote
    if len(sequence) == 0:
        return ''
    if len(sequence) == 1:
        return quote_elem(sequence[0])
    elems = [quote_elem(s) for s in sequence[:-2]]
    elems.append(quote_elem(sequence[-2]) + lastsep + quote_elem(sequence[-1]))
    return sep.join(elems)
コード例 #12
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _format_message(name, message, java=False):
    message = unic(message or '')
    if java:
        message = _clean_up_java_message(message, name)
    name = name.split('.')[-1]  # Use only last part of the name
    if message == '':
        return name
    if name in _generic_exceptions:
        return message
    return '%s: %s' % (name, message)
コード例 #13
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _format_message(name, message, java=False):
    message = unic(message or '')
    if java:
        message = _clean_up_java_message(message, name)
    name = name.split('.')[-1]  # Use only last part of the name
    if message == '':
        return name
    if name in _generic_exceptions:
        return message
    return '%s: %s' % (name, message)
コード例 #14
0
def seq2str(sequence, quote="'", sep=', ', lastsep=' and '):
    """Returns sequence in format 'item 1', 'item 2' and 'item 3'"""
    quote_elem = lambda string: quote + unic(string) + quote
    if len(sequence) == 0:
        return ''
    if len(sequence) == 1:
        return quote_elem(sequence[0])
    elems = [quote_elem(s) for s in sequence[:-2]]
    elems.append(quote_elem(sequence[-2]) + lastsep + quote_elem(sequence[-1]))
    return sep.join(elems)
コード例 #15
0
 def _get_details(self):
     # OOME.printStackTrace seems to throw NullPointerException
     if self._is_out_of_memory_error(self._exc_type):
         return ''
     output = StringWriter()
     self._exc_value.printStackTrace(PrintWriter(output))
     lines = [ line for line in output.toString().splitlines()
               if line and not self._is_ignored_stack_trace_line(line) ]
     details = '\n'.join(lines)
     msg = unic(self._exc_value.getMessage() or '')
     if msg:
         details = details.replace(msg, '', 1)
     return details
コード例 #16
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_java_details(exc_value):
    # OOME.printStackTrace seems to throw NullPointerException
    if isinstance(exc_value, OutOfMemoryError):
        return ''
    output = StringWriter()
    exc_value.printStackTrace(PrintWriter(output))
    lines = [ line for line in output.toString().splitlines()
              if line and not _is_ignored_stacktrace_line(line) ]
    details = '\n'.join(lines)
    msg = unic(exc_value.getMessage() or '')
    if msg:
        details = details.replace(msg, '', 1)
    return details
コード例 #17
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_java_details(exc_value):
    # OOME.printStackTrace seems to throw NullPointerException
    if isinstance(exc_value, OutOfMemoryError):
        return ''
    output = StringWriter()
    exc_value.printStackTrace(PrintWriter(output))
    lines = [
        line for line in output.toString().splitlines()
        if line and not _is_ignored_stacktrace_line(line)
    ]
    details = '\n'.join(lines)
    msg = unic(exc_value.getMessage() or '')
    if msg:
        details = details.replace(msg, '', 1)
    return details
コード例 #18
0
ファイル: htmlutils.py プロジェクト: superbaby11/autoOMC
def html_escape(text, formatting=False):
    if not isinstance(text, basestring):
        text = unic(text)
    for name, value in [('&', '&amp;'), ('<', '&lt;'), ('>', '&gt;')]:
        text = text.replace(name, value)

    ret = []
    table = _Table()
    hr = None

    for line in text.splitlines():
        if formatting and table.is_table_row(line):
            if hr:
                ret.append(hr)
                hr = None
            table.add_row(line)
        elif table.is_started():
            if _hr_re.match(line):
                hr = '<hr />\n'
                line = ''
            else:
                line = _format_line(line, True)
            ret.append(table.end() + line)
        elif formatting and _hr_re.match(line):
            hr = '<hr />\n'
        else:
            line = _format_line(line, formatting)
            if hr:
                line = hr + line
                hr = None
            ret.append(line)

    if table.is_started():
        ret.append(table.end())
    if hr:
        ret.append(hr)

    return '<br />\n'.join(ret)
コード例 #19
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_name(exc_type):
    try:
        return exc_type.__name__
    except AttributeError:
        return unic(exc_type)
コード例 #20
0
 def format(self, text):
     text = self._html_escape(unic(text))
     for line in text.splitlines():
         self.add_line(line)
     return self.get_result()
コード例 #21
0
 def _encode(self, message):
     message = unic(message)
     for char in _ILLEGAL_CHARS_IN_XML:
         message = message.replace(char, '')
     return message
コード例 #22
0
ファイル: htmlwriter.py プロジェクト: superbaby11/autoOMC
 def _escape_content(self, content):
     return html_escape(unic(content))
コード例 #23
0
ファイル: encoding.py プロジェクト: superbaby11/autoOMC
def decode_output(string):
    """Decodes string from console encoding to Unicode."""
    if _output_encoding:
        return unic(string, _output_encoding)
    return string
コード例 #24
0
ファイル: text.py プロジェクト: superbaby11/autoOMC
def format_assign_message(variable, value, cut_long=True):
    value = unic(value) if variable.startswith('$') else seq2str2(value)
    if cut_long and len(value) > _MAX_ASSIGN_LENGTH:
        value = value[:_MAX_ASSIGN_LENGTH] + '...'
    return '%s = %s' % (variable, value)
コード例 #25
0
ファイル: error.py プロジェクト: superbaby11/autoOMC
def _get_name(exc_type):
    try:
        return exc_type.__name__
    except AttributeError:
        return unic(exc_type)
コード例 #26
0
ファイル: misc.py プロジェクト: EnochManohar/RIDE
def seq2str2(sequence):
    """Returns sequence in format [ item 1 | item 2 | ... ] """
    if not sequence:
        return '[ ]'
    return '[ %s ]' % ' | '.join(unic(item) for item in sequence)
コード例 #27
0
ファイル: encoding.py プロジェクト: gdw2/robot-framework
def decode_output(string):
    """Decodes string from console encoding to Unicode."""
    if _output_encoding:
        return unic(string, _output_encoding)
    return string
コード例 #28
0
 def _encode(self, message):
     message = unic(message)
     for char in _ILLEGAL_CHARS_IN_XML:
         message = message.replace(char, '')
     return message
コード例 #29
0
def seq2str2(sequence):
    """Returns sequence in format [ item 1 | item 2 | ... ] """
    if not sequence:
        return '[ ]'
    return '[ %s ]' % ' | '.join(unic(item) for item in sequence)
 def content(self, content=None, escape=True):
     """Given content doesn't need to be a string"""
     if content is not None:
         if escape:
             content = html_escape(unic(content))
         self._write(content)
コード例 #31
0
ファイル: htmlwriter.py プロジェクト: superbaby11/autoOMC
 def _escape_content(self, content):
     return html_escape(unic(content))