def pom_filetype(file_to_check): file_in_question = file_to_check # Examining pom.xml seperately - to quickly call dependency-check or maven if needed if (file_by_mime.from_file(file_in_question) == 'text/plain' or file_by_mime.from_file(file_in_question) == 'application/xml'): print("probably a text file or xml file") # From validfile.py -- part of reason -- reuse of a function return validateFile(file_in_question) else: print("pom.xml is invalid OR something is wrong") return False
def upload(): form = pomxmlForm() if form.validate_on_submit(): filename = secure_filename(form.pomxml.data.filename) with TemporaryDirectory() as tempdir: saveAs = os.path.abspath(os.path.join(tempdir, filename)) form.pomxml.data.save(saveAs) filesign = validateFile(saveAs) if filesign == "Good": results = callsocs(tempdir, saveAs) return render_template('data.html', results=results) else: flash('Invalid file') return render_template('upload.html', form=form)