def __init__(self, prefix): assert type(prefix) in [types.ListType, types.TupleType], prefix CompositePackageRepository.__init__(self, []) repodir = prefix+self.REPO_FULL_PATH if not os.path.isdir(os.sep.join(repodir)): debug.warn('No repository directory '+os.sep.join(repodir)) return fs = scan_filesystem(path=repodir) errlist = [] for name, entry in fs.rootdirectory().entries(): if not isinstance(entry, VFSFile): continue if _re_repo.match(name): try: self.add_repo(PackageFileRepository(file=entry)) except Error, e: errlist.append(Error('Error reading file "'+os.sep.join(entry.abspath()), [e])) except Exception, e: errlist.append(Error('Error reading file "'+os.sep.join(entry.abspath()), [e])) pass pass
def add_module_file(self, name, lines): my_lines = helper.normalize_lines(lines) existing_file = self.directory().get(name) if existing_file is None: self.directory().add(name=name, entry=File(lines=my_lines)) elif helper.md5_hexdigest_from_lines( my_lines) != helper.md5_hexdigest_from_lines( existing_file.lines()): debug.warn('Module file ' + name + ' already exists with different content') existing_file.truncate() existing_file.add_lines(my_lines) pass pass
def raise_unresolved(self): error = NotResolved() for require, node in self.__unresolved_requires: if require.urgency() == Require.URGENCY_ERROR: error.add(require, node) continue if require.urgency() == Require.URGENCY_WARN: debug.warn('Require object '+str(require)+' could not be resolved') continue if require.urgency() == Require.URGENCY_IGNORE: continue assert 0, 'huh? missed urgency level '+str(require.urgency()) pass if len(error) > 0: raise error pass
# You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA from libconfix.core.utils.error import Error, NativeError import sys # pickle segfaults on interix. this should be fixed in python 2.5, but # we leave it in for a while from now. mypickle = None if sys.platform.startswith('interix'): from libconfix.core.utils import debug debug.warn('using pickle instead of cPickle on interix') import pickle mypickle = pickle else: import cPickle mypickle = cPickle pass def load_object_from_file(filename): try: file = open(filename, 'r') except IOError, e: raise Error('Cannot open file ' + filename + ' for reading', [e]) try: