<commit_before># -*- coding: utf-8 -*-
"""
como.battery - the power connection
"""

import sys
from datetime import date, datetime

from clint.textui import puts

from .help import is_osx, is_lin, is_win
from como.settings import LOCATION_CODES

# OS dependent imports

if is_osx or is_lin:
    import subprocess

if is_win:
    try:
        import win32api
    except ImportError:
        print "The windows python api isn't installed. Please install pywin32."
        sys.exit(1)
    try:
        import wmi
    except ImportError:
        print "Make sure wmi is installed."
        sys.exit(1)


def get_age():
    """Get age of computer. Only OSX for now"""
    if is_osx:
        serial = {}
        cmd = "ioreg -l | awk '/IOPlatformSerialNumber/ " + \
              "{ split($0, line, \"\\\"\"); printf(\"%s\\n\", line[4]); }'"
        serial['number'] = subprocess.check_output(
            cmd, shell=True).translate(None, '\n')
        temp = serial['number']
        for code in LOCATION_CODES:
            temp = temp.lstrip(code)
        serial['year'] = int(temp[0])
        serial['week'] = int(temp[1:3])

        creation = str(date.today().year)[:-1] + str(
            serial['year']) + str(serial['week']) + "1"<commit_msg>Getting battery age only works with the old serial number format<commit_after># -*- coding: utf-8 -*-
"""
como.battery - the power connection
"""

# http://www.macrumors.com/2010/04/16/apple-tweaks-serial-number-format-with-new-macbook-pro/

import sys
from datetime import date, datetime

from clint.textui import puts

from .help import is_osx, is_lin, is_win
from como.settings import LOCATION_CODES

# OS dependent imports

if is_osx or is_lin:
    import subprocess

if is_win:
    try:
        import win32api
    except ImportError:
        print "The windows python api isn't installed. Please install pywin32."
        sys.exit(1)
    try:
        import wmi
    except ImportError:
        print "Make sure wmi is installed."
        sys.exit(1)


def get_age():
    """Get age of computer. Only OSX for now"""
    if is_osx:
        serial = {}
        cmd = "ioreg -l | awk '/IOPlatformSerialNumber/ " + \
              "{ split($0, line, \"\\\"\"); printf(\"%s\\n\", line[4]); }'"
        serial['number'] = subprocess.check_output(
            cmd, shell=True).translate(None, '\n')
        temp = serial['number']
        if len(temp) == 11:
            for code in LOCATION_CODES:
                temp = temp.lstrip(code)
            serial['year'] = int(temp[0])
            serial['week'] = int(temp[1:3])
        else:
            serial['year'] = 0
            serial['week'] = 0
            return "N/A"

        creation = str(date.today().year)[:-1] + str(
            serial['year']) + str(serial['week']) + "1"
{'fraction_non_alphanumeric': 0.14105793450881612, 'fraction_numerical': 0.01439366678661389, 'mean_word_length': 2.2514619883040936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '569187', 'n_tokens_mistral': 896, 'n_tokens_neox': 880, 'n_words': 244}