Commit f5578dfab440350c0b144346f6902100c3f97f23

Authored by mykhaly
1 parent 79fbc9a2

Correct faker errors related to flake8 requirements

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