old_contents: import os
  import re
  
  from citeproc import CitationStylesStyle, CitationStylesBibliography
  from citeproc import Citation, CitationItem
  from citeproc import formatter
  from citeproc.source.json import CiteProcJSON
  
  from website.preprints.model import PreprintService
  from website.project.model import Node
  from website.settings import CITATION_STYLES_PATH
  
  
  def clean_up_common_errors(cit):
      cit = re.sub(r"\.+", '.', cit)
      cit = re.sub(r" +", ' ', cit)
      return cit
  
  def display_absolute_url(node):
      url = node.absolute_url
      if url is not None:
          return re.sub(r'https?:', '', url).strip('/')
  
  
  def preprint_csl(preprint, node):
      csl = node.csl
  
      csl['id'] = preprint._id
      csl['publisher'] = preprint.provider.name
      csl['URL'] = display_absolute_url(preprint)
  
      if csl.get('DOI'):
          csl.pop('DOI')
  
      doi = preprint.article_doi
      if doi:
          csl['DOI'] = doi
  
      return csl
  
  def render_citation(node, style='apa'):
      """Given a node, return a citation"""
      csl = None
      if isinstance(node, Node):
          data = [node.csl, ]
      elif isinstance(node, PreprintService):
          csl = preprint_csl(node, node.node)
          data = [csl, ]
      else:
          raise ValueError
  
      bib_source = CiteProcJSON(data)
  
      bib_style = CitationStylesStyle(os.path.join(CITATION_STYLES_PATH, style), validate=False)
  
      bibliography = CitationStylesBibliography(bib_style, bib_source, formatter.plain)
  
      citation = Citation([CitationItem(node._id)])
  
      bibliography.register(citation)
  
      bibliography.cite(citation, warn)
      bib = bibliography.bibliography()
      cit = unicode(bib[0] if len(bib) else '')
  
      title = csl['title'] if csl else node.csl['title']
      if cit.count(title) == 1:
          i = cit.index(title)
          prefix = clean_up_common_errors(cit[0:i])
          suffix = clean_up_common_errors(cit[i + len(title):])
          cit = prefix + title + suffix
      elif cit.count(title) == 0:
          cit = clean_up_common_errors(cit)
  
      return cit
  
new_contents: import os
  import re
  
  from citeproc import CitationStylesStyle, CitationStylesBibliography
  from citeproc import Citation, CitationItem
  from citeproc import formatter
  from citeproc.source.json import CiteProcJSON
  
  from website.preprints.model import PreprintService
  from website.project.model import Node
  from website.settings import CITATION_STYLES_PATH
  
  
  def clean_up_common_errors(cit):
      cit = re.sub(r"\.+", '.', cit)
      cit = re.sub(r" +", ' ', cit)
      return cit
  
  def display_absolute_url(node):
      url = node.absolute_url
      if url is not None:
          return re.sub(r'https?:', '', url).strip('/')
  
  
  def preprint_csl(preprint, node):
      csl = node.csl
  
      csl['id'] = preprint._id
      csl['publisher'] = preprint.provider.name
      csl['URL'] = display_absolute_url(preprint)
  
      if csl.get('DOI'):
          csl.pop('DOI')
  
      doi = preprint.article_doi
      if doi:
          csl['DOI'] = doi
  
      return csl
  
  def render_citation(node, style='apa'):
      """Given a node, return a citation"""
      csl = None
      if isinstance(node, Node):
          data = [node.csl, ]
      elif isinstance(node, PreprintService):
          csl = preprint_csl(node, node.node)
          data = [csl, ]
      else:
          raise ValueError
  
      bib_source = CiteProcJSON(data)
  
      bib_style = CitationStylesStyle(os.path.join(CITATION_STYLES_PATH, style), validate=False)
  
      bibliography = CitationStylesBibliography(bib_style, bib_source, formatter.plain)
  
      citation = Citation([CitationItem(node._id)])
  
      bibliography.register(citation)
  
      def warn(citation_item):
          pass
  
      bibliography.cite(citation, warn)
      bib = bibliography.bibliography()
      cit = unicode(bib[0] if len(bib) else '')
  
      title = csl['title'] if csl else node.csl['title']
      if cit.count(title) == 1:
          i = cit.index(title)
          prefix = clean_up_common_errors(cit[0:i])
          suffix = clean_up_common_errors(cit[i + len(title):])
          cit = prefix + title + suffix
      elif cit.count(title) == 0:
          cit = clean_up_common_errors(cit)
  
      return cit
  
subject: put back the noop warn