def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kind=None, report=None, pathname=None): if pathname is None: pathname = os.path.join(module, filename) fp = misc.file_open(pathname) ext = os.path.splitext(filename)[1].lower() try: if ext == '.csv': convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate) elif ext == '.sql': convert_sql_import(cr, fp) elif ext == '.yml': convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report) elif ext == '.xml': convert_xml_import(cr, module, fp, idref, mode, noupdate, report) elif ext == '.js': pass # .js files are valid but ignored here. else: _logger.warning("Can't load unknown file type %s.", filename) finally: fp.close()
def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kind=None, report=None): pathname = os.path.join(module, filename) fp = misc.file_open(pathname) ext = os.path.splitext(filename)[1].lower() try: if ext == '.csv': convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate) elif ext == '.sql': convert_sql_import(cr, fp) elif ext == '.yml': convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report) elif ext == '.xml': convert_xml_import(cr, module, fp, idref, mode, noupdate, report) elif ext == '.js': pass # .js files are valid but ignored here. else: _logger.warning("Can't load unknown file type %s.", filename) finally: fp.close()
def convert_file(cr, module, filename, idref, mode="update", noupdate=False, kind=None, report=None, pathname=None): if pathname is None: pathname = os.path.join(module, filename) fp = misc.file_open(pathname) ext = os.path.splitext(filename)[1].lower() try: if ext == ".csv": convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate) elif ext == ".sql": convert_sql_import(cr, fp) elif ext == ".yml": convert_yaml_import(cr, module, fp, kind, idref, mode, noupdate, report) elif ext == ".xml": convert_xml_import(cr, module, fp, idref, mode, noupdate, report) elif ext == ".js": pass # .js files are valid but ignored here. else: raise ValueError("Can't load unknown file type %s.", filename) finally: fp.close()