New script to generate all_id2.txt
- Legacy-Id: 2202
This commit is contained in:
parent
c99b4e72e5
commit
381117c742
|
@ -1,3 +1,10 @@
|
|||
ietfdb (2.49)
|
||||
|
||||
* New script to generate all_id2.txt. This should be called in
|
||||
www6s/scripts/datatracker-updater: run "python -m
|
||||
ietf.idindex.generate_all_id2_txt" and place its output
|
||||
in $ID/all_id2.txt.
|
||||
|
||||
ietfdb (2.48)
|
||||
|
||||
From Pasi:
|
||||
|
|
38
ietf/idindex/generate_all_id2_txt.py
Normal file
38
ietf/idindex/generate_all_id2_txt.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Portions Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
||||
from ietf.idindex.views import all_id2_txt
|
||||
print all_id2_txt().encode('utf-8'),
|
|
@ -14,5 +14,7 @@
|
|||
301 /drafts/all_id.html
|
||||
301 /drafts/
|
||||
200,heavy /drafts/_test/all_id.txt
|
||||
# this takes 3 minutes, so disabled by default
|
||||
#200,heavy /drafts/_test/all_id2.txt
|
||||
200,heavy /drafts/_test/id_index.txt
|
||||
200,heavy /drafts/_test/id_abstracts.txt
|
||||
|
|
|
@ -20,6 +20,7 @@ urlpatterns = patterns('',
|
|||
if settings.SERVER_MODE != 'production':
|
||||
urlpatterns += patterns('',
|
||||
(r'^_test/all_id.txt$', views.test_all_id_txt),
|
||||
(r'^_test/all_id2.txt$', views.test_all_id2_txt),
|
||||
(r'^_test/id_index.txt$', views.test_id_index_txt),
|
||||
(r'^_test/id_abstracts.txt$', views.test_id_abstracts_txt)
|
||||
)
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
from django.http import HttpResponse, HttpResponsePermanentRedirect
|
||||
from django.template import loader
|
||||
from django.shortcuts import get_object_or_404
|
||||
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal
|
||||
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal,PersonOrOrgInfo
|
||||
from ietf.idtracker.templatetags.ietf_filters import clean_whitespace
|
||||
import re
|
||||
|
||||
def all_id_txt():
|
||||
all_ids = InternetDraft.objects.order_by('filename')
|
||||
|
@ -58,6 +60,81 @@ def all_id_txt():
|
|||
'withdrawn_ietf':withdrawn_ietf,
|
||||
'replaced':replaced})
|
||||
|
||||
def all_id2_entry(id):
|
||||
fields = []
|
||||
# 0
|
||||
fields.append(id.filename+"-"+id.revision_display())
|
||||
# 1
|
||||
fields.append(id.id_document_tag)
|
||||
# 2
|
||||
status = id.status.status
|
||||
fields.append(status)
|
||||
# 3
|
||||
iesgstate = id.idstate() if status=="Active" else ""
|
||||
fields.append(iesgstate)
|
||||
# 4
|
||||
fields.append(id.rfc_number if status=="RFC" else "")
|
||||
# 5
|
||||
if status == "Replaced":
|
||||
try:
|
||||
fields.append(id.replaced_by.filename)
|
||||
except InternetDraft.DoesNotExist:
|
||||
fields.append("")
|
||||
else:
|
||||
fields.append("")
|
||||
# 6
|
||||
fields.append(id.revision_date)
|
||||
# 7
|
||||
group_acronym = id.group.acronym
|
||||
if group_acronym == "none":
|
||||
group_acronym = ""
|
||||
fields.append(group_acronym)
|
||||
|
||||
# 8
|
||||
area = ""
|
||||
if id.idinternal:
|
||||
area = id.idinternal.area_acronym
|
||||
elif not group_acronym:
|
||||
pass
|
||||
else:
|
||||
wgs = id.group.ietfwg_set.all()
|
||||
if len(wgs) > 0:
|
||||
area = wgs[0].area_acronym() or ""
|
||||
fields.append(area)
|
||||
# 9
|
||||
fields.append(id.idinternal.job_owner if id.idinternal else "")
|
||||
# 10
|
||||
if id.intended_status and id.intended_status.intended_status not in ("None","Request"):
|
||||
fields.append(id.intended_status.intended_status)
|
||||
else:
|
||||
fields.append("")
|
||||
# 11
|
||||
if (iesgstate=="In Last Call") or iesgstate.startswith("In Last Call::"):
|
||||
fields.append(id.lc_expiration_date)
|
||||
else:
|
||||
fields.append("")
|
||||
# 12
|
||||
fields.append(id.file_type if status=="Active" else "")
|
||||
# 13
|
||||
fields.append(clean_whitespace(id.title))
|
||||
# 14
|
||||
authors = []
|
||||
for author in sorted(id.authors.all(), key=lambda x: x.final_author_order()):
|
||||
try:
|
||||
realname = unicode(author.person)
|
||||
email = author.email() or ""
|
||||
name = re.sub(u"[<>@,]", u"", realname) + u" <"+re.sub(u"[<>,]", u"", email).strip()+u">"
|
||||
authors.append(clean_whitespace(name))
|
||||
except PersonOrOrgInfo.DoesNotExist:
|
||||
pass
|
||||
fields.append(u", ".join(authors))
|
||||
return "\t".join([unicode(x) for x in fields])
|
||||
|
||||
def all_id2_txt():
|
||||
all_ids = InternetDraft.objects.order_by('filename').select_related('status__status','group__acronym','intended_status__intended_status')
|
||||
data = "\n".join([all_id2_entry(id) for id in all_ids])
|
||||
return loader.render_to_string("idindex/all_id2.txt",{'data':data})
|
||||
|
||||
def id_index_txt():
|
||||
groups = IETFWG.objects.all()
|
||||
return loader.render_to_string("idindex/id_index.txt", {'groups':groups})
|
||||
|
@ -68,6 +145,8 @@ def id_abstracts_txt():
|
|||
|
||||
def test_all_id_txt(request):
|
||||
return HttpResponse(all_id_txt(), mimetype='text/plain')
|
||||
def test_all_id2_txt(request):
|
||||
return HttpResponse(all_id2_txt(), mimetype='text/plain')
|
||||
def test_id_index_txt(request):
|
||||
return HttpResponse(id_index_txt(), mimetype='text/plain')
|
||||
def test_id_abstracts_txt(request):
|
||||
|
|
33
ietf/templates/idindex/all_id2.txt
Normal file
33
ietf/templates/idindex/all_id2.txt
Normal file
|
@ -0,0 +1,33 @@
|
|||
{% autoescape off %}#
|
||||
# Index of all Internet-Drafts
|
||||
# generated: {% now "Y-m-d H:i:s T" %}
|
||||
#
|
||||
# Description of fields:
|
||||
# 0 draft name and latest revision
|
||||
# 1 id_document_tag (internal database identifier; avoid using
|
||||
# unless you really need it)
|
||||
# 2 one of "Active", "Expired", "RFC", "Withdrawn by Submitter",
|
||||
# "Replaced", or "Withdrawn by IETF"
|
||||
# 3 if #2 is "Active", the IESG state for the document (such as
|
||||
# "In Last Call", "AD Evaluation::Revised ID Needed", or "I-D Exists");
|
||||
# otherwise empty
|
||||
# 4 if #2 is "RFC", the RFC number (otherwise empty)
|
||||
# 5 if #2 is "Replaced", the replacing draft name (otherwise empty)
|
||||
# 6 revision date (YYYY-MM-DD)
|
||||
# 7 group acronym (or empty if no group/not known)
|
||||
# 8 area acronym (or empty if not known; not necessarily accurate
|
||||
# for older drafts)
|
||||
# 9 responsible AD name (or empty if not known)
|
||||
# 10 intended maturity level (or empty if not known)
|
||||
# 11 if #3 is "In Last Call" (with any substate), the last call
|
||||
# end date (YYYY-MM-DD); otherwise empty
|
||||
# 12 if #2 is "Active", list of file types; otherwise empty
|
||||
# 13 draft title
|
||||
# 14 draft authors (often quite inaccurate, especially the email
|
||||
# addresses...)
|
||||
#
|
||||
# new fields can be added to the end in the future, so remember to
|
||||
# ignore those in your code
|
||||
#
|
||||
{{ data }}
|
||||
# end{% endautoescape %}
|
Loading…
Reference in a new issue