<commit_before>#!/usr/bin/python
import sys

from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
import AppKit

# constants
# DISPLAY_MODE controls the notification verbosity
#  0 shows nothing, immediately quits
#  1 replace old notification with new one in notification center
#  2 clears old notifications, add new one
#  3 shows a new notification for each cmus status change
DISPLAY_MODE = 2
# the icon file path for notification, or set as '' to disable icon displaying
ICON_PATH    = '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Actions.icns'


#------------------------------------------------------------------------------
class CmusArguments:
    def __init__(self, argv):
        self.title    = ''
        self.subtitle = ''
        self.message  = ''
        self.tags     = {
                'status': '',
                'artist': '',
                'album': '',
                'track': '',
                'title': '',
                'date': ''
                }

        argc = len(argv)
        if argc < 4:
            print('invalid arguments')
            sys.exit(1)

        n = 1
        while n < argc:
            arg = argv[n]

            if arg == 'status':
                n += 1
                self.tags['status'] = argv[n]
            elif arg == 'artist':
                n += 1
                self.tags['artist'] = argv[n]
            elif arg == 'album':
                n += 1
                self.tags['album'] = argv[n]
            elif arg == 'tracknumber':
                n += 1
                self.tags['track'] = argv[n]
            elif arg == 'title':
                n += 1
                self.tags['title'] = argv[n]
            elif arg == 'date':
                n += 1
                self.tags['date'] = argv[n]

            n += 1


    def make(self):
        if self.tags['status']:
            self.title = 'cmus {status}'.format(**self.tags)

            if self.tags['track']:
                self.subtitle += '{track}) '.format(**self.tags)

            if self.tags['title']:
                self.subtitle += '{title}'.format(**self.tags)

            if self.tags['artist']:<commit_msg>notify: prevent displaying invalid date or track number<commit_after>#!/usr/bin/python
import sys

from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
import AppKit

# constants
# DISPLAY_MODE controls the notification verbosity
#  0 shows nothing, immediately quits
#  1 replace old notification with new one in notification center
#  2 clears old notifications, add new one
#  3 shows a new notification for each cmus status change
DISPLAY_MODE = 2
# the icon file path for notification, or set as '' to disable icon displaying
ICON_PATH    = '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Actions.icns'


#------------------------------------------------------------------------------
class CmusArguments:
    def __init__(self, argv):
        self.title    = ''
        self.subtitle = ''
        self.message  = ''
        self.tags     = {
                'status': '',
                'artist': '',
                'album': '',
                'track': '',
                'title': '',
                'date': ''
                }

        argc = len(argv)
        if argc < 4:
            print('invalid arguments')
            sys.exit(1)

        n = 1
        while n < argc:
            arg = argv[n]

            if arg == 'status':
                n += 1
                self.tags['status'] = argv[n]
            elif arg == 'artist':
                n += 1
                self.tags['artist'] = argv[n]
            elif arg == 'album':
                n += 1
                self.tags['album'] = argv[n]
            elif arg == 'tracknumber':
                n += 1
                if argv[n] and argv[n] != '0':
                    self.tags['track'] = argv[n]
            elif arg == 'title':
                n += 1
                self.tags['title'] = argv[n]
            elif arg == 'date':
                n += 1
                if argv[n] and argv[n] != '0':
                    self.tags['date'] = argv[n]

            n += 1


    def make(self):
        if self.tags['status']:
            self.title = 'cmus {status}'.format(**self.tags)

            if self.tags['track']:
                self.subtitle += '{track}) '.format(**self.tags)

            if self.tags['title']:
                self.subtitle += '{title}'.format(**self.tags)

            if self.tags['artist']:
{'fraction_non_alphanumeric': 0.1547723292469352, 'fraction_numerical': 0.0070052539404553416, 'mean_word_length': 1.3600206611570247, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7519899', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1168, 'n_words': 336}