<commit_before>'''
Screen
======

This module change some environement and configuration to match the density /
dpi / screensize of a specific devices.

To see a list of the available screenid, just run::

    python main.py -m screen

Simulate a medium-density screen as Motolora Droid 2::

    python main.py -m screen:droid2

Simulate a high-density screen as HTC One X, in portrait::

    python main.py -m screen:onex,portrait

Simulate the iPad 2 screen::

    python main.py -m screen:ipad
'''

import sys
from os import environ
from kivy.config import Config
from kivy.logger import Logger

# taken from http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
devices = {
    # device: (name, width, height, dpi, density)
    'onex': ('HTC One X', 1280, 720, 312, 2),
    's3': ('Galaxy SIII', 1280, 720, 306, 2),
    'droid2': ('Motolora Droid 2', 854, 480, 240, 1.5),
    'xoom': ('Motolora Xoom', 1280, 800, 149, 1),
    'ipad': ('iPad (1 and 2)', 1024, 768, 132, 1),
    'ipad3': ('iPad 3', 2048, 1536, 264, 2),
    'iphone4': ('iPhone 4', 640, 960, 326, 2),
    'iphone5': ('iPhone 5', 640, 1136, 326, 2),
}


def start(win, ctx):
    pass


def stop(win, ctx):
    pass


def apply_device(device, scale, orientation):
    name, width, height, dpi, density = devices[device]
    if orientation == 'portrait':
        width, height = height, width
    Logger.info('Screen: Apply screen settings for {0}'.format(name))
    Logger.info('Screen: size={0}x{1} dpi={2} density={3} '
        'orientation={4}'.format(width, height, dpi, density, orientation))
    environ['KIVY_METRICS_DENSITY'] = str(density)
    environ['KIVY_DPI'] = str(dpi)
    Config.set('graphics', 'width', str(width))
    Config.set('graphics', 'height', str(height))
    Config.set('graphics', 'fullscreen', '0')
    Config.set('graphics', 'show_mousecursor', '1')


def usage(device=None):
    if device:
        Logger.error('Screen: The specified device ({0}) is unknow.',
                device)
    print '\nModule usage: python main.py -m screen,deviceid[,orientation]\n'
    print 'Availables devices:\n'
    print '{0:12} {1:<22} {2:<8} {3:<8} {4:<5} {5:<8}'.format(
        'Device ID', 'Name', 'Width', 'Height', 'DPI', 'Density')
    for device, info in devices.iteritems():
        print '{0:12} {1:<22} {2:<8} {3:<8} {4:<5} {5:<8}'.format(
            device, *info)
    print '\n'
    print 'Simulate a medium-density screen as Motolora Droid 2:\n'
    print '    python main.py -m screen,droid2\n'
    print 'Simulate a high-density screen as HTC One X, in portrait:\n'
    print '    python main.py -m screen,onex,portrait\n'
    print 'Simulate the iPad 2 screen\n'
    print '    python main.py -m screen,ipad\n'
    sys.exit(1)


def configure(ctx):
    scale = ctx.pop('scale', None)
    orientation = 'landscape'<commit_msg>fix usage of screen module: replace "," with ":"<commit_after>'''
Screen
======

This module change some environement and configuration to match the density /
dpi / screensize of a specific devices.

To see a list of the available screenid, just run::

    python main.py -m screen

Simulate a medium-density screen as Motolora Droid 2::

    python main.py -m screen:droid2

Simulate a high-density screen as HTC One X, in portrait::

    python main.py -m screen:onex,portrait

Simulate the iPad 2 screen::

    python main.py -m screen:ipad
'''

import sys
from os import environ
from kivy.config import Config
from kivy.logger import Logger

# taken from http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
devices = {
    # device: (name, width, height, dpi, density)
    'onex': ('HTC One X', 1280, 720, 312, 2),
    's3': ('Galaxy SIII', 1280, 720, 306, 2),
    'droid2': ('Motolora Droid 2', 854, 480, 240, 1.5),
    'xoom': ('Motolora Xoom', 1280, 800, 149, 1),
    'ipad': ('iPad (1 and 2)', 1024, 768, 132, 1),
    'ipad3': ('iPad 3', 2048, 1536, 264, 2),
    'iphone4': ('iPhone 4', 640, 960, 326, 2),
    'iphone5': ('iPhone 5', 640, 1136, 326, 2),
}


def start(win, ctx):
    pass


def stop(win, ctx):
    pass


def apply_device(device, scale, orientation):
    name, width, height, dpi, density = devices[device]
    if orientation == 'portrait':
        width, height = height, width
    Logger.info('Screen: Apply screen settings for {0}'.format(name))
    Logger.info('Screen: size={0}x{1} dpi={2} density={3} '
        'orientation={4}'.format(width, height, dpi, density, orientation))
    environ['KIVY_METRICS_DENSITY'] = str(density)
    environ['KIVY_DPI'] = str(dpi)
    Config.set('graphics', 'width', str(width))
    Config.set('graphics', 'height', str(height))
    Config.set('graphics', 'fullscreen', '0')
    Config.set('graphics', 'show_mousecursor', '1')


def usage(device=None):
    if device:
        Logger.error('Screen: The specified device ({0}) is unknow.',
                device)
    print '\nModule usage: python main.py -m screen,deviceid[,orientation]\n'
    print 'Availables devices:\n'
    print '{0:12} {1:<22} {2:<8} {3:<8} {4:<5} {5:<8}'.format(
        'Device ID', 'Name', 'Width', 'Height', 'DPI', 'Density')
    for device, info in devices.iteritems():
        print '{0:12} {1:<22} {2:<8} {3:<8} {4:<5} {5:<8}'.format(
            device, *info)
    print '\n'
    print 'Simulate a medium-density screen as Motolora Droid 2:\n'
    print '    python main.py -m screen:droid2\n'
    print 'Simulate a high-density screen as HTC One X, in portrait:\n'
    print '    python main.py -m screen:onex,portrait\n'
    print 'Simulate the iPad 2 screen\n'
    print '    python main.py -m screen:ipad\n'
    sys.exit(1)


def configure(ctx):
    scale = ctx.pop('scale', None)
    orientation = 'landscape'
{'fraction_non_alphanumeric': 0.15968448729184925, 'fraction_numerical': 0.05013146362839614, 'mean_word_length': 3.4061776061776063, 'pattern_counts': {'":': 1, '<': 23, '<?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': '623144', 'n_tokens_mistral': 2211, 'n_tokens_neox': 1986, 'n_words': 624}