X7ROOT File Manager
Current Path:
/usr/lib/python2.7/site-packages/meh
usr
/
lib
/
python2.7
/
site-packages
/
meh
/
📁
..
📄
__init__.py
(6.22 KB)
📄
__init__.pyc
(5.41 KB)
📄
__init__.pyo
(5.41 KB)
📄
dump.py
(18.11 KB)
📄
dump.pyc
(14.65 KB)
📄
dump.pyo
(14.65 KB)
📄
handler.py
(10.73 KB)
📄
handler.pyc
(10.49 KB)
📄
handler.pyo
(10.49 KB)
📄
network.py
(1.45 KB)
📄
network.pyc
(862 B)
📄
network.pyo
(862 B)
📄
safe_string.py
(1.83 KB)
📄
safe_string.pyc
(1.23 KB)
📄
safe_string.pyo
(1.23 KB)
📁
ui
Editing: safe_string.py
# # Copyright (C) 2013 Red Hat, Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # Author: Vratislav Podzimek <vpodzime@redhat.com> # # """ This module provides a SafeStr class. @see: SafeStr """ class SafeStr(str): """ String class that has a modified __add__ method so that ascii strings, binary data represented as a byte string and unicode objects can be safely appended to it (not causing traceback). BINARY DATA IS OMITTED. """ def __add__(self, other): if not (isinstance(other, str) or isinstance(other, unicode)): if hasattr(other, "__str__"): other = other.__str__() else: other = "OMITTED OBJECT WITHOUT __str__ METHOD" if isinstance(other, unicode): ret = SafeStr(str.__add__(self, other.encode("utf-8"))) else: try: # try to decode which doesn't cause traceback for utf-8 encoded # non-ascii string and ascii string other.decode("utf-8") ret = SafeStr(str.__add__(self, other)) except UnicodeDecodeError: # binary data ret = SafeStr(str.__add__(self, "OMITTED BINARY DATA")) return ret
Upload File
Create Folder