11import os
22import json
3- import StringIO
3+
4+ try :
5+ from StringIO import StringIO
6+ except ImportError :
7+ from io import BytesIO as StringIO
8+
49from zipfile import ZipFile
510
611from lxml import etree
712import requests
813
9- from exceptions import (
14+ from . exceptions import (
1015 NoContainerError , OperationFailedError , UnpublishedDataverseError ,
1116 ConnectionError , MetadataNotFoundError , VersionJsonNotFoundError ,
1217)
13- from file import DataverseFile
14- from settings import SWORD_BOOTSTRAP
15- from utils import get_element , get_files_in_path , add_field
18+ from . file import DataverseFile
19+ from . settings import SWORD_BOOTSTRAP
20+ from . utils import get_element , get_files_in_path , add_field
1621
1722
1823class Dataset (object ):
@@ -35,7 +40,8 @@ def __init__(self, entry=SWORD_BOOTSTRAP, dataverse=None, edit_uri=None,
3540 self ._id = None
3641
3742 # Updates sword entry from keyword arguments
38- for key , value in kwargs .iteritems ():
43+ for key in kwargs :
44+ value = kwargs [key ]
3945 if isinstance (value , list ):
4046 for item in value :
4147 add_field (self ._entry , key , item , 'dcterms' )
@@ -271,7 +277,7 @@ def upload_filepaths(self, filepaths):
271277 filepaths = get_files_in_path (filepaths [0 ])
272278
273279 # Zip up files
274- s = StringIO . StringIO ()
280+ s = StringIO ()
275281 zip_file = ZipFile (s , 'w' )
276282 for filepath in filepaths :
277283 zip_file .write (filepath )
@@ -282,7 +288,7 @@ def upload_filepaths(self, filepaths):
282288
283289 def upload_file (self , filename , content , zip_files = True ):
284290 if zip_files :
285- s = StringIO . StringIO ()
291+ s = StringIO ()
286292 zip_file = ZipFile (s , 'w' )
287293 zip_file .writestr (filename , content )
288294 zip_file .close ()
0 commit comments