<s> """<STR_LIT>""" <EOL> __copyright__ = "<STR_LIT>" <EOL> import os <EOL> import sys <EOL> import glob <EOL> import ConfigParser as configparser <EOL> import gettext <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> try : <EOL> from Foundation import * <EOL> except : <EOL> pass <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> if hasattr ( sys , '<STR_LIT>' ) : <EOL> try : <EOL> resourceBasePath = NSBundle . mainBundle ( ) . resourcePath ( ) <EOL> except : <EOL> resourceBasePath = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" ) <EOL> else : <EOL> resourceBasePath = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" ) <EOL> else : <EOL> resourceBasePath = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" ) <EOL> def getPathForResource ( dir , subdir , resource_name ) : <EOL> assert os . path . isdir ( dir ) , "<STR_LIT>" . format ( p = dir ) <EOL> path = os . path . normpath ( os . path . join ( dir , subdir , resource_name ) ) <EOL> if not os . path . isfile ( path ) : <EOL> return None <EOL> return path <EOL> def getPathForImage ( name ) : <EOL> return getPathForResource ( resourceBasePath , '<STR_LIT>' , name ) <EOL> def getPathForMesh ( name ) : <EOL> return getPathForResource ( resourceBasePath , '<STR_LIT>' , name ) <EOL> def getPathForFirmware ( name ) : <EOL> return getPathForResource ( resourceBasePath , '<STR_LIT>' , name ) <EOL> def getDefaultMachineProfiles ( ) : <EOL> path = os . path . normpath ( os . path . join ( resourceBasePath , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return glob . glob ( path ) <EOL> def getSimpleModeProfiles ( machine_type ) : <EOL> path = os . path . normpath ( os . path . join ( resourceBasePath , '<STR_LIT>' , '<STR_LIT>' , machine_type , '<STR_LIT>' ) ) <EOL> if os . path . isfile ( os . path . join ( os . path . dirname ( path ) , '<STR_LIT>' ) ) : <EOL> cp = configparser . ConfigParser ( ) <EOL> cp . read ( os . path . join ( os . path . dirname ( path ) , '<STR_LIT>' ) ) <EOL> machine_type = cp . get ( '<STR_LIT:target>' , '<STR_LIT>' ) <EOL> return getSimpleModeProfiles ( machine_type ) <EOL> if not os . path . isdir ( os . path . dirname ( path ) ) : <EOL> path = os . path . normpath ( os . path . join ( resourceBasePath , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> user_path = os . path . normpath ( os . path . expanduser ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> if os . path . isdir ( user_path ) : <EOL> files = sorted ( glob . glob ( os . path . join ( user_path , '<STR_LIT>' ) ) ) <EOL> if len ( files ) > <NUM_LIT:0> : <EOL> return files <EOL> return sorted ( glob . glob ( path ) ) <EOL> def getSimpleModeMaterials ( ) : <EOL> path = os . path . normpath ( os . path . join ( resourceBasePath , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> user_path = os . path . normpath ( os . path . expanduser ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> if os . path . isdir ( user_path ) : <EOL> files = sorted ( glob . glob ( os . path . join ( user_path , '<STR_LIT>' ) ) ) <EOL> if len ( files ) > <NUM_LIT:0> : <EOL> return files <EOL> return sorted ( glob . glob ( path ) ) <EOL> def setupLocalization ( selectedLanguage = None ) : <EOL> languages = [ '<STR_LIT>' ] <EOL> if selectedLanguage is not None : <EOL> for item in getLanguageOptions ( ) : <EOL> if item [ <NUM_LIT:1> ] == selectedLanguage and item [ <NUM_LIT:0> ] is not None : <EOL> languages = [ item [ <NUM_LIT:0> ] ] <EOL> locale_path = os . path . normpath ( os . path . join ( resourceBasePath , '<STR_LIT>' ) ) <EOL> translation = gettext . translation ( '<STR_LIT>' , locale_path , languages , fallback = True ) <EOL> translation . install ( unicode = True ) <EOL> def getLanguageOptions ( ) : <EOL> return [ <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ] </s>
