<commit_before>"""Register the protocol handler on various OSes."""

from subprocess import call, Popen, PIPE
import os
import platform
import re

def main():
    
    if platform.system() == 'Darwin':
        lsregister = '/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'
        print 'Cleaning old handlers...'
        proc = Popen([lsregister, '-dump'], stdout=PIPE, stderr=PIPE)
        for line in proc.stdout:
            m = re.match(r'\s*path:\s*(.+?/sgactions/.+?\.app)\s*$', line)
            if m:
                print m.group(1)
                call([lsregister, '-u', m.group(1)], stdout=PIPE, stderr=PIPE)
        print 'Registering new handler...'
        call([
            lsregister,
            '-v', '-f',
            os.path.abspath(os.path.join(__file__, '..', '..', 'Shotgun Action Dispatcher.app')),
        ])
        print 'Done.'
    
    elif platform.system() == 'Linux':
        call([
            os.path.abspath(os.path.join(__file__, '..', '..', 'register-linux.sh')),
        ])
    
    else:
        print 'We are not setup for protocol handlers on %s' % platform.system()


if __name__ == '__main__':
    main()<commit_msg>Be less agressive about re-registering<commit_after>"""Register the protocol handler on various OSes."""

from subprocess import call, Popen, PIPE
import os
import platform
import re

def main():
    
    if platform.system() == 'Darwin':
        lsregister = '/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'
        handler = os.path.abspath(os.path.join(__file__, '..', '..', 'Shotgun Action Dispatcher.app'))
        print 'Cleaning old handlers...'
        proc = Popen([lsregister, '-dump'], stdout=PIPE, stderr=PIPE)
        for line in proc.stdout:
            m = re.match(r'\s*path:\s*(.+?/sgactions/.+?\.app)\s*$', line)
            if m and m.group(1) != handler:
                print m.group(1)
                call([lsregister, '-u', m.group(1)], stdout=PIPE, stderr=PIPE)
        print 'Registering new handler...'
        call([
            lsregister,
            '-v',
            handler,
        ])
        print 'Done.'
    
    elif platform.system() == 'Linux':
        call([
            os.path.abspath(os.path.join(__file__, '..', '..', 'register-linux.sh')),
        ])
    
    else:
        print 'We are not setup for protocol handlers on %s' % platform.system()


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.15942028985507245, 'fraction_numerical': 0.0019584802193497847, 'mean_word_length': 2.216624685138539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3355407', 'n_tokens_mistral': 813, 'n_tokens_neox': 785, 'n_words': 181}