1 # -*- coding: utf-8 -*-
 
   3 #    This file is part of Librarian.
 
   5 #    Copyright © 2008,2009,2010 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
 
   7 #    For full list of contributors see AUTHORS file. 
 
   9 #    This program is free software: you can redistribute it and/or modify
 
  10 #    it under the terms of the GNU Affero General Public License as published by
 
  11 #    the Free Software Foundation, either version 3 of the License, or
 
  12 #    (at your option) any later version.
 
  14 #    This program is distributed in the hope that it will be useful,
 
  15 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  16 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  17 #    GNU Affero General Public License for more details.
 
  19 #    You should have received a copy of the GNU Affero General Public License
 
  20 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
  22 from __future__ import with_statement
 
  23 from os.path import realpath, join, dirname
 
  27 def get_fixture_dir(dir_name):
 
  28     """Returns path to fixtures directory dir_name."""
 
  29     return realpath(join(dirname(__file__), 'files', dir_name))
 
  32 def get_fixture(dir_name, file_name):
 
  33     """Returns path to fixture file_name in directory dir_name."""
 
  34     return join(get_fixture_dir(dir_name), file_name)
 
  37 def get_all_fixtures(dir_name, glob_pattern='*'):
 
  38     """Returns list of paths for fixtures in directory dir_name matching the glob_pattern."""
 
  39     return [get_fixture(dir_name, file_name) for file_name in glob.glob(join(get_fixture_dir(dir_name), glob_pattern))]
 
  42 def remove_output_file(dir_name, file_name):
 
  44         os.remove(get_fixture(dir_name, file_name))