1

我已经阅读了关于错误的大部分内容,但我看不出它与我正在写的这个类有什么关系。

# Copyright (C) 2013 Marco Ceppi <marco@ceppi.net>.
#
# 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, either version 3 of the License, or
# (at your option) any 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, see <http://www.gnu.org/licenses/>.

import os
import ConfigParser

from bzrlib.bzrdir import BzrDir


class Mr:
    def __init__(self, directory=False, config=False, trust_all=False):
        self.directory = directory or os.getcwd()
        self.control_dir = os.path.join(self.directory, '.bzr')
        self.trust_all = trust_all
        self.config_file = config or os.path.join(self.directory, '.mrconfig')

        if self._check_repository_exists():
            if not config or not os.path.exists(config):
                raise Exception('No .mrconfig specified')
            cp = ConfigParser.ConfigParser()
            self.config = ConfigParser.read(config)
            self.bzr_dir = BzrDir.open(self.directory)
        else:
            self.config = ConfigParser.RawConfigParser()
            self.bzr_dir = BzrDir.create(self.directory)
            self.bzr_dir.create_repository(shared=True)

    def update(self):
        #print 'Not today'

    def add(self, name=False, repository='lp:charms'):
        if not name:
            raise Exception('No name provided')

    def checkout(self):
        #t

    def remove(self, name=False):
        if not name:
            raise Exception('No name provided')

    def _write_cfg(self):
        #t

    def _read_cfg(self):
        #t

    def _check_repository_exists(self):
        # Eventually do more checks to make sure it is a shared repository
        # and not a branch, etc.
        return os.path.exists(self.control_dir)

它在这些方面抱怨:

def add(self, name=False, repository='lp:charms'):
def remove(self, name=False):
def _read_cfg(self):
def _check_repository_exists(self):
4

1 回答 1

3

在这 4 个函数之前,您有“空”函数。在这些函数中添加一条pass语句:

def update(self):
    #print 'Not today'
    pass

def checkout(self):
    #t
    pass

def _write_cfg(self):
    #t
    pass

def _read_cfg(self):
    #t
    pass
于 2013-03-15T17:49:49.133 回答