Mercurial > pyarq-presupuestos
comparison Generic/durusdatabase.py @ 1:2ac1551ad2ab version 0.0.0
add code
| author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
|---|---|
| date | Sun, 31 Oct 2010 20:07:33 +0100 |
| parents | |
| children | 6502bfdaa84d |
comparison
equal
deleted
inserted
replaced
| 0:a1703c4f2990 | 1:2ac1551ad2ab |
|---|---|
| 1 #!/usr/bin/python | |
| 2 # -*- coding: utf-8 -*- | |
| 3 ## File durus.py | |
| 4 ## This file is part of pyArq-Presupuestos. | |
| 5 ## | |
| 6 ## Copyright (C) 2010 Miguel Ángel Bárcena Rodríguez | |
| 7 ## <miguelangel@obraencurso.es> | |
| 8 ## | |
| 9 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify | |
| 10 ## it under the terms of the GNU 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. | |
| 13 ## | |
| 14 ## pyArq-Presupuestos 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 General Public License for more details. | |
| 18 ## | |
| 19 ## You should have received a copy of the GNU General Public License | |
| 20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | |
| 22 # Modules | |
| 23 import os.path | |
| 24 # Durus Modules | |
| 25 from durus.file_storage import FileStorage | |
| 26 from durus.connection import Connection | |
| 27 | |
| 28 class DurusFile(object): | |
| 29 def __init__(self, file, new): | |
| 30 self.__file = file | |
| 31 if new: | |
| 32 if os.path.exists(self.__file): | |
| 33 os.remove(self.__file) | |
| 34 self.__connection = Connection(FileStorage(self.__file)) | |
| 35 self.__root = self.__connection.get_root() | |
| 36 | |
| 37 def close(self): | |
| 38 self.__connection.get_storage().close() | |
| 39 | |
| 40 def getBudget(self): | |
| 41 return self.__root["budget"] | |
| 42 | |
| 43 def setBudget(self, budget): | |
| 44 self.__root["budget"] = budget | |
| 45 self.__connection.commit() | |
| 46 |
