<commit_before># -*- coding: utf-8 -*-

import json

from io import StringIO
from collections import defaultdict

from Pegasus import yaml
from Pegasus.api.site_catalog import Arch
from Pegasus.api.site_catalog import OS
from Pegasus.api.site_catalog import Site
from Pegasus.api.site_catalog import Directory
from Pegasus.api.site_catalog import FileServer
from Pegasus.api.site_catalog import Operation
from Pegasus.api.site_catalog import Scheduler
from Pegasus.api.site_catalog import SupportedJobs
from Pegasus.api.site_catalog import Grid
from Pegasus.api.site_catalog import SiteCatalog
from Pegasus.api.errors import PegasusError

"""
:mod:`site_catalog` exposes an API to serialize and deserialize Pegasus's site catalog file.

Basic Usage::

    >>> from Pegasus import site_catalog
    >>> site_catalog.loads("... ")
    ...

    >>> print(site_catalog.dumps( ... ))
    ' ... '

.. moduleauthor:: <NAME> <<EMAIL>>
.. moduleauthor:: <NAME> <<EMAIL>>
"""

from typing import Dict, TextIO

__all__ = (
    "load",
    "loads",
    "dump",
    "dumps",
)


def _to_sc(d: dict) -> SiteCatalog:
    """Convert dict to SiteCatalog
    
    :param d: SiteCatalog represented as a dict
    :type d: dict
    :raises PegasusError: encountered error parsing 
    :return: a SiteCatalog object based on d
    :rtype: SiteCatalog
    """
<commit_msg>isort sc<commit_after># -*- coding: utf-8 -*-

import json
from collections import defaultdict
from io import StringIO
from typing import Dict, TextIO

from Pegasus import yaml
from Pegasus.api.errors import PegasusError
from Pegasus.api.site_catalog import (
    OS,
    Arch,
    Directory,
    FileServer,
    Grid,
    Operation,
    Scheduler,
    Site,
    SiteCatalog,
    SupportedJobs,
)

"""
:mod:`site_catalog` exposes an API to serialize and deserialize Pegasus's site catalog file.

Basic Usage::

    >>> from Pegasus import site_catalog
    >>> site_catalog.loads("... ")
    ...

    >>> print(site_catalog.dumps( ... ))
    ' ... '

.. moduleauthor:: <NAME> <<EMAIL>>
.. moduleauthor:: <NAME> <<EMAIL>>
"""


__all__ = (
    "load",
    "loads",
    "dump",
    "dumps",
)


def _to_sc(d: dict) -> SiteCatalog:
    """Convert dict to SiteCatalog
    
    :param d: SiteCatalog represented as a dict
    :type d: dict
    :raises PegasusError: encountered error parsing 
    :return: a SiteCatalog object based on d
    :rtype: SiteCatalog
    """

{'fraction_non_alphanumeric': 0.112722751761293, 'fraction_numerical': 0.0008288437629506838, 'mean_word_length': 3.341726618705036, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 35, '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': '6122452', 'n_tokens_mistral': 781, 'n_tokens_neox': 751, 'n_words': 232}