Skip to content

Commit 6d45020

Browse files
author
Wasin Waeosri
committed
Change log:
1. Remove all is not None statements, change them to be a bit more Pythonic
1 parent 32d6546 commit 6d45020

File tree

8 files changed

+21
-19
lines changed

8 files changed

+21
-19
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ The best way is via the pip package management tool
7575
- Fix the issue that some scripts still send request message to the old REST endpoint.
7676
- version 1.0.9: 26 Jan 2018
7777
- Add debug log for checking outgoing message (disabled by default)
78+
- version 1.0.10: 9 Aug 2018
79+
- remove all ```is not None``` statements and make them a bit more **Pythonic**

trkd_chart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ def downloadChartImage(chartURL):
320320
token = CreateAuthorization(username,password,appid)
321321
print('Token = %s'%(token))
322322
## if authentiacation success, continue subscribing Chart
323-
if token is not None:
323+
if token:
324324
chartURL = RetrieveChart(token,appid)
325325
## if chart request success, continue downloading Chart image
326-
if chartURL is not None:
326+
if chartURL:
327327
print('############### Downloading Chart file from TRKD ###############')
328328
downloadChartImage(chartURL)
329329

trkd_interday.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def CreateAuthorization(username, password, appid):
4444
headers = {'content-type': 'application/json;charset=utf-8'}
4545
print('############### Sending Authentication request message to TRKD ###############')
4646
authenResult = doSendRequest(authenURL, authenMsg, headers)
47-
if authenResult is not None and authenResult.status_code == 200:
47+
if authenResult and authenResult.status_code == 200:
4848
print('Authen success')
4949
print('response status %s'%(authenResult.status_code))
5050
##get Token
@@ -81,7 +81,7 @@ def RetrieveInteraday(token, appid):
8181

8282
print('############### Sending Time Series Interday request message to TRKD ###############')
8383
interdayResult = doSendRequest(interdayURL, interdayRequestMsg, headers)
84-
if interdayResult is not None and interdayResult.status_code == 200:
84+
if interdayResult and interdayResult.status_code == 200:
8585
print('Time Series Interday response message: ')
8686
print(interdayResult.json())
8787

trkd_intraday.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def CreateAuthorization(username, password, appid):
4848
headers = {'content-type': 'application/json;charset=utf-8'}
4949
print('############### Sending Authentication request message to TRKD ###############')
5050
authenResult = doSendRequest(authenURL, authenMsg, headers)
51-
if authenResult is not None and authenResult.status_code == 200:
51+
if authenResult and authenResult.status_code == 200:
5252
print('Authen success')
5353
print('response status %s' % (authenResult.status_code))
5454
# get Token
@@ -90,7 +90,7 @@ def RetrieveIntraday(token, appid):
9090

9191
print('############### Sending Time Series Intraday request message to TRKD ###############')
9292
intradayResult = doSendRequest(intradayURL, intradayRequestMsg, headers)
93-
if intradayResult is not None and intradayResult.status_code == 200:
93+
if intradayResult and intradayResult.status_code == 200:
9494
print('Time Series Intraday response message: ')
9595
print(intradayResult.json())
9696

@@ -106,5 +106,5 @@ def RetrieveIntraday(token, appid):
106106
token = CreateAuthorization(username, password, appid)
107107
print('Token = %s' % (token))
108108
# if authentiacation success, continue subscribing Time Series intraday
109-
if token is not None:
109+
if token:
110110
RetrieveIntraday(token, appid)

trkd_newsheadline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def CreateAuthorization(username, password, appid):
4343
headers = {'content-type': 'application/json;charset=utf-8'}
4444
print('############### Sending Authentication request message to TRKD ###############')
4545
authenResult = doSendRequest(authenURL, authenMsg, headers)
46-
if authenResult is not None and authenResult.status_code == 200:
46+
if authenResult and authenResult.status_code == 200:
4747
print('Authen success')
4848
print('response status %s'%(authenResult.status_code))
4949
##get Token
@@ -76,7 +76,7 @@ def RetrieveNewsHeadline(token, appid):
7676

7777
print('############### Sending News Headline request message to TRKD ###############')
7878
newsResult = doSendRequest(newsURL, newsRequestMsg,headers)
79-
if newsResult is not None and newsResult.status_code == 200:
79+
if newsResult and newsResult.status_code == 200:
8080
print('News Headline response message: ')
8181
print(newsResult.json())
8282

