Example #1
0
def jsonDiff(request, file1, file2):
    if not (file1 and file2 and isPathOrTag(file1) and isPathOrTag(file2)):
        summary = { "error": "Not able to generate diff without two valid parameters." }
    else:
        mh = ManifestHandler()
        summaryObj = mh.diff(file1, file2, { 'remote': True })
        summary = summaryObj.toJSON()

    return HttpResponse(summary, content_type="application/json")
Example #2
0
def diff(request, file1, file2):
    param = {'file1': file1,
             'file2': file2 }

    if not file1 or not file2:
        summary = { "error": "Not able to generate diff without two parameters" }
        template = loader.get_template('manifest/error.html')
    elif not (isPathOrTag(file1) and isPathOrTag(file2)):
        summary = { "error": "Malformed parameter. Please cross check that the given input is a path or a string containing A-z, 0-9, _, -." }
        template = loader.get_template('manifest/error.html')
    else:
        mh = ManifestHandler()
        summary = mh.diff(file1, file2, { 'remote': False, 'full': False })
        param['summary'] = summary
        if summary.error:
            template = loader.get_template('manifest/error.html')
        else:
            template = loader.get_template('manifest/diff.html')

    context = RequestContext(request, param)
    return HttpResponse(template.render(context))