Ejemplo n.º 1
0
def _get_test_files_by_module(modules):
    assert isinstance(modules, list), 'modules argument should be a list'
    test_files = {}
    for module in modules:
        info = load_information_from_description_file(module)
        test_files[module] = info.get('test', [])
    return test_files
Ejemplo n.º 2
0
def main():
    d = load_information_from_description_file(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
    with open('manifest', 'w') as out:
        manifest_content = (d['description'] if 'description' in d else
                            d['summary'] if 'summary' in d else '')
        out.write(manifest_content)
Ejemplo n.º 3
0
 def load_manifest(self, name):
     manifest = module.load_information_from_description_file(name)
     if manifest:
         path = module.get_module_path(name)
         manifest['js'] = list(
             self.expand_patterns(path, manifest.get('js', [])))
         manifest['test'] = list(
             self.expand_patterns(path, manifest.get('test', [])))
         manifest['qweb'] = list(
             self.expand_patterns(path, manifest.get('qweb', [])))
     return manifest
Ejemplo n.º 4
0
 def load_manifest(self, name):
     manifest = module.load_information_from_description_file(name)
     if manifest:
         path = module.get_module_path(name)
         manifest['js'] = list(
             self.expand_patterns(path, manifest.get('js', [])))
         manifest['test'] = list(
             self.expand_patterns(path, manifest.get('test', [])))
         manifest['qweb'] = list(
             self.expand_patterns(path, manifest.get('qweb', [])))
     return manifest
Ejemplo n.º 5
0
    def _get_xml_files(self, mod_name, demo=False):
        """ Gets all XML file paths from module manifest file

            :param mod_name (basestring): name of the module
            :param demo (bool): include demo XML files

            :return ([basestring]): XML relative file paths
        """
        data = []

        info = load_information_from_description_file(mod_name)
        if info:
            data = info['data'] if 'data' in info else []

            if demo:
                data += info['demo'] if 'demo' in info else []

        return filter(lambda x: x.endswith('.xml'), data)
Ejemplo n.º 6
0
    def _get_xml_files(self, mod_name, demo=False):
        """ Gets all XML file paths from module manifest file

            :param mod_name (basestring): name of the module
            :param demo (bool): include demo XML files

            :return ([basestring]): XML relative file paths
        """
        data = []

        info = load_information_from_description_file(mod_name)
        if info:
            data = info['data'] if 'data' in info else []

            if demo:
                data += info['demo'] if 'demo' in info else []

        return filter(lambda x: x.endswith('.xml'), data)
Ejemplo n.º 7
0
 def test_base_manifest_extension(self):
     # write a test manifest
     module_path = tempfile.mkdtemp(dir=os.path.join(
         get_module_path('base_manifest_extension'), 'static'))
     with open(os.path.join(module_path, MANIFEST), 'w') as manifest:
         manifest.write(
             repr({
                 'depends_if_installed': [
                     'base_manifest_extension',
                     'not installed',
                 ],
             }))
     # parse it
     parsed = load_information_from_description_file(
         # this name won't really be used, but avoids a warning
         'base',
         mod_path=module_path,
     )
     self.assertIn('base_manifest_extension', parsed['depends'])
     self.assertNotIn('not installed', parsed['depends'])
     self.assertNotIn('depends_if_installed', parsed)
Ejemplo n.º 8
0
 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) 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 == '.yml':
                 tools.convert_yaml_import(cr,
                                           module_name,
                                           fp,
                                           kind=kind,
                                           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