<commit_before>#!/usr/bin/python
"""
compare.py

Creates snapshots and checksums of websites
Compares snapshots
Shows changes between snapshots
"""

import requests
import base64
import time
import os

site_url = 'https://range.roche.net/'
res = requests.get(site_url)

if os.path.isfile('snapshot.b64'):
    print '\n[+] snapshot found, compare snapshot with current source...'
    snapshot_source = open('snapshot.b64', 'r').readlines()
    site_source = res.text.encode('utf-8').split('\n')
    line_counter = 0
    differencies = 0
    
    for snapshot_line in snapshot_source:
        # print 'snapshot:  ' + snapshot_line.strip()
        # print 'source:    ' + site_source[line_counter].strip()

        if snapshot_line.strip() != site_source[line_counter].strip():
            print '  >>> snaphsot line {}: '.format(line_counter + 1)
            print snapshot_line
            print '  <<< site source line {}'.format(line_counter + 1)
            print site_source[line_counter]
            differencies = differencies + 1

        line_counter = line_counter + 1

else:
    print '\n[+] snapshot not found, saving snapshot...'
    f = open('snapshot.b64', 'w')
    f.write(res.text.encode('utf-8'))

if differencies > 0:
    print '[+] {} differencies between snapshot and current source found'
else:
    print '[+] no differencies found; snapshot and current {} source are identical'.format(site_url)    
print '\n[+] DONE.'<commit_msg>[compare.py] improvements; refactoring; work in progress...<commit_after>#!/usr/bin/python
"""
compare.py

Creates snapshots and checksums of websites
Compares snapshots
Shows changes between snapshots
"""
import requests
import os

site_url = os.sys.argv[1]
snapshot_filename = site_url.replace('https://','').replace('http://','').replace('/','_').replace(':','_').replace('.','_') + '_SNAPSHOT'
differencies = 0

res = requests.get(site_url)

if os.path.isfile(snapshot_filename):
    print '\n[+] snapshot found, compare snapshot with current source...'
    snapshot_source = open(snapshot_filename, 'r').readlines()
    site_source = res.text.encode('utf-8').split('\n')
    line_counter = 0
    
    for snapshot_line in snapshot_source:
        # print 'snapshot:  ' + snapshot_line.strip()
        # print 'source:    ' + site_source[line_counter].strip()

        if snapshot_line.strip() != site_source[line_counter].strip():
            print '>>>>>     snaphsot line {}: '.format(line_counter + 1)
            print snapshot_line
            print '\n<<<<<     site source line {}'.format(line_counter + 1)
            print site_source[line_counter]

            print '\n--------------------------------------------------------------------------------------------------\n'
            differencies = differencies + 1

        line_counter = line_counter + 1

else:
    print '\n[+] snapshot not found, saving snapshot...'
    f = open(snapshot_filename, 'w')
    f.write(res.text.encode('utf-8'))

if differencies > 0:
    print '[+] {} differencies between snapshot and current source found'
else:
    print '[+] no differencies found; snapshot and current {} source are identical'.format(site_url)    
print '\n[+] DONE.'
{'fraction_non_alphanumeric': 0.16844416562107906, 'fraction_numerical': 0.008469259723964869, 'mean_word_length': 2.842168674698795, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3888118', 'n_tokens_mistral': 948, 'n_tokens_neox': 941, 'n_words': 240}