Skip to content

Commit 381117c

Browse files
committed
New script to generate all_id2.txt
- Legacy-Id: 2202
1 parent c99b4e7 commit 381117c

6 files changed

Lines changed: 161 additions & 1 deletion

File tree

changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
ietfdb (2.49)
2+
3+
* New script to generate all_id2.txt. This should be called in
4+
www6s/scripts/datatracker-updater: run "python -m
5+
ietf.idindex.generate_all_id2_txt" and place its output
6+
in $ID/all_id2.txt.
7+
18
ietfdb (2.48)
29

310
From Pasi:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Portions Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
2+
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions
6+
# are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above
12+
# copyright notice, this list of conditions and the following
13+
# disclaimer in the documentation and/or other materials provided
14+
# with the distribution.
15+
#
16+
# * Neither the name of the Nokia Corporation and/or its
17+
# subsidiary(-ies) nor the names of its contributors may be used
18+
# to endorse or promote products derived from this software
19+
# without specific prior written permission.
20+
#
21+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
33+
from ietf import settings
34+
from django.core import management
35+
management.setup_environ(settings)
36+
37+
from ietf.idindex.views import all_id2_txt
38+
print all_id2_txt().encode('utf-8'),

ietf/idindex/testurl.list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
301 /drafts/all_id.html
1515
301 /drafts/
1616
200,heavy /drafts/_test/all_id.txt
17+
# this takes 3 minutes, so disabled by default
18+
#200,heavy /drafts/_test/all_id2.txt
1719
200,heavy /drafts/_test/id_index.txt
1820
200,heavy /drafts/_test/id_abstracts.txt

ietf/idindex/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
if settings.SERVER_MODE != 'production':
2121
urlpatterns += patterns('',
2222
(r'^_test/all_id.txt$', views.test_all_id_txt),
23+
(r'^_test/all_id2.txt$', views.test_all_id2_txt),
2324
(r'^_test/id_index.txt$', views.test_id_index_txt),
2425
(r'^_test/id_abstracts.txt$', views.test_id_abstracts_txt)
2526
)

ietf/idindex/views.py

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
from django.http import HttpResponse, HttpResponsePermanentRedirect
3636
from django.template import loader
3737
from django.shortcuts import get_object_or_404
38-
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal
38+
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal,PersonOrOrgInfo
39+
from ietf.idtracker.templatetags.ietf_filters import clean_whitespace
40+
import re
3941

4042
def all_id_txt():
4143
all_ids = InternetDraft.objects.order_by('filename')
@@ -58,6 +60,81 @@ def all_id_txt():
5860
'withdrawn_ietf':withdrawn_ietf,
5961
'replaced':replaced})
6062

