ofd-validator 0.4.0__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/Cargo.lock +3 -3
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/PKG-INFO +1 -1
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/Cargo.toml +1 -1
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-python/Cargo.toml +1 -1
- ofd_validator-0.5.0/crates/ofd-validator-python/src/orchestrator.rs +171 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/pyproject.toml +1 -1
- ofd_validator-0.4.0/crates/ofd-validator-python/src/orchestrator.rs +0 -139
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/Cargo.toml +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/README.md +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/lib.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/orchestrator.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/schema_cache.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/types.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/util.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/folder_name.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/gtin.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/json_validator.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/logo_validator.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/missing_files.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/mod.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/store_id.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-python/src/lib.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-python/src/types.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-python/src/util.rs +0 -0
- {ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-python/src/validators.rs +0 -0
|
@@ -805,7 +805,7 @@ dependencies = [
|
|
|
805
805
|
|
|
806
806
|
[[package]]
|
|
807
807
|
name = "ofd-validator-core"
|
|
808
|
-
version = "0.
|
|
808
|
+
version = "0.5.0"
|
|
809
809
|
dependencies = [
|
|
810
810
|
"image",
|
|
811
811
|
"jsonschema",
|
|
@@ -818,7 +818,7 @@ dependencies = [
|
|
|
818
818
|
|
|
819
819
|
[[package]]
|
|
820
820
|
name = "ofd-validator-js"
|
|
821
|
-
version = "0.
|
|
821
|
+
version = "0.5.0"
|
|
822
822
|
dependencies = [
|
|
823
823
|
"napi",
|
|
824
824
|
"napi-build",
|
|
@@ -831,7 +831,7 @@ dependencies = [
|
|
|
831
831
|
|
|
832
832
|
[[package]]
|
|
833
833
|
name = "ofd-validator-python"
|
|
834
|
-
version = "0.
|
|
834
|
+
version = "0.5.0"
|
|
835
835
|
dependencies = [
|
|
836
836
|
"ofd-validator-core",
|
|
837
837
|
"pyo3",
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
use std::path::PathBuf;
|
|
2
|
+
|
|
3
|
+
use pyo3::prelude::*;
|
|
4
|
+
use rayon::ThreadPoolBuilder;
|
|
5
|
+
|
|
6
|
+
use ofd_validator_core as core;
|
|
7
|
+
|
|
8
|
+
use crate::types::ValidationResult;
|
|
9
|
+
use crate::util::log_step;
|
|
10
|
+
|
|
11
|
+
/// Run the closure on a custom Rayon thread pool when `max_workers` is set,
|
|
12
|
+
/// otherwise use the global pool (default Rayon behaviour).
|
|
13
|
+
fn with_thread_pool<F, R>(max_workers: Option<usize>, f: F) -> R
|
|
14
|
+
where
|
|
15
|
+
F: FnOnce() -> R + Send,
|
|
16
|
+
R: Send,
|
|
17
|
+
{
|
|
18
|
+
match max_workers {
|
|
19
|
+
Some(n) if n > 0 => {
|
|
20
|
+
let pool = ThreadPoolBuilder::new()
|
|
21
|
+
.num_threads(n)
|
|
22
|
+
.build()
|
|
23
|
+
.expect("failed to build Rayon thread pool");
|
|
24
|
+
pool.install(f)
|
|
25
|
+
}
|
|
26
|
+
_ => f(),
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[pyfunction]
|
|
31
|
+
#[pyo3(signature = (data_dir, stores_dir, schemas_dir=None, max_workers=None))]
|
|
32
|
+
pub fn validate_all(
|
|
33
|
+
py: Python<'_>,
|
|
34
|
+
data_dir: &str,
|
|
35
|
+
stores_dir: &str,
|
|
36
|
+
schemas_dir: Option<&str>,
|
|
37
|
+
max_workers: Option<usize>,
|
|
38
|
+
) -> ValidationResult {
|
|
39
|
+
let data_dir = PathBuf::from(data_dir);
|
|
40
|
+
let stores_dir = PathBuf::from(stores_dir);
|
|
41
|
+
let schemas_dir = PathBuf::from(schemas_dir.unwrap_or("schemas"));
|
|
42
|
+
|
|
43
|
+
py.allow_threads(|| {
|
|
44
|
+
with_thread_pool(max_workers, || {
|
|
45
|
+
log_step("Loading dataset", None);
|
|
46
|
+
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
47
|
+
|
|
48
|
+
log_step("Checking required files", None);
|
|
49
|
+
log_step("Validating JSON schemas", Some(dataset.json_entries.len()));
|
|
50
|
+
log_step("Validating logos", Some(dataset.logo_entries.len()));
|
|
51
|
+
log_step("Validating folder names", Some(dataset.folder_entries.len()));
|
|
52
|
+
log_step("Validating store IDs", None);
|
|
53
|
+
log_step("Validating GTIN/EAN codes", None);
|
|
54
|
+
|
|
55
|
+
core::validate_dataset(&dataset).into()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#[pyfunction]
|
|
61
|
+
#[pyo3(signature = (data_dir, stores_dir, schemas_dir=None, max_workers=None))]
|
|
62
|
+
pub fn validate_json_files(
|
|
63
|
+
py: Python<'_>,
|
|
64
|
+
data_dir: &str,
|
|
65
|
+
stores_dir: &str,
|
|
66
|
+
schemas_dir: Option<&str>,
|
|
67
|
+
max_workers: Option<usize>,
|
|
68
|
+
) -> ValidationResult {
|
|
69
|
+
let data_dir = PathBuf::from(data_dir);
|
|
70
|
+
let stores_dir = PathBuf::from(stores_dir);
|
|
71
|
+
let schemas_dir = PathBuf::from(schemas_dir.unwrap_or("schemas"));
|
|
72
|
+
|
|
73
|
+
py.allow_threads(|| {
|
|
74
|
+
with_thread_pool(max_workers, || {
|
|
75
|
+
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
76
|
+
log_step("Validating JSON schemas", Some(dataset.json_entries.len()));
|
|
77
|
+
|
|
78
|
+
use rayon::prelude::*;
|
|
79
|
+
let results: Vec<core::ValidationResult> = dataset.json_entries
|
|
80
|
+
.par_iter()
|
|
81
|
+
.map(|(path, schema_name, data)| {
|
|
82
|
+
core::validators::validate_json(data, schema_name, &dataset.schema_cache, Some(path))
|
|
83
|
+
})
|
|
84
|
+
.collect();
|
|
85
|
+
|
|
86
|
+
let mut result = core::ValidationResult::default();
|
|
87
|
+
for r in results {
|
|
88
|
+
result.merge_from(&r);
|
|
89
|
+
}
|
|
90
|
+
result.into()
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#[pyfunction]
|
|
96
|
+
#[pyo3(signature = (data_dir, stores_dir, max_workers=None))]
|
|
97
|
+
pub fn validate_logo_files(
|
|
98
|
+
py: Python<'_>,
|
|
99
|
+
data_dir: &str,
|
|
100
|
+
stores_dir: &str,
|
|
101
|
+
max_workers: Option<usize>,
|
|
102
|
+
) -> ValidationResult {
|
|
103
|
+
let data_dir = PathBuf::from(data_dir);
|
|
104
|
+
let stores_dir = PathBuf::from(stores_dir);
|
|
105
|
+
let schemas_dir = PathBuf::from("schemas");
|
|
106
|
+
|
|
107
|
+
py.allow_threads(|| {
|
|
108
|
+
with_thread_pool(max_workers, || {
|
|
109
|
+
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
110
|
+
log_step("Validating logos", Some(dataset.logo_entries.len()));
|
|
111
|
+
|
|
112
|
+
use rayon::prelude::*;
|
|
113
|
+
let results: Vec<core::ValidationResult> = dataset.logo_entries
|
|
114
|
+
.par_iter()
|
|
115
|
+
.map(|(path, filename, bytes, logo_name)| {
|
|
116
|
+
if bytes.is_empty() {
|
|
117
|
+
let mut r = core::ValidationResult::default();
|
|
118
|
+
r.add(core::ValidationError::error(
|
|
119
|
+
"Logo",
|
|
120
|
+
"Logo file not found",
|
|
121
|
+
Some(path.clone()),
|
|
122
|
+
));
|
|
123
|
+
r
|
|
124
|
+
} else {
|
|
125
|
+
core::validators::validate_logo(bytes, filename, logo_name.as_deref(), Some(path))
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
.collect();
|
|
129
|
+
|
|
130
|
+
let mut result = core::ValidationResult::default();
|
|
131
|
+
for r in results {
|
|
132
|
+
result.merge_from(&r);
|
|
133
|
+
}
|
|
134
|
+
result.into()
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#[pyfunction]
|
|
140
|
+
#[pyo3(signature = (data_dir, stores_dir, max_workers=None))]
|
|
141
|
+
pub fn validate_folder_names(
|
|
142
|
+
py: Python<'_>,
|
|
143
|
+
data_dir: &str,
|
|
144
|
+
stores_dir: &str,
|
|
145
|
+
max_workers: Option<usize>,
|
|
146
|
+
) -> ValidationResult {
|
|
147
|
+
let data_dir = PathBuf::from(data_dir);
|
|
148
|
+
let stores_dir = PathBuf::from(stores_dir);
|
|
149
|
+
let schemas_dir = PathBuf::from("schemas");
|
|
150
|
+
|
|
151
|
+
py.allow_threads(|| {
|
|
152
|
+
with_thread_pool(max_workers, || {
|
|
153
|
+
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
154
|
+
log_step("Validating folder names", Some(dataset.folder_entries.len()));
|
|
155
|
+
|
|
156
|
+
use rayon::prelude::*;
|
|
157
|
+
let results: Vec<core::ValidationResult> = dataset.folder_entries
|
|
158
|
+
.par_iter()
|
|
159
|
+
.map(|(path, folder_name, json_data, json_key)| {
|
|
160
|
+
core::validators::validate_folder_name(folder_name, json_data, json_key, Some(path))
|
|
161
|
+
})
|
|
162
|
+
.collect();
|
|
163
|
+
|
|
164
|
+
let mut result = core::ValidationResult::default();
|
|
165
|
+
for r in results {
|
|
166
|
+
result.merge_from(&r);
|
|
167
|
+
}
|
|
168
|
+
result.into()
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
use std::path::PathBuf;
|
|
2
|
-
|
|
3
|
-
use pyo3::prelude::*;
|
|
4
|
-
|
|
5
|
-
use ofd_validator_core as core;
|
|
6
|
-
|
|
7
|
-
use crate::types::ValidationResult;
|
|
8
|
-
use crate::util::log_step;
|
|
9
|
-
|
|
10
|
-
#[pyfunction]
|
|
11
|
-
#[pyo3(signature = (data_dir, stores_dir, schemas_dir=None))]
|
|
12
|
-
pub fn validate_all(
|
|
13
|
-
py: Python<'_>,
|
|
14
|
-
data_dir: &str,
|
|
15
|
-
stores_dir: &str,
|
|
16
|
-
schemas_dir: Option<&str>,
|
|
17
|
-
) -> ValidationResult {
|
|
18
|
-
let data_dir = PathBuf::from(data_dir);
|
|
19
|
-
let stores_dir = PathBuf::from(stores_dir);
|
|
20
|
-
let schemas_dir = PathBuf::from(schemas_dir.unwrap_or("schemas"));
|
|
21
|
-
|
|
22
|
-
py.allow_threads(|| {
|
|
23
|
-
log_step("Loading dataset", None);
|
|
24
|
-
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
25
|
-
|
|
26
|
-
log_step("Checking required files", None);
|
|
27
|
-
log_step("Validating JSON schemas", Some(dataset.json_entries.len()));
|
|
28
|
-
log_step("Validating logos", Some(dataset.logo_entries.len()));
|
|
29
|
-
log_step("Validating folder names", Some(dataset.folder_entries.len()));
|
|
30
|
-
log_step("Validating store IDs", None);
|
|
31
|
-
log_step("Validating GTIN/EAN codes", None);
|
|
32
|
-
|
|
33
|
-
core::validate_dataset(&dataset).into()
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
#[pyfunction]
|
|
38
|
-
#[pyo3(signature = (data_dir, stores_dir, schemas_dir=None))]
|
|
39
|
-
pub fn validate_json_files(
|
|
40
|
-
py: Python<'_>,
|
|
41
|
-
data_dir: &str,
|
|
42
|
-
stores_dir: &str,
|
|
43
|
-
schemas_dir: Option<&str>,
|
|
44
|
-
) -> ValidationResult {
|
|
45
|
-
let data_dir = PathBuf::from(data_dir);
|
|
46
|
-
let stores_dir = PathBuf::from(stores_dir);
|
|
47
|
-
let schemas_dir = PathBuf::from(schemas_dir.unwrap_or("schemas"));
|
|
48
|
-
|
|
49
|
-
py.allow_threads(|| {
|
|
50
|
-
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
51
|
-
log_step("Validating JSON schemas", Some(dataset.json_entries.len()));
|
|
52
|
-
|
|
53
|
-
use rayon::prelude::*;
|
|
54
|
-
let results: Vec<core::ValidationResult> = dataset.json_entries
|
|
55
|
-
.par_iter()
|
|
56
|
-
.map(|(path, schema_name, data)| {
|
|
57
|
-
core::validators::validate_json(data, schema_name, &dataset.schema_cache, Some(path))
|
|
58
|
-
})
|
|
59
|
-
.collect();
|
|
60
|
-
|
|
61
|
-
let mut result = core::ValidationResult::default();
|
|
62
|
-
for r in results {
|
|
63
|
-
result.merge_from(&r);
|
|
64
|
-
}
|
|
65
|
-
result.into()
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#[pyfunction]
|
|
70
|
-
#[pyo3(signature = (data_dir, stores_dir))]
|
|
71
|
-
pub fn validate_logo_files(
|
|
72
|
-
py: Python<'_>,
|
|
73
|
-
data_dir: &str,
|
|
74
|
-
stores_dir: &str,
|
|
75
|
-
) -> ValidationResult {
|
|
76
|
-
let data_dir = PathBuf::from(data_dir);
|
|
77
|
-
let stores_dir = PathBuf::from(stores_dir);
|
|
78
|
-
let schemas_dir = PathBuf::from("schemas");
|
|
79
|
-
|
|
80
|
-
py.allow_threads(|| {
|
|
81
|
-
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
82
|
-
log_step("Validating logos", Some(dataset.logo_entries.len()));
|
|
83
|
-
|
|
84
|
-
use rayon::prelude::*;
|
|
85
|
-
let results: Vec<core::ValidationResult> = dataset.logo_entries
|
|
86
|
-
.par_iter()
|
|
87
|
-
.map(|(path, filename, bytes, logo_name)| {
|
|
88
|
-
if bytes.is_empty() {
|
|
89
|
-
let mut r = core::ValidationResult::default();
|
|
90
|
-
r.add(core::ValidationError::error(
|
|
91
|
-
"Logo",
|
|
92
|
-
"Logo file not found",
|
|
93
|
-
Some(path.clone()),
|
|
94
|
-
));
|
|
95
|
-
r
|
|
96
|
-
} else {
|
|
97
|
-
core::validators::validate_logo(bytes, filename, logo_name.as_deref(), Some(path))
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
.collect();
|
|
101
|
-
|
|
102
|
-
let mut result = core::ValidationResult::default();
|
|
103
|
-
for r in results {
|
|
104
|
-
result.merge_from(&r);
|
|
105
|
-
}
|
|
106
|
-
result.into()
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
#[pyfunction]
|
|
111
|
-
#[pyo3(signature = (data_dir, stores_dir))]
|
|
112
|
-
pub fn validate_folder_names(
|
|
113
|
-
py: Python<'_>,
|
|
114
|
-
data_dir: &str,
|
|
115
|
-
stores_dir: &str,
|
|
116
|
-
) -> ValidationResult {
|
|
117
|
-
let data_dir = PathBuf::from(data_dir);
|
|
118
|
-
let stores_dir = PathBuf::from(stores_dir);
|
|
119
|
-
let schemas_dir = PathBuf::from("schemas");
|
|
120
|
-
|
|
121
|
-
py.allow_threads(|| {
|
|
122
|
-
let dataset = core::DataSet::from_directories(&data_dir, &stores_dir, &schemas_dir);
|
|
123
|
-
log_step("Validating folder names", Some(dataset.folder_entries.len()));
|
|
124
|
-
|
|
125
|
-
use rayon::prelude::*;
|
|
126
|
-
let results: Vec<core::ValidationResult> = dataset.folder_entries
|
|
127
|
-
.par_iter()
|
|
128
|
-
.map(|(path, folder_name, json_data, json_key)| {
|
|
129
|
-
core::validators::validate_folder_name(folder_name, json_data, json_key, Some(path))
|
|
130
|
-
})
|
|
131
|
-
.collect();
|
|
132
|
-
|
|
133
|
-
let mut result = core::ValidationResult::default();
|
|
134
|
-
for r in results {
|
|
135
|
-
result.merge_from(&r);
|
|
136
|
-
}
|
|
137
|
-
result.into()
|
|
138
|
-
})
|
|
139
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/folder_name.rs
RENAMED
|
File without changes
|
{ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/gtin.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ofd_validator-0.4.0 → ofd_validator-0.5.0}/crates/ofd-validator-core/src/validators/store_id.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|