import os
import io
import json

from aiohttp import web


class Handler:
    def __init__(self, *, loop):
        self.loop = loop

        self.files = {}

    def lookup_files(self, path):
        for obj in os.listdir(path):
            _path = os.path.join(path, obj)

            if os.path.isfile(_path) or os.path.islink(_path):
                name, _ = os.path.splitext(obj)

                with io.open(_path, mode='rt', encoding='utf-8') as fp:
                    self.files[name] = json.dumps(json.load(fp)).encode('utf-8')  # noqa

    def browsers(self, request):
        version = request.match_info['version']

        if version not in self.files:
            raise web.HTTPNotFound(
                text='No data was found for version {version}'.format(
                    version=version,
                ),
            )

        return web.json_response(body=self.files[version])

import os
import io
import json

from aiohttp import web


class Handler:
    def __init__(self, *, loop):
        self.loop = loop

        self.files = {}

    def lookup_files(self, path):
        for obj in os.listdir(path):
            _path = os.path.join(path, obj)

            if os.path.isfile(_path):
                name, _ = os.path.splitext(obj)

                with io.open(_path, mode='rt', encoding='utf-8') as fp:
                    self.files[name] = json.dumps(json.load(fp)).encode('utf-8')  # noqa

    def browsers(self, request):
        version = request.match_info['version']

        if version not in self.files:
            raise web.HTTPNotFound(
                text='No data was found for version {version}'.format(
                    version=version,
                ),
            )

        return web.json_response(body=self.files[version])

Remove extra check of symlinks.
Remove extra check of symlinks.

  import os
  import io
  import json
  
  from aiohttp import web
  
  
  class Handler:
      def __init__(self, *, loop):
          self.loop = loop
  
          self.files = {}
  
      def lookup_files(self, path):
          for obj in os.listdir(path):
              _path = os.path.join(path, obj)
  
-             if os.path.isfile(_path) or os.path.islink(_path):
+             if os.path.isfile(_path):
                  name, _ = os.path.splitext(obj)
  
                  with io.open(_path, mode='rt', encoding='utf-8') as fp:
                      self.files[name] = json.dumps(json.load(fp)).encode('utf-8')  # noqa
  
      def browsers(self, request):
          version = request.match_info['version']
  
          if version not in self.files:
              raise web.HTTPNotFound(
                  text='No data was found for version {version}'.format(
                      version=version,
                  ),
              )
  
          return web.json_response(body=self.files[version])
  
Remove extra check of symlinks.
## Code Before:
import os
import io
import json

from aiohttp import web


class Handler:
    def __init__(self, *, loop):
        self.loop = loop

        self.files = {}

    def lookup_files(self, path):
        for obj in os.listdir(path):
            _path = os.path.join(path, obj)

            if os.path.isfile(_path) or os.path.islink(_path):
                name, _ = os.path.splitext(obj)

                with io.open(_path, mode='rt', encoding='utf-8') as fp:
                    self.files[name] = json.dumps(json.load(fp)).encode('utf-8')  # noqa

    def browsers(self, request):
        version = request.match_info['version']

        if version not in self.files:
            raise web.HTTPNotFound(
                text='No data was found for version {version}'.format(
                    version=version,
                ),
            )

        return web.json_response(body=self.files[version])

## Instruction:
Remove extra check of symlinks.
## Code After:
import os
import io
import json

from aiohttp import web


class Handler:
    def __init__(self, *, loop):
        self.loop = loop

        self.files = {}

    def lookup_files(self, path):
        for obj in os.listdir(path):
            _path = os.path.join(path, obj)

            if os.path.isfile(_path):
                name, _ = os.path.splitext(obj)

                with io.open(_path, mode='rt', encoding='utf-8') as fp:
                    self.files[name] = json.dumps(json.load(fp)).encode('utf-8')  # noqa

    def browsers(self, request):
        version = request.match_info['version']

        if version not in self.files:
            raise web.HTTPNotFound(
                text='No data was found for version {version}'.format(
                    version=version,
                ),
            )

        return web.json_response(body=self.files[version])
