<commit_before>import sys
import os
import shutil

me_filename = 'mediaelement'
mep_filename = 'mediaelementplayer'
combined_filename = 'mediaelement-and-player'

# BUILD MediaElement (single file)

print('building MediaElement.js')
me_files = []
me_files.append('me-header.js')
me_files.append('me-namespace.js')
me_files.append('me-utility.js')
me_files.append('me-plugindetector.js')
me_files.append('me-featuredetection.js')
me_files.append('me-mediaelements.js')
me_files.append('me-shim.js')
me_files.append('me-i18n.js')
me_files.append('me-i18n-locale-de.js')
me_files.append('me-i18n-locale-zh.js')

code = ''

for item in me_files:
	src_file = open('js/' + item,'r')
	code += src_file.read() + "\n"

tmp_file = open('../build/' + me_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

# BUILD MediaElementPlayer (single file)
print('building MediaElementPlayer.js')
mep_files = []
mep_files.append('mep-header.js')
mep_files.append('mep-library.js')
mep_files.append('mep-player.js')
mep_files.append('mep-feature-playpause.js')
mep_files.append('mep-feature-stop.js')
mep_files.append('mep-feature-progress.js')
mep_files.append('mep-feature-time.js')
mep_files.append('mep-feature-volume.js')
mep_files.append('mep-feature-fullscreen.js')
mep_files.append('mep-feature-tracks.js')
mep_files.append('mep-feature-contextmenu.js')
mep_files.append('mep-feature-postroll.js')
# mep_files.append('mep-feature-sourcechooser.js')

code = ''

for item in mep_files:
        src_file = open('js/' + item,'r')
        code += src_file.read() + "\n"

tmp_file = open('../build/' + mep_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

# MINIFY both scripts

print('Minifying JavaScript')
# os.system("java -jar yuicompressor-2.4.2.jar ../build/" + me_filename + ".js -o ../build/" + me_filename + ".min.js --charset utf-8 -v")
# os.system("java -jar yuicompressor-2.4.2.jar ../build/" + mep_filename + ".js -o ../build/" + mep_filename + ".min.js --charset utf-8 -v")
os.system("java -jar compiler.jar --js ../build/" + me_filename + ".js --js_output_file ../build/" + me_filename + ".min.js")
os.system("java -jar compiler.jar --js ../build/" + mep_filename + ".js --js_output_file ../build/" + mep_filename + ".min.js")

# PREPEND intros
def addHeader(headerFilename, filename):

	# get the header text
	tmp_file = open(headerFilename)
	header_txt = tmp_file.read();
	tmp_file.close()

	# read the current contents of the file
	tmp_file = open(filename)
	file_txt = tmp_file.read()
	tmp_file.close()

	# open the file again for writing
	tmp_file = open(filename, 'w')
	tmp_file.write(header_txt)
	# write the original contents
	tmp_file.write(file_txt)
	tmp_file.close()

addHeader('js/me-header.js', '../build/' + me_filename + '.min.js')
addHeader('js/mep-header.js', '../build/' + mep_filename + '.min.js')

# COMBINE into single script
print('Combining scripts')
code = ''
src_file = open('../build/' + me_filename + '.js','r')
code += src_file.read() + "\n"
src_file = open('../build/' + mep_filename + '.js','r')
code += src_file.read() + "\n"

tmp_file = open('../build/' + combined_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

code = ''
src_file = open('../build/' + me_filename + '.min.js','r')
code += src_file.read() + "\n"
src_file = open('../build/' + mep_filename + '.min.js','r')
code += src_file.read() + "\n"

tmp_file = open('../build/' + combined_filename + '.min.js','w')
tmp_file.write(code)
tmp_file.close()

# MINIFY CSS
print('Minifying CSS')
src_file = open('css/mediaelementplayer.css','r')
tmp_file = open('../build/mediaelementplayer.css','w')
tmp_file.write(src_file.read())
tmp_file.close()
os.system("java -jar yuicompressor-2.4.2.jar ../build/mediaelementplayer.css -o ../build/mediaelementplayer.min.css --charset utf-8 -v")

#COPY skin files
print('Copying Skin Files')
shutil.copy2('css/controls.png','../build/controls.png')
shutil.copy2('css/controls.svg','../build/controls.svg')
shutil.copy2('css/bigplay.png','../build/bigplay.png')
shutil.copy2('css/bigplay.svg','../build/bigplay.svg')
shutil.copy2('css/loading.gif','../build/loading.gif')

shutil.copy2('css/mejs-skins.css','../build/mejs-skins.css')
shutil.copy2('css/controls-ted.png','../build/controls-ted.png')
shutil.copy2('css/controls-wmp.png','../build/controls-wmp.png')
shutil.copy2('css/controls-wmp-bg.png','../build/controls-wmp-bg.png')

print('DONE!')
<commit_msg>remove console.log statements from builds<commit_after>import sys
import os
import shutil
import re

def remove_console(text):
	return re.sub('console.(log|debug)\((.*)\);?', '', text)

me_filename = 'mediaelement'
mep_filename = 'mediaelementplayer'
combined_filename = 'mediaelement-and-player'

# BUILD MediaElement (single file)

print('building MediaElement.js')
me_files = []
me_files.append('me-header.js')
me_files.append('me-namespace.js')
me_files.append('me-utility.js')
me_files.append('me-plugindetector.js')
me_files.append('me-featuredetection.js')
me_files.append('me-mediaelements.js')
me_files.append('me-shim.js')
me_files.append('me-i18n.js')
me_files.append('me-i18n-locale-de.js')
me_files.append('me-i18n-locale-zh.js')

code = ''

for item in me_files:
	src_file = open('js/' + item,'r')
	code += src_file.read() + "\n"

code = remove_console(code)

tmp_file = open('../build/' + me_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

# BUILD MediaElementPlayer (single file)
print('building MediaElementPlayer.js')
mep_files = []
mep_files.append('mep-header.js')
mep_files.append('mep-library.js')
mep_files.append('mep-player.js')
mep_files.append('mep-feature-playpause.js')
mep_files.append('mep-feature-stop.js')
mep_files.append('mep-feature-progress.js')
mep_files.append('mep-feature-time.js')
mep_files.append('mep-feature-volume.js')
mep_files.append('mep-feature-fullscreen.js')
mep_files.append('mep-feature-tracks.js')
mep_files.append('mep-feature-contextmenu.js')
mep_files.append('mep-feature-postroll.js')
# mep_files.append('mep-feature-sourcechooser.js')

code = ''

for item in mep_files:
    src_file = open('js/' + item,'r')
    code += src_file.read() + "\n"

code = remove_console(code)

tmp_file = open('../build/' + mep_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

# MINIFY both scripts

print('Minifying JavaScript')
# os.system("java -jar yuicompressor-2.4.2.jar ../build/" + me_filename + ".js -o ../build/" + me_filename + ".min.js --charset utf-8 -v")
# os.system("java -jar yuicompressor-2.4.2.jar ../build/" + mep_filename + ".js -o ../build/" + mep_filename + ".min.js --charset utf-8 -v")
os.system("java -jar compiler.jar --js ../build/" + me_filename + ".js --js_output_file ../build/" + me_filename + ".min.js")
os.system("java -jar compiler.jar --js ../build/" + mep_filename + ".js --js_output_file ../build/" + mep_filename + ".min.js")

# PREPEND intros
def addHeader(headerFilename, filename):

	# get the header text
	tmp_file = open(headerFilename)
	header_txt = tmp_file.read();
	tmp_file.close()

	# read the current contents of the file
	tmp_file = open(filename)
	file_txt = tmp_file.read()
	tmp_file.close()

	# open the file again for writing
	tmp_file = open(filename, 'w')
	tmp_file.write(header_txt)
	# write the original contents
	tmp_file.write(file_txt)
	tmp_file.close()

addHeader('js/me-header.js', '../build/' + me_filename + '.min.js')
addHeader('js/mep-header.js', '../build/' + mep_filename + '.min.js')

# COMBINE into single script
print('Combining scripts')
code = ''
src_file = open('../build/' + me_filename + '.js','r')
code += src_file.read() + "\n"
src_file = open('../build/' + mep_filename + '.js','r')
code += src_file.read() + "\n"

tmp_file = open('../build/' + combined_filename + '.js','w')
tmp_file.write(code)
tmp_file.close()

code = ''
src_file = open('../build/' + me_filename + '.min.js','r')
code += src_file.read() + "\n"
src_file = open('../build/' + mep_filename + '.min.js','r')
code += src_file.read() + "\n"

tmp_file = open('../build/' + combined_filename + '.min.js','w')
tmp_file.write(code)
tmp_file.close()

# MINIFY CSS
print('Minifying CSS')
src_file = open('css/mediaelementplayer.css','r')
tmp_file = open('../build/mediaelementplayer.css','w')
tmp_file.write(src_file.read())
tmp_file.close()
os.system("java -jar yuicompressor-2.4.2.jar ../build/mediaelementplayer.css -o ../build/mediaelementplayer.min.css --charset utf-8 -v")

#COPY skin files
print('Copying Skin Files')
shutil.copy2('css/controls.png','../build/controls.png')
shutil.copy2('css/controls.svg','../build/controls.svg')
shutil.copy2('css/bigplay.png','../build/bigplay.png')
shutil.copy2('css/bigplay.svg','../build/bigplay.svg')
shutil.copy2('css/loading.gif','../build/loading.gif')

shutil.copy2('css/mejs-skins.css','../build/mejs-skins.css')
shutil.copy2('css/controls-ted.png','../build/controls-ted.png')
shutil.copy2('css/controls-wmp.png','../build/controls-wmp.png')
shutil.copy2('css/controls-wmp-bg.png','../build/controls-wmp-bg.png')

print('DONE!')
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import get_service
def edit_spread(cels, row):

    print 'INIT_EDIT'
    print row

    service_in = get_service.get_service()
    service = service_in[0]
    spreadsheetId_in = service_in[1]

    row_titles = service.spreadsheets().values().get(spreadsheetId=spreadsheetId_in, majorDimension='ROWS', valueRenderOption='FORMATTED_VALUE', range='1:1').execute()
    print row_titles

    ranges = str(row) + ':' + str(row)

    print ranges
    values = []

    for title in row_titles['values'][0]:

        value = []

        value.append(cels[title])
        values.append(value)

    data_in = [  { "range": ranges,
                  "majorDimension":"COLUMNS",
                  "values": values  },
            ]
    print data_in
    data_out = {
              "valueInputOption": "RAW",

              "data":data_in}

    result = service.spreadsheets().values().batchUpdate(spreadsheetId=spreadsheetId_in, body=data_out).execute()
    list_update = []
    if result['responses']:

        for r in result['responses']:
            list_update.append(r['updatedRange'])

    print result
    print('END EDIT')

    return row

if __name__ == '__main__':

    data_no = [  { "range": "2:3",
               "majorDimension":"COLUMNS",
                "values": [ ["A1a1a1a1a1a"], ["A1a1a1a1a1a"], ["A1a1a1a1a1a"]]  },
            ]
    data = {"PROVINCE": "BARCELONA", "OWNER": "VODAFONE", "U900_COORDINADO": "NO", "ACCION PTE ASP": "", "site": "0555455", "PLANI 07-05-16": "#N/A", "SUBPROYECTO": "ANE 2016", "AUTOSWAP_3G": "NO", "ESTADO": "", "GOG 07-05-16": "#N/A", "PRIORIDAD_REPLANTEO": "2. MAYOR", "SEG. DIARIO": "SEG2016", "pt": "345587", "PREV ENTREGA": "19/04/2016", "ACCION PTE ERICSSON": "", "D_EMPLAZAMIENTO": "SABADELL/CAN RULL", "ROW": "2", "Fecha comentario": "27/04/2016", "CONTADOR RECHAZOS": "A2", "Fecha ULTIMO RECHAZO": "Bingo!", "LTE_1800": "NO", "ultimo tme": "Bingo!", "ESTADO REPLANTEO ASP": "Bingo!", "OTRAS_ACTIVIDADES": "", "ESTADO REPLANTEO ANE": "01. PTE PLANIFICAR", "Semana replanteo": "Bingo!", "CONTADOR": "A2", "Week rechazo": "#VALUE!", "smartel": "Bingo!", "ASP REPLANTEO": "Bingo!", "TIPO_PLAN": "#N/A", "COMENTARIOS": "25/04/16 editado nuevo", "LTE_800": "NO", "COCs SITE": "201408003659 IMPLANTACI\u0420\u2014?N LTE1800 201407004186 IMPLANTACI\u0420\u2014?N TCU", "ACCION": "", "AUTOSWAP_2G": "NO", "EXPRESS": "", "U900_NO_COORDINADO": "SI (W08/15)", "coc": "", "SITE CODE_F": "0800042", "ESTADO CAP": "#N/A"}
    row = 2
    edit_spread(data, row)

<commit_msg>Delete spread_edit.py<commit_after><|endoftext|>


<commit_before># -*- encoding: utf-8 -*-
################################################################################
## TexPack Sprite and Sheet classes
################################################################################

__all__ = ['Rect', 'Sprite', 'Sheet']

import logging
log = logging.getLogger(__name__)

################################################################################

def get_next_power_of_2(n):
    n = int(n) & 0x7fffffffffffffff
    n -= 1
    n |= n >> 32
    n |= n >> 16
    n |= n >>  8
    n |= n >>  4
    n |= n >>  2
    n |= n >>  1
    n += 1
    return n

################################################################################

class Rect(object):
    def __init__(self, w=0, h=0, x=0, y=0):
        self.x = x
        self.y = y
        self.w = w
        self.h = h

    def __repr__(self):
        return 'Rect<x=%s,y=%s,w=%s,h=%s>' % (self.x, self.y, self.w, self.h)

    @property
    def left(self):
        return self.x
    @left.setter
    def left(self, value):
        self.x = value

    @property
    def top(self):
        return self.y
    @top.setter
    def top(self, value):
        self.y = value

    @property
    def right(self):
        return self.x + self.w
    @right.setter
    def right(self, value):
        self.w = max(0, value - self.x)

    @property
    def bottom(self):
        return self.y + self.h
    @bottom.setter
    def bottom(self, value):
        self.h = max(0, value - self.y)

    @property
    def width(self):
        return self.w
    @width.setter
    def width(self, value):
        self.w = max(0, value)

    @property
    def height(self):
        return self.h
    @height.setter
    def height(self, value):
        self.h = max(0, value)

    @property
    def empty(self):
        return self.w <= 0 and self.h <= 0

    def copy(self):
        return Rect(self.w, self.h, self.x, self.y)

    def intersects(self, rect):
        return self.x + self.w > rect.x and self.x < rect.x + rect.w and \
               self.y + self.h > rect.y and self.y < rect.y + rect.h

    def contains(self, rect):
        return rect.x >= self.x and rect.x + rect.w <= self.x + self.w and \
               rect.y >= self.y and rect.y + rect.h <= self.y + self.h

    def intersect(self, rect):
        r = Rect()
        r.left   = max(self.left,   rect.left  )
        r.top    = max(self.top,    rect.top   )
        r.right  = min(self.right,  rect.right )
        r.bottom = min(self.bottom, rect.bottom)
        return r

    def union(self, rect):
        r = Rect()
        r.left   = min(self.left,   rect.left  )
        r.top    = min(self.top,    rect.top   )
        r.right  = max(self.right,  rect.right )
        r.bottom = max(self.bottom, rect.bottom)
        return r

################################################################################

from PIL import Image
from PIL import ImageDraw
import os

class Sprite(Rect):
    def __init__(self, image, *args, **kwargs):
        if str(image) == image:
            self.filename = image
            kwargs.setdefault('name', os.path.basename(image))
            image = Image.open(image).convert('RGBA')

        self.name = kwargs.get('name')
        self.image = image
        self.pixels = image.load() if image else None
        self.rotated = False
        self.x, self.y = 0, 0

    @property
    def image(self):
        if self.rotated:
            try:
                return self._rimage
            except AttributeError:
                self._rimage = self._image.transpose(Image.ROTATE_90)
                return self._rimage
        else:
            return self._image

    @image.setter
    def image(self, value):
        self._image = value
        self._rimage = None
        self.w, self.h = value.size
        self.rotated = False

    def rotate(self):
        self.rotated = not self.rotated
        self.w, self.h = self.h, self.w

class Sheet(object):
    def __init__(
        self,
        layout=None,
        min_size=0,
        max_size=0,
        rotate=False,
        npot=False,
        square=False,
    ):
        try:
            min_size = int(min_size)
            min_size = min_size, min_size
        finally:
            pass

        try:
            max_size = int(max_size)
            max_size = max_size, max_size
        finally:
            pass

        if not npot:
            min_size = (
                get_next_power_of_2(min_size[0]),
                get_next_power_of_2(min_size[1])
                )
            max_size = (
                get_next_power_of_2(max_size[0]),
                get_next_power_of_2(max_size[1])
                )

        self.layout_type = layout
        self.min_size = min_size
        self.max_size = max_size
        self.rotate = rotate
        self.npot = npot
        self.square = square

        self.clear()

    def clear(self):
        self.sprites = []
        self.size = self.min_size

    def grow(self):
        maxw, maxh = self.max_size
        oldw, oldh = self.size

        w = oldw * 2
        h = oldh * 2

        if maxw > 0 and w > maxw:
            w = maxw
        elif w < 1:
            w = 1
        if maxh > 0 and h > maxh:
            h = maxh
        elif h < 1:
            h = 1

        if not self.npot:
            w = get_next_power_of_2(w)
            h = get_next_power_of_2(h)

        self.size = w, h
        return w > oldw or h > oldh

    def checkw(self, rect):
        w, h = self.size
        rw = rect.x + rect.w
        return rw <= w

    def checkh(self, rect):
        w, h = self.size
        rh = rect.y + rect.h
        return rh <= h

    def check(self, rect):
        return self.checkw(rect) and self.checkh(rect)

    def do_layout(self, sprites=None):
        placed = []
        remain = []

        if self.layout_type:
            if sprites is None:
                sprites = self.sprites
            self.layout = self.layout_type(self)
            placed, remain = self.layout.add(*sprites)

        return placed, remain

    def add(self, sprites):
        temp = self.sprites + sprites

        placed, remain = self.do_layout(temp)

        while remain:
            if not self.grow():
                break

            placed, remain = self.do_layout(temp)

        self.sprites = placed

        return remain

    def prepare(self, debug=None):
        texture = Image.new('RGBA', self.size) # args.color_depth

        for spr in self.sprites:
            texture.paste(spr.image, (spr.x, spr.y), spr.image)

        if debug:
            draw = ImageDraw.Draw(texture)
            color = debug

            for spr in self.sprites:
                x0, y0, x1, y1 = spr.left, spr.top, spr.right, spr.bottom
                draw.rectangle((x0, y0, x1, y1), None, color)
                draw.text((x0+2, y0+2), spr.name, color)
                if hasattr(spr, 'alias'):
                    y0 += draw.textsize(spr.alias.name)[1]
                    draw.text((x0+2, y0+2), spr.alias.name, color)

            self.layout.debug_draw(texture, draw)

        return texture

    @property
    def coverage(self):
        area = self.size[0] * self.size[1]
        used = 0
        for spr in self.sprites:
            used += spr.w * spr.h
        return float(used) / float(area)

################################################################################
## EOF
################################################################################

<commit_msg>Fix Sprite.image returning incorrect value after rotate()<commit_after># -*- encoding: utf-8 -*-
################################################################################
## TexPack Sprite and Sheet classes
################################################################################

__all__ = ['Rect', 'Sprite', 'Sheet']

import logging
log = logging.getLogger(__name__)

################################################################################

def get_next_power_of_2(n):
    n = int(n) & 0x7fffffffffffffff
    n -= 1
    n |= n >> 32
    n |= n >> 16
    n |= n >>  8
    n |= n >>  4
    n |= n >>  2
    n |= n >>  1
    n += 1
    return n

################################################################################

class Rect(object):
    def __init__(self, w=0, h=0, x=0, y=0):
        self.x = x
        self.y = y
        self.w = w
        self.h = h

    def __repr__(self):
        return 'Rect<x=%s,y=%s,w=%s,h=%s>' % (self.x, self.y, self.w, self.h)

    @property
    def left(self):
        return self.x
    @left.setter
    def left(self, value):
        self.x = value

    @property
    def top(self):
        return self.y
    @top.setter
    def top(self, value):
        self.y = value

    @property
    def right(self):
        return self.x + self.w
    @right.setter
    def right(self, value):
        self.w = max(0, value - self.x)

    @property
    def bottom(self):
        return self.y + self.h
    @bottom.setter
    def bottom(self, value):
        self.h = max(0, value - self.y)

    @property
    def width(self):
        return self.w
    @width.setter
    def width(self, value):
        self.w = max(0, value)

    @property
    def height(self):
        return self.h
    @height.setter
    def height(self, value):
        self.h = max(0, value)

    @property
    def empty(self):
        return self.w <= 0 and self.h <= 0

    def copy(self):
        return Rect(self.w, self.h, self.x, self.y)

    def intersects(self, rect):
        return self.x + self.w > rect.x and self.x < rect.x + rect.w and \
               self.y + self.h > rect.y and self.y < rect.y + rect.h

    def contains(self, rect):
        return rect.x >= self.x and rect.x + rect.w <= self.x + self.w and \
               rect.y >= self.y and rect.y + rect.h <= self.y + self.h

    def intersect(self, rect):
        r = Rect()
        r.left   = max(self.left,   rect.left  )
        r.top    = max(self.top,    rect.top   )
        r.right  = min(self.right,  rect.right )
        r.bottom = min(self.bottom, rect.bottom)
        return r

    def union(self, rect):
        r = Rect()
        r.left   = min(self.left,   rect.left  )
        r.top    = min(self.top,    rect.top   )
        r.right  = max(self.right,  rect.right )
        r.bottom = max(self.bottom, rect.bottom)
        return r

################################################################################

from PIL import Image
from PIL import ImageDraw
import os

class Sprite(Rect):
    def __init__(self, image, *args, **kwargs):
        if str(image) == image:
            self.filename = image
            kwargs.setdefault('name', os.path.basename(image))
            image = Image.open(image).convert('RGBA')

        self.name = kwargs.get('name')
        self.image = image
        self.pixels = image.load() if image else None
        self.rotated = False
        self.x, self.y = 0, 0

    @property
    def image(self):
        if self.rotated:
            if not hasattr(self, '_rimage') or self._rimage is None:
                self._rimage = self._image.transpose(Image.ROTATE_90)
            return self._rimage
        else:
            return self._image

    @image.setter
    def image(self, value):
        self._image = value
        self._rimage = None
        self.w, self.h = value.size
        self.rotated = False

    def rotate(self):
        self.rotated = not self.rotated
        self.w, self.h = self.h, self.w

class Sheet(object):
    def __init__(
        self,
        layout=None,
        min_size=0,
        max_size=0,
        rotate=False,
        npot=False,
        square=False,
    ):
        try:
            min_size = int(min_size)
            min_size = min_size, min_size
        finally:
            pass

        try:
            max_size = int(max_size)
            max_size = max_size, max_size
        finally:
            pass

        if not npot:
            min_size = (
                get_next_power_of_2(min_size[0]),
                get_next_power_of_2(min_size[1])
                )
            max_size = (
                get_next_power_of_2(max_size[0]),
                get_next_power_of_2(max_size[1])
                )

        self.layout_type = layout
        self.min_size = min_size
        self.max_size = max_size
        self.rotate = rotate
        self.npot = npot
        self.square = square

        self.clear()

    def clear(self):
        self.sprites = []
        self.size = self.min_size

    def grow(self):
        maxw, maxh = self.max_size
        oldw, oldh = self.size

        w = oldw * 2
        h = oldh * 2

        if maxw > 0 and w > maxw:
            w = maxw
        elif w < 1:
            w = 1
        if maxh > 0 and h > maxh:
            h = maxh
        elif h < 1:
            h = 1

        if not self.npot:
            w = get_next_power_of_2(w)
            h = get_next_power_of_2(h)

        self.size = w, h
        return w > oldw or h > oldh

    def checkw(self, rect):
        w, h = self.size
        rw = rect.x + rect.w
        return rw <= w

    def checkh(self, rect):
        w, h = self.size
        rh = rect.y + rect.h
        return rh <= h

    def check(self, rect):
        return self.checkw(rect) and self.checkh(rect)

    def do_layout(self, sprites=None):
        placed = []
        remain = []

        if self.layout_type:
            if sprites is None:
                sprites = self.sprites
            self.layout = self.layout_type(self)
            placed, remain = self.layout.add(*sprites)

        return placed, remain

    def add(self, sprites):
        temp = self.sprites + sprites

        placed, remain = self.do_layout(temp)

        while remain:
            if not self.grow():
                break

            placed, remain = self.do_layout(temp)

        self.sprites = placed

        return remain

    def prepare(self, debug=None):
        texture = Image.new('RGBA', self.size) # args.color_depth

        for spr in self.sprites:
            texture.paste(spr.image, (spr.x, spr.y), spr.image)

        if debug:
            draw = ImageDraw.Draw(texture)
            color = debug

            for spr in self.sprites:
                x0, y0, x1, y1 = spr.left, spr.top, spr.right, spr.bottom
                draw.rectangle((x0, y0, x1, y1), None, color)
                draw.text((x0+2, y0+2), spr.name, color)
                if hasattr(spr, 'alias'):
                    y0 += draw.textsize(spr.alias.name)[1]
                    draw.text((x0+2, y0+2), spr.alias.name, color)

            self.layout.debug_draw(texture, draw)

        return texture

    @property
    def coverage(self):
        area = self.size[0] * self.size[1]
        used = 0
        for spr in self.sprites:
            used += spr.w * spr.h
        return float(used) / float(area)

################################################################################
## EOF
################################################################################

<|endoftext|>


<commit_before>DUBLIN_CORE_XML = '''<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
  <dc:title qualifier="officialtitle">The Bronco, Yearbook of Hardin-Simmons University, 1944</dc:title>
  <dc:title qualifier="serialtitle">The Bronco</dc:title>
  <dc:title qualifier="addedtitle">The Bronco 1944</dc:title>
  <dc:creator qualifier="aut">
    <type>org</type>
    <name>Hardin-Simmons University</name>
  </dc:creator>
  <dc:creator qualifier="edt">
    <type>per</type>
    <name>Mahoney, Doris</name>
  </dc:creator>
  <dc:publisher>
    <name>Hardin-Simmons University</name>
    <location>Abilene, Texas</location>
  </dc:publisher>
  <dc:date qualifier="creation">1944</dc:date>
  <dc:date qualifier="digitized">2008</dc:date>
  <dc:language>eng</dc:language>
  <dc:description qualifier="content">Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.</dc:description>
  <dc:description qualifier="physical">Not paginated : ill ; 31 cm.</dc:description>
  <dc:subject qualifier="LCSH">Simmons College (Abilene, Tex.) -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">Simmons University (Abilene, Tex.) -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">Hardin-Simmons University -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">World War, 1939-1945 -- Texas.</dc:subject>
  <dc:subject qualifier="UNTL-BS">Education - Colleges and Universities</dc:subject>
  <dc:subject qualifier="UNTL-BS">Education - Yearbooks</dc:subject>
  <dc:subject qualifier="UNTL-BS">People</dc:subject>
  <dc:subject qualifier="UNTL-BS">Social Life and Customs - Clubs and Organizations</dc:subject>
  <dc:subject qualifier="UNTL-BS">Sports and Recreation</dc:subject>
  <dc:subject qualifier="UNTL-BS">Arts and Crafts</dc:subject>
  <dc:subject qualifier="KWD">louie</dc:subject>
  <dc:subject qualifier="KWD">sarge</dc:subject>
  <dc:coverage qualifier="placeName">United States - Texas</dc:coverage>
  <dc:coverage qualifier="timePeriod">mod-tim</dc:coverage>
  <dc:coverage qualifier="sDate">1943</dc:coverage>
  <dc:coverage qualifier="eDate">1944</dc:coverage>
  <dc:format>text</dc:format>
  <dc:identifier qualifier="OCLC">14281668</dc:identifier>
</oai_dc:dc>
'''

UNTL_DICT = {
    'publisher': [
        {'content': {'name': 'Hardin-Simmons University', 'location': 'Abilene, Texas'}}],
    'description': [
        {'content': 'Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.', 'qualifier': 'content'},
        {'content': 'Not paginated : ill ; 31 cm.', 'qualifier': 'physical'}],
    'language': [
        {'content': 'eng'}],
    'creator': [
        {'content': {'type': 'org', 'name': 'Hardin-Simmons University'}, 'qualifier': 'aut'},
        {'content': {'type': 'per', 'name': 'Mahoney, Doris'}, 'qualifier': 'edt'}],
    'resourceType': [
        {'content': 'text_book'}],
    'format': [
        {'content': 'text'}],
    'title': [
        {'content': 'The Bronco, Yearbook of Hardin-Simmons University, 1944', 'qualifier': 'officialtitle'},
        {'content': 'The Bronco', 'qualifier': 'serialtitle'},
        {'content': 'The Bronco 1944', 'qualifier': 'addedtitle'}],
    'collection': [
        {'content': 'HSUY'}],
    'note': [
        {'content': '"Published Annually by Hardin-Simmons University, Abilene, Texas, 37th Edition."', 'qualifier': 'display'},
        {'content': 'comment: Descriptive metadata by htarver 2008-06-27.', 'qualifier': 'nonDisplay'},
        {'content': 'creationAppName: Adobe Photoshop\ncreationAppVersion: 7', 'qualifier': 'digitalPreservation'}],
    'meta': [
        {'content': 'ark:/67531/metapth38622', 'qualifier': 'ark'},
        {'content': 'meta-pth-38622', 'qualifier': 'meta-id'},
        {'content': 'meta-pcc-ae70cfc0-4572-11dd-8cf9-001676db018a', 'qualifier': 'meta-id'},
        {'content': '3203213158', 'qualifier': 'objectMasterSize'},
        {'content': '2008-06-29, 00:31:14', 'qualifier': 'metadataCreationDate'},
        {'content': 'mphillips', 'qualifier': 'metadataCreator'},
        {'content': 'PTH', 'qualifier': 'system'},
        {'content': '/data/ALC/HSUL/HSUY', 'qualifier': 'TKLPath'}],
    'coverage': [
        {'content': 'United States - Texas', 'qualifier': 'placeName'},
        {'content': 'mod-tim', 'qualifier': 'timePeriod'},
        {'content': '1943', 'qualifier': 'sDate'},
        {'content': '1944', 'qualifier': 'eDate'}],
    'date': [
        {'content': '1944', 'qualifier': 'creation'},
        {'content': '2008', 'qualifier': 'digitized'}],
    'identifier': [
        {'content': '14281668', 'qualifier': 'OCLC'}],
    'primarySource': [
        {'content': '1'}],
    'institution': [
        {'content': 'HSUL'}],
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'Education - Colleges and Universities', 'qualifier': 'UNTL-BS'},
        {'content': 'Education - Yearbooks', 'qualifier': 'UNTL-BS'},
        {'content': 'People', 'qualifier': 'UNTL-BS'},
        {'content': 'Social Life and Customs - Clubs and Organizations', 'qualifier': 'UNTL-BS'},
        {'content': 'Sports and Recreation', 'qualifier': 'UNTL-BS'},
        {'content': 'Arts and Crafts', 'qualifier': 'UNTL-BS'},
        {'content': 'louie', 'qualifier': 'KWD'},
        {'content': 'sarge', 'qualifier': 'KWD'}, ]
    }

BAD_UNTL_DICT = {
    'publisher': [
        {'content': {'name': 'Hardin-Simmons University', 'location': 'Abilene, Texas'}}],
    'description': [
        {'content': 'Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.', 'qualifier': 'content'},
        {'content': 'Not paginated : ill ; 31 cm.'}]
}

# Example of UNTL dict that needs normalization
UNNORMALIZED_DICT = {
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.)--Students--Yearbooks', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students --Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Food supply -- United States.', 'qualifier': 'LCSH'},
        {'content': 'Business, Economics and Finance  - Journalism', 'qualifier': 'UNTL-BS'},
        {'content': 'Business, Economics and Finance  -  Journalism', 'qualifier': 'UNTL-BS'},
        ]
    }

