Skip to content

Commit d6b4869

Browse files
authored
Merge pull request #8 from davidteather/nightly
V0.1.2
2 parents dca4b3e + 92e3e4a commit d6b4869

File tree

5 files changed

+102
-42
lines changed

5 files changed

+102
-42
lines changed

BackpackTF/account.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def __init__(self, client_id="", client_secret="", api_key=""):
2626
#
2727
# id - the listing's ID
2828
#
29-
30-
def getListing(self, listing_id=0):
29+
def get_listing(self, listing_id=0):
3130
from requests_oauthlib import OAuth2Session
3231
from oauthlib.oauth2 import TokenExpiredError
3332

@@ -46,12 +45,16 @@ def getListing(self, listing_id=0):
4645

4746
return r.text
4847

48+
# alias for compatibility with older versions
49+
# please use the new name, "get_listing"
50+
getListing = get_listing
51+
4952
#
5053
# Delete a listing by ID
5154
#
5255
# id - the listing's ID
5356
#
54-
def deleteListing(self, listing_id=0):
57+
def delete_listing(self, listing_id=0):
5558
from requests_oauthlib import OAuth2Session
5659
from oauthlib.oauth2 import TokenExpiredError
5760

@@ -70,6 +73,10 @@ def deleteListing(self, listing_id=0):
7073

7174
return r.text
7275

76+
# alias for compatibility with older versions
77+
# please use the new name, "delete_listing"
78+
deleteListing = delete_listing
79+
7380
#
7481
# Create a listing
7582
#
@@ -92,8 +99,7 @@ def deleteListing(self, listing_id=0):
9299
#
93100
# returns int: 0 or 1, states the success of the listing
94101
#
95-
96-
def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craftable=1, priceindex=0, offers=0, buyout=1, promoted=0, details="", currencies={"metal": 0}, account_token=""):
102+
def create_listing(self, intent=0, id=0, quality=6, item_name="", craftable=1, priceindex=0, offers=0, buyout=1, promoted=0, details="", currencies={"metal": 0}, account_token=""):
97103
from requests_oauthlib import OAuth2Session
98104
from oauthlib.oauth2 import BackendApplicationClient
99105
from oauthlib.oauth2 import TokenExpiredError
@@ -147,6 +153,10 @@ def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craf
147153
except:
148154
return jsonResponse
149155

