@@ -33,6 +33,7 @@ basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
3333sys .path = [ basedir ] + sys .path
3434os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "ietf.settings" )
3535
36+ from django .conf import settings
3637
3738from ietf .doc .models import Document
3839from ietf .group .utils import get_group_chairs_emails , get_group_ads_emails
@@ -65,7 +66,7 @@ def get_draft_notify_emails(draft):
6566 " Get list of email addresses to notify for the given draft."
6667 n = draft .notify
6768 if not n :
68- return
69+ return []
6970 l = []
7071 draft_email = draft .name + DRAFT_EMAIL_SUFFIX
7172 for e in n .split (',' ):
@@ -92,7 +93,13 @@ if __name__ == '__main__':
9293
9394 modname = 'ietf.generate_draft_aliases'
9495 date = time .strftime ("%Y-%m-%d_%H:%M:%S" )
95- print '# Generated by python -m %s at %s' % (modname , date )
96+ signature = '# Generated by python -m %s at %s\n ' % (modname , date )
97+
98+ afile = open (settings .DRAFT_ALIASES_PATH , "w" )
99+ vfile = open (settings .DRAFT_VIRTUAL_PATH , "w" )
100+
101+ afile .write (signature )
102+ vfile .write (signature )
96103
97104 drafts = Document .objects .all ()
98105
@@ -104,42 +111,44 @@ if __name__ == '__main__':
104111
105112 interesting_drafts = active_drafts | inactive_recent_drafts
106113
114+ count = 0
107115 for draft in interesting_drafts .distinct ().iterator ():
108116 # Omit RFCs, we care only about drafts
109117 if draft .docalias_set .filter (name__startswith = 'rfc' ):
110118 continue
111- name = draft .name
112- done = []
119+
120+ count += 1
121+ if (count % 100 ) == 0 :
122+ sys .stderr .write ('.' )
123+ alias = draft .name
113124 all = []
114- def handle_sublist (name , f , o , is_ad = False ):
115- r = dump_sublist (name , f , o , is_ad )
116- if r :
117- done .append (name )
118- all .extend (r )
119- return r
125+ def handle_sublist (afile , vfile , alias , emails ):
126+ try :
127+ all .extend ( dump_sublist (afile , vfile , alias , emails ) )
128+ except TypeError :
129+ import debug
130+ debug .show ('alias' )
131+ debug .show ('emails' )
132+ raise
120133 #.authors (/and no suffix) = authors
121-
122134 # First, do no suffix case
123- # If no authors, don't generate list either
124- r = dump_sublist (name , get_draft_authors_emails , draft )
125- if not r :
126- continue
127- handle_sublist ('%s%s' % (name , '.authors' ), get_draft_authors_emails , draft )
128- wg = draft .group
135+ handle_sublist (afile , vfile , alias , get_draft_authors_emails (draft ))
136+ handle_sublist (afile , vfile , alias + '.authors' , get_draft_authors_emails (draft ))
129137
130- if wg :
131- # .chairs = WG chairs
132- handle_sublist ('%s%s' % ( name , '.chairs' ) , get_group_chairs_emails , wg )
138+ # .chairs = group chairs
139+ if draft . group :
140+ handle_sublist (afile , vfile , alias + '.chairs' , get_group_chairs_emails ( draft . group ) )
133141
134142 # .ad = sponsoring AD / WG AD (WG document)
135- handle_sublist ('%s%s' % ( name , '.ad' ), get_draft_ad_emails , draft , True )
143+ handle_sublist (afile , vfile , alias + '.ad' , get_draft_ad_emails ( draft ) )
136144
137145 # .notify = notify email list from the Document
138- handle_sublist ('%s%s' % ( name , '.notify' ), get_draft_notify_emails , draft )
146+ handle_sublist (afile , vfile , alias + '.notify' , get_draft_notify_emails ( draft ) )
139147
140- # .all = everything on 'done' (recursive aliases)
141- #dump_sublist('%s%s' % (name, '.all'), None, done)
142148 # .all = everything on 'all' (expanded aliases)
143- dump_sublist ( '%s%s' % ( name , '.all' ), None , all )
149+ handle_sublist ( afile , vfile , alias + '.all' , all )
144150
145151
152+ afile .close ()
153+ vfile .close ()
154+
0 commit comments