Commit 2eafc3bfcad437a5309c74dc7210ed6ca1bde3d9
1 parent
94d0a38d
- added: get tenderData from tenderUaId
Showing
1 changed file
with
53 additions
and
11 deletions
| ... | ... | @@ -4,6 +4,7 @@ import copy |
| 4 | 4 | import urllib |
| 5 | 5 | import urllib3 |
| 6 | 6 | import string |
| 7 | +import requests | |
| 7 | 8 | |
| 8 | 9 | import dateutil.parser |
| 9 | 10 | from iso8601 import parse_date |
| ... | ... | @@ -13,6 +14,7 @@ import pytz |
| 13 | 14 | |
| 14 | 15 | TZ = pytz.timezone('Europe/Kiev') |
| 15 | 16 | |
| 17 | + | |
| 16 | 18 | def get_library(): |
| 17 | 19 | return BuiltIn().get_library_instance('Selenium2Library') |
| 18 | 20 | |
| ... | ... | @@ -184,22 +186,23 @@ def procuring_entity_name(tender_data): |
| 184 | 186 | tender_data.data.procuringEntity.identifier['legalName'] = u"ТОВ \"ПлейТендер\"" |
| 185 | 187 | tender_data.data.procuringEntity.identifier['legalName_en'] = u"TOV \"playtender\"" |
| 186 | 188 | if 'address' in tender_data.data.procuringEntity: |
| 187 | - tender_data.data.procuringEntity.address['region'] = u"м. Київ" | |
| 188 | - tender_data.data.procuringEntity.address['postalCode'] = u"123123" | |
| 189 | - tender_data.data.procuringEntity.address['locality'] = u"Київ" | |
| 190 | - tender_data.data.procuringEntity.address['streetAddress'] = u"address" | |
| 189 | + tender_data.data.procuringEntity.address['region'] = u"м. Київ" | |
| 190 | + tender_data.data.procuringEntity.address['postalCode'] = u"123123" | |
| 191 | + tender_data.data.procuringEntity.address['locality'] = u"Київ" | |
| 192 | + tender_data.data.procuringEntity.address['streetAddress'] = u"address" | |
| 191 | 193 | if 'contactPoint' in tender_data.data.procuringEntity: |
| 192 | - tender_data.data.procuringEntity.contactPoint['name'] = u"Test ЗамовникОборони" | |
| 193 | - tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test" | |
| 194 | - tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua" | |
| 195 | - tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111" | |
| 196 | - tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua" | |
| 194 | + tender_data.data.procuringEntity.contactPoint['name'] = u"Test ЗамовникОборони" | |
| 195 | + tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test" | |
| 196 | + tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua" | |
| 197 | + tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111" | |
| 198 | + tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua" | |
| 197 | 199 | if 'buyers' in tender_data.data: |
| 198 | 200 | tender_data.data.buyers[0]['name'] = u"ТОВ \"ПлейТендер\"" |
| 199 | 201 | tender_data.data.buyers[0].identifier['id'] = u"1234567890-playtender" |
| 200 | 202 | tender_data.data.buyers[0].identifier['legalName'] = u"ТОВ \"ПлейТендер\"" |
| 201 | 203 | return tender_data |
| 202 | 204 | |
| 205 | + | |
| 203 | 206 | # prepare data |
| 204 | 207 | def prepare_procuring_entity_data(data): |
| 205 | 208 | try: |
| ... | ... | @@ -254,7 +257,8 @@ def generate_dictionary_from_field_path_and_value(path, value): |
| 254 | 257 | value = generate_dictionary_from_field_path_and_value('.'.join(path_keys_list), value) |
| 255 | 258 | indexRegex = re.compile(r'(\[(\d+)\]$)') |
| 256 | 259 | matchObj = indexRegex.search(key) |
| 257 | - print matchObj | |
| 260 | ||
| 261 | + matchObj | |
| 258 | 262 | if matchObj: |
| 259 | 263 | key = indexRegex.sub('', key) |
| 260 | 264 | value['list_index'] = matchObj.group(2) |
| ... | ... | @@ -364,23 +368,29 @@ def convert_date_to_string_contr(date): |
| 364 | 368 | date = date.strftime("%d.%m.%Y %H:%M:%S") |
| 365 | 369 | return date |
| 366 | 370 | |
| 371 | + | |
| 367 | 372 | def get_value_minimalStepPercentage(value): |
| 368 | 373 | value = value / 100 |
| 369 | 374 | return value |
| 370 | 375 | |
| 376 | + | |
| 371 | 377 | def set_value_minimalStepPercentage(value): |
| 372 | 378 | value = value * 100 |
| 373 | 379 | return value |
| 374 | 380 | |
| 381 | + | |
| 375 | 382 | def convert_esco__float_to_string(number): |
| 376 | 383 | return '{0:.5f}'.format(float(number)) |
| 377 | 384 | |
| 385 | + | |
| 378 | 386 | def convert_string_to_float(number): |
| 379 | 387 | return float(number) |
| 380 | 388 | |
| 389 | + | |
| 381 | 390 | def download_file(url, file_name, output_dir): |
| 382 | 391 | urllib.urlretrieve(url, ('{}/{}'.format(output_dir, file_name))) |
| 383 | 392 | |
| 393 | + | |
| 384 | 394 | def parse_complaintPeriod_date(date_string): |
| 385 | 395 | date_str = datetime.strptime(date_string, "%d.%m.%Y %H:%M") |
| 386 | 396 | date = datetime(date_str.year, date_str.month, date_str.day, date_str.hour, date_str.minute, date_str.second, |
| ... | ... | @@ -388,13 +398,15 @@ def parse_complaintPeriod_date(date_string): |
| 388 | 398 | date = TZ.localize(date).isoformat() |
| 389 | 399 | return date |
| 390 | 400 | |
| 401 | + | |
| 391 | 402 | def parse_deliveryPeriod_date1(date): |
| 392 | 403 | date = dateutil.parser.parse(date) |
| 393 | 404 | date = date.strftime("%d.%m.%Y") |
| 394 | 405 | return date |
| 395 | 406 | |
| 407 | + | |
| 396 | 408 | def parse_deliveryPeriod_date(date_string): |
| 397 | -# date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00") | |
| 409 | + # date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00") | |
| 398 | 410 | if '+03' in date_string: |
| 399 | 411 | date_str = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S+03:00") |
| 400 | 412 | else: |
| ... | ... | @@ -403,9 +415,39 @@ def parse_deliveryPeriod_date(date_string): |
| 403 | 415 | date = date.strftime("%d.%m.%Y") |
| 404 | 416 | return date |
| 405 | 417 | |
| 418 | + | |
| 406 | 419 | def split_joinvalue(str_value): |
| 407 | 420 | str_value = str_value.split() |
| 408 | 421 | str_value = ''.join(str_value) |
| 409 | 422 | print(str_value) |
| 410 | 423 | str_value.replace(" ", "") |
| 411 | 424 | return str_value |
| 425 | + | |
| 426 | + | |
| 427 | +def doGetRequest(url, data): | |
| 428 | + r = requests.get(url, params=data) | |
| 429 | + response = {} | |
| 430 | + response['status_code'] = r.status_code | |
| 431 | + response['reason'] = r.reason | |
| 432 | + response['content'] = r.content | |
| 433 | + response['json'] = r.json() | |
| 434 | + return response | |
| 435 | + | |
| 436 | + | |
| 437 | +def getTenderDataByTenderUaId(apiBaseUrl, tenderUaId): | |
| 438 | + requestData = {"opt_fields": "tenderID", "descending": "1", "mode": "_all_"} | |
| 439 | + updatesResponse = doGetRequest(apiBaseUrl.strip("/") + "/tenders", data=requestData) | |
| 440 | + if "json" not in updatesResponse: | |
| 441 | + print('json key not found') | |
| 442 | + return {} | |
| 443 | + tenderId = None | |
| 444 | + print("lastTenders:") | |
| 445 | + print(updatesResponse['json']['data']) | |
| 446 | + for item in updatesResponse['json']['data']: | |
| 447 | + if tenderUaId == item['tenderID']: | |
| 448 | + tenderId = item['id'] | |
| 449 | + break | |
| 450 | + if tenderId is None: | |
| 451 | + return {} | |
| 452 | + tenderDataResponse = doGetRequest(apiBaseUrl.strip("/") + "/tenders/" + tenderId, data={}) | |
| 453 | + return tenderDataResponse['json'] | ... | ... |
Please
register
or
login
to post a comment