Skip to content

Commit 49bd52e

Browse files
bhorsujalgoneallbact
authored
Upgrade Django to 4.2.x (#558)
* Upgrade Django to 4.2.x * Update required files according to Django 4.2.x * Update tests.py file for compatibility with selenium 4.10.0 * Add suggested update to numpy version Co-authored-by: Arthit Suriyawongkul <[email protected]> * Add suggested update to lxml version Co-authored-by: Arthit Suriyawongkul <[email protected]> --------- Co-authored-by: Gary O'Neall <[email protected]> Co-authored-by: Arthit Suriyawongkul <[email protected]>
1 parent a4b0463 commit 49bd52e

File tree

8 files changed

+199
-211
lines changed

8 files changed

+199
-211
lines changed

requirements.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
Django==3.2.25
2-
jpype1==1.3.0
3-
numpy==1.22.4
4-
djangorestframework==3.12.4
1+
Django>=4.2,<4.3
2+
jpype1==1.4.0
3+
numpy>=1.25.2
4+
djangorestframework>=3.14.0
55
bs4==0.0.1
66
requests==2.32.5
7-
lxml==4.9.4
8-
webdriver-manager==3.4.2
9-
social-auth-core==4.1.0
10-
social-auth-app-django==4.0.0
11-
python-dotenv==0.17.1
7+
lxml>=5.3.2
8+
webdriver-manager>=3.8.6
9+
social-auth-core>=4.3,<5.0
10+
social-auth-app-django>=5.0,<6.0
11+
python-dotenv>=1.0.0
1212
gevent==23.9.1
1313
gunicorn==23.0.0
1414
#for testing
15-
selenium==3.14.1
16-
django-oauth-toolkit==1.5.0
17-
django-rest-framework-social-oauth2==1.1.0
15+
selenium>=4.10.0
16+
django-oauth-toolkit>=2.0.0
17+
django-rest-framework-social-oauth2>=1.1.0
1818
spdx-tools==0.8.3
1919
ntia-conformance-checker==4.0.0
2020
spdx-python-model==0.0.3

src/app/core.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def license_compare_helper(request):
108108
compareclass.onlineFunction(callfunc)
109109
except Exception as ex:
110110
"""Error raised by onlineFunction"""
111-
if (request.is_ajax()):
111+
if utils.is_ajax(request):
112112
ajaxdict["type"] = "warning2"
113113
ajaxdict["files"] = filelist
114114
ajaxdict["errors"] = errorlist
@@ -124,7 +124,7 @@ def license_compare_helper(request):
124124
return result
125125
if (warningoccurred==False):
126126
"""If no warning raised """
127-
if (request.is_ajax()):
127+
if utils.is_ajax(request):
128128
ajaxdict["medialink"] = settings.MEDIA_URL + folder + "/"+ rfilename
129129
response = dumps(ajaxdict)
130130
result['response'] = response
@@ -136,7 +136,7 @@ def license_compare_helper(request):
136136
result['context'] = context_dict
137137
return result
138138
else :
139-
if (request.is_ajax()):
139+
if utils.is_ajax(request):
140140
ajaxdict["type"] = "warning"
141141
ajaxdict["files"] = filelist
142142
ajaxdict["errors"] = errorlist
@@ -153,7 +153,7 @@ def license_compare_helper(request):
153153
result['context'] = context_dict
154154
return result
155155
else :
156-
if (request.is_ajax()):
156+
if utils.is_ajax(request):
157157
ajaxdict["files"] = filelist
158158
ajaxdict["type"] = "error"
159159
ajaxdict["errors"] = errorlist
@@ -175,7 +175,7 @@ def license_compare_helper(request):
175175

176176
except MultiValueDictKeyError:
177177
""" If no files uploaded"""
178-
if (request.is_ajax()):
178+
if utils.is_ajax(request):
179179
filelist.append("Files not selected.")
180180
errorlist.append("Please select at least 2 files.")
181181
ajaxdict["files"] = filelist
@@ -229,7 +229,7 @@ def ntia_check_helper(request):
229229
retval = tempstdout.getvalue().replace(",",", ").replace("\n","<br/>")
230230
if not retval.startswith("No components with missing information."):
231231
""" If any warnings are returned """
232-
if (request.is_ajax()):
232+
if utils.is_ajax(request):
233233
ajaxdict["type"] = "warning"
234234
warnings = str(retval)
235235
ajaxdict["data"] = "The following warning(s) were raised:<br />\n" + warnings.replace('\n', '<br />\n')
@@ -241,7 +241,7 @@ def ntia_check_helper(request):
241241
result['context'] = context_dict
242242
result['status'] = 400
243243
return result
244-
if (request.is_ajax()):
244+
if utils.is_ajax(request):
245245
""" Valid SPDX Document """
246246
ajaxdict["data"] = "This SPDX Document is valid:\n" + retval
247247
response = dumps(ajaxdict)
@@ -254,7 +254,7 @@ def ntia_check_helper(request):
254254
return result
255255
else:
256256
""" If no file uploaded."""
257-
if (request.is_ajax()):
257+
if utils.is_ajax(request):
258258
ajaxdict = dict()
259259
ajaxdict["type"] = "error"
260260
ajaxdict["data"] = "No file uploaded"
@@ -268,7 +268,7 @@ def ntia_check_helper(request):
268268
return result
269269
except jpype.JException as ex:
270270
""" Error raised by check_anything.check_minimum_elements without exiting the application"""
271-
if (request.is_ajax()):
271+
if utils.is_ajax(request):
272272
ajaxdict = dict()
273273
ajaxdict["type"] = "error"
274274
ajaxdict["data"] = jpype.JException.message(ex)
@@ -282,7 +282,7 @@ def ntia_check_helper(request):
282282
return result
283283
except MultiValueDictKeyError:
284284
""" If no files selected"""
285-
if (request.is_ajax()):
285+
if utils.is_ajax(request):
286286
ajaxdict = dict()
287287
ajaxdict["type"] = "error"
288288
ajaxdict["data"] = "No files selected."
@@ -296,7 +296,7 @@ def ntia_check_helper(request):
296296
return result
297297
except Exception as ex:
298298
""" Other error raised """
299-
if (request.is_ajax()):
299+
if utils.is_ajax(request):
300300
ajaxdict = dict()
301301
ajaxdict["type"] = "error"
302302
ajaxdict["data"] = format_exc()
@@ -336,7 +336,7 @@ def license_validate_helper(request):
336336
retval = verifyclass.verify(str(settings.APP_DIR+uploaded_file_url), fileformat)
337337
if (len(retval) > 0):
338338
""" If any warnings are returned """
339-
if (request.is_ajax()):
339+
if utils.is_ajax(request):
340340
ajaxdict["type"] = "warning"
341341
warnings = str(retval)
342342
ajaxdict["data"] = "The following warning(s) were raised:<br />\n" + warnings.replace('\n', '<br />\n')
@@ -348,7 +348,7 @@ def license_validate_helper(request):
348348
result['context'] = context_dict
349349
result['status'] = 400
350350
return result
351-
if (request.is_ajax()):
351+
if utils.is_ajax(request):
352352
""" Valid SPDX Document """
353353
ajaxdict["data"] = "This SPDX Document is valid."
354354
response = dumps(ajaxdict)
@@ -361,7 +361,7 @@ def license_validate_helper(request):
361361
return result
362362
else :
363363
""" If no file uploaded."""
364-
if (request.is_ajax()):
364+
if utils.is_ajax(request):
365365
ajaxdict=dict()
366366
ajaxdict["type"] = "error"
367367
ajaxdict["data"] = "No file uploaded"
@@ -375,7 +375,7 @@ def license_validate_helper(request):
375375
return result
376376
except jpype.JException as ex :
377377
""" Error raised by verifyclass.verify without exiting the application"""
378-
if (request.is_ajax()):
378+
if utils.is_ajax(request):
379379
ajaxdict=dict()
380380
ajaxdict["type"] = "error"
381381
ajaxdict["data"] = jpype.JException.message(ex)
@@ -389,7 +389,7 @@ def license_validate_helper(request):
389389
return result
390390
except MultiValueDictKeyError:
391391
""" If no files selected"""
392-
if (request.is_ajax()):
392+
if utils.is_ajax(request):
393393
ajaxdict=dict()
394394
ajaxdict["type"] = "error"
395395
ajaxdict["data"] = "No files selected."
@@ -403,7 +403,7 @@ def license_validate_helper(request):
403403
return result
404404
except Exception as ex:
405405
""" Other error raised """
406-
if (request.is_ajax()):
406+
if utils.is_ajax(request):
407407
ajaxdict=dict()
408408
ajaxdict["type"] = "error"
409409
ajaxdict["data"] = format_exc()
@@ -428,7 +428,7 @@ def license_check_helper(request):
428428
try:
429429
matchingId, matchingType, _ = utils.check_spdx_license(licensetext)
430430
if not matchingId:
431-
if (request.is_ajax()):
431+
if utils.is_ajax(request):
432432
ajaxdict = dict()
433433
ajaxdict["data"] = "There are no matching SPDX listed licenses"
434434
response = dumps(ajaxdict)
@@ -444,7 +444,7 @@ def license_check_helper(request):
444444
if isinstance(matchingId, list):
445445
matchingId = ",".join(matchingId)
446446
matching_str += matchingId
447-
if request.is_ajax():
447+
if utils.is_ajax(request):
448448
ajaxdict = dict()
449449
ajaxdict["data"] = matching_str
450450
response = dumps(ajaxdict)
@@ -457,7 +457,7 @@ def license_check_helper(request):
457457
return result
458458
except jpype.JException as ex :
459459
""" Java exception raised without exiting the application """
460-
if request.is_ajax():
460+
if utils.is_ajax(request):
461461
ajaxdict = dict()
462462
ajaxdict["data"] = jpype.JException.message(ex)
463463
response = dumps(ajaxdict)
@@ -470,7 +470,7 @@ def license_check_helper(request):
470470
return result
471471
except Exception as ex:
472472
""" Other exception raised """
473-
if request.is_ajax():
473+
if utils.is_ajax(request):
474474
ajaxdict = dict()
475475
ajaxdict["data"] = format_exc()
476476
response = dumps(ajaxdict)
@@ -517,7 +517,7 @@ def license_convert_helper(request):
517517
warnings = verifyclass.verify(str(settings.MEDIA_ROOT+"/"+folder+"/"+"/"+convertfile), toFileFormat)
518518
if (len(warnings) == 0) :
519519
""" If no warnings raised """
520-
if (request.is_ajax()):
520+
if utils.is_ajax(request):
521521
ajaxdict["medialink"] = settings.MEDIA_URL + folder + "/"+ convertfile
522522
response = dumps(ajaxdict)
523523
result['response'] = response
@@ -529,7 +529,7 @@ def license_convert_helper(request):
529529
result['status'] = 200
530530
return result
531531
else :
532-
if (request.is_ajax()):
532+
if utils.is_ajax(request):
533533
ajaxdict["type"] = "warning"
534534
warnings = str(warnings)
535535
ajaxdict["data"] = "The following warning(s) were raised by "+ myfile.name + ":<br />\n" + warnings.replace('\n', '<br />\n')
@@ -554,7 +554,7 @@ def license_convert_helper(request):
554554
return result
555555
except jpype.JException as ex :
556556
""" Java exception raised without exiting the application"""
557-
if (request.is_ajax()):
557+
if utils.is_ajax(request):
558558
ajaxdict["type"] = "error"
559559
ajaxdict["data"] = jpype.JException.message(ex)
560560
response = dumps(ajaxdict)
@@ -568,7 +568,7 @@ def license_convert_helper(request):
568568
return result
569569
except MultiValueDictKeyError:
570570
""" If no files uploaded"""
571-
if (request.is_ajax()):
571+
if utils.is_ajax(request):
572572
ajaxdict["type"] = "error"
573573
ajaxdict["data"] = "No files selected."
574574
response = dumps(ajaxdict)
@@ -582,7 +582,7 @@ def license_convert_helper(request):
582582
return result
583583
except Exception as ex:
584584
""" Other error raised """
585-
if (request.is_ajax()):
585+
if utils.is_ajax(request):
586586
ajaxdict["type"] = "error"
587587
ajaxdict["data"] = format_exc()
588588
response = dumps(ajaxdict)
@@ -624,7 +624,7 @@ def license_diff_helper(request):
624624
return data
625625
except jpype.JException as ex :
626626
""" Java exception raised without exiting the application """
627-
if (request.is_ajax()):
627+
if utils.is_ajax(request):
628628
ajaxdict=dict()
629629
ajaxdict["data"] = jpype.JException.message(ex)
630630
response = dumps(ajaxdict)
@@ -637,7 +637,7 @@ def license_diff_helper(request):
637637
return data
638638
except Exception as ex:
639639
""" Other exception raised """
640-
if (request.is_ajax()):
640+
if utils.is_ajax(request):
641641
ajaxdict = dict()
642642
ajaxdict["data"] = format_exc()
643643
response = dumps(ajaxdict)

src/app/generateXml.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import math
21
import re
32
import xml.etree.ElementTree as ET
43
from xml.dom import minidom
@@ -22,12 +21,6 @@ def previous_and_current(some_iterable):
2221
return list(zip(prevs, items))
2322

2423

25-
def escapeXmlData(string):
26-
for initial,final in list(entityMap.items()):
27-
string = string.replace(initial, final) # assign changed string back
28-
return string
29-
30-
3124
def isBullet(string):
3225
""" To check if the line has bullet or not.
3326
"""
@@ -149,23 +142,10 @@ def generateLicenseXml(licenseOsi, licenseIdentifier, licenseName, listVersionAd
149142
ET.SubElement(crossRefs, "crossRef").text = sourceUrl
150143
ET.SubElement(license, "standardLicenseHeader").text = licenseHeader
151144
ET.SubElement(license, "notes").text = licenseNotes
152-
licenseText = escapeXmlData(licenseText)
153145
licenseLines = licenseText.replace('\r','').split('\n\n')
154146
objList = groupLines(licenseLines)
155147
points = insertOls(objList)
156148
textElement = getTextElement(points)
157149
license.append(textElement)
158150
xmlString = ET.tostring(root, method='xml', encoding='unicode')
159-
160-
# Format the XML string with indentation for better readability
161-
xmlString = minidom.parseString(xmlString).toprettyxml(indent=" ")
162-
163-
# Remove extra blank lines added by `toprettyxml()`, ensuring clean output
164-
clean_lines = []
165-
for line in xmlString.splitlines():
166-
if line.strip(): # Only keep non-empty lines
167-
clean_lines.append(line)
168-
169-
xmlString = "\n".join(clean_lines)
170-
171151
return xmlString

0 commit comments

Comments
 (0)