63+
def all_id2_entry(id):
64+
fields = []
65+
# 0
66+
fields.append(id.filename+"-"+id.revision_display())
67+
# 1
68+
fields.append(id.id_document_tag)
69+
# 2
70+
status = id.status.status
71+
fields.append(status)
72+
# 3
73+
iesgstate = id.idstate() if status=="Active" else ""
74+
fields.append(iesgstate)
75+
# 4
76+
fields.append(id.rfc_number if status=="RFC" else "")
77+
# 5
78+
if status == "Replaced":
79+
try:
80+
fields.append(id.replaced_by.filename)
81+
except InternetDraft.DoesNotExist:
82+
fields.append("")
83+
else:
84+
fields.append("")
85+
# 6
86+
fields.append(id.revision_date)
87+
# 7
88+
group_acronym = id.group.acronym
89+
if group_acronym == "none":
90+
group_acronym = ""
91+
fields.append(group_acronym)
92+
93+
# 8
94+
area = ""
95+
if id.idinternal:
96+
area = id.idinternal.area_acronym
97+
elif not group_acronym:
98+
pass
99+
else:
100+
wgs = id.group.ietfwg_set.all()
101+
if len(wgs) > 0:
102+
area = wgs[0].area_acronym() or ""
103+
fields.append(area)
104+
# 9
105+
fields.append(id.idinternal.job_owner if id.idinternal else "")
106+
# 10
107+
if id.intended_status and id.intended_status.intended_status not in ("None","Request"):
108+
fields.append(id.intended_status.intended_status)
109+
else:
110+
fields.append("")
111+
# 11
112+
if (iesgstate=="In Last Call") or iesgstate.startswith("In Last Call::"):
113+
fields.append(id.lc_expiration_date)
114+
else:
115+
fields.append("")
116+
# 12
117+
fields.append(id.file_type if status=="Active" else "")
118+
# 13
119+
fields.append(clean_whitespace(id.title))
120+
# 14
121+
authors = []
122+
for author in sorted(id.authors.all(), key=lambda x: x.final_author_order()):
123+
try:
124+
realname = unicode(author.person)
125+
email = author.email() or ""
126+
name = re.sub(u"[<>@,]", u"", realname) + u" <"+re.sub(u"[<>,]", u"", email).strip()+u">"
127+
authors.append(clean_whitespace(name))
128+
except PersonOrOrgInfo.DoesNotExist:
129+
pass
130+
fields.append(u", ".join(authors))
131+
return "\t".join([unicode(x) for x in fields])
132+
133+
def all_id2_txt():
134+
all_ids = InternetDraft.objects.order_by('filename').select_related('status__status','group__acronym','intended_status__intended_status')
135+
data = "\n".join([all_id2_entry(id) for id in all_ids])
136+
return loader.render_to_string("idindex/all_id2.txt",{'data':data})
137+
61138
def id_index_txt():
62139
groups = IETFWG.objects.all()
63140
return loader.render_to_string("idindex/id_index.txt", {'groups':groups})
@@ -68,6 +145,8 @@ def id_abstracts_txt():
68145

69146
def test_all_id_txt(request):
70147
return HttpResponse(all_id_txt(), mimetype='text/plain')
148+
def test_all_id2_txt(request):
149+
return HttpResponse(all_id2_txt(), mimetype='text/plain')
71150
def test_id_index_txt(request):
72151
return HttpResponse(id_index_txt(), mimetype='text/plain')
73152
def test_id_abstracts_txt(request):

ietf/templates/idindex/all_id2.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{% autoescape off %}#
2+
# Index of all Internet-Drafts
3+
# generated: {% now "Y-m-d H:i:s T" %}
4+
#
5+
# Description of fields:
6+
# 0 draft name and latest revision
7+
# 1 id_document_tag (internal database identifier; avoid using
8+
# unless you really need it)
9+
# 2 one of "Active", "Expired", "RFC", "Withdrawn by Submitter",
10+
# "Replaced", or "Withdrawn by IETF"
11+
# 3 if #2 is "Active", the IESG state for the document (such as
12+
# "In Last Call", "AD Evaluation::Revised ID Needed", or "I-D Exists");
13+
# otherwise empty
14+
# 4 if #2 is "RFC", the RFC number (otherwise empty)
15+
# 5 if #2 is "Replaced", the replacing draft name (otherwise empty)
16+
# 6 revision date (YYYY-MM-DD)
17+
# 7 group acronym (or empty if no group/not known)
18+
# 8 area acronym (or empty if not known; not necessarily accurate
19+
# for older drafts)
20+
# 9 responsible AD name (or empty if not known)
21+
# 10 intended maturity level (or empty if not known)
22+
# 11 if #3 is "In Last Call" (with any substate), the last call
23+
# end date (YYYY-MM-DD); otherwise empty
24+
# 12 if #2 is "Active", list of file types; otherwise empty
25+
# 13 draft title
26+
# 14 draft authors (often quite inaccurate, especially the email
27+
# addresses...)
28+
#
29+
# new fields can be added to the end in the future, so remember to
30+
# ignore those in your code
31+
#
32+
{{ data }}
33+
# end{% endautoescape %}

0 commit comments

Comments
 (0)