def list_modules(self): for m in self.modules_pool: if not m.isfetched: p.rawprint("#!UNFETCHED") p.rawprint(m.url + '\n') else: p.rawprint(path.relpath(m.path)) if m.source in ["svn", "git"]: p.rawprint("#" + m.url) if not len(m.files): p.rawprint(" # no files") else: for f in m.files: p.rawprint(" " + path.relpath(f.path, m.path)) p.rawprint("")
def list_modules(self): for m in self.modules_pool: if not m.isfetched: p.rawprint("#!UNFETCHED") p.rawprint(m.url+'\n') else: p.rawprint(path.relpath(m.path)) if m.source in ["svn", "git"]: p.rawprint ("#"+m.url) if not len(m.files): p.rawprint(" # no files") else: for f in m.files: p.rawprint(" " + path.relpath(f.path, m.path)) p.rawprint("")
def __init__(self, path, library = None, vlog_opt = None, include_dirs = None): if not library: library = "work" SourceFile.__init__(self, path, library) self.__create_deps() if not vlog_opt: self.vlog_opt = "" else: self.vlog_opt = vlog_opt self.include_dirs = [] if include_dirs: self.include_dirs.extend(include_dirs) self.include_dirs.append(path_mod.relpath(self.dirname))
def __init__(self, path, library=None, vlog_opt=None, include_dirs=None): if not library: library = "work" SourceFile.__init__(self, path, library) self.__create_deps() if not vlog_opt: self.vlog_opt = "" else: self.vlog_opt = vlog_opt self.include_dirs = [] if include_dirs: self.include_dirs.extend(include_dirs) self.include_dirs.append(path_mod.relpath(self.dirname))
def rel_path(self, dir=None): import path if dir == None: dir = os.getcwd() return path.relpath(self.path, dir)
def check_orphans(opts): def _find_files(path, globs, excludes = []): ff = [] for root, dirs, files in os.walk(path, followlinks = True): for f in files: for g in globs: if fnmatch.fnmatch(f, g) and f not in excludes: ff += [os.path.join(root, f)] return sorted(ff) def _clean(line): line = line[0:-1] b = line.find('#') if b >= 0: line = line[1:b] return line.strip() def _find(name, opts): ename = opts.defaults.expand(name) if ':' in ename: paths = path.dirname(ename).split(':') name = path.basename(name) else: paths = opts.defaults.get_value('_configdir').split(':') for p in paths: n = path.join(opts.defaults.expand(p), name) if path.exists(n): return n return None paths = opts.defaults.get_value('_configdir').split(':') cfgs = {} for p in paths: ep = opts.defaults.expand(p) print('Scanning: %s (%s)' % (p, ep)) for f in _find_files(ep, ['*.cfg', '*.bset']): root, ext = path.splitext(f) cfgs[f] = { 'src': None, 'ext': ext, 'refs': 0, 'errors':[] } wss = re.compile(r'\s+') for c in cfgs: with open(c, 'r') as f: cfgs[c]['src'] = f.readlines() lc = 0 for l in cfgs[c]['src']: lc += 1 l = _clean(l) if len(l) == 0: continue if l[0] == '%': ls = wss.split(l, 2) if ls[0] == '%include': name = _find(ls[1], opts) if name is None: cfgs[c]['errors'] += [lc] elif name not in cfgs: raise error.general('include: %s: not present' % (ls[1])) else: cfgs[name]['refs'] += 1 elif cfgs[c]['ext'] == '.bset' and ':' not in l: for ext in ['', '.cfg', '.bset']: name = _find(l + ext, opts) if name is not None: if name not in cfgs: raise error.general('include: %s: not present' % (ls[1])) else: cfgs[name]['refs'] += 1 break topdir = opts.defaults.expand('%{_topdir}') orphans = [] show = True for c in cfgs: if cfgs[c]['refs'] == 0: orphans += [c] if len(cfgs[c]['errors']) != 0: if show: print('Warnings:') show = False print(' %s:' % (path.relpath(c))) for l in cfgs[c]['errors']: print(' %3d: %s' % (l, cfgs[c]['src'][l - 1][:-1])) show = True for o in sorted(orphans): if show: print('Orphans:') show = False print(' %s' % (path.relpath(o)))
def check_orphans(opts): def _find_files(path, globs, excludes=[]): ff = [] for root, dirs, files in os.walk(path, followlinks=True): for f in files: for g in globs: if fnmatch.fnmatch(f, g) and f not in excludes: ff += [os.path.join(root, f)] return sorted(ff) def _clean(line): line = line[0:-1] b = line.find('#') if b >= 0: line = line[1:b] return line.strip() def _find(name, opts): ename = opts.defaults.expand(name) if ':' in ename: paths = path.dirname(ename).split(':') name = path.basename(name) else: paths = opts.defaults.get_value('_configdir').split(':') for p in paths: n = path.join(opts.defaults.expand(p), name) if path.exists(n): return n return None paths = opts.defaults.get_value('_configdir').split(':') cfgs = {} for p in paths: ep = opts.defaults.expand(p) print('Scanning: %s (%s)' % (p, ep)) for f in _find_files(ep, ['*.cfg', '*.bset']): root, ext = path.splitext(f) cfgs[f] = {'src': None, 'ext': ext, 'refs': 0, 'errors': []} wss = re.compile(r'\s+') for c in cfgs: with open(c, 'r') as f: cfgs[c]['src'] = f.readlines() lc = 0 for l in cfgs[c]['src']: lc += 1 l = _clean(l) if len(l) == 0: continue if l[0] == '%': ls = wss.split(l, 2) if ls[0] == '%include': name = _find(ls[1], opts) if name is None: cfgs[c]['errors'] += [lc] elif name not in cfgs: raise error.general('include: %s: not present' % (ls[1])) else: cfgs[name]['refs'] += 1 elif cfgs[c]['ext'] == '.bset' and ':' not in l: for ext in ['', '.cfg', '.bset']: name = _find(l + ext, opts) if name is not None: if name not in cfgs: raise error.general('include: %s: not present' % (ls[1])) else: cfgs[name]['refs'] += 1 break topdir = opts.defaults.expand('%{_topdir}') orphans = [] show = True for c in cfgs: if cfgs[c]['refs'] == 0: orphans += [c] if len(cfgs[c]['errors']) != 0: if show: print('Warnings:') show = False print(' %s:' % (path.relpath(c))) for l in cfgs[c]['errors']: print(' %3d: %s' % (l, cfgs[c]['src'][l - 1][:-1])) show = True for o in sorted(orphans): if show: print('Orphans:') show = False print(' %s' % (path.relpath(o)))