Skip to content

Commit 5d5a871

Browse files
Change print statement to print() function
1 parent 0374de9 commit 5d5a871

9 files changed

Lines changed: 41 additions & 35 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ use the `revoke_token` method on APIClient
8787
client = APIClient(APP_ID, APP_SECRET, token)
8888

8989
# Print out the email address and provider (Gmail, Exchange)
90-
print client.account.email_address
91-
print client.account.provider
90+
print(client.account.email_address)
91+
print(client.account.provider)
9292
```
9393

9494

@@ -104,19 +104,19 @@ thread = client.threads.find('ac123acd123ef123')
104104
# List all threads tagged `inbox`
105105
# (paginating 50 at a time until no more are returned.)
106106
for thread in client.threads.items():
107-
print thread.subject
107+
print(thread.subject)
108108

109109
# List the 5 most recent unread threads
110110
for thread in client.threads.where(unread=True, limit=5):
111-
print thread.subject
111+
print(thread.subject)
112112

113113
# List starred threads
114114
for thread in client.threads.where(starred=True):
115-
print thread.subject
115+
print(thread.subject)
116116

117117
# List all threads with 'ben@nylas.com'
118118
for thread in client.threads.where(any_email='ben@nylas.com').items():
119-
print thread.subject
119+
print(thread.subject)
120120
```
121121

122122
### Searching Messages and Threads
@@ -137,7 +137,7 @@ messages = client.messages.search("nylas")
137137
```python
138138
# List thread participants
139139
for participant in thread.participants:
140-
print participant["email"]
140+
print(participant["email"])
141141

142142
# Mark as read
143143
thread.mark_as_read()
@@ -170,10 +170,10 @@ message.update_folder(trash_id)
170170

171171
# List messages
172172
for message in thread.messages.items():
173-
print message.subject
173+
print(message.subject)
174174

175175
# Get the raw contents of a message
176-
print message.raw
176+
print(message.raw)
177177
```
178178

