<s> from __future__ import absolute_import <EOL> from . . models . clipboardmodels import Clipboard , ClipboardItem <EOL> from . . models . foldermodels import Folder <EOL> from . . utils . compatibility import PILImage , PILImageDraw <EOL> def create_superuser ( ) : <EOL> try : <EOL> from django . contrib . auth import get_user_model <EOL> User = get_user_model ( ) <EOL> except ImportError : <EOL> from django . contrib . auth . models import User <EOL> superuser = User . objects . create_superuser ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> return superuser <EOL> def create_folder_structure ( depth = <NUM_LIT:2> , sibling = <NUM_LIT:2> , parent = None ) : <EOL> """<STR_LIT>""" <EOL> if depth > <NUM_LIT:0> and sibling > <NUM_LIT:0> : <EOL> depth_range = list ( range ( <NUM_LIT:1> , depth + <NUM_LIT:1> ) ) <EOL> depth_range . reverse ( ) <EOL> for d in depth_range : <EOL> for s in range ( <NUM_LIT:1> , sibling + <NUM_LIT:1> ) : <EOL> name = "<STR_LIT>" % ( str ( d ) , str ( s ) ) <EOL> folder = Folder ( name = name , parent = parent ) <EOL> folder . save ( ) <EOL> create_folder_structure ( depth = d - <NUM_LIT:1> , sibling = sibling , parent = folder ) <EOL> def create_clipboard_item ( user , file_obj ) : <EOL> clipboard , was_clipboard_created = Clipboard . objects . get_or_create ( user = user ) <EOL> clipboard_item = ClipboardItem ( clipboard = clipboard , file = file_obj ) <EOL> return clipboard_item <EOL> def create_image ( mode = '<STR_LIT>' , size = ( <NUM_LIT> , <NUM_LIT> ) ) : <EOL> image = PILImage . new ( mode , size ) <EOL> draw = PILImageDraw . Draw ( image ) <EOL> x_bit , y_bit = size [ <NUM_LIT:0> ] // <NUM_LIT:10> , size [ <NUM_LIT:1> ] // <NUM_LIT:10> <EOL> draw . rectangle ( ( x_bit , y_bit * <NUM_LIT:2> , x_bit * <NUM_LIT:7> , y_bit * <NUM_LIT:3> ) , '<STR_LIT>' ) <EOL> draw . rectangle ( ( x_bit * <NUM_LIT:2> , y_bit , x_bit * <NUM_LIT:3> , y_bit * <NUM_LIT:8> ) , '<STR_LIT>' ) <EOL> return image <EOL> class SettingsOverride ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , settings_module , ** overrides ) : <EOL> self . settings_module = settings_module <EOL> self . overrides = overrides <EOL> def __enter__ ( self ) : <EOL> self . old = { } <EOL> for key , value in list ( self . overrides . items ( ) ) : <EOL> self . old [ key ] = getattr ( self . settings_module , key , None ) <EOL> setattr ( self . settings_module , key , value ) <EOL> def __exit__ ( self , _type , value , traceback ) : <EOL> for key , value in list ( self . old . items ( ) ) : <EOL> if value is not None : <EOL> setattr ( self . settings_module , key , value ) <EOL> else : <EOL> delattr ( self . settings_module , key ) </s>
