| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- # config.py - Reading and writing Git config files
- # Copyright (C) 2011 Jelmer Vernooij <jelmer@samba.org>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; version 2
- # of the License or (at your option) a later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- """Reading and writing Git configuration files.
- """
- from dulwich.file import GitFile
- class ConfigFile(object):
- """A Git configuration file, like .git/config or ~/.gitconfig."""
- def __init__(self):
- """Create a new ConfigFile."""
- def __eq__(self, other):
- return isinstance(other, self.__class__)
- @classmethod
- def from_file(cls, f):
- """Read configuration from a file-like object."""
- ret = cls()
- # FIXME
- return ret
- @classmethod
- def from_path(cls, path):
- """Read configuration from a file on disk."""
- f = GitFile(path, 'r')
- try:
- return cls.from_file(f)
- finally:
- f.close()
- def write_to_path(self, path):
- """Write configuration to a file on disk."""
- f = GitFile(path, 'w')
- try:
- self.write_to_file(f)
- finally:
- f.close()
- def write_to_file(self, f):
- """Write configuration to a file-like object."""
- # FIXME
|