156+
# alias for compatibility with older versions
157+
# please use the new name, "create_listing"
158+
createListing = create_listing
159+
150160
#
151161
# This function searches for classified listings
152162
#
@@ -168,7 +178,7 @@ def createListing(self, intent=0, id=0, quality=6, item_name="Haunted Hat", craf
168178
# sheen - 0-7, in order team shine, deadly daffodil, manndarin, mean green, agonizing emerald, villainous violet, hot rod
169179
# killstreaker - the id of the killstreaker
170180
#
171-
def search_Classifieds(self, intent="dual", page_size=10, fold=1, item_name="Soda Popper", steamid="", tradable="", craftable="", australium="", wear_tier="", quality="",
181+
def search_classifieds(self, intent="dual", page_size=10, fold=1, item_name="", steamid="", tradable="", craftable="", australium="", wear_tier="", quality="",
172182
paint="", particle="", killstreak_tier="", sheen="", killstreaker="", page=0, texture_name=""):
173183
import requests
174184
import urllib.parse
@@ -203,6 +213,10 @@ def search_Classifieds(self, intent="dual", page_size=10, fold=1, item_name="Sod
203213

204214
return jsondata
205215

216+
# alias for compatibility with older verisions
217+
# please use the new function name, "search_classifieds" (lowercase c)
218+
search_Classifieds = search_classifieds
219+
206220

207221
#
208222
# This function extracts the trade url.
@@ -239,4 +253,4 @@ def extract_trade_url(self, listingJSON, proxy=None):
239253
url = tree.xpath("//li[@id='listing-" + listingJSON['id'] + "']/div[@class='listing-item']/div")[0].get('data-listing_offers_url')
240254
return url
241255
except:
242-
raise IndexError('List index out of range')
256+
raise IndexError('List index out of range')

BackpackTF/currency.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def __init__(self, apikey=""):
1515
#
1616
# Function Returns A JSON of the value of currencies
1717
#
18-
19-
def getCurrencies(self):
18+
def get_currencies(self):
2019
import requests
2120
import json
2221

@@ -28,6 +27,10 @@ def getCurrencies(self):
2827
else:
2928
raise Exception('Your API key is invalid')
3029

30+
# alias for compatibility with older versions
31+
# please use the new name, "get_currencies"
32+
getCurrencies = get_currencies
33+
3134
#
3235
# Gets Price History of a specific item in an array of previous values
3336
#
@@ -42,7 +45,7 @@ def getCurrencies(self):
4245
# here's a link to an item http://prntscr.com/pf2s0h
4346
#
4447

45-
def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tradable=1, priceIndex=0):
48+
def price_history(self, name="", quality="Unique", craftable=1, tradable=1, priceIndex=0):
4649
import requests
4750
import urllib.parse
4851
import json
@@ -70,6 +73,10 @@ def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1,
7073

7174
if success:
7275
return jsondata['response']['history']
76+
77+
# alias for compatibility with older versions
78+
# please use the new name, "price_history"
79+
priceHistory = price_history
7380

7481
#
7582
# Gets Price of a specific item
@@ -81,7 +88,7 @@ def priceHistory(self, name="Pyromancer's Mask", quality="Unique", craftable=1,
8188
# PriceIndex - Not really sure to be honest
8289
#
8390

84-
def itemPrice(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tradable=1, priceIndex=0):
91+
def item_price(self, name="", quality="Unique", craftable=1, tradable=1, priceIndex=0):
8592
import requests
8693
import urllib.parse
8794
import json
@@ -110,13 +117,17 @@ def itemPrice(self, name="Pyromancer's Mask", quality="Unique", craftable=1, tra
110117
if success:
111118
return jsondata['response']['history'][len(jsondata['response']['history']) - 1]
112119

120+
# alias for compatibility with older versions
121+
# please use the new name, "item_price"
122+
itemPrice = item_price
123+
113124
#
114125
# Gets all prices, requires an elevated API key
115126
#
116127
# Since - Only prices that have been updated since the unix EPOCH will be shown
117128
#
118129

119-
def getAllPrices(self, raw=2, since=0):
130+
def get_all_prices(self, raw=2, since=0):
120131
import requests
121132
import json
122133

@@ -131,3 +142,7 @@ def getAllPrices(self, raw=2, since=0):
131142

132143
if success:
133144
return jsondata['response']
145+
146+
# alias for compatibility with older versions
147+
# please use the new name, "get_all_prices"
148+
getAllPrices = get_all_prices

BackpackTF/miscutils.py

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,105 +63,136 @@ def __init__(self):
6363
#
6464
# Converts quality string to quality int
6565
#
66-
def quality_String_To_Int(self, string):
66+
def quality_string_to_int(self, string):
6767
try:
6868
return self.qualitiesObj[string.lower()]
6969
except:
7070
return ""
7171

72+
# alias for compatibility with older versions
73+
# please use the new name, "quality_string_to_int"
74+
quality_String_To_Int = quality_string_to_int
75+
7276
#
7377
# Converts particle string to particle int
7478
#
75-
def particle_String_To_Int(self, string):
79+
def particle_string_to_int(self, string):
7680
try:
7781
return self.particleObj[string.lower()]
7882
except:
7983
return ""
8084

85+
# alias for compatibility with older versions
86+
# please use the new name, "particle_string_to_int"
87+
particle_String_To_Int = particle_string_to_int
88+
8189
#
8290
# Converts rarity string to rarity int
8391
#
84-
def rarity_String_To_Int(self, string):
92+
def rarity_string_to_int(self, string):
8593
try:
8694
return self.raritiesObj[string.lower()]
8795
except:
8896
return ""
8997

98+
# alias for compatibility with older versions
99+
# please use the new name, "rarity_string_to_int"
100+
rarity_String_To_Int = rarity_string_to_int
90101

91102
#
92103
# Origin quality string to origin int
93104
#
94-
def origin_String_To_Int(self, string):
105+
def origin_string_to_int(self, string):
95106
try:
96107
return self.originsObj[string.lower()]
97108
except:
98109
return ""
99110

111+
# alias for compatibility with older versions
112+
# please use the new name, "origin_string_to_int"
113+
origin_String_To_Int = origin_string_to_int
100114

101115
#
102116
# Converts wear_tier string to wear_tier int
103117
#
104-
def wear_tier_String_To_Int(self, string):
118+
def wear_tier_string_to_int(self, string):
105119
try:
106120
return self.wear_tiersObj[string.lower()]
107121
except:
108122
return ""
109123

124+
# alias for compatibility with older versions
125+
# please use the new name, "wear_tier_string_to_int"
126+
wear_tier_String_To_Int = wear_tier_string_to_int
110127

111128
#
112129
# Converts killstreaker string to killstreaker int
113130
#
114-
def killstreaker_String_To_Int(self, string):
131+
def killstreaker_string_to_int(self, string):
115132
try:
116133
return self.killstreakers[string.lower()]
117134
except:
118135
return ""
119136

120-
137+
# alias for compatibility with older versions
138+
# please use the new name, "killstreaker_string_to_int"
139+
killstreaker_String_To_Int = killstreaker_string_to_int
121140

122141
#
123142
# Converts sheen string to sheen int
124143
#
125-
def sheen_String_To_Int(self, string):
144+
def sheen_string_to_int(self, string):
126145
try:
127146
return self.sheensObj[string.lower()]
128147
except:
129148
return ""
130149

150+
# alias for compatibility with older versions
151+
# please use the new name, "sheen_string_to_int"
152+
sheen_String_To_Int = sheen_string_to_int
131153

132154
#
133155
# Converts killstreak_tier string to killstreak_tier int
134156
#
135-
def killstreak_tier_String_To_Int(self, string):
157+
def killstreak_tier_string_to_int(self, string):
136158
try:
137159
return self.killstreak_tiers[string.lower()]
138160
except:
139161
return ""
140162

163+
# alias for compatibility with older versions
164+
# please use the new name, "killstreak_tier_string_to_int"
165+
killstreak_tier_String_To_Int = killstreak_tier_string_to_int
141166

142167
#
143168
# Converts strange_part string to strange_part int
144169
#
145-
def strange_parts_String_To_Int(self, string):
170+
def strange_parts_string_to_int(self, string):
146171
try:
147172
return self.strange_partsObj[string.lower()]
148173
except:
149174
return ""
150175

176+
# alias for compatibility with older versions
177+
# please use the new name, "strange_parts_string_to_int"
178+
strange_parts_String_To_Int = strange_parts_string_to_int
151179

152180
#
153181
# Converts paint string to paint int
154182
#
155-
def paint_String_To_Int(self, string):
183+
def paint_string_to_int(self, string):
156184
try:
157185
return self.paintsObj[string.lower()]
158186
except:
159187
return ""
160188

189+
# alias for compatibility with older versions
190+
# please use the new name, "paint_string_to_int"
191+
paint_String_To_Int = paint_string_to_int
161192

162193
#
163194
# Converts steam ID into the account_id account ID is used in trading requests
164195
#
165196
def steam_id_to_account_id(self, steam_id):
166197
import struct
167-
return str(struct.unpack('>L', int(steam_id).to_bytes(8, byteorder='big')[4:])[0])
198+
return str(struct.unpack('>L', int(steam_id).to_bytes(8, byteorder='big')[4:])[0])

0 commit comments

Comments
 (0)