def pretaxonomy_hook(generator):
 category_objects = {}
 real_articles = []
 for article in generator.articles:
  (dirname, fname) = os.path.split(article.source_path)
  (fname, _) = os.path.splitext(fname)
  if (fname == 'index'):
   category_objects[dirname] = make_category(article, os.path.basename(dirname))
  else:
   real_articles.append(article)
 category_assignment = re.compile((('^(' + '|'.join((re.escape(prefix) for prefix in category_objects.keys()))) + ')/'))
 for article in real_articles:
  m = category_assignment.match(article.source_path)
  if ((not m) or (m.group(1) not in category_objects)):
   logger.error('No category assignment for %s (%s)', article, article.source_path)
   continue
  article.category = category_objects[m.group(1)]
  patch_urlformat(article)
 generator.articles = real_articles

def pretaxonomy_hook ( generator ) : category_objects = { } real_articles = [ ] for article in generator . articles : ( dirname , fname ) = os . path . split ( article . source_path ) ( fname , _ ) = os . path . splitext ( fname ) if ( fname == 'index' ) : category_objects [ dirname ] = make_category ( article , os . path . basename ( dirname ) ) else : real_articles . append ( article ) category_assignment = re . compile ( ( ( '^(' + '|' . join ( ( re . escape ( prefix ) for prefix in category_objects . keys ( ) ) ) ) + ')/' ) ) for article in real_articles : m = category_assignment . match ( article . source_path ) if ( ( not m ) or ( m . group ( 1 ) not in category_objects ) ) : logger . error ( 'No category assignment for %s (%s)' , article , article . source_path ) continue article . category = category_objects [ m . group ( 1 ) ] patch_urlformat ( article ) generator . articles = real_articles
this hook is invoked before the generators .