179179
To get the [expanded message view](https://www.nylas.com/docs/platform#expanded_message_view) that includes convenient header information, include `view='expanded'` in the where clause
@@ -191,7 +191,7 @@ The Folders and Labels API replaces the now deprecated Tags API. For Gmail accou
191191
```python
192192
# List labels
193193
for label in client.labels:
194-
print label.id, label.display_name
194+
print(label.id, label.display_name)
195195

196196
# Create a label
197197
label = client.labels.create()
@@ -219,7 +219,7 @@ Files can be uploaded via two interfaces. One is providing data directly, anothe
219219
```python
220220
# List files
221221
for file in client.files:
222-
print file.filename
222+
print(file.filename)
223223

224224
# Create a new file with the stream interface
225225
f = open('test.py', 'r')
@@ -259,15 +259,15 @@ draft.attach(myfile)
259259
try:
260260
draft.send()
261261
except nylas.client.errors.ConnectionError as e:
262-
print "Unable to connect to the SMTP server."
262+
print("Unable to connect to the SMTP server.")
263263
except nylas.client.errors.MessageRejectedError as e:
264-
print "Message got rejected by the SMTP server!"
265-
print e.message
264+
print("Message got rejected by the SMTP server!")
265+
print(e.message)
266266

267267
# Sometimes the API gives us the exact error message
268268
# returned by the server. Display it since it can be
269269
# helpful to know exactly why our message got rejected:
270-
print e.server_error
270+
print(e.server_error)
271271

272272
# Delete a draft
273273
draft = client.drafts.create()
@@ -352,7 +352,7 @@ It's possible to query the status of all the user accounts registered to an app
352352

353353
```python
354354
accounts = client.accounts
355-
print [(acc.sync_status, acc.account_id, acc.trial, acc.trial_expires) for acc in accounts.all()]
355+
print([(acc.sync_status, acc.account_id, acc.trial, acc.trial_expires) for acc in accounts.all()])
356356
```
357357

358358
## Open-Source Sync Engine
@@ -369,7 +369,7 @@ account_id = client.accounts.first().id
369369

370370
# Display the contents of the first message for the first account
371371
client = APIClient(None, None, account_id, 'http://localhost:5555/')
372-
print client.messages.first().body
372+
print(client.messages.first().body)
373373
```
374374

375375

examples/lib/random_words.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import random
34
import json
45
import sys
@@ -11,8 +12,8 @@ def get_words():
1112
with open(DICT_FILE, 'r') as f:
1213
words.extend(f.read().split('\n'))
1314
except IOError:
14-
print json.dumps({'error': "couldn't open dictionary file",
15-
'filename': DICT_FILE})
15+
print(json.dumps({'error': "couldn't open dictionary file",
16+
'filename': DICT_FILE}))
1617
sys.exit(1)
1718
return words
1819

@@ -68,4 +69,4 @@ def random_words(count=int(random.uniform(1,500)), sig='me'):
6869

6970

7071
if __name__ == '__main__':
71-
print random_words()
72+
print(random_words())

examples/most_talked_to.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/python
2-
2+
from __future__ import print_function
33
from operator import itemgetter
44
from nylas import APIClient
55

@@ -18,4 +18,4 @@
1818

1919
most_chatted = sorted(counts.iteritems(), key=itemgetter(1))
2020
for i in most_chatted:
21-
print i
21+
print(i)

examples/nylas-connect/app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import json
34
import sys
45
import os
@@ -175,12 +176,12 @@ def nylas_token(data):
175176
def initialize():
176177
global REDIRECT_URI
177178
REDIRECT_URI = "{}/oauth2callback".format("http://lvh.me:1234")
178-
print REDIRECT_URI
179+
print(REDIRECT_URI)
179180
s = raw_input("Have you added the url above as an authorized callback "
180181
"in Google's Developer console? y/n ")
181182
if s != "y":
182-
print "You need to set that up first!"
183-
print "See https://support.nylas.com/hc/en-us/articles/222176307-Google-OAuth-Setup-Guide for more information"
183+
print("You need to set that up first!")
184+
print("See https://support.nylas.com/hc/en-us/articles/222176307-Google-OAuth-Setup-Guide for more information")
184185
sys.exit(-1)
185186

186187

@@ -189,5 +190,5 @@ def initialize():
189190
initialize()
190191
app.secret_key = str(uuid.uuid4())
191192
app.debug = False
192-
print "Visit http://localhost:1234 in your browser"
193+
print("Visit http://localhost:1234 in your browser")
193194
app.run(port=1234)

examples/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
# 6. In the browser, visit http://localhost:8888/
3434
#
3535

36+
from __future__ import print_function
37+
3638
import time
3739
from flask import Flask, url_for, session, request, redirect, Response
3840

@@ -60,7 +62,7 @@ def index():
6062
# Get the latest message from namespace zero.
6163
message = client.messages.first()
6264
if not message: # A new account takes a little time to sync
63-
print "No messages yet. Checking again in 2 seconds."
65+
print("No messages yet. Checking again in 2 seconds.")
6466
time.sleep(2)
6567
except Exception as e:
6668
print(e.message)

examples/upload_and_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/python
2-
2+
from __future__ import print_function
33
import time
44
from nylas import APIClient
55
from nylas.util import generate_id
@@ -36,4 +36,4 @@
3636

3737
m = th.messages[0]
3838

39-
print m.attachments[0].download()
39+
print(m.attachments[0].download())

examples/upload_files_in_dir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/python
2-
2+
from __future__ import print_function
33
import os
44
import time
55
from nylas import APIClient
@@ -32,4 +32,4 @@
3232
time.sleep(0.5)
3333
th = client.threads.where({'in': 'Sent', 'subject': subject}).first()
3434

35-
print th.messages[0].attachments[0].download()
35+
print(th.messages[0].attachments[0].download())

examples/webhooks/app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import sys
34
import json
45
import flask
@@ -37,8 +38,8 @@ def index():
3738
# Print some of the information Nylas sent us. This is where you
3839
# would normally process the webhook notification and do things like
3940
# fetch relevant message ids, update your database, etc.
40-
print "{} at {} with id {}".format(delta['type'], delta['date'],
41-
delta['object_data']['id'])
41+
print("{} at {} with id {}".format(delta['type'], delta['date'],
42+
delta['object_data']['id']))
4243
# Don't forget to let Nylas know that everything was pretty ok.
4344
return "Success", 200
4445

@@ -62,7 +63,7 @@ def initialize():
6263
try:
6364
resp = requests.get('http://localhost:4040/api/tunnels').json()
6465
except requests.exceptions.ConnectionError:
65-
print "It looks like ngrok isn't running! Make sure you've started that first with 'ngrok http 1234'"
66+
print("It looks like ngrok isn't running! Make sure you've started that first with 'ngrok http 1234'")
6667
sys.exit(-1)
6768

6869
global WEBHOOK_URI
@@ -73,5 +74,5 @@ def initialize():
7374
initialize()
7475
app.secret_key = str(uuid.uuid4())
7576
app.debug = False
76-
print "{}\nAdd the above url to the webhooks page at https://developer.nylas.com".format(WEBHOOK_URI)
77+
print("{}\nAdd the above url to the webhooks page at https://developer.nylas.com".format(WEBHOOK_URI))
7778
app.run(port=1234)

nylas/client/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23
import requests
34
import json

0 commit comments

Comments
 (0)