# UNTL dict with proper normalization
NORMALIZED_DICT = {
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Food supply -- United States.', 'qualifier': 'LCSH'},
        {'content': 'Business, Economics and Finance - Journalism', 'qualifier': 'UNTL-BS'},
        {'content': 'Business, Economics and Finance - Journalism', 'qualifier': 'UNTL-BS'},
        ]
    }

# An unnormalized untl-bs string
UNNORMALIZED_UNTLBS = 'Business, Economics and Finance  - Journalism'

# An unnormalized lcsh string
UNNORMALIZED_LCSH = 'Guitar music--History and criticism'

# A normalized untl-bs string
NORMALIZED_UNTLBS = 'Business, Economics and Finance - Journalism'

# A normalized lcsh string
NORMALIZED_LCSH = 'Guitar music -- History and criticism.'

# Defined for testing post2pydict
IGNORE_POST_LIST = [
    'publish',
    'save',
    'csrfmiddlewaretoken',
    ]

# Defined for testing post2pydict
EXPECTED_POST_TO_PYDICT = {
    'collection': [{'content': u'UNTCVA'}, {'content': u'UNTSW'}],
    'coverage': [{'content': u'2000', 'qualifier': u'date'}],
    'creator': [{'content': {'info': u'University of North Texas',
                             'name': u'Falsetta, Vincent',
                             'type': u'per'},
                 'qualifier': u'art'}],
    'date': [{'content': u'2000', 'qualifier': u'creation'}],
    'degree': [{'content': u'Studio Arts', 'qualifier': u'department'}],
    'description': [{'content': u'1 art original : oil paint on canvas ;' +
                     ' 72 x 84 in.',
                     'qualifier': u'physical'},
                    {'content': u'This abstract painting is mostly black ' +
                     'with some white vertical scrapes.',
                     'qualifier': u'content'}],
    'format': [{'content': u'image'}],
    'identifier': [{'content': u'2010063245', 'qualifier': u'LOCAL-CONT-NO'}],
    'institution': [{'content': u'UNTCVA'}],
    'language': [{'content': u'nol'}],
    'meta': [{'content': u'metadc27160', 'qualifier': u'meta-id'},
             {'content': u'DC', 'qualifier': u'system'},
             {'content': u'ark:/67531/metadc27160', 'qualifier': u'ark'},
             {'content': u'2010-08-25, 21:10:41',
              'qualifier': u'metadataCreationDate'},
             {'content': u'acpmaker', 'qualifier': u'metadataCreator'},
             {'content': u'jliechty', 'qualifier': u'metadataModifier'},
             {'content': u'2013-10-31, 13:09:12',
              'qualifier': u'metadataModificationDate'},
             {'content': u'False', 'qualifier': u'hidden'}],
    'note': [{'content': u'comment: Descriptive metadata template created ' +
              'by htarver 2010-07-05.',
              'qualifier': u'nonDisplay'}],
    'primarySource': [{'content': u'1'}],
    'resourceType': [{'content': u'image_artwork'}],
    'rights': [{'content': u'public', 'qualifier': u'access'},
               {'content': u'Vincent Falsetta, Denton, TX',
                'qualifier': u'holder'},
               {'content': u'copyright', 'qualifier': u'license'},
               {'content': u'Copyright 2010, Vincent Falsetta, All Rights' +
                ' Reserved',
                'qualifier': u'statement'}],
    'subject': [{'content': u'paintings (visual works)', 'qualifier': u'AAT'},
                {'content': u'works of art', 'qualifier': u'AAT'},
                {'content': u'oil paint (paint)', 'qualifier': u'AAT'}],
    'title': [{'content': u'AL 00-3.', 'qualifier': u'officialtitle'}]
    }

