소스 검색

Pylint corrections.

Marco Quezada 10 년 전
부모
커밋
fd59723d37
3개의 변경된 파일60개의 추가작업 그리고 61개의 파일을 삭제
  1. 25 30
      hackathon_starter/hackathon/scripts/quandl.py
  2. 33 29
      hackathon_starter/hackathon/scripts/steam.py
  3. 2 2
      hackathon_starter/hackathon/views.py

+ 25 - 30
hackathon_starter/hackathon/scripts/quandl.py

@@ -1,37 +1,32 @@
-'''Module containing a handful of methods for 
+'''Module containing a handful of methods for
 aggregating data from markets throughout the world'''
 
 import requests
 import simplejson as json
-from datetime import datetime
 
 APIKEY = ' fANs6ykrCdAxas7zpMz7'
 
-def DOWJonesIndustrialavg(APIKEY):
-    #Returns JSON data of the Dow Jones Average. 
-    parameters = {
-    'rows' : 1, 
-    'auth_token' : APIKEY,
-    }
-    r = requests.get('https://www.quandl.com/api/v1/datasets/BCB/UDJIAD1.json?',params=parameters)
-    d = json.loads(r.content)
-    return d['data']
-def SnP500Indexpull(APIKEY):
-    #Returns JSON data of the S&P 500 Index. 
-    parameters = {
-    'rows' : 1, 
-    'auth_token' : APIKEY,
-    }
-    r = requests.get('https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_GSPC.json?',params=parameters)
-    d = json.loads(r.content)
-    return d['data']
-def Nasdaqpull(APIKEY):
-    #Returns JSON data of the Nasdaq Index. 
-    parameters = {
-    'rows' : 1, 
-    'auth_token' : APIKEY,
-    }
-    r = requests.get('https://www.quandl.com/api/v1/datasets/GOOG/NASDAQ_SWTX.json?',params=parameters)
-    d = json.loads(r.content)
-    return d['data']
-# print DOWJonesIndustrialavg(APIKEY)
+def dowjonesindustrialavg(APIKEY):
+    '''Returns JSON data of the Dow Jones Average.'''
+    parameters = {'rows' : 1, 'auth_token' : APIKEY}
+    apiurl = 'https://www.quandl.com/api/v1/datasets/BCB/UDJIAD1.json?'
+    reap = requests.get(apiurl, params=parameters)
+    desu = json.loads(reap.content)
+    return desu['data']
+
+def snp500indexpull(APIKEY):
+    '''Returns JSON data of the S&P 500 Index.'''
+    parameters = {'rows' : 1, 'auth_token' : APIKEY}
+    apiurl = 'https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_GSPC.json?'
+    reap = requests.get(apiurl, params=parameters)
+    desu = json.loads(reap.content)
+    return desu['data']
+
+def nasdaqpull(APIKEY):
+    '''Returns JSON data of the Nasdaq Index.'''
+    parameters = {'rows' : 1, 'auth_token' : APIKEY}
+    apiurl = 'https://www.quandl.com/api/v1/datasets/GOOG/NASDAQ_SWTX.json?'
+    reap = requests.get(apiurl, params=parameters)
+    desu = json.loads(reap.content)
+    return desu['data']
+    

+ 33 - 29
hackathon_starter/hackathon/scripts/steam.py

@@ -1,46 +1,50 @@
-# pylint: disable=C0303
-
+'''This script contains methods belonging to the Steam web API
+that can collect information based on an user's gaming library.'''
 import requests
 import json
 
-SteamUN = "Marorin"
-key = '231E98D442E52B87110816C3D5114A1D'
+steamun = "Marorin"
+apikey = '231E98D442E52B87110816C3D5114A1D'
 
-def gamesPulling(steamID,key):
-    # Returns the JSON data from the Steam API based of one's 
-    # Steam ID number and returns a dictionary of gameids and minutes played.
+def gamespulling(steamid, apikey):
+    '''Returns the JSON data from the Steam API based of one's
+    Steam ID number and returns a dictionary of
+    gameids and minutes played.'''
     steaminfo = {
-        'key': key, 
-        'steamid': steamID,
+        'key': apikey,
+        'steamid': steamid,
         'format':'JSON',
         'include_appinfo':'1'
     }
-    r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/', params=steaminfo)
-    d = json.loads(r.content)
-    return d['response']['games']
- 
-def steamIDPulling(SteamUN,key):
-    #Pulls out and returns the steam id number for use in steam queries.
-    steaminfo = {'key': key,'vanityurl': SteamUN}
-    a = requests.get('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/', params=steaminfo)
-    k = json.loads(a.content)
-    SteamID = k['response']['steamid']
-    
-    return SteamID
-def steamlibrarypull(steamID, key):
-#Pulls out a CSV of Steam appids.
+    apiurl = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/'
+    reap = requests.get(apiurl, params=steaminfo)
+    desu = json.loads(reap.content)
+    return desu['response']['games']
+
+def steamidpulling(steamun, apikey):
+    '''Pulls out and returns the steam id number for use in steam queries.'''
+    steaminfo = {'key': apikey, 'vanityurl': steamun}
+    apiurl = 'http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/'
+    allo = requests.get(apiurl, params=steaminfo)
+    kuzu = json.loads(allo.content)
+    steamid = kuzu['response']['steamid']
+    return steamid
+def steamlibrarypull(steamid, apikey):
+    '''Pulls out a CSV of Steam appids.'''
     steaminfo = {
-        'key': key,
-        'steamid': steamID,
+        'key': apikey,
+        'steamid': steamid,
         'format':'JSON',
         'include_appinfo':'1'
     }
-    r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/', params=steaminfo)
-    d = json.loads(r.content)
-    response = d['response']['games']
+    apiurl = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/'
+    reap = requests.get(apiurl, params=steaminfo)
+    desu = json.loads(reap.content)
+    response = desu['response']['games']
     games = {}
     for game in response:
-        getprice = requests.get('http://store.steampowered.com/api/appdetails/?appids=%d&filters=price_overview&cc=us' % game['appid'])
+        apiurl = 'http://store.steampowered.com/api/appdetails/?appids=%d&filters=price_overview&cc=us'
+        getprice = requests.get(apiurl % game['appid'])
         if getprice.status_code == 200:
             rjson = json.loads(getprice.text)
             # use the appid to fetch the value and convert to decimal

+ 2 - 2
hackathon_starter/hackathon/views.py

@@ -60,8 +60,8 @@ def steam(request):
     #Should link to test of Steam API example.
     key = '231E98D442E52B87110816C3D5114A1D'
     SteamUN = "Marorin"
-    steamID = steamIDPulling(SteamUN, key)
-    game = gamesPulling(steamID, key)
+    steamID = steamidpulling(SteamUN, key)
+    game = gamespulling(steamID, key)
     return render(request,'hackathon/steam.html', {"game": game })