<commit_before># coding: utf-8

from __future__ import division
import ui
import clipboard
from console import hud_alert
from textlayout import BuildView

shows_result = False

def button_tapped(sender):
    '@type sender: ui.Button'
    # Get the button's title for the following logic:
    t = sender.title
    global shows_result
    # Get the labels:
    label = sender.superview['label1']
    label2 = sender.superview['label2']
    if t in '0123456789':
        if shows_result or label.text == '0':
            # Replace 0 or last result with number:
            label.text = t
        else:
            # Append number:
            label.text += t
    elif t == '.' and label.text[-1] != '.':
        # Append decimal point (if not already there)
        label.text += t
    elif t in '+-÷×':
        if label.text[-1] in '+-÷×':
            # Replace current operator
            label.text = label.text[:-1] + t
        else:
            # Append operator
            label.text += t
    elif t == 'AC':
        # Clear All
        label.text = '0'
    elif t == 'C':
        # Delete the last character:
        label.text = label.text[:-1]
        if len(label.text) == 0:
            label.text = '0'
    elif t == '=':
        # Evaluate the result:
        try:
            label2.text = label.text + ' ='
            expr = label.text.replace('÷', '/').replace('×', '*')
            label.text = str(eval(expr))
        except (SyntaxError, ZeroDivisionError):
            label.text = 'ERROR'
        shows_result = True
    if t != '=':
        shows_result = False
        label2.text = ''

def copy_action(sender):
    '@type sender: ui.Button'
    t1 = sender.superview['label1'].text
    t2 = sender.superview['label2'].text
    if t2:
        text = t2 + ' ' + t1
    else:
        text = t1
    clipboard.set(text)
    hud_alert('Copied')
   
layout_text = ''' \
l-------
l-------
b-b-b-b-
b-b-b-b-
b-b-b-b-
b-b-b-b-
b--b--|-
'''


attributes = {<commit_msg>Ternary if and other misc changes<commit_after># coding: utf-8

from __future__ import division
import ui
import clipboard
from console import hud_alert
from textlayout import BuildView

shows_result = False

def button_tapped(sender):
    '@type sender: ui.Button'
    # Get the button's title for the following logic:
    t = sender.title
    global shows_result
    # Get the labels:
    label = sender.superview['label1']
    label2 = sender.superview['label2']
    if t in '0123456789':
        if shows_result or label.text == '0':
            # Replace 0 or last result with number:
            label.text = t
        else:
            # Append number:
            label.text += t
    elif t == '.' and label.text[-1] != '.':
        # Append decimal point (if not already there)
        label.text += t
    elif t in '+-÷×':
        if label.text[-1] in '+-÷×':
            # Replace current operator
            label.text = label.text[:-1] + t
        else:
            # Append operator
            label.text += t
    elif t == 'AC':
        # Clear All
        label.text = '0'
    elif t == 'C':
        # Delete the last character:
        label.text = label.text[:-1]
        if len(label.text) == 0:
            label.text = '0'
    elif t == '=':
        # Evaluate the result:
        try:
            label2.text = label.text + ' ='
            expr = label.text.replace('÷', '/').replace('×', '*')
            label.text = str(eval(expr))
        except (SyntaxError, ZeroDivisionError):
            label.text = 'ERROR'
        shows_result = True
    if t != '=':
        shows_result = False
        label2.text = ''

def copy_action(sender):
    '@type sender: ui.Button'
    t1 = sender.superview['label1'].text
    t2 = sender.superview['label2'].text
    text = t2 + ' ' + t1 if t2 else t1
    clipboard.set(text)
    hud_alert('Copied')
   
layout_text = '''
l-------
l-------
b-b-b-b-
b-b-b-b-
b-b-b-b-
b-b-b-b-
b--b--|-
'''


attributes = {
{'fraction_non_alphanumeric': 0.1441942828231723, 'fraction_numerical': 0.016696180116367317, 'mean_word_length': 1.804255319148936, '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': '2676926', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1286, 'n_words': 352}