Skip to content
Snippets Groups Projects
Unverified Commit 793fa718 authored by Han Xiao's avatar Han Xiao Committed by GitHub
Browse files

fix(windows): fix windows newline issue (#364)

parent d85a597f
No related branches found
No related tags found
No related merge requests found
......@@ -140,10 +140,15 @@ class ContentPropertyMixin:
):
"""Set the :attr:`.content` of all Documents.
:param value: a list of texts, blobs or :class:`ArrayType`
:param value: a list of texts, blobs or :class:`ArrayType`. If the value is a two-element tuple,
then the second element is used as the :attr:`.content_type`
"""
if self:
content_type = self[0].content_type or self[-1].content_type
if isinstance(value, tuple) and len(value) == 2:
content_type = value[1]
else:
content_type = self[0].content_type or self[-1].content_type
if content_type:
setattr(self, f'{content_type}s', value)
......
......@@ -3,8 +3,6 @@ import urllib.parse
import urllib.request
from contextlib import nullcontext
from ...helper import __windows__
def _uri_to_blob(uri: str) -> bytes:
"""Convert uri to blob
......@@ -28,10 +26,7 @@ def _get_file_context(file):
if hasattr(file, 'write'):
file_ctx = nullcontext(file)
else:
if __windows__:
file_ctx = open(file, 'wb', newline='')
else:
file_ctx = open(file, 'wb')
file_ctx = open(file, 'wb')
return file_ctx
......
......@@ -17,7 +17,6 @@ from rich.panel import Panel
ALLOWED_PROTOCOLS = {'pickle', 'protobuf', 'protobuf-array', 'pickle-array'}
ALLOWED_COMPRESSIONS = {'lz4', 'bz2', 'lzma', 'zlib', 'gzip'}
__windows__ = sys.platform == 'win32'
__resources_path__ = os.path.join(
os.path.dirname(
......
import os
import sys
import numpy as np
import pytest
from docarray import Document
from docarray.document.generators import from_files
from docarray.helper import __windows__
__windows__ = sys.platform == 'win32'
cur_dir = os.path.dirname(os.path.abspath(__file__))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment