예제 #1
0
def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
    """
    Converts any URLs in text into clickable links.

    Works on http://, https://, www. links and links ending in .org, .net or
    .com. Links can have trailing punctuation (periods, commas, close-parens)
    and leading punctuation (opening parens) and it'll still do the right
    thing.

    If trim_url_limit is not None, the URLs in link text longer than this limit
    will truncated to trim_url_limit-3 characters and appended with an elipsis.

    If nofollow is True, the URLs in link text will get a rel="nofollow"
    attribute.

    If autoescape is True, the link text and URLs will get autoescaped.
    """
    trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
    safe_input = isinstance(text, SafeData)
    words = word_split_re.split(force_unicode(text))
    nofollow_attr = nofollow and ' rel="nofollow"' or ''
    for i, word in enumerate(words):
        match = None
        if '.' in word or '@' in word or ':' in word:
            match = punctuation_re.match(word)
        if match:
            lead, middle, trail = match.groups()
            # Make URL we want to point to.
            url = None
            if middle.startswith('http://') or middle.startswith('https://'):
                url = urlquote(middle, safe='/&=:;#?+*')
            elif middle.startswith('www.') or ('@' not in middle and middle and middle[0] in string.ascii_letters + string.digits and (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))):
                url = urlquote('http://%s' % middle, safe='/&=:;#?+*')
            elif '@' in middle and not ':' in middle and simple_email_re.match(middle):
                url = 'mailto:%s' % middle
                nofollow_attr = ''
            # Make link.
            if url:
                trimmed = trim_url(middle)
                if autoescape and not safe_input:
                    lead, trail = escape(lead), escape(trail)
                    url, trimmed = escape(url), escape(trimmed)
                middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr, trimmed)
                words[i] = mark_safe('%s%s%s' % (lead, middle, trail))
            else:
                if safe_input:
                    words[i] = mark_safe(word)
                elif autoescape:
                    words[i] = escape(word)
        elif safe_input:
            words[i] = mark_safe(word)
        elif autoescape:
            words[i] = escape(word)
    return ''.join(words)
예제 #2
0
 def render(self, context):
     csrf_token = context.get('csrf_token', None)
     if csrf_token:
         if csrf_token == 'NOTPROVIDED':
             return mark_safe(u"")
         else:
             return mark_safe(u"<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='%s' /></div>" % csrf_token)
     else:
         # It's very probable that the token is missing because of
         # misconfiguration, so we raise a warning
         from google.appengine._internal.django.conf import settings
         if settings.DEBUG:
             import warnings
             warnings.warn("A {% csrf_token %} was used in a template, but the context did not provide the value.  This is usually caused by not using RequestContext.")
         return u''
예제 #3
0
def safeseq(value):
    """
    A "safe" filter for sequences. Marks each element in the sequence,
    individually, as safe, after converting them to unicode. Returns a list
    with the results.
    """
    return [mark_safe(force_unicode(obj)) for obj in value]
예제 #4
0
 def _dec(*args, **kwargs):
     if args:
         args = list(args)
         args[0] = force_unicode(args[0])
         if isinstance(args[0], SafeData) and getattr(func, 'is_safe', False):
             return mark_safe(func(*args, **kwargs))
     return func(*args, **kwargs)
예제 #5
0
def obfuscate(email, linktext=None, autoescape=None):
    """
    Given a string representing an email address,
	returns a mailto link with rot13 JavaScript obfuscation.

    Accepts an optional argument to use as the link text;
	otherwise uses the email address itself.
    """
#    if autoescape:
#        esc = conditional_escape
#    else:
#        esc = lambda x: x

    esc = lambda x: x

    email = re.sub('@','\\\\100', re.sub('\.', '\\\\056', \
        esc(email))).encode('rot13')

    if linktext:
        linktext = esc(linktext).encode('rot13')
    else:
        linktext = email

    rotten_link = """<script type="text/javascript">document.write \
        ("<n uers=\\\"znvygb:%s\\\">%s<\\057n>".replace(/[a-zA-Z]/g, \
        function(c){return String.fromCharCode((c<="Z"?90:122)>=\
        (c=c.charCodeAt(0)+13)?c:c-26);}));</script>""" % (email, linktext)
    return mark_safe(rotten_link)
