Ejemplo n.º 1
0
def get_sheet_stream(**keywords):
    """
    Get an instance of SheetStream from an excel source
    """
    a_source = SOURCE.get_source(**keywords)
    sheets = a_source.get_data()
    sheet_name, data = _one_sheet_tuple(sheets.items())
    return SheetStream(sheet_name, data)
Ejemplo n.º 2
0
 def custom_book_importer(self, content, **keywords):
     """docstring is assigned a few lines down the line"""
     keyword = SOURCE.get_keyword_for_parameter(attribute)
     if keyword == "file_type":
         keywords[keyword] = attribute
         keywords["file_content"] = content
     else:
         keywords[keyword] = content
     sheets, filename, path = _get_book(**keywords)
     self.init(sheets=sheets, filename=filename, path=path)
Ejemplo n.º 3
0
def _get_book(**keywords):
    """Get an instance of :class:`Book` from an excel source

    Where the dictionary should have text as keys and two dimensional
    array as values.
    """
    a_source = SOURCE.get_book_source(**keywords)
    sheets = a_source.get_data()
    filename, path = a_source.get_source_info()
    return sheets, filename, path
Ejemplo n.º 4
0
 def custom_book_importer(self, content, **keywords):
     """docstring is assigned a few lines down the line"""
     keyword = SOURCE.get_keyword_for_parameter(attribute)
     if keyword == "file_type":
         keywords[keyword] = attribute
         keywords["file_content"] = content
     else:
         keywords[keyword] = content
     sheets, filename, path = _get_book(**keywords)
     self.init(sheets=sheets, filename=filename, path=path)
Ejemplo n.º 5
0
def _get_book(**keywords):
    """Get an instance of :class:`Book` from an excel source

    Where the dictionary should have text as keys and two dimensional
    array as values.
    """
    a_source = SOURCE.get_book_source(**keywords)
    sheets = a_source.get_data()
    filename, path = a_source.get_source_info()
    return sheets, filename, path
Ejemplo n.º 6
0
def get_book_stream(**keywords):
    """
    Get an instance of BookStream from an excel source

    Where the dictionary should have text as keys and two dimensional
    array as values.
    """
    a_source = SOURCE.get_book_source(**keywords)
    filename, path = a_source.get_source_info()
    sheets = a_source.get_data()
    return BookStream(sheets, filename=filename, path=path)
Ejemplo n.º 7
0
def get_sheet_stream(**keywords):
    """
    Get an instance of SheetStream from an excel source
    """
    a_source = SOURCE.get_source(**keywords)
    filename, path = a_source.get_source_info()
    sheets = a_source.get_data()
    if sheets:
        sheet_name, data = _one_sheet_tuple(sheets.items())
        return SheetStream(sheet_name, data)
    else:
        return SheetStream(DEFAULT_NO_DATA, [[]])
Ejemplo n.º 8
0
 def custom_importer1(self, content, **keywords):
     """docstring is assigned a few lines down the line"""
     sheet_params = {}
     for field in constants.VALID_SHEET_PARAMETERS:
         if field in keywords:
             sheet_params[field] = keywords.pop(field)
     keyword = SOURCE.get_keyword_for_parameter(attribute)
     if keyword == "file_type":
         keywords[keyword] = attribute
         keywords["file_content"] = content
     else:
         keywords[keyword] = content
     named_content = get_sheet_stream(**keywords)
     self.init(named_content.payload, named_content.name, **sheet_params)
Ejemplo n.º 9
0
    def custom_presenter(self, **keywords):
        """docstring is assigned a few lines down the line"""
        keyword = SOURCE.get_keyword_for_parameter(attribute)
        keywords[keyword] = attribute
        memory_source = source_getter(**keywords)
        memory_source.write_data(self)
        try:
            content_stream = memory_source.get_content()
            content = content_stream.getvalue()
        except AttributeError:
            # python 3 _io.TextWrapper
            content = None

        return content
Ejemplo n.º 10
0
    def custom_presenter(self, **keywords):
        """docstring is assigned a few lines down the line"""
        keyword = SOURCE.get_keyword_for_parameter(attribute)
        keywords[keyword] = attribute
        memory_source = source_getter(**keywords)
        memory_source.write_data(self)
        try:
            content_stream = memory_source.get_content()
            content = content_stream.getvalue()
        except AttributeError:
            # python 3 _io.TextWrapper
            content = None

        return content
Ejemplo n.º 11
0
 def custom_importer1(self, content, **keywords):
     """docstring is assigned a few lines down the line"""
     sheet_params = {}
     for field in constants.VALID_SHEET_PARAMETERS:
         if field in keywords:
             sheet_params[field] = keywords.pop(field)
     keyword = SOURCE.get_keyword_for_parameter(attribute)
     if keyword == "file_type":
         keywords[keyword] = attribute
         keywords["file_content"] = content
     else:
         keywords[keyword] = content
     named_content = get_sheet_stream(**keywords)
     self.init(named_content.payload,
               named_content.name, **sheet_params)
Ejemplo n.º 12
0
def save_book(book, **keywords):
    """
    Save a book instance to any source
    """
    a_source = SOURCE.get_writable_book_source(**keywords)
    return _save_any(a_source, book)
Ejemplo n.º 13
0
def save_sheet(sheet, **keywords):
    """
    Save a sheet instance to any source
    """
    a_source = SOURCE.get_writable_source(**keywords)
    return _save_any(a_source, sheet)