# Skeleton vocabulary for mock return value.
VOCAB = {'title-qualifiers': [],
         'identifier-qualifiers': [],
         'note-qualifiers': [],
         'subject-qualifiers': [],
         'description-qualifiers': [],
         'date-qualifiers': [],
         'sourceQualifiers': [],
         'coverage-qualifiers': [],
         'relation-qualifiers': [],
         'rights-qualifiers': [],
         'degree-information': [],
         'meta-qualifiers': [],
         'citationQualifiers': [],
         'agent-type': [],
         'agent-qualifiers': [],
         'institutions': [],
         'collections': [],
         'languages': [],
         'resource-types': [],
         'formats': [],
         'coverage-eras': [],
         'rights-access': [],
         'rights-licenses': [],
         'publication-types': []}
<commit_msg>Remove encoding from DUBLIN_CORE_XML<commit_after>DUBLIN_CORE_XML = '''<?xml version="1.0"?>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
  <dc:title qualifier="officialtitle">The Bronco, Yearbook of Hardin-Simmons University, 1944</dc:title>
  <dc:title qualifier="serialtitle">The Bronco</dc:title>
  <dc:title qualifier="addedtitle">The Bronco 1944</dc:title>
  <dc:creator qualifier="aut">
    <type>org</type>
    <name>Hardin-Simmons University</name>
  </dc:creator>
  <dc:creator qualifier="edt">
    <type>per</type>
    <name>Mahoney, Doris</name>
  </dc:creator>
  <dc:publisher>
    <name>Hardin-Simmons University</name>
    <location>Abilene, Texas</location>
  </dc:publisher>
  <dc:date qualifier="creation">1944</dc:date>
  <dc:date qualifier="digitized">2008</dc:date>
  <dc:language>eng</dc:language>
  <dc:description qualifier="content">Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.</dc:description>
  <dc:description qualifier="physical">Not paginated : ill ; 31 cm.</dc:description>
  <dc:subject qualifier="LCSH">Simmons College (Abilene, Tex.) -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">Simmons University (Abilene, Tex.) -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">Hardin-Simmons University -- Students -- Yearbooks.</dc:subject>
  <dc:subject qualifier="LCSH">World War, 1939-1945 -- Texas.</dc:subject>
  <dc:subject qualifier="UNTL-BS">Education - Colleges and Universities</dc:subject>
  <dc:subject qualifier="UNTL-BS">Education - Yearbooks</dc:subject>
  <dc:subject qualifier="UNTL-BS">People</dc:subject>
  <dc:subject qualifier="UNTL-BS">Social Life and Customs - Clubs and Organizations</dc:subject>
  <dc:subject qualifier="UNTL-BS">Sports and Recreation</dc:subject>
  <dc:subject qualifier="UNTL-BS">Arts and Crafts</dc:subject>
  <dc:subject qualifier="KWD">louie</dc:subject>
  <dc:subject qualifier="KWD">sarge</dc:subject>
  <dc:coverage qualifier="placeName">United States - Texas</dc:coverage>
  <dc:coverage qualifier="timePeriod">mod-tim</dc:coverage>
  <dc:coverage qualifier="sDate">1943</dc:coverage>
  <dc:coverage qualifier="eDate">1944</dc:coverage>
  <dc:format>text</dc:format>
  <dc:identifier qualifier="OCLC">14281668</dc:identifier>
</oai_dc:dc>
'''

