<commit_before># coding: utf-8

"""
filecompare
~~~~~~~~~~~

Compares files; tells you whether they're the same or different.

Copyright: © 2015 <NAME>
Licence: MIT, see LICENSE for details

"""

__title__ = 'filecompare'
__version__ = '0.1-dev'
__author__ = '<NAME>'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015 <NAME>'



import argparse



"""
global variables
----------------
path1: The path of the first file.
path2: The path of the second file.
show_same: Output result of comparison if files are the same (default: True).
show_different: Output result of comparison if files are different (default: True).
"""

path1 = ""
path2 = ""
show_same = True
show_different = True



"""
helper functions
----------------
"""

def getFileSize(path):
    """Get the size of a file.

    Parameters:
        path: A string containing the path to the file.

    Returns:
        The size of the file in bytes.
    """
    f = open(path, "rb")
    f.seek(0, 2)
    size = f.tell()
    f.close()

    return size



"""
main code
---------
"""

argparser = argparse.ArgumentParser(description="Compare files; tell whether they're the same or different.")
output_opts = argparser.add_mutually_exclusive_group()
output_opts.add_argument("--show-same-only", action="store_true")
output_opts.add_argument("--show-different-only", action="store_true")
argparser.add_argument("path1", type=str)
argparser.add_argument("path2", type=str)
args = argparser.parse_args()

path1 = args.path1
path2 = args.path2
if args.show_same_only:
    show_different = False
if args.show_different_only:
    show_same = False

if getFileSize(path1) != getFileSize(path2):
    if show_different:
        print path1 + "\t!\t" + path2
    exit(0)

f1 = open(path1, "rb")
f2 = open(path2, "rb")

for b1 in iter(f1.read(1)):<commit_msg>Added a check to make sure the files to compare exist.<commit_after># coding: utf-8

"""
filecompare
~~~~~~~~~~~

Compares files; tells you whether they're the same or different.

Copyright: © 2015 <NAME>
Licence: MIT, see LICENSE for details

"""

__title__ = 'filecompare'
__version__ = '0.1-dev'
__author__ = '<NAME>'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015 <NAME>'



import argparse
from os.path import isfile



"""
global variables
----------------
path1: The path of the first file.
path2: The path of the second file.
show_same: Output result of comparison if files are the same (default: True).
show_different: Output result of comparison if files are different (default: True).
"""

path1 = ""
path2 = ""
show_same = True
show_different = True



"""
helper functions
----------------
"""

def getFileSize(path):
    """Get the size of a file.

    Parameters:
        path: A string containing the path to the file.

    Returns:
        The size of the file in bytes.
    """
    f = open(path, "rb")
    f.seek(0, 2)
    size = f.tell()
    f.close()

    return size

def err_FNF(path):
    """Displays an error and exits when a file is not found.

    Parameters:
        path: A string containing the path to the file.

    Returns:
        -1 to indicate an error occurred.
    """
    print "Error: " + path + " does not exist."
    exit(-1)



"""
main code
---------
"""

argparser = argparse.ArgumentParser(description="Compare files; tell whether they're the same or different.")
output_opts = argparser.add_mutually_exclusive_group()
output_opts.add_argument("--show-same-only", action="store_true")
output_opts.add_argument("--show-different-only", action="store_true")
argparser.add_argument("path1", type=str)
argparser.add_argument("path2", type=str)
args = argparser.parse_args()

path1 = args.path1
path2 = args.path2
if args.show_same_only:
    show_different = False
if args.show_different_only:
    show_same = False

if not isfile(path1):
    err_FNF(path1)

if not isfile(path2):
    err_FNF(path2)

if getFileSize(path1) != getFileSize(path2):
    if show_different:
        print path1 + "\t!\t" + path2
    exit(0)

f1 = open(path1, "rb")
f2 = open(path2, "rb")

for b1 in iter(f1.read(1)):
{'fraction_non_alphanumeric': 0.14250432205482835, 'fraction_numerical': 0.018770066683131637, 'mean_word_length': 3.421397379912664, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '55114', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1303, 'n_words': 412}