Example #1
0
    def info_files(self):
        raw = self.t.extractfile('info/files').read()
        if not all_ascii(raw, self.win_pkg):
            raise PackageError("non-ASCII in: info/files")
        lista = [p.strip() for p in raw.decode('utf-8').splitlines()]
        for p in lista:
            if p.startswith('info/'):
                raise PackageError("Did not expect '%s' in info/files" % p)

        seta = set(lista)
        if len(lista) != len(seta):
            raise PackageError('info/files: duplicates')

        listb = [
            m.path for m in self.t.getmembers()
            if not (m.path.startswith('info/') or m.isdir())
        ]
        setb = set(listb)
        if len(listb) != len(setb):
            raise PackageError("info_files: duplicate members")

        if seta == setb:
            return
        for p in sorted(seta | setb):
            if p not in seta:
                print('%r not in info/files' % p)
            if p not in setb:
                print('%r not in tarball' % p)
        raise PackageError("info/files")
Example #2
0
 def check_members(self):
     for m in self.t.getmembers():
         path = m.path
         if not all_ascii(path):
             raise PackageError("non-ASCII path: %r" % path)
         if ' ' in path:
             print("WARNING: ' ' (space) in path: %r" % path)
Example #3
0
    def info_files(self):
        raw = self.t.extractfile('info/files').read()
        if not all_ascii(raw, self.win_pkg):
            raise PackageError("non-ASCII in: info/files")
        lista = [p.strip() for p in raw.decode('utf-8').splitlines()]
        for p in lista:
            if p.startswith('info/'):
                raise PackageError("Did not expect '%s' in info/files" % p)

        seta = set(lista)
        if len(lista) != len(seta):
            raise PackageError('info/files: duplicates')

        listb = [m.path for m in self.t.getmembers()
                 if not (m.path.startswith('info/') or m.isdir())]
        setb = set(listb)
        if len(listb) != len(setb):
            raise PackageError("info_files: duplicate members")

        if seta == setb:
            return
        for p in sorted(seta | setb):
            if p not in seta:
                print('%r not in info/files' % p)
            if p not in setb:
                print('%r not in tarball' % p)
        raise PackageError("info/files")
Example #4
0
 def has_prefix(self):
     for m in self.t.getmembers():
         if m.path != 'info/has_prefix':
             continue
         if self.win_pkg:
             print("WARNING: %s" % m.path)
         data = self.t.extractfile(m.path).read()
         if not all_ascii(data, self.win_pkg):
             raise PackageError("non-ASCII in: info/has_prefix")
         for line in data.decode('utf-8').splitlines():
             self._check_has_prefix_line(line)
Example #5
0
 def has_prefix(self):
     for m in self.t.getmembers():
         if m.path != 'info/has_prefix':
             continue
         if self.info['platform'] == 'win':
             print("WARNING: %s" % m.path)
         data = self.t.extractfile(m.path).read()
         if not all_ascii(data):
             raise PackageError("non-ASCII in: info/has_prefix")
         for line in data.decode('utf-8').splitlines():
             self._check_has_prefix_line(line)
Example #6
0
 def __init__(self, path, verbose=False):
     self.verbose = verbose
     self.t = tarfile.open(path)
     self.dist = dist_fn(basename(path))
     self.name, self.version, self.build = self.dist.rsplit('-', 2)
     paths = [m.path for m in self.t.getmembers()]
     self.paths = set(paths)
     if len(paths) != len(self.paths):
         raise PackageError("duplicate members")
     raw = self.t.extractfile('info/index.json').read()
     if not all_ascii(raw):
         raise PackageError("non-ASCII in: info/index.json")
     self.info = json.loads(raw.decode('utf-8'))
Example #7
0
 def __init__(self, path, verbose=False):
     self.verbose = verbose
     self.t = tarfile.open(path)
     self.dist = dist_fn(basename(path))
     self.name, self.version, self.build = self.dist.rsplit('-', 2)
     paths = [m.path for m in self.t.getmembers()]
     self.paths = set(paths)
     if len(paths) != len(self.paths):
         raise PackageError("duplicate members")
     raw = self.t.extractfile('info/index.json').read()
     self.info = json.loads(raw.decode('utf-8'))
     self.win_pkg = bool(self.info['platform'] == 'win')
     if not all_ascii(raw, self.win_pkg):
         raise PackageError("non-ASCII in: info/index.json")
Example #8
0
def validate_recipe(recipe_dir):
    meta_path = join(recipe_dir, 'meta.yaml')
    with open(meta_path, 'rb') as fi:
        data = fi.read()
    if not all_ascii(data):
        raise RecipeError("non-ASCII in: %s" % meta_path)
    if b'{{' in data:
        raise RecipeError("found {{ in %s (Jinja templating not allowed)" %
                          meta_path)

    check_dir_content(recipe_dir)

    for cfg in iter_cfgs():
        meta = parse(data.decode('utf-8'), cfg)
        validate_meta(meta)
        validate_files(recipe_dir, meta)
Example #9
0
def validate_recipe(recipe_dir, pedantic=True):
    global PEDANTIC
    PEDANTIC = bool(pedantic)

    meta_path = join(recipe_dir, 'meta.yaml')
    with open(meta_path, 'rb') as fi:
        data = fi.read()
    if PEDANTIC and not all_ascii(data):
        raise RecipeError("non-ASCII in: %s" % meta_path)
    if b'{{' in data:
        data = render_jinja2(recipe_dir)
    else:
        data = data.decode('utf-8')

    check_dir_content(recipe_dir)

    for cfg in iter_cfgs():
        meta = parse(data, cfg)
        validate_meta(meta)
        validate_files(recipe_dir, meta)
Example #10
0
def validate_recipe(recipe_dir, pedantic=True):
    global PEDANTIC
    PEDANTIC = bool(pedantic)

    meta_path = join(recipe_dir, 'meta.yaml')
    with open(meta_path, 'rb') as fi:
        data = fi.read()
    if PEDANTIC and not all_ascii(data):
        raise RecipeError("non-ASCII in: %s" % meta_path)
    if b'{{' in data:
        data = render_jinja2(recipe_dir)
    else:
        data = data.decode('utf-8')

    check_dir_content(recipe_dir)

    for cfg in iter_cfgs():
        meta = parse(data, cfg)
        validate_meta(meta)
        validate_files(recipe_dir, meta)
Example #11
0
 def check_members(self):
     for m in self.t.getmembers():
         path = m.path
         if not all_ascii(path.encode('utf-8')):
             raise PackageError("non-ASCII path: %r" % path)
Example #12
0
 def check_members(self):
     for m in self.t.getmembers():
         path = m.path
         if not all_ascii(path.encode('utf-8')):
             raise PackageError("non-ASCII path: %r" % path)