UNTL_DICT = {
    'publisher': [
        {'content': {'name': 'Hardin-Simmons University', 'location': 'Abilene, Texas'}}],
    'description': [
        {'content': 'Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.', 'qualifier': 'content'},
        {'content': 'Not paginated : ill ; 31 cm.', 'qualifier': 'physical'}],
    'language': [
        {'content': 'eng'}],
    'creator': [
        {'content': {'type': 'org', 'name': 'Hardin-Simmons University'}, 'qualifier': 'aut'},
        {'content': {'type': 'per', 'name': 'Mahoney, Doris'}, 'qualifier': 'edt'}],
    'resourceType': [
        {'content': 'text_book'}],
    'format': [
        {'content': 'text'}],
    'title': [
        {'content': 'The Bronco, Yearbook of Hardin-Simmons University, 1944', 'qualifier': 'officialtitle'},
        {'content': 'The Bronco', 'qualifier': 'serialtitle'},
        {'content': 'The Bronco 1944', 'qualifier': 'addedtitle'}],
    'collection': [
        {'content': 'HSUY'}],
    'note': [
        {'content': '"Published Annually by Hardin-Simmons University, Abilene, Texas, 37th Edition."', 'qualifier': 'display'},
        {'content': 'comment: Descriptive metadata by htarver 2008-06-27.', 'qualifier': 'nonDisplay'},
        {'content': 'creationAppName: Adobe Photoshop\ncreationAppVersion: 7', 'qualifier': 'digitalPreservation'}],
    'meta': [
        {'content': 'ark:/67531/metapth38622', 'qualifier': 'ark'},
        {'content': 'meta-pth-38622', 'qualifier': 'meta-id'},
        {'content': 'meta-pcc-ae70cfc0-4572-11dd-8cf9-001676db018a', 'qualifier': 'meta-id'},
        {'content': '3203213158', 'qualifier': 'objectMasterSize'},
        {'content': '2008-06-29, 00:31:14', 'qualifier': 'metadataCreationDate'},
        {'content': 'mphillips', 'qualifier': 'metadataCreator'},
        {'content': 'PTH', 'qualifier': 'system'},
        {'content': '/data/ALC/HSUL/HSUY', 'qualifier': 'TKLPath'}],
    'coverage': [
        {'content': 'United States - Texas', 'qualifier': 'placeName'},
        {'content': 'mod-tim', 'qualifier': 'timePeriod'},
        {'content': '1943', 'qualifier': 'sDate'},
        {'content': '1944', 'qualifier': 'eDate'}],
    'date': [
        {'content': '1944', 'qualifier': 'creation'},
        {'content': '2008', 'qualifier': 'digitized'}],
    'identifier': [
        {'content': '14281668', 'qualifier': 'OCLC'}],
    'primarySource': [
        {'content': '1'}],
    'institution': [
        {'content': 'HSUL'}],
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'Education - Colleges and Universities', 'qualifier': 'UNTL-BS'},
        {'content': 'Education - Yearbooks', 'qualifier': 'UNTL-BS'},
        {'content': 'People', 'qualifier': 'UNTL-BS'},
        {'content': 'Social Life and Customs - Clubs and Organizations', 'qualifier': 'UNTL-BS'},
        {'content': 'Sports and Recreation', 'qualifier': 'UNTL-BS'},
        {'content': 'Arts and Crafts', 'qualifier': 'UNTL-BS'},
        {'content': 'louie', 'qualifier': 'KWD'},
        {'content': 'sarge', 'qualifier': 'KWD'}, ]
    }

