How to use the mike.git_utils.file_mode function in mike

To help you get started, we’ve selected a few mike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_nonexistent_file(self):
        self.assertRaises(git_utils.GitError, git_utils.file_mode, 'branch',
                          'nonexist.txt')
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_root_mode(self):
        self.assertEqual(git_utils.file_mode('branch', ''), 0o040000)
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_directory_mode(self):
        self.assertEqual(git_utils.file_mode('branch', 'dir'), 0o040000)
        self.assertEqual(git_utils.file_mode('branch', 'dir/'), 0o040000)
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_directory_mode(self):
        self.assertEqual(git_utils.file_mode('branch', 'dir'), 0o040000)
        self.assertEqual(git_utils.file_mode('branch', 'dir/'), 0o040000)
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_file_mode(self):
        self.assertEqual(git_utils.file_mode('branch', 'dir/file.txt'),
                         0o100644)
github jimporter / mike / mike / server.py View on Github external
def send_headers(self):
        path = _to_git_path(self.path)
        try:
            if stat.S_ISDIR(git_utils.file_mode(self.branch, path)):
                url = urlparse.urlsplit(self.path)
                if not url.path.endswith('/'):
                    # Redirect the browser to a URL with a slash at the end,
                    # like Apache.
                    self.send_response(301)
                    dest = urlparse.urlunsplit(
                        url[:2] + (url[2] + '/',) + url[3:]
                    )
                    self.send_header('Location', dest)
                    self.end_headers()
                    return

                path = posixpath.join(path, 'index.html')
                git_utils.file_mode(self.branch, path)

            self.send_response(200)
github jimporter / mike / mike / server.py View on Github external
try:
            if stat.S_ISDIR(git_utils.file_mode(self.branch, path)):
                url = urlparse.urlsplit(self.path)
                if not url.path.endswith('/'):
                    # Redirect the browser to a URL with a slash at the end,
                    # like Apache.
                    self.send_response(301)
                    dest = urlparse.urlunsplit(
                        url[:2] + (url[2] + '/',) + url[3:]
                    )
                    self.send_header('Location', dest)
                    self.end_headers()
                    return

                path = posixpath.join(path, 'index.html')
                git_utils.file_mode(self.branch, path)

            self.send_response(200)
            self.send_header('Content-Type', self.guess_type(path))
            self.end_headers()

            return path
        except git_utils.GitError:
            self.send_error(404, 'File not found')
        except Exception:  # pragma: no cover
            self.send_error(500, 'Internal server error')