Adiciona interface IRPFDir para configuração de diretórios.
[cascardo/irpf-gui.git] / src / dirs.py
1 #
2 #   Copyright 2013 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
3 #
4 #   This program is free software: you can redistribute it and/or modify
5 #   it under the terms of the GNU General Public License as published by
6 #   the Free Software Foundation, either version 3 of the License, or
7 #   (at your option) any later version.
8 #
9 #   This program is distributed in the hope that it will be useful,
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #   GNU General Public License for more details.
13 #
14 #   You should have received a copy of the GNU General Public License
15 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # -*- mode: python; encoding: utf-8; -*-
17
18 import os
19
20 class IRPFDir:
21     def __init__(self, resource_dir, userdata_dir):
22         self.resource_dir = resource_dir
23         self.userdata_dir = userdata_dir
24     def get_resource_dir(self):
25         return self.resource_dir
26     def get_userdata_dir(self):
27         return self.userdata_dir
28     def get_resource_file(self, file):
29         return self.get_resource_dir() + file
30     def get_userdata_file(self, file):
31         return self.get_userdata_dir() + file
32
33 class IRPFDevelDir(IRPFDir):
34     def __init__(self):
35         self.resource_dir = "res/"
36         self.userdata_dir = "aplicacao/dados/"
37
38 class IRPFInstallDir(IRPFDir):
39     def __init__(self):
40         self.resource_dir = "/usr/share/irpflivre/res/"
41         self.userdata_dir = os.path.expanduser("~/.irpflivre/aplicacao/dados/")
42
43 default_irpf_dir = None
44
45 def set_default_irpf_dir(dir):
46     default_irpf_dir = dir
47
48 def get_default_irpf_dir():
49     global default_irpf_dir
50     if default_irpf_dir == None:
51         default_irpf_dir = IRPFDevelDir()
52     return default_irpf_dir
53
54 # vim:tabstop=4:expandtab:smartindent