<commit_before>#!/usr/bin/env python
import subprocess
import os, shutil, tempfile
from numpy_towiki import *

MERGEDOC = os.path.join(DIR, "merge_docstrings.py")
MERGEDXML = os.path.join(DIR, "merged.xml")
WIKIXML = os.path.join(DIR, "wiki.xml")


def main():
    regenerate_base_xml()
    os.chdir(DIR)

    # -- Collect
    exec_cmd([PYDOCMOIN, 'moin-collect-local', '-o', WIKIXML, WIKI_CONF])

    # -- Merge
    f = open(MERGEDXML, 'w')
    ret = subprocess.call([MERGEDOC, BASEXML, LASTUPLOAD, WIKIXML],
                          stdout=f)
    f.close()

    if ret != 0:
        raise RuntimeError("Running %s failed" % MERGEDOC)

    # -- Upload
    exec_cmd([PYDOCMOIN, 'moin-upload-local', '-p', PREFIX,
        '-s', SITE_PTH,
        '--src-url-fmt=http://scipy.org/scipy/numpy/browser/trunk/%(file)s#L%(line)d',
        '--message=Merged docstring with SVN',
        '-i', MERGEDXML, WIKI_CONF], echo=True)

    shutil.copy(BASEXML, LASTUPLOAD)

    # this is needed to refresh group information in Moin!
    group_cache = os.path.join(WIKI_CONF, "data/cache/wikidicts/dicts_groups")
    if os.path.isfile(group_cache):
        os.unlink(group_cache)

    # all done
    print "All done."

if __name__ == "__main__": main()

# vim:sw=4 expandtab smarttab<commit_msg>Never overlap with previous merge; should be robust against failing moin upload<commit_after>#!/usr/bin/env python
import subprocess
import os, shutil, tempfile
from numpy_towiki import *

MERGEDOC = os.path.join(DIR, "merge_docstrings.py")
MERGEDXML = os.path.join(DIR, "merged.xml")
WIKIXML = os.path.join(DIR, "wiki.xml")


def main():
    if os.path.isfile(MERGEDXML):
        print "%s already exists." % MERGEDXML
        print "If you want to re-do the merge, remove merged.xml and try again."
        print "If you want to continue an interrupted merge, upload this file to Moin manually."
        raise SystemExit(1)

    regenerate_base_xml()
    os.chdir(DIR)

    # -- Collect
    exec_cmd([PYDOCMOIN, 'moin-collect-local', '-o', WIKIXML, WIKI_CONF])

    # -- Merge
    f = open(MERGEDXML, 'w')
    ret = subprocess.call([MERGEDOC, BASEXML, LASTUPLOAD, WIKIXML],
                          stdout=f)
    f.close()

    if ret != 0:
        raise RuntimeError("Running %s failed" % MERGEDOC)

    shutil.copy(BASEXML, LASTUPLOAD)

    # -- Upload
    exec_cmd([PYDOCMOIN, 'moin-upload-local', '-p', PREFIX,
        '-s', SITE_PTH,
        '--src-url-fmt=http://scipy.org/scipy/numpy/browser/trunk/%(file)s#L%(line)d',
        '--message=Merged docstring with SVN',
        '-i', MERGEDXML, WIKI_CONF], echo=True)

    # this is needed to refresh group information in Moin!
    group_cache = os.path.join(WIKI_CONF, "data/cache/wikidicts/dicts_groups")
    if os.path.isfile(group_cache):
        os.unlink(group_cache)

    # all done
    print "All done."

if __name__ == "__main__": main()

# vim:sw=4 expandtab smarttab
{'fraction_non_alphanumeric': 0.14182692307692307, 'fraction_numerical': 0.001717032967032967, 'mean_word_length': 2.9795081967213113, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1503001', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1078, 'n_words': 235}