예제 #6
0
파일: __init__.py 프로젝트: 0xmilk/appscale
 def render(self, context):
     bits = []
     for node in self:
         if isinstance(node, Node):
             bits.append(self.render_node(node, context))
         else:
             bits.append(node)
     return mark_safe(''.join([force_unicode(b) for b in bits]))
예제 #7
0
def force_escape(value):
    """
    Escapes a string's HTML. This returns a new string containing the escaped
    characters (as opposed to "escape", which marks the content for later
    possible escaping).
    """
    from google.appengine._internal.django.utils.html import escape
    return mark_safe(escape(value))
예제 #8
0
def linebreaks(value, autoescape=None):
    """
    Replaces line breaks in plain text with appropriate HTML; a single
    newline becomes an HTML line break (``<br />``) and a new line
    followed by a blank line becomes a paragraph break (``</p>``).
    """
    from google.appengine._internal.django.utils.html import linebreaks
    autoescape = autoescape and not isinstance(value, SafeData)
    return mark_safe(linebreaks(value, autoescape))
예제 #9
0
def cut(value, arg):
    """
    Removes all values of arg from the given string.
    """
    safe = isinstance(value, SafeData)
    value = value.replace(arg, '')
    if safe and arg != ';':
        return mark_safe(value)
    return value
예제 #10
0
def slugify(value):
    """
    Normalizes string, converts to lowercase, removes non-alpha characters,
    and converts spaces to hyphens.
    """
    import unicodedata
    value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
    value = str(re.sub('[^\w\s-]', '', value).strip().lower())
    return mark_safe(re.sub('[-\s]+', '-', value))
예제 #11
0
 def render(self, context):
     old_setting = context.autoescape
     context.autoescape = self.setting
     output = self.nodelist.render(context)
     context.autoescape = old_setting
     if self.setting:
         return mark_safe(output)
     else:
         return output
예제 #12
0
def tracks_display(tracks):
  """Prints out [u][t][s]-style track information for a list of tracks."""
  if not tracks:
    return ''
  html = []
  for track in sorted(tracks, reverse=True):
    html.append(
        '<span class="track %s" title="%s"></span>' % (track, track))
  return mark_safe(''.join(html))
예제 #13
0
def linebreaksbr(value, autoescape=None):
    """
    Converts all newlines in a piece of plain text to HTML line breaks
    (``<br />``).
    """
    if autoescape and not isinstance(value, SafeData):
        from google.appengine._internal.django.utils.html import escape
        value = escape(value)
    return mark_safe(value.replace('\n', '<br />'))
예제 #14
0
def tracks_display(track_dict):
  """Prints out [u][t][s]-style track with pending proposals marked."""
  if not track_dict:
    return ''
  html = []
  for track in sorted(track_dict, reverse=True):
    html.append('<span class="track %s %s" title="%s"></span>' % (
        track, track_dict[track], track))
  return mark_safe(''.join(html))
예제 #15
0
def tracks_display_no_proposals(track_list):
  """Prints out [u][t][s]-style track with no proposals."""
  if not track_list:
    return ''
  html = []
  for track in sorted(track_list, reverse=True):
    html.append('<span class="track %s" title="%s"></span>' % (
        track, track))
  return mark_safe(''.join(html))
예제 #16
0
def urlizetrunc(value, limit, autoescape=None):
    """
    Converts URLs into clickable links, truncating URLs to the given character
    limit, and adding 'rel=nofollow' attribute to discourage spamming.

    Argument: Length to truncate URLs to.
    """
    from google.appengine._internal.django.utils.html import urlize
    return mark_safe(urlize(value, trim_url_limit=int(limit), nofollow=True,
                            autoescape=autoescape))
예제 #17
0
def join(value, arg, autoescape=None):
    """
    Joins a list with a string, like Python's ``str.join(list)``.
    """
    value = list(map(force_unicode, value))
    if autoescape:
        value = [conditional_escape(v) for v in value]
    try:
        data = conditional_escape(arg).join(value)
    except AttributeError: # fail silently but nicely
        return value
    return mark_safe(data)
