def compare_locales(a, b):
if a is None or b is None:<EOL><INDENT>if a == b:<EOL><INDENT>return <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT><DEDENT>a = split_locale(a)<EOL>b = split_locale(b)<EOL>if a == b:<EOL><INDENT>return <NUM_LIT:2><EOL><DEDENT>elif a[<NUM_LIT:0>] == b[<NUM_LIT:0>]:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>
Compares two locales to find the level of compatibility

:param a: First locale
:param b: Second locale
:return: 2 full match, 1 lang match, 0 no match