<s> import os <EOL> try : <EOL> from mojo . roboFont import OpenFont <EOL> except ImportError : <EOL> from robofab . world import OpenFont <EOL> from vanilla import * <EOL> from vanilla . dialogs import getFolder <EOL> from hTools2 import hDialog <EOL> from hTools2 . modules . fileutils import walk <EOL> from hTools2 . modules . messages import no_font_in_folder <EOL> class WOFFsToUFOsDialog ( hDialog ) : <EOL> """<STR_LIT>""" <EOL> otfs_folder = None <EOL> ufos_folder = None <EOL> def __init__ ( self ) : <EOL> self . title = "<STR_LIT>" <EOL> self . height = ( self . button_height * <NUM_LIT:3> ) + ( self . padding_y * <NUM_LIT:5> ) + self . progress_bar <EOL> self . w = FloatingWindow ( ( self . width , self . height ) , self . title ) <EOL> x = self . padding_x <EOL> y = self . padding_y <EOL> self . w . woffs_get_folder_button = SquareButton ( <EOL> ( x , y , <EOL> - self . padding_x , <EOL> self . button_height ) , <EOL> "<STR_LIT>" , <EOL> sizeStyle = self . size_style , <EOL> callback = self . woffs_get_folder_callback ) <EOL> y += ( self . button_height + self . padding_y ) <EOL> self . w . ufos_get_folder_button = SquareButton ( <EOL> ( x , y , <EOL> - self . padding_x , <EOL> self . button_height ) , <EOL> "<STR_LIT>" , <EOL> sizeStyle = self . size_style , <EOL> callback = self . ufos_get_folder_callback ) <EOL> y += ( self . button_height + self . padding_y ) <EOL> self . w . bar = ProgressBar ( <EOL> ( x , y , <EOL> - self . padding_x , <EOL> self . progress_bar ) , <EOL> isIndeterminate = True , <EOL> sizeStyle = self . size_style ) <EOL> y += ( self . progress_bar + self . padding_y ) <EOL> self . w . button_apply = SquareButton ( <EOL> ( x , y , <EOL> - self . padding_x , <EOL> self . button_height ) , <EOL> "<STR_LIT>" , <EOL> callback = self . button_apply_callback , <EOL> sizeStyle = self . size_style ) <EOL> self . w . open ( ) <EOL> def woffs_get_folder_callback ( self , sender ) : <EOL> folder_woffs = getFolder ( ) <EOL> self . woffs_folder = folder_woffs [ <NUM_LIT:0> ] <EOL> def ufos_get_folder_callback ( self , sender ) : <EOL> folder_ufos = getFolder ( ) <EOL> self . ufos_folder = folder_ufos [ <NUM_LIT:0> ] <EOL> def button_apply_callback ( self , sender ) : <EOL> if self . woffs_folder is not None : <EOL> _woffs_paths = walk ( self . woffs_folder , '<STR_LIT>' ) <EOL> if len ( _woffs_paths ) > <NUM_LIT:0> : <EOL> if self . ufos_folder is None : <EOL> self . ufos_folder = self . woffs_folder <EOL> boolstring = ( "<STR_LIT:False>" , "<STR_LIT:True>" ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % self . woffs_folder <EOL> print '<STR_LIT>' % self . ufos_folder <EOL> print <EOL> self . w . bar . start ( ) <EOL> for woff_path in _woffs_paths : <EOL> print '<STR_LIT>' % os . path . split ( woff_path ) [ <NUM_LIT:1> ] <EOL> woff = OpenFont ( woff_path , showUI = True ) <EOL> ufo_file = os . path . splitext ( os . path . split ( woff_path ) [ <NUM_LIT:1> ] ) [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> ufo_path = os . path . join ( self . ufos_folder , ufo_file ) <EOL> woff . save ( ufo_path ) <EOL> woff . close ( ) <EOL> print '<STR_LIT>' % ufo_path <EOL> print '<STR_LIT>' % os . path . exists ( ufo_path ) <EOL> self . w . bar . stop ( ) <EOL> print <EOL> print '<STR_LIT>' <EOL> else : <EOL> print no_font_in_folder </s>
