playtender_service.py
4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- coding: utf-8 -
from iso8601 import parse_date
from datetime import datetime
from robot.libraries.BuiltIn import BuiltIn
from robot.output import librarylogger
import urllib
import urllib3
def get_library():
return BuiltIn().get_library_instance('Selenium2Library')
def get_webdriver_instance():
return get_library()._current_browser()
def convert_datetime_for_delivery(isodate):
iso_dt = parse_date(isodate)
date_string = iso_dt.strftime("%Y-%m-%d %H:%M")
return date_string
def convert_isodate_to_site_date(isodate):
iso_dt = parse_date(isodate)
date_string = iso_dt.strftime("%d.%m.%Y")
return date_string
def convert_isodate_to_site_date_plan(isodate):
iso_dt = parse_date(isodate)
date_string = iso_dt.strftime("%m.%Y")
return date_string
def convert_isodate_to_site_datetime(isodate):
iso_dt = parse_date(isodate)
date_string = iso_dt.strftime("%d.%m.%Y %H:%M")
return date_string
def convert_date_for_compare(datestr):
return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M")
def procuring_entity_name(tender_data):
tender_data.data.procuringEntity['name'] = u"ТОВ \"ПлейТендер\""
tender_data.data.procuringEntity['name_en'] = u"TOV \"playtender\""
tender_data.data.procuringEntity.identifier['id'] = u"1234567890-playtender"
tender_data.data.procuringEntity.identifier['legalName'] = u"ТОВ \"ПлейТендер\""
tender_data.data.procuringEntity.identifier['legalName_en'] = u"TOV \"playtender\""
if 'address' in tender_data.data.procuringEntity:
tender_data.data.procuringEntity.address['region'] = u"Житомирська область"
tender_data.data.procuringEntity.address['postalCode'] = u"123123"
tender_data.data.procuringEntity.address['locality'] = u"населений пункт"
tender_data.data.procuringEntity.address['streetAddress'] = u"адреса"
if 'contactPoint' in tender_data.data.procuringEntity:
tender_data.data.procuringEntity.contactPoint['name'] = u"Замовник Тест"
tender_data.data.procuringEntity.contactPoint['name_en'] = u"Test"
tender_data.data.procuringEntity.contactPoint['email'] = u"chuzhin@mail.ua"
tender_data.data.procuringEntity.contactPoint['telephone'] = u"+3801111111111"
tender_data.data.procuringEntity.contactPoint['url'] = u"http://playtender.com.ua"
return tender_data
def split_take_item(value, separator, index):
librarylogger.console('split_take_item')
librarylogger.console(value)
librarylogger.console(separator)
librarylogger.console(index)
return value.split(separator)[int(index)]
def split_take_slice(value, separator, _from=None, to=None):
librarylogger.console(value)
librarylogger.console(separator)
librarylogger.console(_from)
librarylogger.console(to)
l = value.split(separator)
if to:
l = l[:int(to)]
if _from:
l = l[int(_from):]
return l
def split_take_slice_from(value, separator, _from):
librarylogger.console('split_take_slice_from')
return split_take_slice(value, separator, _from)
def split_take_slice_to(value, separator, to):
librarylogger.console('split_take_slice_to')
return split_take_slice(value, separator, to=to)
def join(l, separator):
librarylogger.console('join')
librarylogger.console(l)
return separator.join(l)
def get_invisible_text(locator):
element = get_library()._element_find(locator, False, True)
text = get_webdriver_instance().execute_script('return jQuery(arguments[0]).text();', element)
return text
def get_text_excluding_children(locator):
element = get_library()._element_find(locator, False, True)
text = get_webdriver_instance().execute_script("""
return jQuery(arguments[0]).contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).text();
""", element)
return text.strip()
def convert_float_to_string(number):
return repr(float(number));
def convert_date_for_compare_ex(datestr):
return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M+02:00")
def convert_date_for_compare_ex2(datestr):
return datetime.strptime(datestr, "%d.%m.%Y %H:%M").strftime("%Y-%m-%d %H:%M+02:00")
def download_file(url, file_name, output_dir):
urllib.urlretrieve(url, ('{}/{}'.format(output_dir, file_name)))
def multiply_hundred(number):
return number*100
def inject_urllib3():
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()