<commit_before>
# This is a Makefile for the `mk` tool. (Limited) details for that here:
# <http://svn.openkomodo.com/openkomodo/browse/mk>

import sys
import os
from os.path import join, dirname, normpath, abspath, exists, basename
import re
from glob import glob
import codecs
import webbrowser

import mklib
assert mklib.__version_info__ >= (0,7,2)  # for `mklib.mk`
from mklib.common import MkError
from mklib import Task, mk
from mklib import sh


class bugs(Task):
    """open bug/issues page"""
    def make(self):
        webbrowser.open("http://github.com/trentm/django-markdown-deux/issues")

class site(Task):
    """open project page"""
    def make(self):
        webbrowser.open("http://github.com/trentm/django-markdown-deux")

class pypi(Task):
    """open project page"""
    def make(self):
        webbrowser.open("http://pypi.python.org/pypi/django-markdown-deux/")


class cut_a_release(Task):
    """automate the steps for cutting a release
    
    See 'docs/devguide.markdown' in <http://github.com/trentm/eol> for details.
    """
    proj_name = "django-markdown-deux"
    version_py_path = "lib/markdown_deux/__init__.py"
    version_module = "markdown_deux"
    _changes_parser = re.compile(r'^## %s (?P<ver>[\d\.abc]+)'
        r'(?P<nyr>\s+\(not yet released\))?'
        r'(?P<body>.*?)(?=^##|\Z)' % proj_name, re.M | re.S)

    def make(self):
        DRY_RUN = False
        version = self._get_version()
        
        # Confirm
        if not DRY_RUN:
            answer = query_yes_no("* * *\n"
                "Are you sure you want cut a v%s release?\n"
                "This will involved commits and a release to pypi." % version,
                default="no")
            if answer != "yes":
                self.log.info("user abort")
                return
            print "* * *"
        self.log.info("cutting a v%s release", version)

        # Checks: Ensure there is a section in changes for this version.
        changes_path = join(self.dir, "CHANGES.markdown")
        changes_txt = codecs.open(changes_path, 'r', 'utf-8').read()
        changes_sections = self._changes_parser.findall(changes_txt)
        top_ver = changes_sections[0][0]
        if top_ver != version:
            raise MkError("top section in `CHANGES.markdown' is for "
                "version %r, expected version %r: aborting"
                % (top_ver, version))
        top_nyr = changes_sections[0][1]
        if not top_nyr:
            raise MkError("top section in `CHANGES.markdown' doesn't have "
                "the expected '(not yet released)' marker: has this been "
                "released already?")
        top_body = changes_sections[0][2]
        if top_body.strip() == "(nothing yet)":
            raise MkError("top section body is `(nothing yet)': it looks like "
                "nothing has been added to this release")
        
        # Commits to prepare release.
        self.log.info("prepare `CHANGES.markdown' for release")
        changes_txt = changes_txt.replace(" (not yet released)", "", 1)
        if not DRY_RUN:
            f = codecs.open(changes_path, 'w', 'utf-8')
            f.write(changes_txt)
            f.close()
            sh.run('git commit %s -m "prepare for v%s release"'
                % (changes_path, version), self.log.debug)

        # Tag version and push.
        self.log.info("tag the release")
        if not DRY_RUN:
            sh.run('git tag -a "%s" -m "version %s"' % (version, version),
                self.log.debug)
            sh.run('git --tags push', self.log.debug)<commit_msg>correct changelog filename<commit_after>
# This is a Makefile for the `mk` tool. (Limited) details for that here:
# <http://svn.openkomodo.com/openkomodo/browse/mk>

import sys
import os
from os.path import join, dirname, normpath, abspath, exists, basename
import re
from glob import glob
import codecs
import webbrowser

import mklib
assert mklib.__version_info__ >= (0,7,2)  # for `mklib.mk`
from mklib.common import MkError
from mklib import Task, mk
from mklib import sh


class bugs(Task):
    """open bug/issues page"""
    def make(self):
        webbrowser.open("http://github.com/trentm/django-markdown-deux/issues")

class site(Task):
    """open project page"""
    def make(self):
        webbrowser.open("http://github.com/trentm/django-markdown-deux")

class pypi(Task):
    """open project page"""
    def make(self):
        webbrowser.open("http://pypi.python.org/pypi/django-markdown-deux/")


class cut_a_release(Task):
    """automate the steps for cutting a release
    
    See 'docs/devguide.markdown' in <http://github.com/trentm/eol> for details.
    """
    proj_name = "django-markdown-deux"
    version_py_path = "lib/markdown_deux/__init__.py"
    version_module = "markdown_deux"
    _changes_parser = re.compile(r'^## %s (?P<ver>[\d\.abc]+)'
        r'(?P<nyr>\s+\(not yet released\))?'
        r'(?P<body>.*?)(?=^##|\Z)' % proj_name, re.M | re.S)

    def make(self):
        DRY_RUN = False
        version = self._get_version()
        
        # Confirm
        if not DRY_RUN:
            answer = query_yes_no("* * *\n"
                "Are you sure you want cut a v%s release?\n"
                "This will involved commits and a release to pypi." % version,
                default="no")
            if answer != "yes":
                self.log.info("user abort")
                return
            print "* * *"
        self.log.info("cutting a v%s release", version)

        # Checks: Ensure there is a section in changes for this version.
        changes_path = join(self.dir, "CHANGES.md")
        changes_txt = codecs.open(changes_path, 'r', 'utf-8').read()
        changes_sections = self._changes_parser.findall(changes_txt)
        top_ver = changes_sections[0][0]
        if top_ver != version:
            raise MkError("top section in `CHANGES.md' is for "
                "version %r, expected version %r: aborting"
                % (top_ver, version))
        top_nyr = changes_sections[0][1]
        if not top_nyr:
            raise MkError("top section in `CHANGES.md' doesn't have "
                "the expected '(not yet released)' marker: has this been "
                "released already?")
        top_body = changes_sections[0][2]
        if top_body.strip() == "(nothing yet)":
            raise MkError("top section body is `(nothing yet)': it looks like "
                "nothing has been added to this release")
        
        # Commits to prepare release.
        self.log.info("prepare `CHANGES.md' for release")
        changes_txt = changes_txt.replace(" (not yet released)", "", 1)
        if not DRY_RUN:
            f = codecs.open(changes_path, 'w', 'utf-8')
            f.write(changes_txt)
            f.close()
            sh.run('git commit %s -m "prepare for v%s release"'
                % (changes_path, version), self.log.debug)

        # Tag version and push.
        self.log.info("tag the release")
        if not DRY_RUN:
            sh.run('git tag -a "%s" -m "version %s"' % (version, version),
                self.log.debug)
            sh.run('git --tags push', self.log.debug)
{'fraction_non_alphanumeric': 0.1318251640832286, 'fraction_numerical': 0.0033514872224549644, 'mean_word_length': 2.262870159453303, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1485047', 'n_tokens_mistral': 2329, 'n_tokens_neox': 2239, 'n_words': 607}