Ejemplo n.º 1
0
class XLSDateTimeRenderer(XLSObjectRenderer):
    """Renders timestamps as python datetime objects."""
    renders_type = "UnixTimeStamp"
    STYLE = styles.Style(number_format='MM/DD/YYYY HH:MM:SS')

    def GetData(self, item, **options):
        if item.v() == 0:
            return None

        return item.as_datetime()
Ejemplo n.º 2
0
from openpyxl.styles import colors
from openpyxl.styles import fills

from rekall_lib import utils
from rekall.ui import renderer
from rekall.ui import text

import six
if six.PY3:
    long = int


# pylint: disable=unexpected-keyword-arg,no-value-for-parameter
# pylint: disable=redefined-outer-name

HEADER_STYLE = styles.Style(font=styles.Font(bold=True))
SECTION_STYLE = styles.Style(
    fill=styles.PatternFill(
        fill_type=fills.FILL_SOLID, start_color=styles.Color(colors.RED)))
FORMAT_STYLE = styles.Style(
    alignment=styles.Alignment(vertical="top", wrap_text=False))


class XLSObjectRenderer(renderer.ObjectRenderer):
    """By default the XLS renderer delegates to the text renderer."""
    renders_type = "object"
    renderers = ["XLSRenderer"]

    STYLE = None

    def _GetDelegateObjectRenderer(self, item):
Ejemplo n.º 3
0
import re
from openpyxl import Workbook
from openpyxl import styles
from cStringIO import StringIO
from django.core.files import File
from django.utils.safestring import mark_safe
from django.utils.datastructures import SortedDict
import unicodedata

try:
    from django.utils import timezone
except ImportError:
    from datetime import datetime as timezone

# default yellow backgroung for first line
DEFAULT_HEADER_STYLE = styles.Style(
    fill=styles.PatternFill(patternType='solid', fgColor=styles.colors.YELLOW))


def slugify(value):
    """
    Converts to ASCII. Converts spaces to hyphens. Removes characters that
    aren't alphanumerics, underscores, or hyphens. Converts to lowercase.
    Also strips leading and trailing whitespace.
    """
    value = unicodedata.normalize('NFKD', unicode(value)).encode(
        'ascii', 'ignore').decode('ascii')
    value = re.sub('[^\w\s-]', '', value).strip().lower()
    return mark_safe(re.sub('[-\s]+', '_', value))


class QuerysetToWorkbook(object):