Commit f5578dfab440350c0b144346f6902100c3f97f23

Authored by mykhaly
1 parent 79fbc9a2

Correct faker errors related to flake8 requirements

Delete unused units field
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 -from faker import Faker  
3 from faker.providers import BaseProvider 2 from faker.providers import BaseProvider
4 from munch import Munch 3 from munch import Munch
5 from json import load 4 from json import load
@@ -13,7 +12,7 @@ def load_data_from_file(file_name): @@ -13,7 +12,7 @@ def load_data_from_file(file_name):
13 if file_name.endswith(".json"): 12 if file_name.endswith(".json"):
14 return Munch.fromDict(load(file_obj)) 13 return Munch.fromDict(load(file_obj))
15 elif file_name.endswith(".yaml"): 14 elif file_name.endswith(".yaml"):
16 - return fromYAML(file_obj) 15 + return Munch.fromYAML(file_obj)
17 16
18 17
19 class OP_Provider(BaseProvider): 18 class OP_Provider(BaseProvider):
@@ -22,11 +21,9 @@ class OP_Provider(BaseProvider): @@ -22,11 +21,9 @@ class OP_Provider(BaseProvider):
22 procuringEntities = __fake_data.procuringEntities 21 procuringEntities = __fake_data.procuringEntities
23 addresses = __fake_data.addresses 22 addresses = __fake_data.addresses
24 classifications = __fake_data.classifications 23 classifications = __fake_data.classifications
25 - units = __fake_data.units  
26 cpvs = __fake_data.cpvs 24 cpvs = __fake_data.cpvs
27 items_base_data = __fake_data.items_base_data 25 items_base_data = __fake_data.items_base_data
28 26
29 -  
30 @classmethod 27 @classmethod
31 def randomize_nb_elements(self, number=10, le=60, ge=140): 28 def randomize_nb_elements(self, number=10, le=60, ge=140):
32 """ 29 """
@@ -42,7 +39,6 @@ class OP_Provider(BaseProvider): @@ -42,7 +39,6 @@ class OP_Provider(BaseProvider):
42 raise Exception("Lower bound: {} is greater then upper: {}.".format(le, ge)) 39 raise Exception("Lower bound: {} is greater then upper: {}.".format(le, ge))
43 return int(number * self.random_int(min=le, max=ge) / 100) + 1 40 return int(number * self.random_int(min=le, max=ge) / 100) + 1
44 41
45 -  
46 @classmethod 42 @classmethod
47 def word(self): 43 def word(self):
48 """ 44 """
@@ -50,7 +46,6 @@ class OP_Provider(BaseProvider): @@ -50,7 +46,6 @@ class OP_Provider(BaseProvider):
50 """ 46 """
51 return self.random_element(self.word_list) 47 return self.random_element(self.word_list)
52 48
53 -  
54 @classmethod 49 @classmethod
55 def words(self, nb=3): 50 def words(self, nb=3):
56 """ 51 """
@@ -60,7 +55,6 @@ class OP_Provider(BaseProvider): @@ -60,7 +55,6 @@ class OP_Provider(BaseProvider):
60 """ 55 """
61 return [self.word() for _ in range(0, nb)] 56 return [self.word() for _ in range(0, nb)]
62 57
63 -  
64 @classmethod 58 @classmethod
65 def sentence(self, nb_words=5, variable_nb_words=True): 59 def sentence(self, nb_words=5, variable_nb_words=True):
66 """ 60 """
@@ -81,27 +75,22 @@ class OP_Provider(BaseProvider): @@ -81,27 +75,22 @@ class OP_Provider(BaseProvider):
81 75
82 return " ".join(words) + '.' 76 return " ".join(words) + '.'
83 77
84 -  
85 @classmethod 78 @classmethod
86 def title(self): 79 def title(self):
87 - return self.sentence(nb_words = 3)  
88 - 80 + return self.sentence(nb_words=3)
89 81
90 @classmethod 82 @classmethod
91 def description(self): 83 def description(self):
92 - return self.sentence(nb_words = 10)  
93 - 84 + return self.sentence(nb_words=10)
94 85
95 @classmethod 86 @classmethod
96 def procuringEntity(self): 87 def procuringEntity(self):
97 return self.random_element(self.procuringEntities) 88 return self.random_element(self.procuringEntities)
98 89
99 -  
100 @classmethod 90 @classmethod
101 def cpv(self): 91 def cpv(self):
102 return self.random_element(self.cpvs) 92 return self.random_element(self.cpvs)
103 93
104 -  
105 @classmethod 94 @classmethod
106 def fake_item(self, cpv_group=None): 95 def fake_item(self, cpv_group=None):
107 """ 96 """
@@ -132,7 +121,6 @@ class OP_Provider(BaseProvider): @@ -132,7 +121,6 @@ class OP_Provider(BaseProvider):
132 break 121 break
133 122
134 address = self.random_element(self.addresses) 123 address = self.random_element(self.addresses)
135 - unit = self.random_element(self.units)  
136 item = { 124 item = {
137 "description": item_base_data["description"], 125 "description": item_base_data["description"],
138 "classification": classification["classification"], 126 "classification": classification["classification"],
Please register or login to post a comment