1+ from __future__ import absolute_import
2+
13import os
24import json
3- import StringIO
5+
6+ try :
7+ from StringIO import StringIO
8+ except ImportError :
9+ from io import BytesIO as StringIO
10+
411from zipfile import ZipFile
512
613from lxml import etree
714import requests
815
9- from exceptions import (
16+ from . exceptions import (
1017 NoContainerError , OperationFailedError , UnpublishedDataverseError ,
1118 ConnectionError , MetadataNotFoundError , VersionJsonNotFoundError ,
1219)
13- from file import DataverseFile
14- from settings import SWORD_BOOTSTRAP
15- from utils import get_element , get_files_in_path , add_field
20+ from dataverse . file import DataverseFile
21+ from dataverse . settings import SWORD_BOOTSTRAP
22+ from dataverse . utils import get_element , get_files_in_path , add_field
1623
1724
1825class Dataset (object ):
@@ -35,7 +42,8 @@ def __init__(self, entry=SWORD_BOOTSTRAP, dataverse=None, edit_uri=None,
3542 self ._id = None
3643
3744 # Updates sword entry from keyword arguments
38- for key , value in kwargs .iteritems ():
45+ for key in kwargs :
46+ value = kwargs [key ]
3947 if isinstance (value , list ):
4048 for item in value :
4149 add_field (self ._entry , key , item , 'dcterms' )
@@ -271,7 +279,7 @@ def upload_filepaths(self, filepaths):
271279 filepaths = get_files_in_path (filepaths [0 ])
272280
273281 # Zip up files
274- s = StringIO . StringIO ()
282+ s = StringIO ()
275283 zip_file = ZipFile (s , 'w' )
276284 for filepath in filepaths :
277285 zip_file .write (filepath )
@@ -282,7 +290,7 @@ def upload_filepaths(self, filepaths):
282290
283291 def upload_file (self , filename , content , zip_files = True ):
284292 if zip_files :
285- s = StringIO . StringIO ()
293+ s = StringIO ()
286294 zip_file = ZipFile (s , 'w' )
287295 zip_file .writestr (filename , content )
288296 zip_file .close ()
0 commit comments