BAD_UNTL_DICT = {
    'publisher': [
        {'content': {'name': 'Hardin-Simmons University', 'location': 'Abilene, Texas'}}],
    'description': [
        {'content': 'Yearbook for Hardin-Simmons University in Abilene, Texas includes photos of and information about the school, student body, professors, and organizations.  Includes a student directory at the end of the book.', 'qualifier': 'content'},
        {'content': 'Not paginated : ill ; 31 cm.'}]
}

# Example of UNTL dict that needs normalization
UNNORMALIZED_DICT = {
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.)--Students--Yearbooks', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students --Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Food supply -- United States.', 'qualifier': 'LCSH'},
        {'content': 'Business, Economics and Finance  - Journalism', 'qualifier': 'UNTL-BS'},
        {'content': 'Business, Economics and Finance  -  Journalism', 'qualifier': 'UNTL-BS'},
        ]
    }

# UNTL dict with proper normalization
NORMALIZED_DICT = {
    'subject': [
        {'content': 'Simmons College (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Simmons University (Abilene, Tex.) -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'Hardin-Simmons University -- Students -- Yearbooks.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Texas.', 'qualifier': 'LCSH'},
        {'content': 'World War, 1939-1945 -- Food supply -- United States.', 'qualifier': 'LCSH'},
        {'content': 'Business, Economics and Finance - Journalism', 'qualifier': 'UNTL-BS'},
        {'content': 'Business, Economics and Finance - Journalism', 'qualifier': 'UNTL-BS'},
        ]
    }

# An unnormalized untl-bs string
UNNORMALIZED_UNTLBS = 'Business, Economics and Finance  - Journalism'

# An unnormalized lcsh string
UNNORMALIZED_LCSH = 'Guitar music--History and criticism'

# A normalized untl-bs string
NORMALIZED_UNTLBS = 'Business, Economics and Finance - Journalism'

# A normalized lcsh string
NORMALIZED_LCSH = 'Guitar music -- History and criticism.'

# Defined for testing post2pydict
IGNORE_POST_LIST = [
    'publish',
    'save',
    'csrfmiddlewaretoken',
    ]

# Defined for testing post2pydict
EXPECTED_POST_TO_PYDICT = {
    'collection': [{'content': u'UNTCVA'}, {'content': u'UNTSW'}],
    'coverage': [{'content': u'2000', 'qualifier': u'date'}],
    'creator': [{'content': {'info': u'University of North Texas',
                             'name': u'Falsetta, Vincent',
                             'type': u'per'},
                 'qualifier': u'art'}],
    'date': [{'content': u'2000', 'qualifier': u'creation'}],
    'degree': [{'content': u'Studio Arts', 'qualifier': u'department'}],
    'description': [{'content': u'1 art original : oil paint on canvas ;' +
                     ' 72 x 84 in.',
                     'qualifier': u'physical'},
                    {'content': u'This abstract painting is mostly black ' +
                     'with some white vertical scrapes.',
                     'qualifier': u'content'}],
    'format': [{'content': u'image'}],
    'identifier': [{'content': u'2010063245', 'qualifier': u'LOCAL-CONT-NO'}],
    'institution': [{'content': u'UNTCVA'}],
    'language': [{'content': u'nol'}],
    'meta': [{'content': u'metadc27160', 'qualifier': u'meta-id'},
             {'content': u'DC', 'qualifier': u'system'},
             {'content': u'ark:/67531/metadc27160', 'qualifier': u'ark'},
             {'content': u'2010-08-25, 21:10:41',
              'qualifier': u'metadataCreationDate'},
             {'content': u'acpmaker', 'qualifier': u'metadataCreator'},
             {'content': u'jliechty', 'qualifier': u'metadataModifier'},
             {'content': u'2013-10-31, 13:09:12',
              'qualifier': u'metadataModificationDate'},
             {'content': u'False', 'qualifier': u'hidden'}],
    'note': [{'content': u'comment: Descriptive metadata template created ' +
              'by htarver 2010-07-05.',
              'qualifier': u'nonDisplay'}],
    'primarySource': [{'content': u'1'}],
    'resourceType': [{'content': u'image_artwork'}],
    'rights': [{'content': u'public', 'qualifier': u'access'},
               {'content': u'Vincent Falsetta, Denton, TX',
                'qualifier': u'holder'},
               {'content': u'copyright', 'qualifier': u'license'},
               {'content': u'Copyright 2010, Vincent Falsetta, All Rights' +
                ' Reserved',
                'qualifier': u'statement'}],
    'subject': [{'content': u'paintings (visual works)', 'qualifier': u'AAT'},
                {'content': u'works of art', 'qualifier': u'AAT'},
                {'content': u'oil paint (paint)', 'qualifier': u'AAT'}],
    'title': [{'content': u'AL 00-3.', 'qualifier': u'officialtitle'}]
    }

# Skeleton vocabulary for mock return value.
VOCAB = {'title-qualifiers': [],
         'identifier-qualifiers': [],
         'note-qualifiers': [],
         'subject-qualifiers': [],
         'description-qualifiers': [],
         'date-qualifiers': [],
         'sourceQualifiers': [],
         'coverage-qualifiers': [],
         'relation-qualifiers': [],
         'rights-qualifiers': [],
         'degree-information': [],
         'meta-qualifiers': [],
         'citationQualifiers': [],
         'agent-type': [],
         'agent-qualifiers': [],
         'institutions': [],
         'collections': [],
         'languages': [],
         'resource-types': [],
         'formats': [],
         'coverage-eras': [],
         'rights-access': [],
         'rights-licenses': [],
         'publication-types': []}
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2010-2011, GEM Foundation.
#
# OpenQuake is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenQuake.  If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License.

from alchemy_db_utils_unittest import *
from black_box_tests import *
from bulk_insert_unittest import *
from cache_gc_unittest import *
from db_loader_unittest import *
from db_loader_unittest import *
from deterministic_hazard_unittest import *
from deterministic_risk_unittest import *
from geo_unittest import *
from handlers_unittest import *
from hazard_classical_unittest import *
from hazard_nrml_unittest import *
from hazard_unittest import *
from input_risk_unittest import *
from java_unittest import *
from job_unittest import *
from kvs_unittest import *
from logs_unittest import *
from loss_map_output_unittest import *
from loss_output_unittest import *
from output_hazard_unittest import *
from output_risk_unittest import *
from output_unittest import *
from output_writers_unittest import *
from parser_exposure_portfolio_unittest import *
from parser_hazard_curve_unittest import *
from parser_hazard_map_unittest import *
from parser_vulnerability_model_unittest import *
from probabilistic_unittest import *
from producer_unittest import *
from risk_job_unittest import *
from risk_parser_unittest import *
from risk_unittest import *
from schema_unittest import *
from shapes_unittest import *
from tools_dbmaint_unittest import *
from utils_general_unittest import *
from utils_tasks_unittest import *
from utils_version_unittest import *
from validator_unittest import *

import glob
import os
import sys

for path in glob.glob(os.path.join(os.path.dirname(__file__), '*test*.py')):
    test = os.path.splitext(os.path.basename(path))[0]
    module = 'tests.' + test

    if module not in sys.modules:
        print >>sys.stderr, "Potential missing import of " + module
<commit_msg>Pep8<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2010-2011, GEM Foundation.
#
# OpenQuake is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenQuake.  If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License.

from alchemy_db_utils_unittest import *
from black_box_tests import *
from bulk_insert_unittest import *
from cache_gc_unittest import *
from db_loader_unittest import *
from db_loader_unittest import *
from deterministic_hazard_unittest import *
from deterministic_risk_unittest import *
from geo_unittest import *
from handlers_unittest import *
from hazard_classical_unittest import *
from hazard_nrml_unittest import *
from hazard_unittest import *
from input_risk_unittest import *
from java_unittest import *
from job_unittest import *
from kvs_unittest import *
from logs_unittest import *
from loss_map_output_unittest import *
from loss_output_unittest import *
from output_hazard_unittest import *
from output_risk_unittest import *
from output_unittest import *
from output_writers_unittest import *
from parser_exposure_portfolio_unittest import *
from parser_hazard_curve_unittest import *
from parser_hazard_map_unittest import *
from parser_vulnerability_model_unittest import *
from probabilistic_unittest import *
from producer_unittest import *
from risk_job_unittest import *
from risk_parser_unittest import *
from risk_unittest import *
from schema_unittest import *
from shapes_unittest import *
from tools_dbmaint_unittest import *
from utils_general_unittest import *
from utils_tasks_unittest import *
from utils_version_unittest import *
from validator_unittest import *

import glob
import os
import sys

for path in glob.glob(os.path.join(os.path.dirname(__file__), '*test*.py')):
    test = os.path.splitext(os.path.basename(path))[0]
    module = 'tests.' + test

    if module not in sys.modules:
        print >> sys.stderr, "Potential missing import of " + module
<|endoftext|>


<commit_before>from test_project import *
from test_parser import *

if __name__ == "__main__":
    import unittest
    unittest.main()
<commit_msg>Added serialization tests to full suite.<commit_after>from test_project import *
from test_parser import *
from test_serialization import *

if __name__ == "__main__":
    import unittest
    unittest.main()
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2010-2011, GEM Foundation.
#
# OpenQuake is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenQuake.  If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License.

from alchemy_db_utils_unittest import *
from black_box_tests import *
from bulk_insert_unittest import *
from cache_gc_unittest import *
from db_loader_unittest import *
from db_loader_unittest import *
from db_routers_unittest import *
from deterministic_hazard_unittest import *
from deterministic_risk_unittest import *
from geo_unittest import *
from handlers_unittest import *
from hazard_classical_unittest import *
from hazard_nrml_unittest import *
from hazard_unittest import *
from input_risk_unittest import *
from java_unittest import *
from job_unittest import *
from kvs_unittest import *
from logs_unittest import *
from loss_map_output_unittest import *
from loss_output_unittest import *
from output_hazard_unittest import *
from output_risk_unittest import *
from output_unittest import *
from output_writers_unittest import *
from parser_exposure_portfolio_unittest import *
from parser_hazard_curve_unittest import *
from parser_hazard_map_unittest import *
from parser_vulnerability_model_unittest import *
from probabilistic_unittest import *
from producer_unittest import *
from risk_job_unittest import *
from risk_parser_unittest import *
from risk_unittest import *
from schema_unittest import *
from shapes_unittest import *
from tools_dbmaint_unittest import *
from utils_config_unittest import *
from utils_general_unittest import *
from utils_tasks_unittest import *
from utils_version_unittest import *
from validator_unittest import *

import glob
import os
import sys

for path in glob.glob(os.path.join(os.path.dirname(__file__), '*test*.py')):
    test = os.path.splitext(os.path.basename(path))[0]
    module = 'tests.' + test

    if module not in sys.modules:
        print >> sys.stderr, "Potential missing import of " + module
<commit_msg>Added supervisor_unittest to __init__.py<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2010-2011, GEM Foundation.
#
# OpenQuake is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenQuake.  If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License.

from alchemy_db_utils_unittest import *
from black_box_tests import *
from bulk_insert_unittest import *
from cache_gc_unittest import *
from db_loader_unittest import *
from db_loader_unittest import *
from db_routers_unittest import *
from deterministic_hazard_unittest import *
from deterministic_risk_unittest import *
from geo_unittest import *
from handlers_unittest import *
from hazard_classical_unittest import *
from hazard_nrml_unittest import *
from hazard_unittest import *
from input_risk_unittest import *
from java_unittest import *
from job_unittest import *
from kvs_unittest import *
from logs_unittest import *
from loss_map_output_unittest import *
from loss_output_unittest import *
from output_hazard_unittest import *
from output_risk_unittest import *
from output_unittest import *
from output_writers_unittest import *
from parser_exposure_portfolio_unittest import *
from parser_hazard_curve_unittest import *
from parser_hazard_map_unittest import *
from parser_vulnerability_model_unittest import *
from probabilistic_unittest import *
from producer_unittest import *
from risk_job_unittest import *
from risk_parser_unittest import *
from risk_unittest import *
from schema_unittest import *
from shapes_unittest import *
from supervisor_unittest import *
from tools_dbmaint_unittest import *
from utils_config_unittest import *
from utils_general_unittest import *
from utils_tasks_unittest import *
from utils_version_unittest import *
from validator_unittest import *

import glob
import os
import sys

for path in glob.glob(os.path.join(os.path.dirname(__file__), '*test*.py')):
    test = os.path.splitext(os.path.basename(path))[0]
    module = 'tests.' + test

    if module not in sys.modules:
        print >> sys.stderr, "Potential missing import of " + module
<|endoftext|>


<commit_before>import BaseHTTPServer
import threading
from SimpleHTTPServer import SimpleHTTPRequestHandler

HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"

port = 8888
server_address = ('127.0.0.1', port)

HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()

httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.setDaemon(True)
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd_thread.start()

from unittest import TestCase
import tempfile
import requests
import csv
import sys
from StringIO import StringIO
sort_by_url = lambda k: k['url']

class TestBeautify(TestCase):
    class MockResponse(object):
        def __init__(self, content_type, content):
            self.headers = {'content-type': content_type}
            self.content = content

    def test_return_no_encoding(self):
        from eek.spider import beautify
        response = self.MockResponse('text/html',
                                     '<!doctype html>
Hello
')
        result = beautify(response)
        self.assertIsNone(result.fromEncoding)

    def test_return_not_none_encoding(self):
        from eek.spider import beautify
        response = self.MockResponse('text/html; charset=utf-8',
                                     '<!doctype html>
Hello
')
        result = beautify(response)
        self.assertIsNotNone(result.fromEncoding)

    def test_raise_NotHtmlException_on_messed_up_content_type(self):
        from eek.spider import beautify, NotHtmlException
        response = self.MockResponse('foo',
                                     '<!doctype html>
Hello
')
        with self.assertRaises(NotHtmlException):
            beautify(response)

class TestSpiderUtilities(TestCase):

    def test_encoding_from_content_type_none(self):
        from eek.spider import encoding_from_content_type
        self.assertIsNone(encoding_from_content_type('text/html'))

    def test_encoding_from_content_type_with_charset(self):
        from eek.spider import encoding_from_content_type
        self.assertEquals(
            encoding_from_content_type('text/html; charset=utf-8'),
            'utf-8')

    def test_lremove_prefix_exists(self):
        from eek.spider import lremove
        self.assertEquals(lremove('www.foo.com', 'www.'), 'foo.com')

    def test_lremove_prefix_not_exists(self):
        from eek.spider import lremove
        self.assertEquals(lremove('www.foo.com', 'eggs'), 'www.foo.com')

    def test_force_unicode_is_string_instance(self):
        from eek.spider import force_unicode
        uni_string = force_unicode('spam')
        self.assertIsInstance(uni_string, unicode)
        self.assertEquals(uni_string, u'spam')

    def test_force_unicode_not_string_instance(self):
        from eek.spider import force_unicode
        result = force_unicode(5)
        self.assertNotIsInstance(result, unicode)
        self.assertEquals(result, 5)
        result = force_unicode(None)
        self.assertNotIsInstance(result, unicode)
        self.assertEquals(result, None)

    def test_force_bytes_unicode_literal(self):
        from eek.spider import force_bytes
        self.assertEquals(force_bytes(u'\u2603'), '\xe2\x98\x83')

    def test_force_bytes_string(self):
        from eek.spider import force_bytes
        self.assertEquals(force_bytes('\xe2\x98\x83'), '\xe2\x98\x83')

class FunctionalTests(TestCase):
    base = 'http://localhost:%d/tests/html-files' % port

    def setUp(self):
        self.tmp = tempfile.TemporaryFile()

    def tearDown(self):
        self.tmp.close()

    def test_testsetup(self):
        assert requests.get(self.base).status_code == 200

    def test_metaspider(self):
        from eek import spider
        pages = [dict([(h, '') for h in spider.headers]) for x in range(4)]
        for p in pages:
            p['referer'] = self.base + '/index.html'
            p['status'] = '200'
        pages[0]['url'] = self.base + '/index.html'
        pages[0]['keywords'] = 'my_keywords'
        pages[0]['title'] = 'Index'
        pages[0]['description'] = 'my_description'
        pages[0]['meta robots'] = 'arst'
        pages[1]['url'] = self.base + '/a.html'
        pages[2]['url'] = self.base + '/b.html'
        pages[3]['url'] = self.base + '/c.html'
        pages = sorted(pages, key=sort_by_url)
        spider.metadata_spider(self.base + '/index.html', output=self.tmp)
        self.tmp.seek(0)
        result = sorted(list(csv.DictReader(self.tmp)), key=sort_by_url)
        self.assertEquals(pages, result)

    def test_grepspider(self):
        from eek import spider
        sys.stdout = StringIO()
        spider.grep_spider(self.base + '/index.html', 'Found me')
        self.assertEquals(sys.stdout.getvalue(), self.base + '/b.html:Found me\n')

    def test_graphvizspider(self):
        from eek import spider
        sys.stdout = StringIO()
        spider.graphviz_spider(self.base + '/index.html')
        graphiz_assertion = """digraph links {{
  "{base}/index.html" -> "{base}/a.html";
  "{base}/index.html" -> "{base}/b.html";
  "{base}/index.html" -> "{base}/c.html";
}}
""".format(base=self.base)
        self.assertEquals(sys.stdout.getvalue(), graphiz_assertion)
<commit_msg>let the OS pick the port to run the test server<commit_after>import BaseHTTPServer
import threading
from SimpleHTTPServer import SimpleHTTPRequestHandler

HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"

port = 0  # os will pick an available port.
server_address = ('127.0.0.1', port)

HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()

httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.setDaemon(True)
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd_thread.start()

from unittest import TestCase
import tempfile
import requests
import csv
import sys
from StringIO import StringIO
sort_by_url = lambda k: k['url']

class TestBeautify(TestCase):
    class MockResponse(object):
        def __init__(self, content_type, content):
            self.headers = {'content-type': content_type}
            self.content = content

    def test_return_no_encoding(self):
        from eek.spider import beautify
        response = self.MockResponse('text/html',
                                     '<!doctype html>
Hello
')
        result = beautify(response)
        self.assertIsNone(result.fromEncoding)

    def test_return_not_none_encoding(self):
        from eek.spider import beautify
        response = self.MockResponse('text/html; charset=utf-8',
                                     '<!doctype html>
Hello
')
        result = beautify(response)
        self.assertIsNotNone(result.fromEncoding)

    def test_raise_NotHtmlException_on_messed_up_content_type(self):
        from eek.spider import beautify, NotHtmlException
        response = self.MockResponse('foo',
                                     '<!doctype html>
Hello
')
        with self.assertRaises(NotHtmlException):
            beautify(response)

class TestSpiderUtilities(TestCase):

    def test_encoding_from_content_type_none(self):
        from eek.spider import encoding_from_content_type
        self.assertIsNone(encoding_from_content_type('text/html'))

    def test_encoding_from_content_type_with_charset(self):
        from eek.spider import encoding_from_content_type
        self.assertEquals(
            encoding_from_content_type('text/html; charset=utf-8'),
            'utf-8')

    def test_lremove_prefix_exists(self):
        from eek.spider import lremove
        self.assertEquals(lremove('www.foo.com', 'www.'), 'foo.com')

    def test_lremove_prefix_not_exists(self):
        from eek.spider import lremove
        self.assertEquals(lremove('www.foo.com', 'eggs'), 'www.foo.com')

    def test_force_unicode_is_string_instance(self):
        from eek.spider import force_unicode
        uni_string = force_unicode('spam')
        self.assertIsInstance(uni_string, unicode)
        self.assertEquals(uni_string, u'spam')

    def test_force_unicode_not_string_instance(self):
        from eek.spider import force_unicode
        result = force_unicode(5)
        self.assertNotIsInstance(result, unicode)
        self.assertEquals(result, 5)
        result = force_unicode(None)
        self.assertNotIsInstance(result, unicode)
        self.assertEquals(result, None)

    def test_force_bytes_unicode_literal(self):
        from eek.spider import force_bytes
        self.assertEquals(force_bytes(u'\u2603'), '\xe2\x98\x83')

    def test_force_bytes_string(self):
        from eek.spider import force_bytes
        self.assertEquals(force_bytes('\xe2\x98\x83'), '\xe2\x98\x83')

class FunctionalTests(TestCase):
    base = 'http://localhost:%d/tests/html-files' % sa[1]

    def setUp(self):
        self.tmp = tempfile.TemporaryFile()

    def tearDown(self):
        self.tmp.close()

    def test_testsetup(self):
        assert requests.get(self.base).status_code == 200

    def test_metaspider(self):
        from eek import spider
        pages = [dict([(h, '') for h in spider.headers]) for x in range(4)]
        for p in pages:
            p['referer'] = self.base + '/index.html'
            p['status'] = '200'
        pages[0]['url'] = self.base + '/index.html'
        pages[0]['keywords'] = 'my_keywords'
        pages[0]['title'] = 'Index'
        pages[0]['description'] = 'my_description'
        pages[0]['meta robots'] = 'arst'
        pages[1]['url'] = self.base + '/a.html'
        pages[2]['url'] = self.base + '/b.html'
        pages[3]['url'] = self.base + '/c.html'
        pages = sorted(pages, key=sort_by_url)
        spider.metadata_spider(self.base + '/index.html', output=self.tmp)
        self.tmp.seek(0)
        result = sorted(list(csv.DictReader(self.tmp)), key=sort_by_url)
        self.assertEquals(pages, result)

    def test_grepspider(self):
        from eek import spider
        sys.stdout = StringIO()
        spider.grep_spider(self.base + '/index.html', 'Found me')
        self.assertEquals(sys.stdout.getvalue(), self.base + '/b.html:Found me\n')

    def test_graphvizspider(self):
        from eek import spider
        sys.stdout = StringIO()
        spider.graphviz_spider(self.base + '/index.html')
        graphiz_assertion = """digraph links {{
  "{base}/index.html" -> "{base}/a.html";
  "{base}/index.html" -> "{base}/b.html";
  "{base}/index.html" -> "{base}/c.html";
}}
""".format(base=self.base)
        self.assertEquals(sys.stdout.getvalue(), graphiz_assertion)
<|endoftext|>


<commit_before>from unipath import Path

ROOTDIR = Path(__file__).parent.parent

# load  SETUP_INFO:
execfile(ROOTDIR.child('atelier','project_info.py'),globals())

from atelier.test import TestCase

class BaseTestCase(TestCase):
    project_root = ROOTDIR

class BasicTests(BaseTestCase):

    def test_01(self):
        self.assertEqual(1+1, 2)

    def test_utils(self):
        self.run_simple_doctests('atelier/utils.py')
    def test_rstgen(self):
        self.run_simple_doctests('atelier/rstgen.py')

class PackagesTests(BaseTestCase):
    def test_packages(self):
        self.run_packages_test(SETUP_INFO['packages'])

class SimpleTests(BaseTestCase):
    def test_sphinxconf(self):
        self.run_simple_doctests('atelier/sphinxconf/__init__.py')
<commit_msg>http://docs.lino-framework.org/blog/2014/0610.html<commit_after>from unipath import Path

ROOTDIR = Path(__file__).parent.parent

# load  SETUP_INFO:
execfile(ROOTDIR.child('atelier', 'project_info.py'), globals())

from atelier.test import TestCase

class BaseTestCase(TestCase):
    project_root = ROOTDIR

class BasicTests(BaseTestCase):

    def test_01(self):
        self.assertEqual(1+1, 2)

    def test_utils(self):
        self.run_simple_doctests('atelier/utils.py')
    def test_rstgen(self):
        self.run_simple_doctests('atelier/rstgen.py')

class PackagesTests(BaseTestCase):
    def test_packages(self):
        self.run_packages_test(SETUP_INFO['packages'])

class SimpleTests(BaseTestCase):
    def test_sphinxconf(self):
        self.run_simple_doctests('atelier/sphinxconf/__init__.py')
<|endoftext|>


<commit_before>import os
import re

IS_PYTHONISTA = re.search('Pythonista\d+', os.environ.get('PYTHONPATH', ''), re.ASCII) is not None

if not IS_PYTHONISTA:
    import sys
    from mock import MagicMock

    sys.modules['editor'] = MagicMock()
    sys.modules['ui'] = MagicMock()
    sys.modules['objc_util'] = MagicMock()
    sys.modules['console'] = MagicMock()
<commit_msg>console mock<commit_after>import os
import re

IS_PYTHONISTA = re.search('Pythonista\d+', os.environ.get('PYTHONPATH', ''), re.ASCII) is not None

if not IS_PYTHONISTA:
    import sys
    from mock import MagicMock

    sys.modules['editor'] = MagicMock()
    sys.modules['ui'] = MagicMock()
    sys.modules['objc_util'] = MagicMock()
    sys.modules['console'] = MagicMock()
    sys.modules['clipboard'] = MagicMock()
<|endoftext|>