PyFunceble/production.py
def _update_travis_yml(self):
        """
        Update :code:`.travis.yml` according to current branch.
        """

        # We initiate the file we have to filter/update.
        travis_yml_path = PyFunceble.CURRENT_DIRECTORY + ".travis.yml"

        if self.is_dev_version():
            # The current version is the `dev` version.

            # We map what we have to replace.
            # Format: {match:replacement}
            regexes = {
                "pip3 install pyfunceble-dev": r"pip3\sinstall\spyfunceble.*",
                "pip-autoremove pyfunceble-dev ": r"pip-autoremove\spyfunceble\s",
            }
        elif self.is_master_version():
            # The current version is the `master` version.

            # We map what we have to replace.
            regexes = {
                "pip3 install pyfunceble": r"pip3\sinstall\spyfunceble.*",
                "pip-autoremove pyfunceble ": r"pip-autoremove\spyfunceble[a-z-_]+\s",
            }
        else:
            # The current version is not the `master` nor the `dev` version.

            # We raise an exception, the current branch is not meant for production.
            raise Exception("Please switch to `dev` or `master` branch.")

        # We get the file content.
        to_update = File(travis_yml_path).read()

        for replacement, regex in regexes.items():
            # We loop through the map.

            # And we process the replacement.
            to_update = Regex(to_update, regex, replace_with=replacement).replace()

        # We finaly replace the file content with the filtered
        # content.
        File(travis_yml_path).write(to_update, overwrite=True)
def _update_travis_yml(self):
        """
        Update :code:`.travis.yml` according to current branch.
        """

        # We initiate the file we have to filter/update.
        travis_yml_path = PyFunceble.CURRENT_DIRECTORY + ".travis.yml"

        if self.is_dev_version():
            # The current version is the `dev` version.

            # We map what we have to replace.
            # Format: {match:replacement}
            regexes = {
                "pip3 install pyfunceble-dev": r"pip3\sinstall\spyfunceble.*",
                "pip-autoremove pyfunceble-dev ": r"pip-autoremove\spyfunceble\s",
            }
        elif self.is_master_version():
            # The current version is the `master` version.

            # We map what we have to replace.
            regexes = {
                "pip3 install pyfunceble": r"pip3\sinstall\spyfunceble.*",
                "pip-autoremove pyfunceble ": r"pip-autoremove\spyfunceble[a-z-_]+\s",
            }
        else:
            # The current version is not the `master` nor the `dev` version.

            # We raise an exception, the current branch is not meant for production.
            raise Exception("Please switch to `dev` or `master` branch.")

        # We get the file content.
        to_update = File(travis_yml_path).read()

        for replacement, regex in regexes.items():
            # We loop through the map.

            # And we process the replacement.
            to_update = Regex(to_update, regex, replace_with=replacement).replace()

        # We finaly replace the file content with the filtered
        # content.
        File(travis_yml_path).write(to_update, overwrite=True)
def _update_travis_yml ( self ) : # We initiate the file we have to filter/update. travis_yml_path = PyFunceble . CURRENT_DIRECTORY + ".travis.yml" if self . is_dev_version ( ) : # The current version is the `dev` version. # We map what we have to replace. # Format: {match:replacement} regexes = { "pip3 install pyfunceble-dev" : r"pip3\sinstall\spyfunceble.*" , "pip-autoremove pyfunceble-dev " : r"pip-autoremove\spyfunceble\s" , } elif self . is_master_version ( ) : # The current version is the `master` version. # We map what we have to replace. regexes = { "pip3 install pyfunceble" : r"pip3\sinstall\spyfunceble.*" , "pip-autoremove pyfunceble " : r"pip-autoremove\spyfunceble[a-z-_]+\s" , } else : # The current version is not the `master` nor the `dev` version. # We raise an exception, the current branch is not meant for production. raise Exception ( "Please switch to `dev` or `master` branch." ) # We get the file content. to_update = File ( travis_yml_path ) . read ( ) for replacement , regex in regexes . items ( ) : # We loop through the map. # And we process the replacement. to_update = Regex ( to_update , regex , replace_with = replacement ) . replace ( ) # We finaly replace the file content with the filtered # content. File ( travis_yml_path ) . write ( to_update , overwrite = True )
Update :code:`.travis.yml` according to current branch.
Update : code : . travis . yml according to current branch .