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

Commit 47c837f

Browse files
author
cmayer-ms
committed
Syntax highlighting
1 parent 9b92585 commit 47c837f

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Authentication
1919

2020
To interact with the OneDrive API, you must authenticate. You can use the following code sample to do so.
2121

22-
<pre><code>import onedrivesdk
22+
```python
23+
import onedrivesdk
2324
from onedrivesdk.helpers import GetAuthCodeServer
2425

2526
redirect_uri = "http://localhost:8080/"
@@ -36,7 +37,7 @@ auth_url = client.auth_provider.get_auth_url(redirect_uri)
3637
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
3738

3839
client.auth_provider.authenticate(code, redirect_uri, client_secret)
39-
</code></pre>
40+
```
4041

4142
Once you are authenticated, you should have access to the OneDrive API, and
4243
can begin making calls using the SDK!
@@ -50,32 +51,37 @@ NOTE: All examples assume that the
5051
Upload an Item
5152
--------------
5253

53-
<pre><code>returned_item = client.item(drive="me", id="root").children["newfile.txt"].upload("./path_to_file.txt")</code></pre>
54+
```python
55+
returned_item = client.item(drive="me", id="root").children["newfile.txt"].upload("./path_to_file.txt")
56+
```
5457

5558
Download an Item
5659
----------------
5760

58-
<pre><code>root_folder = client.item(drive="me", id="root").children.get()
61+
```python
62+
root_folder = client.item(drive="me", id="root").children.get()
5963
id_of_file = root_folder[0].id
6064

6165
client.item(drive="me", id=id_of_file).download("./path_to_download_to.txt")
62-
</code></pre>
66+
```
6367

6468
Add a Folder
6569
------------
6670

67-
<pre><code>f = onedrivesdk.Folder()
71+
```python
72+
f = onedrivesdk.Folder()
6873
i = onedrivesdk.Item()
6974
i.name = "New Folder"
7075
i.folder = f
7176

7277
returned_item = client.item(drive="me", id="root").children.add(i)
73-
</code></pre>
78+
```
7479

7580
Copying an Item
7681
---------------
7782

78-
<pre><code>from onedrivesdk.item_reference import ItemReference
83+
```python
84+
from onedrivesdk.item_reference import ItemReference
7985

8086
ref = ItemReference()
8187
ref.id = "yourparent!id" #path also supported
@@ -87,30 +93,32 @@ copy_operation = client.item(drive="me", id="youritemtocopy!id").copy(name="new
8793
#and copy_operation.item is no longer None
8894
copy_operation.poll_until_complete()
8995

90-
</code></pre>
96+
```
9197

9298
Renaming an Item
9399
----------------
94100

95-
<pre><code>renamed_item = onedrivesdk.Item()
101+
```python
102+
renamed_item = onedrivesdk.Item()
96103
renamed_item.name = "NewItemName"
97104
renamed_item.id = "youritemtorename!id"
98105

99106
new_item = client.item(drive="me", id=renamed_item.id).update(renamed_item)
100-
</code></pre>
107+
```
101108

102109
Paging through a Collection
103110
---------------------------
104111

105-
<pre><code>#get the top 3 elements of root, leaving the next page for more elements
112+
```python
113+
#get the top 3 elements of root, leaving the next page for more elements
106114
collection = client.item(drive="me", id="root").children.request(top=3).get()
107115

108116
#get the first item in the collection
109117
item = collection[0]
110118

111119
#get next page of 3 elements, if none exist, returns None
112120
collection2 = collection.next_page_request.get()
113-
</code></pre>
121+
```
114122

115123
Async operations
116124
----------------
@@ -120,7 +128,8 @@ For async operations, you create an asyncio.coroutine which
120128
implements asyncio.ascompleted, and execute it with
121129
loop.run\_until\_complete.
122130

123-
<pre><code>import asyncio
131+
```python
132+
import asyncio
124133

125134
@asyncio.coroutine
126135
def run_gets(client):
@@ -131,4 +140,4 @@ def run_gets(client):
131140

132141
loop = asyncio.get_event_loop()
133142
loop.run_until_complete(run_gets(client))
134-
</code></pre>
143+
```

0 commit comments

Comments
 (0)