PyFunceble/directory_structure.py
def _get_structure(self):
        """
        Get the structure we are going to work with.

        :return: The structure we have to work with.
        :rtype: dict
        """

        # We initiate an empty variable which is going to save the location of
        # file we are going to download.
        structure_file = ""

        # We initiate the variable which will save the request instance.
        req = ""

        if PyFunceble.path.isfile(self.structure):
            # The structure path file exist.

            # We set it as the destination file.
            structure_file = self.structure
        elif PyFunceble.path.isfile(self.base + "dir_structure_production.json"):
            # * The structure path file does not exist.
            # but
            # * The production structure path file exist.

            # We set it as the destination file
            structure_file = self.base + "dir_structure_production.json"
        else:
            # * The structure path file does not exist.
            # and
            # * The production structure path file does not exist.

            if "dev" not in PyFunceble.VERSION:
                # `dev` is not into the local version name.

                # We get the production file from the master branch.
                req = PyFunceble.requests.get(
                    PyFunceble.LINKS["dir_structure"].replace("dev", "master")
                )
            else:
                # `dev` is into the local version name.

                # We get the production file from the dev branch.
                req = PyFunceble.requests.get(
                    PyFunceble.LINKS["dir_structure"].replace("master", "dev")
                )

        if structure_file.endswith("_production.json"):
            # The destination is the production file.

            # And we return the updated the structure from the last read file.
            # (with the names from the configuration file).
            return self._update_structure_from_config(
                Dict().from_json(File(structure_file).read())
            )

        # The destination is not the production file.

        if structure_file.endswith(".json"):
            # The destination ends with `.json`.

            # And we return the updated the structure from the given file.
            # (with the names from the configuration file).
            return self._update_structure_from_config(
                Dict().from_json(File(structure_file).read())
            )

        # The destination does not ends with `.json`.

        # We return the updated the structure from the link we previously got.
        # (with the names from the configuration file).
        return self._update_structure_from_config(Dict().from_json(req.text))
def _get_structure(self):
        # We initiate an empty variable which is going to save the location of
        # file we are going to download.
        structure_file = ""

        # We initiate the variable which will save the request instance.
        req = ""

        if PyFunceble.path.isfile(self.structure):
            # The structure path file exist.

            # We set it as the destination file.
            structure_file = self.structure
        elif PyFunceble.path.isfile(self.base + "dir_structure_production.json"):
            # * The structure path file does not exist.
            # but
            # * The production structure path file exist.

            # We set it as the destination file
            structure_file = self.base + "dir_structure_production.json"
        else:
            # * The structure path file does not exist.
            # and
            # * The production structure path file does not exist.

            if "dev" not in PyFunceble.VERSION:
                # `dev` is not into the local version name.

                # We get the production file from the master branch.
                req = PyFunceble.requests.get(
                    PyFunceble.LINKS["dir_structure"].replace("dev", "master")
                )
            else:
                # `dev` is into the local version name.

                # We get the production file from the dev branch.
                req = PyFunceble.requests.get(
                    PyFunceble.LINKS["dir_structure"].replace("master", "dev")
                )

        if structure_file.endswith("_production.json"):
            # The destination is the production file.

            # And we return the updated the structure from the last read file.
            # (with the names from the configuration file).
            return self._update_structure_from_config(
                Dict().from_json(File(structure_file).read())
            )

        # The destination is not the production file.

        if structure_file.endswith(".json"):
            # The destination ends with `.json`.

            # And we return the updated the structure from the given file.
            # (with the names from the configuration file).
            return self._update_structure_from_config(
                Dict().from_json(File(structure_file).read())
            )

        # The destination does not ends with `.json`.

        # We return the updated the structure from the link we previously got.
        # (with the names from the configuration file).
        return self._update_structure_from_config(Dict().from_json(req.text))
def _get_structure ( self ) : # We initiate an empty variable which is going to save the location of # file we are going to download. structure_file = "" # We initiate the variable which will save the request instance. req = "" if PyFunceble . path . isfile ( self . structure ) : # The structure path file exist. # We set it as the destination file. structure_file = self . structure elif PyFunceble . path . isfile ( self . base + "dir_structure_production.json" ) : # * The structure path file does not exist. # but # * The production structure path file exist. # We set it as the destination file structure_file = self . base + "dir_structure_production.json" else : # * The structure path file does not exist. # and # * The production structure path file does not exist. if "dev" not in PyFunceble . VERSION : # `dev` is not into the local version name. # We get the production file from the master branch. req = PyFunceble . requests . get ( PyFunceble . LINKS [ "dir_structure" ] . replace ( "dev" , "master" ) ) else : # `dev` is into the local version name. # We get the production file from the dev branch. req = PyFunceble . requests . get ( PyFunceble . LINKS [ "dir_structure" ] . replace ( "master" , "dev" ) ) if structure_file . endswith ( "_production.json" ) : # The destination is the production file. # And we return the updated the structure from the last read file. # (with the names from the configuration file). return self . _update_structure_from_config ( Dict ( ) . from_json ( File ( structure_file ) . read ( ) ) ) # The destination is not the production file. if structure_file . endswith ( ".json" ) : # The destination ends with `.json`. # And we return the updated the structure from the given file. # (with the names from the configuration file). return self . _update_structure_from_config ( Dict ( ) . from_json ( File ( structure_file ) . read ( ) ) ) # The destination does not ends with `.json`. # We return the updated the structure from the link we previously got. # (with the names from the configuration file). return self . _update_structure_from_config ( Dict ( ) . from_json ( req . text ) )
Get the structure we are going to work with.

        :return: The structure we have to work with.
        :rtype: dict
Get the structure we are going to work with .