Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 4788e24

Browse files
committed
Add Python2-specifics back in
Mistakes were made in commit f93f4bc. Fixing them. Also fixing test_streams.py to run unit tests.
1 parent d1ec509 commit 4788e24

File tree

4 files changed

+148
-1
lines changed

4 files changed

+148
-1
lines changed

src/onedrivesdk/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.3
1+
1.0.4

src/python2/request/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'''
2+
------------------------------------------------------------------------------
3+
Copyright (c) 2015 Microsoft Corporation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+
------------------------------------------------------------------------------
23+
'''
24+
25+
import os
26+
import glob
27+
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
28+
__all__ = [ os.path.basename(f)[:-3] for f in modules if not os.path.basename(f).startswith('_')]
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# -*- coding: utf-8 -*-
2+
'''
3+
# Copyright (c) 2015 Microsoft Corporation
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
#
23+
# This file was generated and any changes will be overwritten.
24+
'''
25+
26+
from __future__ import unicode_literals
27+
from ..request.drives_collection import DrivesCollectionRequestBuilder
28+
from ..request.shares_collection import SharesCollectionRequestBuilder
29+
import sys
30+
31+
32+
class OneDriveClient(object):
33+
34+
def __init__(self, base_url, auth_provider, http_provider, loop=None):
35+
"""Initialize the :class:`OneDriveClient` to be
36+
used for all OneDrive API interactions
37+
38+
Args:
39+
base_url (str): The OneDrive base url to use for API interactions
40+
auth_provider(:class:`AuthProviderBase<onedrivesdk.auth_provider_base.AuthProviderBase>`):
41+
The authentication provider used by the client to auth
42+
with OneDrive services
43+
http_provider(:class:`HttpProviderBase<onedrivesdk.http_provider_base.HttpProviderBase>`):
44+
The HTTP provider used by the client to send all
45+
requests to OneDrive
46+
loop (BaseEventLoop): Default to None, the AsyncIO loop
47+
to use for all async requests
48+
"""
49+
self.base_url = base_url
50+
self.auth_provider = auth_provider
51+
self.http_provider = http_provider
52+
53+
if sys.version_info >= (3, 4, 0):
54+
import asyncio
55+
self._loop = loop if loop else asyncio.get_event_loop()
56+
57+
@property
58+
def auth_provider(self):
59+
"""Gets and sets the client auth provider
60+
61+
Returns:
62+
:class:`AuthProviderBase<onedrivesdk.auth_provider_base.AuthProviderBase>`:
63+
The authentication provider
64+
"""
65+
return self._auth_provider
66+
67+
@auth_provider.setter
68+
def auth_provider(self, value):
69+
self._auth_provider = value
70+
71+
@property
72+
def http_provider(self):
73+
"""Gets and sets the client HTTP provider
74+
75+
Returns:
76+
:class:`HttpProviderBase<onedrivesdk.http_provider_base.HttpProviderBase>`:
77+
The HTTP provider
78+
"""
79+
return self._http_provider
80+
81+
@http_provider.setter
82+
def http_provider(self, value):
83+
self._http_provider = value
84+
85+
@property
86+
def base_url(self):
87+
"""Gets and sets the base URL used by the client to make requests
88+
89+
Returns:
90+
str: The base URL
91+
"""
92+
return self._base_url
93+
94+
@base_url.setter
95+
def base_url(self, value):
96+
self._base_url = value
97+
98+
@property
99+
def drives(self):
100+
"""Get the DrivesCollectionRequestBuilder for constructing requests
101+
102+
Returns:
103+
:class:`DrivesCollectionRequestBuilder<onedrivesdk.request.drives_collection.DrivesCollectionRequestBuilder>`:
104+
The DrivesCollectionRequestBuilder to return
105+
"""
106+
return DrivesCollectionRequestBuilder(self.base_url + "drives", self)
107+
108+
@property
109+
def shares(self):
110+
"""Get the SharesCollectionRequestBuilder for constructing requests
111+
112+
Returns:
113+
:class:`SharesCollectionRequestBuilder<onedrivesdk.request.shares_collection.SharesCollectionRequestBuilder>`:
114+
The SharesCollectionRequestBuilder to return
115+
"""
116+
return SharesCollectionRequestBuilder(self.base_url + "shares", self)

testonedrivesdk/test_streams.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ def test_download(self, MockHttpProvider, MockAuthProvider):
5555

5656
assert client.http_provider.download.call_args[0][2] == path
5757
assert client.http_provider.download.call_args[0][1] == "onedriveurl/drives/me/items/root/children/newFile.txt/content"
58+
59+
if __name__ == '__main__':
60+
unittest.main()

0 commit comments

Comments
 (0)