Last change
on this file was 47f4eaf, checked in by Marko <Marko@…>, 2 years ago |
Final features implemented
|
-
Property mode
set to
100644
|
File size:
819 bytes
|
Line | |
---|
1 | import json
|
---|
2 | import unicodedata
|
---|
3 | import requests
|
---|
4 | import classes.phone
|
---|
5 | import sys
|
---|
6 |
|
---|
7 |
|
---|
8 | file_path = 'outputfile.txt'
|
---|
9 | sys.stdout = open(file_path, "w")
|
---|
10 |
|
---|
11 | phones = json.loads(requests.get('http://localhost:8080/phones').text)
|
---|
12 | offers = json.loads(requests.get('http://localhost:8080/alloffers').text)
|
---|
13 | phones.sort(key=lambda p: p['model'], reverse=True)
|
---|
14 | offers.sort(key=lambda o: o['offer_name'])
|
---|
15 |
|
---|
16 | for offer in offers:
|
---|
17 | flag = False
|
---|
18 | for phone in phones:
|
---|
19 | if phone['model'].lower() in offer['offer_name'].lower():
|
---|
20 | flag = True
|
---|
21 | # Add phone model to offer
|
---|
22 | requests.put('http://localhost:8080/phoneoffer/'+str(offer['id'])+'/addphonemodel/'+str(phone['id']))
|
---|
23 | break
|
---|
24 | if not flag:
|
---|
25 | requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(offer['id']))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.