def _run_test(cr, module, filename): _, ext = os.path.splitext(filename) pathname = os.path.join(module, filename) with tools.file_open(pathname) as fp: if ext == '.sql': if hasattr(tools, 'convert_sql_import'): tools.convert_sql_import(cr, fp) else: queries = fp.read().split(';') for query in queries: new_query = ' '.join(query.split()) if new_query: cr.execute(new_query) elif ext == '.csv': tools.convert_csv_import(cr, module, pathname, fp.read( ), idref=None, mode='update', noupdate=False) elif ext == '.yml': if LooseVersion(release.major_version) >= LooseVersion('7.0'): tools.convert_yaml_import( cr, module, fp, kind='test', idref=None, mode='update', noupdate=False) else: tools.convert_yaml_import( cr, module, fp, idref=None, mode='update', noupdate=False) elif ext == '.xml': tools.convert_xml_import( cr, module, fp, idref=None, mode='update', noupdate=False)
def _load_data(self, module_name, kind='demo', mode='update', noupdate=False): cr = self._cr info = load_information_from_description_file(module_name) for filename in info.get(kind, []): _logger.info('loading %s/%s...' % (module_name, filename)) _, ext = os.path.splitext(filename) pathname = os.path.join(module_name, filename) with tools.file_open(pathname, 'rb') as fp: if ext == '.sql': tools.convert_sql_import(cr, fp) elif ext == '.csv': tools.convert_csv_import(cr, module_name, pathname, fp.read(), idref=None, mode=mode, noupdate=noupdate) elif ext == '.xml': tools.convert_xml_import(cr, module_name, fp, idref=None, mode=mode, noupdate=noupdate) return True