Пример #1
0
def update_udhr(udhr_dir, fetch_dir, in_repo):
    """Delete udhr_dir and rebuild with files extracted from udhr_xml.zip
  in fetch_dir. Stage if udhr_dir is in the repo."""

    zippath = os.path.join(fetch_dir, UDHR_XML_ZIP_NAME)
    tool_utils.check_file_exists(zippath)

    if in_repo and os.path.isdir(
            udhr_dir) and not tool_utils.git_is_clean(udhr_dir):
        raise ValueError('Please clean %s.' % udhr_dir)

    if os.path.isdir(udhr_dir):
        shutil.rmtree(udhr_dir)
    os.makedirs(udhr_dir)
    tool_utils.zip_extract_with_timestamp(zippath, udhr_dir)

    # dos line endings, sheesh
    tool_utils.dos2unix(udhr_dir, ['*.xml', '*.rnc', '*.rng'])

    if in_repo:
        tool_utils.git_add_all(udhr_dir)

    date = datetime.datetime.now().strftime('%Y-%m-%d')
    dst = 'in %s ' % udhr_dir if not in_repo else ''
    print('Update UDHR files %sfrom %s as of %s.' % (dst, fetch_dir, date))
Пример #2
0
def update_udhr(udhr_dir, fetch_dir, in_repo):
  """Delete udhr_dir and rebuild with files extracted from udhr_xml.zip
  in fetch_dir. Stage if udhr_dir is in the repo."""

  zippath = os.path.join(fetch_dir, UDHR_XML_ZIP_NAME)
  tool_utils.check_file_exists(zippath)

  if in_repo and os.path.isdir(udhr_dir) and not tool_utils.git_is_clean(udhr_dir):
    raise ValueError('Please clean %s.' % udhr_dir)

  if os.path.isdir(udhr_dir):
    shutil.rmtree(udhr_dir)
  os.makedirs(udhr_dir)
  tool_utils.zip_extract_with_timestamp(zippath, udhr_dir)

  # dos line endings, sheesh
  tool_utils.dos2unix(udhr_dir, ['*.xml', '*.rnc', '*.rng'])

  if in_repo:
    tool_utils.git_add_all(udhr_dir)

  date = datetime.datetime.now().strftime('%Y-%m-%d')
  dst = 'in %s ' % udhr_dir if not in_repo else ''
  print 'Update UDHR files %sfrom %s as of %s.' % (dst, fetch_dir, date)