예제 #18
0
def mcjs(var):
    if var is None:
        return 'null'

    if isinstance(var, bool):
        return 'true' if var else 'false'

    if isinstance(var, (str, unicode)):
        return mark_safe(u"'%s'" % escapejs(var))

    if isinstance(var, (float, int, long)):
        return var

    raise RuntimeError('unexpected var type: %s - %s' % (var, type(var)))
예제 #19
0
def linenumbers(value, autoescape=None):
    """Displays text with line numbers."""
    from google.appengine._internal.django.utils.html import escape
    lines = value.split('\n')
    # Find the maximum width of the line count, for use with zero padding
    # string format command
    width = str(len(str(len(lines))))
    if not autoescape or isinstance(value, SafeData):
        for i, line in enumerate(lines):
            lines[i] = ("%0" + width  + "d. %s") % (i + 1, line)
    else:
        for i, line in enumerate(lines):
            lines[i] = ("%0" + width  + "d. %s") % (i + 1, escape(line))
    return mark_safe('\n'.join(lines))
예제 #20
0
def munki_property(tag, tagname=None):
  """Prints a formatted, colored tag."""
  if not tag:
    return ''
  tags = {
      'managed_installs': 'install',
      'managed_updates': 'update',
      'managed_uninstalls': 'uninstall',
      'optional_installs': 'optional',
      'unattended_install': 'unattd',
  }
  html = '<span class="tags %s" title="%s">%s</span>'
  abbr = tags.get(tag, tag)
  return mark_safe(html % (tagname or tag, tag, abbr))
예제 #21
0
파일: __init__.py 프로젝트: 0xmilk/appscale
 def resolve(self, context, ignore_failures=False):
     if isinstance(self.var, Variable):
         try:
             obj = self.var.resolve(context)
         except VariableDoesNotExist:
             if ignore_failures:
                 obj = None
             else:
                 if settings.TEMPLATE_STRING_IF_INVALID:
                     global invalid_var_format_string
                     if invalid_var_format_string is None:
                         invalid_var_format_string = '%s' in settings.TEMPLATE_STRING_IF_INVALID
                     if invalid_var_format_string:
                         return settings.TEMPLATE_STRING_IF_INVALID % self.var
                     return settings.TEMPLATE_STRING_IF_INVALID
                 else:
                     obj = settings.TEMPLATE_STRING_IF_INVALID
     else:
         obj = self.var
     for func, args in self.filters:
         arg_vals = []
         for lookup, arg in args:
             if not lookup:
                 arg_vals.append(mark_safe(arg))
             else:
                 arg_vals.append(arg.resolve(context))
         if getattr(func, 'needs_autoescape', False):
             new_obj = func(obj, autoescape=context.autoescape, *arg_vals)
         else:
             new_obj = func(obj, *arg_vals)
         if getattr(func, 'is_safe', False) and isinstance(obj, SafeData):
             obj = mark_safe(new_obj)
         elif isinstance(obj, EscapeData):
             obj = mark_for_escaping(new_obj)
         else:
             obj = new_obj
     return obj
예제 #22
0
def localize(value):
    """
    Checks if value is a localizable type (date, number...) and returns it
    formatted as a string using current locale format
    """
    if isinstance(value, bool):
        return mark_safe(unicode(value))
    elif isinstance(value, (decimal.Decimal, float, int, long)):
        return number_format(value)
    elif isinstance(value, datetime.datetime):
        return date_format(value, "DATETIME_FORMAT")
    elif isinstance(value, datetime.date):
        return date_format(value)
    elif isinstance(value, datetime.time):
        return time_format(value, "TIME_FORMAT")
    else:
        return value