@@ -95,5 +95,5 @@ def RetrieveNewsHeadline(token, appid):
9595
print('Token = %s'%(token))
9696

9797
## if authentiacation success, continue subscribing News Headline
98-
if token is not None:
98+
if token:
9999
RetrieveNewsHeadline(token,appid)

trkd_newsstory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def CreateAuthorization(username, password, appid):
4545
headers = {'content-type': 'application/json;charset=utf-8'}
4646
print('############### Sending Authentication request message to TRKD ###############')
4747
authenResult = doSendRequest(authenURL, authenMsg, headers)
48-
if authenResult is not None and authenResult.status_code == 200:
48+
if authenResult and authenResult.status_code == 200:
4949
print('Authen success')
5050
print('response status %s' % (authenResult.status_code))
5151
# get Token
@@ -69,7 +69,7 @@ def RetrieveNewsStory(token, appid):
6969

7070
print('############### Sending News Story request message to TRKD ###############')
7171
newsResult = doSendRequest(newsURL, newsRequestMsg, headers)
72-
if newsResult is not None and newsResult.status_code == 200:
72+
if newsResult and newsResult.status_code == 200:
7373
print('News Story response message: ')
7474
print(newsResult.json())
7575

@@ -88,5 +88,5 @@ def RetrieveNewsStory(token, appid):
8888
print('Token = %s' % (token))
8989

9090
# if authentiacation success, continue subscribing News Story
91-
if token is not None:
91+
if token:
9292
RetrieveNewsStory(token, appid)

trkd_onlinereport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def CreateAuthorization(username, password, appid):
4545
headers = {'content-type': 'application/json;charset=utf-8'}
4646
print('############### Sending Authentication request message to TRKD ###############')
4747
authenResult = doSendRequest(authenURL, authenMsg, headers)
48-
if authenResult is not None and authenResult.status_code == 200:
48+
if authenResult and authenResult.status_code == 200:
4949
print('Authen success')
5050
print('response status %s' % (authenResult.status_code))
5151
# get Token
@@ -71,7 +71,7 @@ def RetrieveOnlineReport(token, appid):
7171
print('############### Sending News - Online Report request message to TRKD ###############')
7272
onlinereportResult = doSendRequest(
7373
onlinereportURL, onelinereportRequestMsg, headers)
74-
if onlinereportResult is not None and onlinereportResult.status_code == 200:
74+
if onlinereportResult and onlinereportResult.status_code == 200:
7575
print('Online Report response message: ')
7676
print(onlinereportResult.json())
7777

@@ -90,5 +90,5 @@ def RetrieveOnlineReport(token, appid):
9090
print('Token = %s' % (token))
9191

9292
# if authentiacation success, continue subscribing Online Report
93-
if token is not None:
93+
if token:
9494
RetrieveOnlineReport(token, appid)

trkd_quote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def CreateAuthorization(username, password, appid):
4949
headers = {'content-type': 'application/json;charset=utf-8'}
5050
print('############### Sending Authentication request message to TRKD ###############')
5151
authenResult = doSendRequest(authenURL, authenMsg, headers)
52-
if authenResult is not None and authenResult.status_code == 200:
52+
if authenResult and authenResult.status_code == 200:
5353
print('Authen success')
5454
print('response status %s'%(authenResult.status_code))
5555
##get Token
@@ -87,7 +87,7 @@ def RetrieveQuotes(token, appid):
8787

8888
print('############### Sending Quote request message to TRKD ###############')
8989
quoteResult = doSendRequest(quoteURL, quoteRequestMsg,headers)
90-
if quoteResult is not None and quoteResult.status_code == 200:
90+
if quoteResult and quoteResult.status_code == 200:
9191
print('Quote response message: ')
9292
print(quoteResult.json())
9393

@@ -104,5 +104,5 @@ def RetrieveQuotes(token, appid):
104104
token = CreateAuthorization(username,password,appid)
105105
print('Token = %s'%(token))
106106
## if authentiacation success, continue subscribing Quote
107-
if token is not None:
107+
if token:
108108
RetrieveQuotes(token,appid)

0 commit comments

Comments
 (0)