コード例 #1
0
def update_intersphinx(version_pk):
    version = Version.objects.get(pk=version_pk)
    path = version.project.rtd_build_path(version.slug)
    if not path:
        print "ERR: %s has no path" % version
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, app.srcdir, 'objects.inv')
    except TypeError:
        print "Failed to fetch inventory for %s" % version
        return None
    # I'm entirelty not sure this is even close to correct.
    # There's a lot of info I'm throwing away here; revisit later?
    for keytype in inv:
        for term in inv[keytype]:
            try:
                _, _, url, title = inv[keytype][term]
                if not title or title == '-':
                    if '#' in url:
                        title = url.rsplit('#')[-1]
                    else:
                        title = url
                find_str = "rtd-builds/latest"
                latest = url.find(find_str)
                url = url[latest + len(find_str) + 1:]
                url = "http://%s.readthedocs.org/en/latest/%s" % (
                    version.project.slug, url)
                save_term(version, term, url, title)
                if '.' in term:
                    save_term(version, term.split('.')[-1], url, title)
            except Exception, e: #Yes, I'm an evil person.
                print "*** Failed updating %s: %s" % (term, e)
コード例 #2
0
ファイル: tasks.py プロジェクト: dnerdy/readthedocs.org
def update_intersphinx(version_pk):
    version = Version.objects.get(pk=version_pk)
    path = version.project.rtd_build_path(version.slug)
    if not path:
        print "ERR: %s has no path" % version
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, app.srcdir, 'objects.inv')
    except TypeError:
        print "Failed to fetch inventory for %s" % version
        return None
    # I'm entirelty not sure this is even close to correct.
    # There's a lot of info I'm throwing away here; revisit later?
    for keytype in inv:
        for term in inv[keytype]:
            try:
                _, _, url, title = inv[keytype][term]
                if not title or title == '-':
                    if '#' in url:
                        title = url.rsplit('#')[-1]
                    else:
                        title = url
                find_str = "rtd-builds/latest"
                latest = url.find(find_str)
                url = url[latest + len(find_str) + 1:]
                url = "http://%s.readthedocs.org/en/latest/%s" % (
                    version.project.slug, url)
                save_term(version, term, url, title)
                if '.' in term:
                    save_term(version, term.split('.')[-1], url, title)
            except Exception, e:  #Yes, I'm an evil person.
                print "*** Failed updating %s: %s" % (term, e)
コード例 #3
0
ファイル: tasks.py プロジェクト: rmaceissoft/readthedocs.org
def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    del version_data["resource_uri"]
    project_data = version_data["project"]
    del project_data["users"]
    del project_data["resource_uri"]
    del project_data["absolute_url"]
    project = Project(**project_data)
    version_data["project"] = project
    version = Version(**version_data)

    object_file = version.project.find("objects.inv", version.slug)[0]
    path = version.project.rtd_build_path(version.slug)
    if not path:
        print "ERR: %s has no path" % version
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, path, object_file)
    except TypeError:
        print "Failed to fetch inventory for %s" % version
        return None
    # I'm entirelty not sure this is even close to correct.
    # There's a lot of info I'm throwing away here; revisit later?
    for keytype in inv:
        for term in inv[keytype]:
            try:
                _, _, url, title = inv[keytype][term]
                if not title or title == "-":
                    if "#" in url:
                        title = url.rsplit("#")[-1]
                    else:
                        title = url
                find_str = "rtd-builds/latest"
                latest = url.find(find_str)
                url = url[latest + len(find_str) + 1 :]
                url = "http://%s.readthedocs.org/en/latest/%s" % (version.project.slug, url)
                save_term(version, term, url, title)
                if "." in term:
                    save_term(version, term.split(".")[-1], url, title)
            except Exception, e:  # Yes, I'm an evil person.
                print "*** Failed updating %s: %s" % (term, e)
コード例 #4
0
ファイル: tasks.py プロジェクト: Nagyman/readthedocs.org
def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    del version_data['resource_uri']
    project_data = version_data['project']
    del project_data['users']
    del project_data['resource_uri']
    del project_data['absolute_url']
    project = Project(**project_data)
    version_data['project'] = project
    version = Version(**version_data)

    object_file = version.project.find('objects.inv', version.slug)[0]
    path = version.project.rtd_build_path(version.slug)
    if not path:
        log.warning("%s has no path" % version)
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, path, object_file)
    except TypeError, e:
        log.error("Failed to fetch inventory for %s" % version, exc_info=True)
        return None
コード例 #5
0
def update_intersphinx(version_pk):
    version_data = api.version(version_pk).get()
    del version_data['resource_uri']
    project_data = version_data['project']
    del project_data['users']
    del project_data['resource_uri']
    del project_data['absolute_url']
    project = Project(**project_data)
    version_data['project'] = project
    version = Version(**version_data)

    object_file = version.project.find('objects.inv', version.slug)[0]
    path = version.project.rtd_build_path(version.slug)
    if not path:
        log.warning("%s has no path" % version)
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, path, object_file)
    except TypeError, e:
        log.error("Failed to fetch inventory for %s" % version, exc_info=True)
        return None
コード例 #6
0
ファイル: tasks.py プロジェクト: dangra/readthedocs.org
    del project_data['resource_uri']
    del project_data['absolute_url']
    project = Project(**project_data)
    version_data['project'] = project
    version = Version(**version_data)

    try:
        object_file = version.project.find('objects.inv', version.slug)[0]
    except IndexError, e:
        print "Failed to find objects file"
        return None
    path = version.project.rtd_build_path(version.slug)
    if not path:
        log.warning("%s has no path" % version)
        return None
    app = DictObj()
    app.srcdir = path
    try:
        inv = fetch_inventory(app, path, object_file)
    except TypeError, e:
        log.error("Failed to fetch inventory for %s" % version, exc_info=True)
        return None
    # TODO: I'm entirelty not sure this is even close to correct.
    # There's a lot of info I'm throwing away here; revisit later?
    for keytype in inv:
        for term in inv[keytype]:
            try:
                _, _, url, title = inv[keytype][term]
                if not title or title == '-':
                    if '#' in url:
                        title = url.rsplit('#')[-1]