예제 #23
0
def format(number, decimal_sep, decimal_pos, grouping=0, thousand_sep=''):
    """
    Gets a number (as a number or string), and returns it as a string,
    using formats definied as arguments:

    * decimal_sep: Decimal separator symbol (for example ".")
    * decimal_pos: Number of decimal positions
    * grouping: Number of digits in every group limited by thousand separator
    * thousand_sep: Thousand separator symbol (for example ",")

    """
    use_grouping = settings.USE_L10N and settings.USE_THOUSAND_SEPARATOR and grouping
    # Make the common case fast:
    if isinstance(number, int) and not use_grouping and not decimal_pos:
        return mark_safe(unicode(number))
    # sign
    if float(number) < 0:
        sign = '-'
    else:
        sign = ''
    str_number = unicode(number)
    if str_number[0] == '-':
        str_number = str_number[1:]
    # decimal part
    if '.' in str_number:
        int_part, dec_part = str_number.split('.')
        if decimal_pos:
            dec_part = dec_part[:decimal_pos]
    else:
        int_part, dec_part = str_number, ''
    if decimal_pos:
        dec_part = dec_part + ('0' * (decimal_pos - len(dec_part)))
    if dec_part: dec_part = decimal_sep + dec_part
    # grouping
    if use_grouping:
        int_part_gd = ''
        for cnt, digit in enumerate(int_part[::-1]):
            if cnt and not cnt % grouping:
                int_part_gd += thousand_sep
            int_part_gd += digit
        int_part = int_part_gd[::-1]
    return sign + int_part + dec_part
예제 #24
0
def do_translate(message, translation_function):
    """
    Translates 'message' using the given 'translation_function' name -- which
    will be either gettext or ugettext. It uses the current thread to find the
    translation object to use. If no current translation is activated, the
    message will be run through the default translation object.
    """
    eol_message = message.replace('\r\n', '\n').replace('\r', '\n')
    global _default, _active
    t = _active.get(currentThread(), None)
    if t is not None:
        result = getattr(t, translation_function)(eol_message)
    else:
        if _default is None:
            from google.appengine._internal.django.conf import settings
            _default = translation(settings.LANGUAGE_CODE)
        result = getattr(_default, translation_function)(eol_message)
    if isinstance(message, SafeData):
        return mark_safe(result)
    return result
예제 #25
0
파일: __init__.py 프로젝트: 0xmilk/appscale
    def __init__(self, var):
        self.var = var
        self.literal = None
        self.lookups = None
        self.translate = False

        try:
            # First try to treat this variable as a number.
            #
            # Note that this could cause an OverflowError here that we're not
            # catching. Since this should only happen at compile time, that's
            # probably OK.
            self.literal = float(var)

            # So it's a float... is it an int? If the original value contained a
            # dot or an "e" then it was a float, not an int.
            if '.' not in var and 'e' not in var.lower():
                self.literal = int(self.literal)

            # "2." is invalid
            if var.endswith('.'):
                raise ValueError

        except ValueError:
            # A ValueError means that the variable isn't a number.
            if var.startswith('_(') and var.endswith(')'):
                # The result of the lookup should be translated at rendering
                # time.
                self.translate = True
                var = var[2:-1]
            # If it's wrapped with quotes (single or double), then
            # we're also dealing with a literal.
            try:
                self.literal = mark_safe(unescape_string_literal(var))
            except ValueError:
                # Otherwise we'll set self.lookups so that resolve() knows we're
                # dealing with a bonafide variable
                if var.find(VARIABLE_ATTRIBUTE_SEPARATOR + '_') > -1 or var[0] == '_':
                    raise TemplateSyntaxError("Variables and attributes may not begin with underscores: '%s'" % var)
                self.lookups = tuple(var.split(VARIABLE_ATTRIBUTE_SEPARATOR))
