@contextmanager
def temp_style(style_name, settings=None):
 if (not settings):
  settings = DUMMY_SETTINGS
 temp_file = (u'%s.%s' % (style_name, STYLE_EXTENSION))
 tempdir = tempfile.mkdtemp()
 with open(os.path.join(tempdir, temp_file), u'w') as f:
  for (k, v) in six.iteritems(settings):
   f.write((u'%s: %s' % (k, v)))
 USER_LIBRARY_PATHS.append(tempdir)
 style.reload_library()
 try:
  (yield)
 finally:
  shutil.rmtree(tempdir)
  style.reload_library()

@ contextmanager def temp_style ( style_name , settings = None ) : if ( not settings ) : settings = DUMMY_SETTINGS temp_file = ( u'%s.%s' % ( style_name , STYLE_EXTENSION ) ) tempdir = tempfile . mkdtemp ( ) with open ( os . path . join ( tempdir , temp_file ) , u'w' ) as f : for ( k , v ) in six . iteritems ( settings ) : f . write ( ( u'%s: %s' % ( k , v ) ) ) USER_LIBRARY_PATHS . append ( tempdir ) style . reload_library ( ) try : ( yield ) finally : shutil . rmtree ( tempdir ) style . reload_library ( )
context manager to create a style sheet in a temporary directory .