Ejemplo n.º 1
0
def out_install(setup):
  langs = _langs(setup)
  for lang in langs:
    dot_lang = _set_locale(setup, lang)
    fname = 'INSTALL%s.rst' % dot_lang
    util._safe_overwrite(_install_lines(setup), fname)
  _set_locale(setup, '')
Ejemplo n.º 2
0
def out_readme(setup):
  langs = _langs(setup)
  eng_desc = setup.SETUP['description']
  eng_long_desc = setup.SETUP['long_description']
  for lang in langs:
    dot_lang = _set_locale(setup, lang)
    fname = 'README%s.rst' % dot_lang
    func = _
    setup.SETUP['description'] = func(eng_desc)
    setup.SETUP['long_description'] = func(eng_long_desc)
    util._safe_overwrite(_readme_lines(setup), fname)
  _set_locale(setup, '')
  setup.SETUP['description'] = eng_desc
  setup.SETUP['long_description'] = eng_long_desc
Ejemplo n.º 3
0
def out_license(setup):
  lic_text = setup.SETUP['license']
  to_fetch = None
  for regex, info in LICENSES.items():
    if re.search(regex, lic_text, re.IGNORECASE):
      to_fetch = info
      break
  if not to_fetch:
    raise DocumentsException('Unknown lic_text %r' % lic_text)

  license_fname = _find_license()
  if not license_fname:
    license_fname = 'LICENSE-2.0.txt'
    LOG.info('Creating license file %r' % license_fname)
  else:
    LOG.info('License file already exists as %r' % license_fname)
  url, y_regex, name_regex = to_fetch
  if url.startswith('http'):
    txt = urllib2.urlopen(url).read()
  else:
    txt = open(os.path.join(os.path.dirname(__file__), url)).read()
    if url.endswith('rot13'):
      txt = txt.encode('rot13')

  year = time.strftime('%Y', time.localtime())
  re_yyyy = re.compile(y_regex, re.DOTALL)
  txt = re_yyyy.sub(year, txt)
  copyright_name = setup.SETUP['author']
  if hasattr(setup, 'COPYRIGHT_NAME'):
    copyright_name = setup.COPYRIGHT_NAME
  if name_regex:
    re_name = re.compile(name_regex, re.DOTALL)
    txt = re_name.sub(copyright_name, txt)
  else:
    txt += ' ' + copyright_name
  util._safe_overwrite(txt.split(u'\n'), license_fname)