psdi-data-conversion 0.0.23__py3-none-any.whl
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.
- psdi_data_conversion/__init__.py +11 -0
- psdi_data_conversion/app.py +242 -0
- psdi_data_conversion/bin/linux/atomsk +0 -0
- psdi_data_conversion/bin/linux/c2x +0 -0
- psdi_data_conversion/bin/mac/atomsk +0 -0
- psdi_data_conversion/bin/mac/c2x +0 -0
- psdi_data_conversion/constants.py +185 -0
- psdi_data_conversion/converter.py +459 -0
- psdi_data_conversion/converters/__init__.py +6 -0
- psdi_data_conversion/converters/atomsk.py +32 -0
- psdi_data_conversion/converters/base.py +702 -0
- psdi_data_conversion/converters/c2x.py +32 -0
- psdi_data_conversion/converters/openbabel.py +239 -0
- psdi_data_conversion/database.py +1064 -0
- psdi_data_conversion/dist.py +87 -0
- psdi_data_conversion/file_io.py +216 -0
- psdi_data_conversion/log_utility.py +241 -0
- psdi_data_conversion/main.py +776 -0
- psdi_data_conversion/scripts/atomsk.sh +32 -0
- psdi_data_conversion/scripts/c2x.sh +26 -0
- psdi_data_conversion/security.py +38 -0
- psdi_data_conversion/static/content/accessibility.htm +254 -0
- psdi_data_conversion/static/content/convert.htm +121 -0
- psdi_data_conversion/static/content/convertato.htm +65 -0
- psdi_data_conversion/static/content/convertc2x.htm +65 -0
- psdi_data_conversion/static/content/documentation.htm +94 -0
- psdi_data_conversion/static/content/feedback.htm +53 -0
- psdi_data_conversion/static/content/header-links.html +8 -0
- psdi_data_conversion/static/content/index-versions/header-links.html +8 -0
- psdi_data_conversion/static/content/index-versions/psdi-common-footer.html +99 -0
- psdi_data_conversion/static/content/index-versions/psdi-common-header.html +28 -0
- psdi_data_conversion/static/content/psdi-common-footer.html +99 -0
- psdi_data_conversion/static/content/psdi-common-header.html +28 -0
- psdi_data_conversion/static/content/report.htm +103 -0
- psdi_data_conversion/static/data/data.json +143940 -0
- psdi_data_conversion/static/img/colormode-toggle-dm.svg +3 -0
- psdi_data_conversion/static/img/colormode-toggle-lm.svg +3 -0
- psdi_data_conversion/static/img/psdi-icon-dark.svg +136 -0
- psdi_data_conversion/static/img/psdi-icon-light.svg +208 -0
- psdi_data_conversion/static/img/psdi-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/psdi-logo-lighttext.png +0 -0
- psdi_data_conversion/static/img/social-logo-bluesky-black.svg +4 -0
- psdi_data_conversion/static/img/social-logo-bluesky-white.svg +4 -0
- psdi_data_conversion/static/img/social-logo-instagram-black.svg +1 -0
- psdi_data_conversion/static/img/social-logo-instagram-white.svg +1 -0
- psdi_data_conversion/static/img/social-logo-linkedin-black.png +0 -0
- psdi_data_conversion/static/img/social-logo-linkedin-white.png +0 -0
- psdi_data_conversion/static/img/social-logo-mastodon-black.svg +4 -0
- psdi_data_conversion/static/img/social-logo-mastodon-white.svg +4 -0
- psdi_data_conversion/static/img/social-logo-x-black.svg +3 -0
- psdi_data_conversion/static/img/social-logo-x-white.svg +3 -0
- psdi_data_conversion/static/img/social-logo-youtube-black.png +0 -0
- psdi_data_conversion/static/img/social-logo-youtube-white.png +0 -0
- psdi_data_conversion/static/img/ukri-epsr-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/ukri-epsr-logo-lighttext.png +0 -0
- psdi_data_conversion/static/img/ukri-logo-darktext.png +0 -0
- psdi_data_conversion/static/img/ukri-logo-lighttext.png +0 -0
- psdi_data_conversion/static/javascript/accessibility.js +196 -0
- psdi_data_conversion/static/javascript/common.js +42 -0
- psdi_data_conversion/static/javascript/convert.js +296 -0
- psdi_data_conversion/static/javascript/convert_common.js +252 -0
- psdi_data_conversion/static/javascript/convertato.js +107 -0
- psdi_data_conversion/static/javascript/convertc2x.js +107 -0
- psdi_data_conversion/static/javascript/data.js +176 -0
- psdi_data_conversion/static/javascript/format.js +611 -0
- psdi_data_conversion/static/javascript/load_accessibility.js +89 -0
- psdi_data_conversion/static/javascript/psdi-common.js +177 -0
- psdi_data_conversion/static/javascript/report.js +381 -0
- psdi_data_conversion/static/styles/format.css +147 -0
- psdi_data_conversion/static/styles/psdi-common.css +705 -0
- psdi_data_conversion/templates/index.htm +114 -0
- psdi_data_conversion/testing/__init__.py +5 -0
- psdi_data_conversion/testing/constants.py +12 -0
- psdi_data_conversion/testing/conversion_callbacks.py +394 -0
- psdi_data_conversion/testing/conversion_test_specs.py +208 -0
- psdi_data_conversion/testing/utils.py +522 -0
- psdi_data_conversion-0.0.23.dist-info/METADATA +663 -0
- psdi_data_conversion-0.0.23.dist-info/RECORD +81 -0
- psdi_data_conversion-0.0.23.dist-info/WHEEL +4 -0
- psdi_data_conversion-0.0.23.dist-info/entry_points.txt +2 -0
- psdi_data_conversion-0.0.23.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
/*
|
2
|
+
convertato.js
|
3
|
+
Version 1.0, 10th January 2025
|
4
|
+
|
5
|
+
This is the JavaScript which makes the convertc2x.htm gui work.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { commonConvertReady, convertFile, getExtCheck, splitArchiveExt, isArchiveExt } from "./convert_common.js"
|
9
|
+
|
10
|
+
var token = "",
|
11
|
+
max_file_size = 0,
|
12
|
+
in_ext = "",
|
13
|
+
out_ext = "",
|
14
|
+
in_str = "",
|
15
|
+
out_str = "";
|
16
|
+
|
17
|
+
$(document).ready(function () {
|
18
|
+
[token, max_file_size, in_str, in_ext, out_str, out_ext] = commonConvertReady("c2x");
|
19
|
+
$("#uploadButton").click(submitFile);
|
20
|
+
});
|
21
|
+
|
22
|
+
// Uploads a user-supplied file
|
23
|
+
function submitFile() {
|
24
|
+
const file = $("#fileToUpload")[0].files[0],
|
25
|
+
[fname, ext] = splitArchiveExt(file.name);
|
26
|
+
|
27
|
+
var quality = sessionStorage.getItem("success"),
|
28
|
+
start = quality.indexOf(':') + 2,
|
29
|
+
finish = quality.lastIndexOf('(') - 1;
|
30
|
+
|
31
|
+
quality = quality.substring(start, finish);
|
32
|
+
|
33
|
+
const read_flags_text = $("#inFlags").find(":selected").text(),
|
34
|
+
read_flags = '';
|
35
|
+
|
36
|
+
const write_flags_text = $("#outFlags").find(":selected").text(),
|
37
|
+
write_flags = '';
|
38
|
+
|
39
|
+
var count = 0,
|
40
|
+
read_arg_flags = '',
|
41
|
+
write_arg_flags = '',
|
42
|
+
read_args = '',
|
43
|
+
write_args = '',
|
44
|
+
all_args_entered = true;
|
45
|
+
|
46
|
+
const checked_in = $('input[name=in_arg_check]:checked'),
|
47
|
+
checked_out = $('input[name=out_arg_check]:checked');
|
48
|
+
|
49
|
+
checked_in.each(function () {
|
50
|
+
read_arg_flags += $("#" + this.id).val()[0];
|
51
|
+
const arg = $("#in_arg_text" + this.id.substring(this.id.length - 1, this.id.length)).val();
|
52
|
+
|
53
|
+
if (/\S/.test(arg)) {
|
54
|
+
read_args += arg.trim() + '£';
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
all_args_entered = false;
|
58
|
+
}
|
59
|
+
})
|
60
|
+
|
61
|
+
checked_out.each(function () {
|
62
|
+
write_arg_flags += $("#" + this.id).val()[0];
|
63
|
+
const arg = $("#out_arg_text" + this.id.substring(this.id.length - 1, this.id.length)).val();
|
64
|
+
|
65
|
+
if (/\S/.test(arg)) {
|
66
|
+
write_args += arg.trim() + '£';
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
all_args_entered = false;
|
70
|
+
}
|
71
|
+
})
|
72
|
+
|
73
|
+
if (!all_args_entered) {
|
74
|
+
alert('All ticked option flags need additional information to be entered into the associated text box.');
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
78
|
+
const coordinates = 'neither', //$('input[name="coordinates"]:checked').val(),
|
79
|
+
coordOption = 'medium'; //$('input[name="coordOptions"]:checked').val();
|
80
|
+
|
81
|
+
// If the uploaded file was an archive, we'll expect to download one too. Otherwise we'll expect to download
|
82
|
+
// something with the output extension
|
83
|
+
const download_fname = isArchiveExt(ext) ? fname + "-" + out_ext + "." + ext : fname + "." + out_ext;
|
84
|
+
|
85
|
+
var form_data = new FormData();
|
86
|
+
|
87
|
+
form_data.append("token", token);
|
88
|
+
form_data.append("converter", 'c2x');
|
89
|
+
form_data.append("from", in_ext);
|
90
|
+
form_data.append("to", out_ext);
|
91
|
+
form_data.append("from_full", sessionStorage.getItem("in_str"));
|
92
|
+
form_data.append("to_full", sessionStorage.getItem("out_str"));
|
93
|
+
form_data.append("success", quality);
|
94
|
+
form_data.append("from_flags", read_flags);
|
95
|
+
form_data.append("to_flags", write_flags);
|
96
|
+
form_data.append("from_arg_flags", read_arg_flags);
|
97
|
+
form_data.append("from_args", read_args);
|
98
|
+
form_data.append("to_arg_flags", write_arg_flags);
|
99
|
+
form_data.append("to_args", write_args);
|
100
|
+
form_data.append("coordinates", coordinates);
|
101
|
+
form_data.append("coordOption", coordOption);
|
102
|
+
form_data.append("fileToUpload", file);
|
103
|
+
form_data.append("upload_file", true);
|
104
|
+
form_data.append("check_ext", getExtCheck());
|
105
|
+
|
106
|
+
convertFile(form_data, download_fname, fname);
|
107
|
+
}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
// data.js
|
2
|
+
|
3
|
+
const response = await fetch("/static/data/data.json");
|
4
|
+
const data = JSON.parse(await response.text());
|
5
|
+
|
6
|
+
const collator = new Intl.Collator();
|
7
|
+
|
8
|
+
// This compare function takes multiple pairs of strings so that it can be
|
9
|
+
// used to sort with multiple levels.
|
10
|
+
|
11
|
+
function compare(...pairs) {
|
12
|
+
|
13
|
+
for (const pair of pairs) {
|
14
|
+
|
15
|
+
const pairResult = collator.compare(pair[0], pair[1]);
|
16
|
+
|
17
|
+
if (pairResult !== 0) {
|
18
|
+
return pairResult;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
return 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
async function getFormatByExtensionAndNote(extension, note) {
|
26
|
+
|
27
|
+
const formats = data.formats.filter(format =>
|
28
|
+
(format.extension === extension) && (format.note === note)
|
29
|
+
);
|
30
|
+
|
31
|
+
return formats[0];
|
32
|
+
}
|
33
|
+
|
34
|
+
export async function getInputFormats() {
|
35
|
+
|
36
|
+
const inFormatIds = new Set(data.converts_to.map(record => record.in_id));
|
37
|
+
|
38
|
+
const inFormats = data.formats.filter(format => inFormatIds.has(format.id));
|
39
|
+
|
40
|
+
return inFormats.sort((a, b) => compare([a.extension, b.extension], [a.note, b.note]))
|
41
|
+
}
|
42
|
+
|
43
|
+
export async function getOutputFormats() {
|
44
|
+
|
45
|
+
const outFormatIds = new Set(data.converts_to.map(record => record.out_id));
|
46
|
+
|
47
|
+
const outFormats = data.formats.filter(format => outFormatIds.has(format.id));
|
48
|
+
|
49
|
+
return outFormats.sort((a, b) => compare([a.extension, b.extension], [a.note, b.note]))
|
50
|
+
}
|
51
|
+
|
52
|
+
export async function getOutputFormatsForInputFormat(inExtension, inNote) {
|
53
|
+
|
54
|
+
const inputFormat = (data.formats.filter(format => (format.extension === inExtension) && (format.note === inNote)))[0];
|
55
|
+
|
56
|
+
if (inputFormat === undefined) {
|
57
|
+
return [];
|
58
|
+
}
|
59
|
+
|
60
|
+
const outFormatIds = new Set(data.converts_to.filter(record => record.in_id === inputFormat.id).map(record => record.out_id));
|
61
|
+
|
62
|
+
const outFormats = data.formats.filter(format => outFormatIds.has(format.id));
|
63
|
+
|
64
|
+
return outFormats.sort((a, b) => compare([a.extension, b.extension], [a.note, b.note]))
|
65
|
+
}
|
66
|
+
|
67
|
+
export async function getInputFormatsForOutputFormat(outExtension, outNote) {
|
68
|
+
|
69
|
+
const outputFormat = (data.formats.filter(format => (format.extension === outExtension) && (format.note === outNote)))[0];
|
70
|
+
|
71
|
+
if (outputFormat === undefined) {
|
72
|
+
return [];
|
73
|
+
}
|
74
|
+
|
75
|
+
const inFormatIds = new Set(data.converts_to.filter(record => record.out_id === outputFormat.id).map(record => record.in_id));
|
76
|
+
|
77
|
+
const inFormats = data.formats.filter(format => inFormatIds.has(format.id));
|
78
|
+
|
79
|
+
return inFormats.sort((a, b) => compare([a.extension, b.extension], [a.note, b.note]))
|
80
|
+
}
|
81
|
+
|
82
|
+
export async function getConverters(inExtension, inNote, outExtension, outNote) {
|
83
|
+
|
84
|
+
const inputFormat = (data.formats.filter(format => (format.extension === inExtension) && (format.note === inNote)))[0];
|
85
|
+
const outputFormat = (data.formats.filter(format => (format.extension === outExtension) && (format.note === outNote)))[0];
|
86
|
+
|
87
|
+
if ((inputFormat === undefined) || (outputFormat === undefined)) {
|
88
|
+
return [];
|
89
|
+
}
|
90
|
+
|
91
|
+
const convertersById = new Map(data.converters.map(converter => [converter.id, converter]));
|
92
|
+
|
93
|
+
const conversions = data.converts_to.filter(record => (record.in_id === inputFormat.id) && record.out_id === outputFormat.id);
|
94
|
+
|
95
|
+
const convertersWithDegreeOfSuccess = conversions.map(conversion => ({
|
96
|
+
name: convertersById.get(conversion.converters_id).name
|
97
|
+
}));
|
98
|
+
|
99
|
+
return convertersWithDegreeOfSuccess.sort((a, b) => compare(a.name, b.name ));
|
100
|
+
}
|
101
|
+
|
102
|
+
export async function getConverterByName(name) {
|
103
|
+
return (data.converters.filter(converter => (converter.name === name)))[0];
|
104
|
+
}
|
105
|
+
|
106
|
+
export async function getAllFormats() {
|
107
|
+
return data.formats.sort((a, b) => compare([a.extension, b.extension], [a.note, b.note]));
|
108
|
+
}
|
109
|
+
|
110
|
+
export async function getInputFlags(extension, note) {
|
111
|
+
|
112
|
+
const format = (data.formats.filter(format => (format.extension === extension) && (format.note === note)))[0];
|
113
|
+
|
114
|
+
if (format !== undefined) {
|
115
|
+
|
116
|
+
const obFlagsIn = new Set(data.obformat_to_flags_in.filter(entry => entry.formats_id === format.id).map(entry => entry.obflags_in_id));
|
117
|
+
|
118
|
+
return data.obflags_in.filter(entry => obFlagsIn.has(entry.id)).sort((a, b) => compare([a.flag, b.flag]));
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
export async function getOutputFlags(extension, note) {
|
123
|
+
|
124
|
+
const format = (data.formats.filter(format => (format.extension === extension) && (format.note === note)))[0];
|
125
|
+
|
126
|
+
if (format !== undefined) {
|
127
|
+
|
128
|
+
const obFlagsOut = new Set(data.obformat_to_flags_out.filter(entry => entry.formats_id === format.id).map(entry => entry.obflags_out_id));
|
129
|
+
|
130
|
+
return data.obflags_out.filter(entry => obFlagsOut.has(entry.id)).sort((a, b) => compare([a.flag, b.flag]));
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
export async function getInputArgFlags(extension, note) {
|
135
|
+
|
136
|
+
const format = await getFormatByExtensionAndNote(extension, note);
|
137
|
+
|
138
|
+
if (format === undefined) {
|
139
|
+
throw `Can't find format for ${extension} and ${note}`;
|
140
|
+
}
|
141
|
+
|
142
|
+
const argFlagEntries = data.obformat_to_argflags_in
|
143
|
+
.filter(entry => entry.formats_id === format.id)
|
144
|
+
.map(entry => entry.obargflags_in_id);
|
145
|
+
|
146
|
+
const argFlags = data.obargflags_in
|
147
|
+
.filter(entry => argFlagEntries.indexOf(entry.id) !== -1);
|
148
|
+
|
149
|
+
return argFlags.sort((a, b) => compare([a.flag, b.flag]));
|
150
|
+
}
|
151
|
+
|
152
|
+
export async function getOutputArgFlags(extension, note) {
|
153
|
+
|
154
|
+
const format = await getFormatByExtensionAndNote(extension, note);
|
155
|
+
|
156
|
+
if (format === undefined) {
|
157
|
+
throw `Can't find format for ${extension} and ${note}`;
|
158
|
+
}
|
159
|
+
|
160
|
+
const argFlagEntries = data.obformat_to_argflags_out
|
161
|
+
.filter(entry => entry.formats_id === format.id)
|
162
|
+
.map(entry => entry.obargflags_out_id);
|
163
|
+
|
164
|
+
const argFlags = data.obargflags_out
|
165
|
+
.filter(entry => argFlagEntries.indexOf(entry.id) !== -1);
|
166
|
+
|
167
|
+
return argFlags.sort((a, b) => compare([a.flag, b.flag]));
|
168
|
+
}
|
169
|
+
|
170
|
+
export async function getLevelChemInfo(inExtension, inNote, outExtension, outNote) {
|
171
|
+
|
172
|
+
const inputFormat = (data.formats.filter(format => (format.extension === inExtension) && (format.note === inNote)))[0],
|
173
|
+
outputFormat = (data.formats.filter(format => (format.extension === outExtension) && (format.note === outNote)))[0];
|
174
|
+
|
175
|
+
return [inputFormat, outputFormat];
|
176
|
+
}
|