psdi-data-conversion 0.0.33__py3-none-any.whl → 0.0.36__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.
Files changed (36) hide show
  1. psdi_data_conversion/app.py +23 -3
  2. psdi_data_conversion/constants.py +2 -0
  3. psdi_data_conversion/converter.py +16 -6
  4. psdi_data_conversion/converters/atomsk.py +3 -1
  5. psdi_data_conversion/converters/base.py +99 -39
  6. psdi_data_conversion/converters/c2x.py +3 -1
  7. psdi_data_conversion/converters/openbabel.py +40 -1
  8. psdi_data_conversion/database.py +5 -0
  9. psdi_data_conversion/main.py +18 -10
  10. psdi_data_conversion/static/content/accessibility.htm +5 -5
  11. psdi_data_conversion/static/content/convert.htm +31 -15
  12. psdi_data_conversion/static/content/convertato.htm +46 -28
  13. psdi_data_conversion/static/content/convertc2x.htm +47 -28
  14. psdi_data_conversion/static/content/documentation.htm +4 -4
  15. psdi_data_conversion/static/content/download.htm +4 -1
  16. psdi_data_conversion/static/content/feedback.htm +4 -4
  17. psdi_data_conversion/static/content/index-versions/psdi-common-header.html +1 -1
  18. psdi_data_conversion/static/content/psdi-common-header.html +1 -1
  19. psdi_data_conversion/static/content/report.htm +9 -7
  20. psdi_data_conversion/static/javascript/common.js +20 -0
  21. psdi_data_conversion/static/javascript/convert.js +1 -2
  22. psdi_data_conversion/static/javascript/convert_common.js +100 -7
  23. psdi_data_conversion/static/javascript/convertato.js +1 -2
  24. psdi_data_conversion/static/javascript/convertc2x.js +1 -2
  25. psdi_data_conversion/static/javascript/format.js +12 -0
  26. psdi_data_conversion/static/javascript/report.js +6 -0
  27. psdi_data_conversion/static/styles/format.css +13 -0
  28. psdi_data_conversion/static/styles/psdi-common.css +5 -2
  29. psdi_data_conversion/templates/index.htm +4 -1
  30. psdi_data_conversion/testing/conversion_test_specs.py +240 -149
  31. psdi_data_conversion/testing/utils.py +22 -7
  32. {psdi_data_conversion-0.0.33.dist-info → psdi_data_conversion-0.0.36.dist-info}/METADATA +29 -6
  33. {psdi_data_conversion-0.0.33.dist-info → psdi_data_conversion-0.0.36.dist-info}/RECORD +36 -36
  34. {psdi_data_conversion-0.0.33.dist-info → psdi_data_conversion-0.0.36.dist-info}/WHEEL +0 -0
  35. {psdi_data_conversion-0.0.33.dist-info → psdi_data_conversion-0.0.36.dist-info}/entry_points.txt +0 -0
  36. {psdi_data_conversion-0.0.33.dist-info → psdi_data_conversion-0.0.36.dist-info}/licenses/LICENSE +0 -0
@@ -3,6 +3,8 @@
3
3
  Version 1.0, 17th December 2024
4
4
  */
5
5
 
6
+ import { disableDirtyForms, enableDirtyForms, initDirtyForms } from "./common.js";
7
+
6
8
  const SECOND = 1000; // Milliseconds
7
9
  const CONVERT_TIMEOUT = 60 * SECOND;
8
10
  const MEGABYTE = 1024 * 1024;
@@ -31,7 +33,18 @@ var token = "",
31
33
 
