<s> from ... filters import sass <EOL> from ... utils import get_media_dirs <EOL> from django . conf import settings <EOL> from django . core . management . base import NoArgsCommand <EOL> from subprocess import Popen , PIPE <EOL> import os <EOL> import shutil <EOL> import sys <EOL> import __main__ <EOL> _frameworks_dir = '<STR_LIT>' <EOL> if hasattr ( __main__ , '<STR_LIT>' ) : <EOL> _root = os . path . dirname ( __main__ . __file__ ) <EOL> _frameworks_dir = os . path . join ( _root , _frameworks_dir ) <EOL> FRAMEWORKS_DIR = getattr ( settings , '<STR_LIT>' , <EOL> _frameworks_dir ) <EOL> FRAMEWORKS_DIR = os . path . normcase ( os . path . abspath ( FRAMEWORKS_DIR ) ) <EOL> PATHS_SCRIPT = os . path . join ( os . path . dirname ( sass . __file__ ) , '<STR_LIT>' ) <EOL> def copy_children ( src , dst ) : <EOL> for item in os . listdir ( src ) : <EOL> path = os . path . join ( src , item ) <EOL> copy_fs_node ( path , dst ) <EOL> def copy_fs_node ( src , dst ) : <EOL> basename = os . path . basename ( src ) <EOL> dst = os . path . join ( dst , basename ) <EOL> if os . path . isfile ( src ) : <EOL> shutil . copy ( src , dst ) <EOL> elif os . path . isdir ( src ) : <EOL> shutil . copytree ( src , dst ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % src ) <EOL> class Command ( NoArgsCommand ) : <EOL> help = '<STR_LIT>' <EOL> requires_model_validation = False <EOL> def handle_noargs ( self , ** options ) : <EOL> if os . path . exists ( FRAMEWORKS_DIR ) : <EOL> shutil . rmtree ( FRAMEWORKS_DIR ) <EOL> os . mkdir ( FRAMEWORKS_DIR ) <EOL> for path in self . get_framework_paths ( ) : <EOL> copy_children ( path , FRAMEWORKS_DIR ) <EOL> if FRAMEWORKS_DIR not in get_media_dirs ( ) : <EOL> sys . stderr . write ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % { '<STR_LIT>' : os . path . basename ( FRAMEWORKS_DIR ) } ) <EOL> def get_framework_paths ( self ) : <EOL> run = [ '<STR_LIT>' , PATHS_SCRIPT ] <EOL> run . extend ( sass . SASS_FRAMEWORKS ) <EOL> try : <EOL> cmd = Popen ( run , universal_newlines = True , <EOL> stdin = PIPE , stdout = PIPE , stderr = PIPE ) <EOL> output , error = cmd . communicate ( ) <EOL> assert cmd . wait ( ) == <NUM_LIT:0> , '<STR_LIT>' % error <EOL> return map ( os . path . abspath , filter ( None , output . split ( '<STR_LIT:\n>' ) ) ) <EOL> except Exception , e : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % e ) </s>
