/usr/lib/python2.7/dist-packages/redmine/utilities.py is in python-redmine 1.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import sys
import string
def is_string(string):
"""Python 2 and 3 friendly function to check if a string is really a string"""
return isinstance(string, basestring if sys.version_info[0] < 3 else str)
def is_unicode(string):
"""Python 2 and 3 friendly function to check if an object is a unicode string"""
return isinstance(string, unicode if sys.version_info[0] < 3 else str)
def to_string(string):
"""Converts unicode to utf-8 if on Python 2, leaves as is if on Python 3"""
return string.encode('utf-8') if sys.version_info[0] < 3 else string
class MemorizeFormatter(string.Formatter):
"""Memorizes all arguments, used during string formatting"""
def __init__(self):
self.used_kwargs = {}
self.unused_kwargs = {}
def check_unused_args(self, used_args, args, kwargs):
for item in used_args:
if item in kwargs:
self.used_kwargs[item] = kwargs.pop(item)
self.unused_kwargs = kwargs
|