32
34
  export function commonConvertReady(converter) {
33
35
  token = sessionStorage.getItem("token");
34
- max_file_size = sessionStorage.getItem("max_file_size");
36
+
37
+ // Open Babel uniquely has its own maximum file size
38
+ if (converter == "Open Babel") {
39
+ max_file_size = sessionStorage.getItem("max_file_size_ob");
40
+ } else {
41
+ max_file_size = sessionStorage.getItem("max_file_size");
42
+ }
43
+
44
+ // Set the text for displaying the maximum size
45
+ if (max_file_size > 0) {
46
+ $(".max-file-size").text(" (max size " + (max_file_size / MEGABYTE).toFixed(2) + " MB)");
47
+ }
35
48
 
36
49
  in_str = sessionStorage.getItem("in_str");
37
50
  out_str = sessionStorage.getItem("out_str");
@@ -48,16 +61,26 @@ export function commonConvertReady(converter) {
48
61
  $("#heading").html("Convert from \'" + in_ext + "\' (" + in_note + ") to \'" + out_ext + "\' (" + out_note +
49
62
  ") using " + converter);
50
63
 
64
+ // Connect the buttons to events
51
65
  $("#extCheck").click(setExtCheck);
52
66
  $("#requestLog").click(setRequestLog);
67
+ $("#clearUpload").click(clearUploadedFile);
68
+
69
+ // Connect the file upload to event and limit the types it can accept
53
70
  $("#fileToUpload").change(checkFile);
71
+ limitFileType();
72
+
73
+ initDirtyForms();
54
74
 
55
- return [token, max_file_size, in_str, in_ext, out_str, out_ext];
75
+ return [token, in_str, in_ext, out_str, out_ext];
56
76
  }
57
77
 
58
78
  // Converts user-supplied file to another format and downloads the resulting file
59
79
  export function convertFile(form_data, download_fname, fname) {
60
80
 
81
+ showSpinner();
82
+ disableConvertButton();
83
+
61
84
  let convertTimedOut = false;
62
85
 
63
86
  var jqXHR = $.ajax({
@@ -68,6 +91,12 @@ export function convertFile(form_data, download_fname, fname) {
68
91
  contentType: false,
69
92
  timeout: CONVERT_TIMEOUT,
70
93
  success: async function () {
94
+
95
+ hideSpinner();
96
+ enableConvertButton();
97
+ clearUploadedFile();
98
+ disableDirtyForms();
99
+
71
100
  if (!convertTimedOut) {
72
101
  await downloadFile(`../downloads/${download_fname}`, download_fname)
73
102
 
@@ -105,6 +134,8 @@ export function convertFile(form_data, download_fname, fname) {
105
134
  })
106
135
  },
107
136
  error: function (xmlhttprequest, textstatus, message) {
137
+ hideSpinner();
138
+ enableConvertButton();
108
139
  if (textstatus === "timeout") {
109
140
  convertTimedOut = true;
110
141
  alert("ERROR: Conversion attempt timed out. This may be because the conversion is too complicated, " +
@@ -145,6 +176,13 @@ export function convertFile(form_data, download_fname, fname) {
145
176
 
146
177
  function setExtCheck(event) {
147
178
  extCheck = this.checked;
179
+
180
+ // Toggle whether or not the file upload limits uploaded type based on whether or not this box is ticked
181
+ if (extCheck) {
182
+ limitFileType();
183
+ } else {
184
+ unlimitFileType();
185
+ }
148
186
  }
149
187
 
150
188
  export function getExtCheck() {
@@ -191,6 +229,9 @@ export function isArchiveExt(ext) {
191
229
  // Check that the file meets requirements for upload
192
230
  function checkFile(event) {
193
231
 
232
+ // Enable dirty form checking whenever a file is uploaded
233
+ enableDirtyForms();
234
+
194
235
  let allGood = true;
195
236
  let file = this.files[0];
196
237
  let message = "";
@@ -216,20 +257,58 @@ function checkFile(event) {
216
257
  if (message !== "")
217
258
  message += "\n\n";
218
259
  message += "The file exceeds the maximum size limit of " + (max_file_size / MEGABYTE).toFixed(2) +
219
- " MB; its size is " + (file.size / MEGABYTE).toFixed(2) + " MB.";
260
+ " MB; its size is " + (file.size / MEGABYTE).toFixed(2) + " MB. Please either log in for an increased " +
261
+ "file size limit, or see the Downloads page to run the app locally with no limit.";
220
262
  allGood = false;
221
263
  }
222
264
 
223
265
  if (allGood) {
224
- $("#uploadButton").css({ "background-color": "var(--ifm-color-primary)", "color": "var(--ifm-hero-text-color)" });
225
- $("#uploadButton").prop({ disabled: false });
266
+ enableConvertButton();
226
267
  } else {
227
- $("#uploadButton").css({ "background-color": "var(--psdi-bg-color-secondary)", "color": "gray" });
228
- $("#uploadButton").prop({ disabled: true });
268
+ disableConvertButton();
229
269
  alert(message);
230
270
  }
231
271
  }
232
272
 
273
+ /**
274
+ * Allow the file upload to only accept the expected type of file
275
+ */
276
+ function limitFileType() {
277
+ $("#fileToUpload")[0].accept = "." + in_ext;
278
+ }
279
+
280
+ /**
281
+ * Allow the file upload to accept any type of file
282
+ */
283
+ function unlimitFileType() {
284
+ $("#fileToUpload")[0].accept = "*";
285
+ }
286
+
287
+ /**
288
+ * Clear any uploaded file
289
+ */
290
+ function clearUploadedFile() {
291
+ $("#fileToUpload").val('');
292
+ disableConvertButton();
293
+ }
294
+
295
+ /**
296
+ * Enable the "Convert" button
297
+ */
298
+ function enableConvertButton() {
299
+ $("#uploadButton").css({ "background-color": "var(--ifm-color-primary)", "color": "var(--ifm-hero-text-color)" });
300
+ $("#uploadButton").prop({ disabled: false });
301
+ }
302
+
303
+
304
+ /**
305
+ * Disable the "Convert" button
306
+ */
307
+ function disableConvertButton() {
308
+ $("#uploadButton").css({ "background-color": "var(--psdi-bg-color-secondary)", "color": "gray" });
309
+ $("#uploadButton").prop({ disabled: true });
310
+ }
311
+
233
312
  /**
234
313
  * Start a download of a file
235
314
  *
@@ -249,4 +328,18 @@ async function downloadFile(path, filename) {
249
328
  a.click();
250
329
  a.remove();
251
330
  });
331
+ }
332
+
333
+ /**
334
+ * Show the loading spinner
335
+ */
336
+ function showSpinner() {
337
+ $(".loading-spinner").css({ display: "inherit" });
338
+ }
339
+
340
+ /**
341
+ * Hide the loading spinner
342
+ */
343
+ function hideSpinner() {
344
+ $(".loading-spinner").css({ display: "none" });
252
345
  }
@@ -8,14 +8,13 @@
8
8
  import { commonConvertReady, convertFile, getExtCheck, splitArchiveExt, isArchiveExt } from "./convert_common.js"
9
9
 
10
10
  var token = "",
11
- max_file_size = 0,
12
11
  in_ext = "",
13
12
  out_ext = "",
14
13
  in_str = "",
15
14
  out_str = "";
16
15
 
17
16
  $(document).ready(function () {
18
- [token, max_file_size, in_str, in_ext, out_str, out_ext] = commonConvertReady("Atomsk");
17
+ [token, in_str, in_ext, out_str, out_ext] = commonConvertReady("Atomsk");
19
18
  $("#uploadButton").click(submitFile);
20
19
  });
21
20
 
@@ -8,14 +8,13 @@
8
8
  import { commonConvertReady, convertFile, getExtCheck, splitArchiveExt, isArchiveExt } from "./convert_common.js"
9
9
 
10
10
  var token = "",
11
- max_file_size = 0,
12
11
  in_ext = "",
13
12
  out_ext = "",
14
13
  in_str = "",
15
14
  out_str = "";
16
15
 
17
16
  $(document).ready(function () {
18
- [token, max_file_size, in_str, in_ext, out_str, out_ext] = commonConvertReady("c2x");
17
+ [token, in_str, in_ext, out_str, out_ext] = commonConvertReady("c2x");
19
18
  $("#uploadButton").click(submitFile);
20
19
  });
21
20
 
@@ -5,6 +5,7 @@
5
5
  This is the JavaScript which makes the Format and Converter Selection gui work.
6
6
  */
7
7
 
8
+ import { disableDirtyForms, cleanDirtyForms, initDirtyForms, loadServiceMode, loadProductionMode } from "./common.js";
8
9
  import {
9
10
  getInputFormats, getOutputFormats, getOutputFormatsForInputFormat,
10
11
  getInputFormatsForOutputFormat, getConverters, getConverterByName, getLevelChemInfo
@@ -29,12 +30,16 @@ $(document).ready(function () {
29
30
 
30
31
  sessionStorage.setItem("token", token);
31
32
  sessionStorage.setItem("max_file_size", max_file_size);
33
+ sessionStorage.setItem("max_file_size_ob", max_file_size_ob);
32
34
  sessionStorage.setItem("service_mode", service_mode);
33
35
  sessionStorage.setItem("production_mode", production_mode);
34
36
  sessionStorage.setItem("in_str", "");
35
37
  sessionStorage.setItem("out_str", "");
36
38
  sessionStorage.setItem("success", "");
37
39
 
40
+ loadServiceMode();
41
+ loadProductionMode();
42
+
38
43
  $("#fromList").click(populateConversionSuccess);
39
44
  $("#toList").click(populateConversionSuccess);
40
45
  $("#searchTo").keyup(filterOptions);
@@ -43,6 +48,8 @@ $(document).ready(function () {
43
48
  $("#success").click(showConverterDetails);
44
49
  $("#resetButton").click(resetAll);
45
50
  $("#showButton").click(showQualityDetails);
51
+
52
+ initDirtyForms();
46
53
  });
47
54
 
48
55
  /**
@@ -512,6 +519,9 @@ function getFormat(str) {
512
519
 
513
520
  // Stores chosen formats and switches to the Conversion page
514
521
  function goToConversionPage(event) {
522
+
523
+ disableDirtyForms();
524
+
515
525
  var path = ``;
516
526
 
517
527
  if ($("#name").html() == "Open Babel") {
@@ -604,4 +614,6 @@ function resetAll() {
604
614
 
605
615
  // Populates the "Convert to" selection list
606
616
  getOutputFormats().then(formats => populateList(formats, "to"));
617
+
618
+ cleanDirtyForms();
607
619
  }
@@ -5,6 +5,7 @@
5
5
  This is the JavaScript which makes the report.htm gui work.
6
6
  */
7
7
 
8
+ import { disableDirtyForms, initDirtyForms } from "./common.js";
8
9
  import { getAllFormats, getConverters } from "./data.js";
9
10
 
10
11
  var token = "",
@@ -53,6 +54,8 @@ $(document).ready(function () {
53
54
  $("#resetButton").click(resetAll);
54
55
  $("#resetButton2").click(resetAll);
55
56
  $("#reportButton").click(submitUserInput);
57
+
58
+ initDirtyForms();
56
59
  });
57
60
 
58
61
  // Included in this file for convenience. When the 'Report' button is clicked, a user's missing conversion report
@@ -131,6 +134,7 @@ function hideConverterDetails() {
131
134
 
132
135
  // Submits user input
133
136
  function submitUserInput() {
137
+
134
138
  const from = $("#searchFrom").val(),
135
139
  to = $("#searchTo").val();
136
140
 
@@ -205,6 +209,8 @@ function hideOffer() { }
205
209
 
206
210
  // Submit feedback
207
211
  function submitFeedback(data) {
212
+ disableDirtyForms();
213
+
208
214
  $.post(`/feedback/`, {
209
215
  'token': token,
210
216
  'data': JSON.stringify(data)
@@ -144,4 +144,17 @@ select#dark-background option {
144
144
 
145
145
  [production-mode=False] .dev-only {
146
146
  display: none;
147
+ }
148
+
149
+ /* Convert button and loading spinner */
150
+ .convert-button-and-spinner {
151
+ display : flex;
152
+ flex-direction: row;
153
+ align-items : center;
154
+ }
155
+
156
+ .loading-spinner {
157
+ display: none;
158
+ color : var(--ifm-color-primary);
159
+ scale : 75%;
147
160
  }
@@ -640,8 +640,11 @@ a svg {
640
640
  }
641
641
 
642
642
  .footer__hline hr {
643
- margin: 0.5rem 0;
644
- height: 2px;
643
+ margin : 0.5rem 0;
644
+ height : 2px;
645
+ border-top-style : none;
646
+ border-bottom-style: inset;
647
+ border-bottom-width: 1px;
645
648
  }
646
649
 
647
650
  .max-width-box .footer__col {
@@ -18,10 +18,13 @@
18
18
 
19
19
  <script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
20
20
  crossorigin="anonymous"></script>
21
+ <script src="https://cdn.jsdelivr.net/jquery.dirtyforms/2.0.0/jquery.dirtyforms.min.js"></script>
22
+
21
23
  {% for item in data %}
22
24
  <script>
23
25
  const token = "{{item.token}}";
24
26
  const max_file_size = "{{item.max_file_size}}";
27
+ const max_file_size_ob = "{{item.max_file_size_ob}}";
25
28
  const service_mode = "{{item.service_mode}}";
26
29
  const production_mode = "{{item.production_mode}}";
27
30
  document.documentElement.setAttribute("service-mode", service_mode);
@@ -52,7 +55,7 @@
52
55
  </div>
53
56
  </div>
54
57
 
55
- <form name="gui">
58
+ <form name="gui" class="gui">
56
59
  <div class="max-width-box">
57
60
  <p>Select 'from' and 'to' file formats in the 'Convert from/to' boxes, in either order. Typing where indicated
58
61
  filters the options (case insensitive); for example, typing 'can' or 'NON' reduces the number of options to one: