Пример #1
0
 def list(self, request, *args, **kwargs):
     annotation_templates_dir = find_dir('annotation_templates')
     configs = []
     for config_file in pathlib.Path(annotation_templates_dir).glob('**/*.yml'):
         config = read_yaml(config_file)
         configs.append(config)
     template_groups_file = find_file(os.path.join('annotation_templates', 'groups.txt'))
     with open(template_groups_file) as f:
         groups = f.read().splitlines()
     logger.debug(f'{len(configs)} templates found.')
     return Response({'templates': configs, 'groups': groups})
Пример #2
0
 def list(self, request, *args, **kwargs):
     annotation_templates_dir = find_dir('annotation_templates')
     configs = []
     for config_file in pathlib.Path(annotation_templates_dir).glob('**/*.yml'):
         config = read_yaml(config_file)
         if config.get('image', '').startswith('/static') and settings.HOSTNAME:
             # if hostname set manually, create full image urls
             config['image'] = settings.HOSTNAME + config['image']
         configs.append(config)
     template_groups_file = find_file(os.path.join('annotation_templates', 'groups.txt'))
     with open(template_groups_file, encoding='utf-8') as f:
         groups = f.read().splitlines()
     logger.debug(f'{len(configs)} templates found.')
     return Response({'templates': configs, 'groups': groups})