<commit_before>"""CLI program to read the orcidconfigmanager.py and create a RDF configuration
    file with Turtle syntax
"""
from orcidconfigmanager import OrcidConfig
import rdflib
import os

__author__ = 'cwilli34'


class ConfigManager(object):

    """ Configuration File Creator """

    def __init__(self, orcid_id, sandbox=True):
        """Initialize

        Parameters
        ----------
        :param orcid_id: string
            When s is true, click prompts will be executed and the basic_search() function will be executed.
        :param sandbox: boolean
            Should the sandbox be used. True by default. False (default) indicates production mode.
        """
        self.file = 'orcid_turtle.SCconfig'
        self.exist = os.path.exists(self.file)
        self.config = OrcidConfig(orcid_id, sandbox)
        self.ctgfile = None

    def write_config(self):
        """Write the configuration file
            Writes the configuration file to the SC directory, or program home directory

        Parameters
        ----------
        :param: None

        Returns
        -------
        :returns: none
        """
        if self.exist:
            # Open existing file, read and write
            self.ctgfile = open(self.file, 'w+')
        else:
            # Create config file, write
            self.ctgfile = open(self.file, 'w')
        profile = self.config.get_turtle()
        self.ctgfile.write(str(profile))
        self.ctgfile.close()

    def read_config(self):
        """Read the configuration file.  The configuration file is in a Turtle syntax format and
            is intended for RDF graph creation.  The 'result' returned will be parsed as RDF

        Parameters
        ----------
        :param: None

        Returns
        -------
        :returns: object
            Returns data as a RDF object for creating RDF graphs
        :returns: string
            If the configuration file does not exist, return error string
        """
        g = rdflib.Graph()
        if not self.exist:
            # If the file does not exist, we cannot read it.
            message = 'File does not exist. Cannot read file'
            return message
        else:
            # Open existing file, read and write
            self.ctgfile = open(self.file, 'r')
            # Variable data is not used (This is for customizing the script later for future configuration).
            data = self.ctgfile.read()
            result = g.parse(self.ctgfile, format='turtle')
            self.ctgfile.close()
            return result<commit_msg>Added the default config file pat to be the os.environ["HOME"] + /.SC/ + filename<commit_after>"""CLI program to read the orcidconfigmanager.py and create a RDF configuration
    file with Turtle syntax
"""
from orcidconfigmanager import OrcidConfig
import rdflib
import os

__author__ = 'cwilli34'


class ConfigManager(object):

    """ Configuration File Creator """

    def __init__(self, orcid_id, sandbox=True):
        """Initialize

        Parameters
        ----------
        :param orcid_id: string
            When s is true, click prompts will be executed and the basic_search() function will be executed.
        :param sandbox: boolean
            Should the sandbox be used. True by default. False (default) indicates production mode.
        """
        self.dir_path = os.environ["HOME"] + "/.sc"
        self.filename = 'orcid_turtle.SCconfig'
        self.config_path = self.dir_path + self.filename
        self.exist = os.path.exists(self.config_path)
        self.config = OrcidConfig(orcid_id, sandbox)
        self.ctgfile = None

    def write_config(self):
        """Write the configuration file
            Writes the configuration file to the SC directory, or program home directory

        Parameters
        ----------
        :param: None

        Returns
        -------
        :returns: none
        """
        if self.exist:
            # Open existing file, read and write
            self.ctgfile = open(self.config_path, 'w+')
        else:
            # Create config file, write
            self.ctgfile = open(self.config_path, 'w')
        profile = self.config.get_turtle()
        self.ctgfile.write(str(profile))
        self.ctgfile.close()

    def read_config(self):
        """Read the configuration file.  The configuration file is in a Turtle syntax format and
            is intended for RDF graph creation.  The 'result' returned will be parsed as RDF

        Parameters
        ----------
        :param: None

        Returns
        -------
        :returns: object
            Returns data as a RDF object for creating RDF graphs
        :returns: string
            If the configuration file does not exist, return error string
        """
        g = rdflib.Graph()
        if not self.exist:
            # If the file does not exist, we cannot read it.
            message = 'File does not exist. Cannot read file'
            return message
        else:
            # Open existing file, read and write
            self.ctgfile = open(self.config_path, 'r')
            # Variable data is not used (This is for customizing the script later for future configuration).
            data = self.ctgfile.read()
            result = g.parse(self.ctgfile, format='turtle')
            self.ctgfile.close()
            return result
{'fraction_non_alphanumeric': 0.09019899572252185, 'fraction_numerical': 0.0007439092430723452, 'mean_word_length': 1.8805570433851098, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6395203', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1385, 'n_words': 506}