예제 #26
0
def escape(html):
    """
    Returns the given HTML with ampersands, quotes and angle brackets encoded.
    """
    return mark_safe(force_unicode(html).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;'))
예제 #27
0
def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
    """
    Converts any URLs in text into clickable links.

    Works on http://, https://, www. links and links ending in .org, .net or
    .com. Links can have trailing punctuation (periods, commas, close-parens)
    and leading punctuation (opening parens) and it'll still do the right
    thing.

    If trim_url_limit is not None, the URLs in link text longer than this limit
    will truncated to trim_url_limit-3 characters and appended with an elipsis.

    If nofollow is True, the URLs in link text will get a rel="nofollow"
    attribute.

    If autoescape is True, the link text and URLs will get autoescaped.
    """
    trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(
        x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
    safe_input = isinstance(text, SafeData)
    words = word_split_re.split(force_unicode(text))
    nofollow_attr = nofollow and ' rel="nofollow"' or ''
    for i, word in enumerate(words):
        match = None
        if '.' in word or '@' in word or ':' in word:
            match = punctuation_re.match(word)
        if match:
            lead, middle, trail = match.groups()
            # Make URL we want to point to.
            url = None
            if middle.startswith('http://') or middle.startswith('https://'):
                url = urlquote(middle, safe='/&=:;#?+*')
            elif middle.startswith('www.') or (
                    '@' not in middle and middle
                    and middle[0] in string.ascii_letters + string.digits and
                (middle.endswith('.org') or middle.endswith('.net')
                 or middle.endswith('.com'))):
                url = urlquote('http://%s' % middle, safe='/&=:;#?+*')
            elif '@' in middle and not ':' in middle and simple_email_re.match(
                    middle):
                url = 'mailto:%s' % middle
                nofollow_attr = ''
            # Make link.
            if url:
                trimmed = trim_url(middle)
                if autoescape and not safe_input:
                    lead, trail = escape(lead), escape(trail)
                    url, trimmed = escape(url), escape(trimmed)
                middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr,
                                                    trimmed)
                words[i] = mark_safe('%s%s%s' % (lead, middle, trail))
            else:
                if safe_input:
                    words[i] = mark_safe(word)
                elif autoescape:
                    words[i] = escape(word)
        elif safe_input:
            words[i] = mark_safe(word)
        elif autoescape:
            words[i] = escape(word)
    return u''.join(words)
예제 #28
0
def escapejs(value):
    """Hex encodes characters for use in JavaScript strings."""
    for bad, good in _js_escapes:
        value = mark_safe(force_unicode(value).replace(bad, good))
    return value
예제 #29
0
def spacify(value, autoescape=None):
    if autoescape:
        esc = conditional_escape
    else:
        esc = lambda x: x
    return mark_safe(re.sub(r'\s', '&nbsp;', esc(value)))
예제 #30
0
def urlize(value, autoescape=None):
    """Converts URLs in plain text into clickable links."""
    from google.appengine._internal.django.utils.html import urlize
    return mark_safe(urlize(value, nofollow=True, autoescape=autoescape))
예제 #31
0
def unordered_list(value, autoescape=None):
    """
    Recursively takes a self-nested list and returns an HTML unordered list --
    WITHOUT opening and closing <ul> tags.

    The list is assumed to be in the proper format. For example, if ``var``
    contains: ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``,
    then ``{{ var|unordered_list }}`` would return::

        <li>States
        <ul>
                <li>Kansas
                <ul>
                        <li>Lawrence</li>
                        <li>Topeka</li>
                </ul>
                </li>
                <li>Illinois</li>
        </ul>
        </li>
    """
    if autoescape:
        from google.appengine._internal.django.utils.html import conditional_escape
        escaper = conditional_escape
    else:
        escaper = lambda x: x
    def convert_old_style_list(list_):
        """
        Converts old style lists to the new easier to understand format.

        The old list format looked like:
            ['Item 1', [['Item 1.1', []], ['Item 1.2', []]]

        And it is converted to:
            ['Item 1', ['Item 1.1', 'Item 1.2]]
        """
        if not isinstance(list_, (tuple, list)) or len(list_) != 2:
            return list_, False
        first_item, second_item = list_
        if second_item == []:
            return [first_item], True
        try:
            it = iter(second_item)  # see if second item is iterable
        except TypeError:
            return list_, False
        old_style_list = True
        new_second_item = []
        for sublist in second_item:
            item, old_style_list = convert_old_style_list(sublist)
            if not old_style_list:
                break
            new_second_item.extend(item)
        if old_style_list:
            second_item = new_second_item
        return [first_item, second_item], old_style_list
    def _helper(list_, tabs=1):
        indent = '\t' * tabs
        output = []

        list_length = len(list_)
        i = 0
        while i < list_length:
            title = list_[i]
            sublist = ''
            sublist_item = None
            if isinstance(title, (list, tuple)):
                sublist_item = title
                title = ''
            elif i < list_length - 1:
                next_item = list_[i+1]
                if next_item and isinstance(next_item, (list, tuple)):
                    # The next item is a sub-list.
                    sublist_item = next_item
                    # We've processed the next item now too.
                    i += 1
            if sublist_item:
                sublist = _helper(sublist_item, tabs+1)
                sublist = '\n%s<ul>\n%s\n%s</ul>\n%s' % (indent, sublist,
                                                         indent, indent)
            output.append('%s<li>%s%s</li>' % (indent,
                    escaper(force_unicode(title)), sublist))
            i += 1
        return '\n'.join(output)
    value, converted = convert_old_style_list(value)
    return mark_safe(_helper(value))
예제 #32
0
def host_details_link(uri, uuid):
  """Returns a joined URL to host record details page."""
  url = urlparse.urljoin(uri, uuid)
  return mark_safe('<a href="%s" class="host_details">view</a>' % url)
예제 #33
0
def munki_property_forcedate(date):
  if not date: return ''
  return mark_safe(munki_property(
      'force install: %s' % date.strftime('%b %d, %Y %I%p').lower(),
      'force_install'))
예제 #34
0
def floatformat(text, arg=-1):
    """
    Displays a float to a specified number of decimal places.

    If called without an argument, it displays the floating point number with
    one decimal place -- but only if there's a decimal place to be displayed:

    * num1 = 34.23234
    * num2 = 34.00000
    * num3 = 34.26000
    * {{ num1|floatformat }} displays "34.2"
    * {{ num2|floatformat }} displays "34"
    * {{ num3|floatformat }} displays "34.3"

    If arg is positive, it will always display exactly arg number of decimal
    places:

    * {{ num1|floatformat:3 }} displays "34.232"
    * {{ num2|floatformat:3 }} displays "34.000"
    * {{ num3|floatformat:3 }} displays "34.260"

    If arg is negative, it will display arg number of decimal places -- but
    only if there are places to be displayed:

    * {{ num1|floatformat:"-3" }} displays "34.232"
    * {{ num2|floatformat:"-3" }} displays "34"
    * {{ num3|floatformat:"-3" }} displays "34.260"

    If the input float is infinity or NaN, the (platform-dependent) string
    representation of that value will be displayed.
    """

    try:
        input_val = force_unicode(text)
        d = Decimal(input_val)
    except UnicodeEncodeError:
        return ''
    except InvalidOperation:
        if input_val in special_floats:
            return input_val
        try:
            d = Decimal(force_unicode(float(text)))
        except (ValueError, InvalidOperation, TypeError, UnicodeEncodeError):
            return ''
    try:
        p = int(arg)
    except ValueError:
        return input_val

    try:
        m = int(d) - d
    except (ValueError, OverflowError, InvalidOperation):
        return input_val

    if not m and p < 0:
        return mark_safe(formats.number_format('%d' % (int(d)), 0))

    if p == 0:
        exp = Decimal(1)
    else:
        exp = Decimal('1.0') / (Decimal(10) ** abs(p))
    try:
        return mark_safe(formats.number_format('%s' % str(d.quantize(exp, ROUND_HALF_UP)), abs(p)))
    except InvalidOperation:
        return input_val
예제 #35
0
def host_details_link(uri, uuid):
  """Returns a joined URL to host record details page."""
  url = urlparse.urljoin(uri, uuid)
  return mark_safe('<a href="%s">view</a>' % url)
예제 #36
0
def spacify(value, autoescape=None):
  if autoescape:
    esc = conditional_escape
  else:
    esc = lambda x: x
  return mark_safe(re.sub(r'\s', '&nbsp;', esc(value)))
예제 #37
0
def host_uuid_link(uuid):
  """Returns an HTML anchor tag linking to the report for the given uuid."""
  return mark_safe(
      '<a href="/admin/host/%s/" class="uuidhover">%s</a>' % (uuid, uuid))
예제 #38
0
def escapejs(value):
    """Hex encodes characters for use in JavaScript strings."""
    for bad, good in _js_escapes:
        value = mark_safe(force_unicode(value).replace(bad, good))
    return value
예제 #39
0
def safe(value):
    """
    Marks the value as a string that should not be auto-escaped.
    """
    return mark_safe(value)
예제 #40
0
def munki_properties(tags):
  return mark_safe('\n'.join([munki_property(tag) for tag in tags]))
예제 #41
0
def host_uuid_link(uuid):
  """Returns an HTML anchor tag linking to the report for the given uuid."""
  return mark_safe(
      '<a href="/admin/host/%s/" class="uuidhover">%s</a>' % (uuid, uuid))