File: __main__.py

package info (click to toggle)
pygame 1.9.6%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,060 kB
  • sloc: ansic: 59,765; python: 31,220; objc: 334; makefile: 57; cpp: 25
file content (28 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# python -m pygame.docs

import os
import webbrowser
try:
    from urllib.parse import urlunparse, quote
except ImportError:
    from urlparse import urlunparse
    from urllib import quote

def iterpath(path):
    path, last = os.path.split(path)
    if last:
        for p in iterpath(path):
            yield p
        yield last

pkg_dir = os.path.dirname(os.path.abspath(__file__))
main_page = os.path.join(pkg_dir, 'index.html')
if os.path.exists(main_page):
    url_path = quote('/'.join(iterpath(main_page)))
    drive, rest = os.path.splitdrive(__file__)
    if drive:
        url_path = "%s/%s" % (drive, url_path)
    url = urlunparse(('file', '', url_path, '', '', ''))
else:
    url = "https://www.pygame.org/docs/"
webbrowser.open(url)