def verification(self, dsc_filesize, dsc_checksums, file_list): """ verification of signed files. :rtype: bool :return: ``True`` is valid, ``False`` is invalid. :param int dsc_filesize: file size retreived from .changes :param tuple dsc_checksums: .dsc checksums retrieved from .changes :param list file_list: file list retrieve .changes """ result = guard( g(ValueError('difference file size of .dsc'), self.verify_filesize(dsc_filesize, file_list) is False), g(ValueError('invalid checksums of .dsc'), self.verify_checksums(dsc_checksums, file_list) is False), g(ValueError('invalid signature of .dsc'), self.verify_signature(self.dsc_path) is False), g(ValueError('invalid signature of .changes'), self.verify_signature(self.changes_path) is False), g(ValueError('invalid checking with dput'), self.verify_with_dput() != 0), g(True)) if result is not True: raise result return result
def _generate_files(self): generator = (lambda f: guard( g(self._generate_init, f == '__init__.py.j2'), g(self._generate_exec_file, f == 'utils/pre-commit.j2', (f,)), g(self._generate_samples, f.endswith('sample.py.j2'), (f,)), g(self._generate_file, params=(f,)))) for file_path in self.templates.list_templates(): generator(file_path) os.chdir(self.tmpdir) os.symlink('../../README.rst', 'docs/source/README.rst') os.chdir(self.cwd)
def _generate_files(self): generator = (lambda f: guard( g(self._generate_init, f == '__init__.py.j2'), g(self._generate_exec_file, f == 'utils/pre-commit.j2', (f, )), g(self._generate_samples, f.endswith('sample.py.j2'), (f, )), g(self._generate_file, params=(f, )))) for file_path in self.templates.list_templates(): generator(file_path) os.chdir(self.tmpdir) os.symlink('../../README.rst', 'docs/source/README.rst') os.chdir(self.cwd)
def generate_atena_tex(template, address_file, outfile_path): """Generate atena TeX file. :param str template: template dictionary :param str address_file: address list csv file :param str outfile_path: output TeX file path """ renderer = pystache.Renderer(file_encoding='utf-8', search_dirs=template.get('search_dirs'), string_encoding='utf-8') # set template tmpl = renderer.load_template(template.get('template_name')) # load address data addresses = convert.csv2addr(address_file) # generate atena TeX data data = guard( g(renderer.render(tmpl, addresses), sys.version_info > (3, 1)), g(renderer.render(tmpl, addresses).encode('utf-8'))) with open(outfile_path, 'w') as fobj: fobj.write(data)
def verify_checksums(dsc_checksums, file_list): """ verify checksums (and size) with file list retrieved from changes. :rtype: bool :return: ``True`` is valid, ``False`` is invalid. :param list file_list: file list as return of parse_changes(). """ pattern = re.compile(r'.dsc\Z') return guard( g(False, dsc_checksums[0] != [_file.get('md5sum') for _file in file_list[0] if pattern.search(_file.get('name'))][0]), g(False, dsc_checksums[1] != [_file.get('sha1') for _file in file_list[1] if pattern.search(_file.get('name'))][0]), g(False, dsc_checksums[2] != [_file.get('sha256') for _file in file_list[2] if pattern.search(_file.get('name'))][0]), g(True))