Commit 8c314072bea99cc51bc2ab4422f7de2b950d2b69
Committed by
GitHub
Merge pull request #1014 from ivanka12/master
change generation of items.classification
Showing
2 changed files
with
15 additions
and
9 deletions
| ... | ... | @@ -26,6 +26,7 @@ class OP_Provider(BaseProvider): |
| 26 | 26 | addresses = _fake_data.addresses |
| 27 | 27 | classifications = _fake_data.classifications |
| 28 | 28 | cpvs = _fake_data.cpvs |
| 29 | + moz_cpvs = _fake_data.moz_cpvs | |
| 29 | 30 | items_base_data = _fake_data.items_base_data |
| 30 | 31 | rationale_types = _fake_data.rationale_types |
| 31 | 32 | |
| ... | ... | @@ -121,8 +122,11 @@ class OP_Provider(BaseProvider): |
| 121 | 122 | in the beginning of each cpv id. |
| 122 | 123 | """ |
| 123 | 124 | item_base_data = None |
| 125 | + cpv = None | |
| 124 | 126 | if cpv_group is None: |
| 125 | - item_base_data = self.random_element(self.items_base_data) | |
| 127 | + cpv = self.random_element(self.cpvs) | |
| 128 | + elif cpv_group == 336: | |
| 129 | + cpv = self.random_element(self.moz_cpvs) | |
| 126 | 130 | else: |
| 127 | 131 | cpv_group = str(cpv_group) |
| 128 | 132 | similar_cpvs = [] |
| ... | ... | @@ -130,12 +134,12 @@ class OP_Provider(BaseProvider): |
| 130 | 134 | if cpv_element.startswith(cpv_group): |
| 131 | 135 | similar_cpvs.append(cpv_element) |
| 132 | 136 | cpv = self.random_element(similar_cpvs) |
| 133 | - for entity in self.items_base_data: | |
| 134 | - if entity["cpv_id"] == cpv: | |
| 135 | - item_base_data = entity | |
| 136 | - break | |
| 137 | - if not item_base_data: | |
| 138 | - raise ValueError('unable to find an item with CPV ' + cpv) | |
| 137 | + for entity in self.items_base_data: | |
| 138 | + if entity["cpv_id"] == cpv: | |
| 139 | + item_base_data = entity | |
| 140 | + break | |
| 141 | + if not item_base_data: | |
| 142 | + raise ValueError('unable to find an item with CPV ' + cpv) | |
| 139 | 143 | |
| 140 | 144 | # choose appropriate additional classification for item_base_data's cpv |
| 141 | 145 | additional_class = [] | ... | ... |
| ... | ... | @@ -7875,14 +7875,16 @@ |
| 7875 | 7875 | "30192130-1", |
| 7876 | 7876 | "30197600-2", |
| 7877 | 7877 | "30199000-0", |
| 7878 | + "99999999-9" | |
| 7879 | + ], | |
| 7880 | + "moz_cpvs": [ | |
| 7878 | 7881 | "33615100-5", |
| 7879 | 7882 | "33622200-8", |
| 7880 | 7883 | "33632100-0", |
| 7881 | 7884 | "33612000-3", |
| 7882 | 7885 | "33692500-2", |
| 7883 | 7886 | "33692100-8", |
| 7884 | - "33600000-6", | |
| 7885 | - "99999999-9" | |
| 7887 | + "33600000-6" | |
| 7886 | 7888 | ], |
| 7887 | 7889 | "items_base_data": [ |
| 7888 | 7890 | { | ... | ... |
Please
register
or
login
to post a comment