<commit_before>"""Stores Research Object including provenance."""
from __future__ import absolute_import

import copy
import datetime
import hashlib
import logging
import os
import os.path
import posixpath
import re
import shutil
import tempfile
import uuid
from collections import OrderedDict
from getpass import getuser
from io import BytesIO, FileIO, TextIOWrapper, open
from socket import getfqdn
from typing import (IO, Any, Callable, Dict, List, Generator, MutableMapping,
                    Optional, Set, Tuple, Union, cast)

import prov.model as provM
import six
from prov.identifier import Identifier, Namespace
from prov.model import (PROV, ProvActivity,  # pylint: disable=unused-import
                        ProvDocument, ProvEntity)
from ruamel import yaml
from schema_salad.sourceline import SourceLine
from six.moves import urllib
from typing_extensions import (TYPE_CHECKING,  # pylint: disable=unused-import
                               Text)
# move to a regular typing import when Python 3.3-3.6 is no longer supported

from .context import RuntimeContext  # pylint: disable=unused-import
from .errors import WorkflowException
from .loghandler import _logger
from .pathmapper import get_listing
from .process import Process, shortname  # pylint: disable=unused-import
from .stdfsaccess import StdFsAccess  # pylint: disable=unused-import
from .utils import json_dumps, versionstring

# Disabled due to excessive transitive dependencies
# from networkx.drawing.nx_agraph import graphviz_layout
# from networkx.drawing.nx_pydot import write_dot


GET_PW_NAM = False
try:
    # pwd is only available on Unix
    from pwd import struct_passwd  # pylint: disable=unused-import
    from pwd import getpwnam  # pylint: disable=unused-import
    GET_PW_NAME = True
except ImportError:
    pass

if TYPE_CHECKING:
    from .command_line_tool import CommandLineTool, ExpressionTool  # pylint: disable=unused-import
    from .workflow import Workflow  # pylint: disable=unused-import

if six.PY2:
    class PermissionError(OSError):  # pylint: disable=redefined-builtin
        """Needed for Python2."""

        pass
__citation__ = "https://doi.org/10.5281/zenodo.1208477"

# NOTE: Semantic versioning of the CWLProv Research Object
# **and** the cwlprov files
#
# Rough guide (major.minor.patch):
# 1. Bump major number if removing/"breaking" resources or PROV statements
# 2. Bump minor number if adding resources or PROV statements
# 3. Bump patch number for non-breaking non-adding changes,
#    e.g. fixing broken relative paths
CWLPROV_VERSION = "https://w3id.org/cwl/prov/0.5.0"

# Research Object folders
METADATA = "metadata"<commit_msg>update version<commit_after>"""Stores Research Object including provenance."""
from __future__ import absolute_import

import copy
import datetime
import hashlib
import logging
import os
import os.path
import posixpath
import re
import shutil
import tempfile
import uuid
from collections import OrderedDict
from getpass import getuser
from io import BytesIO, FileIO, TextIOWrapper, open
from socket import getfqdn
from typing import (IO, Any, Callable, Dict, List, Generator, MutableMapping,
                    Optional, Set, Tuple, Union, cast)

import prov.model as provM
import six
from prov.identifier import Identifier, Namespace
from prov.model import (PROV, ProvActivity,  # pylint: disable=unused-import
                        ProvDocument, ProvEntity)
from ruamel import yaml
from schema_salad.sourceline import SourceLine
from six.moves import urllib
from typing_extensions import (TYPE_CHECKING,  # pylint: disable=unused-import
                               Text)
# move to a regular typing import when Python 3.3-3.6 is no longer supported

from .context import RuntimeContext  # pylint: disable=unused-import
from .errors import WorkflowException
from .loghandler import _logger
from .pathmapper import get_listing
from .process import Process, shortname  # pylint: disable=unused-import
from .stdfsaccess import StdFsAccess  # pylint: disable=unused-import
from .utils import json_dumps, versionstring

# Disabled due to excessive transitive dependencies
# from networkx.drawing.nx_agraph import graphviz_layout
# from networkx.drawing.nx_pydot import write_dot


GET_PW_NAM = False
try:
    # pwd is only available on Unix
    from pwd import struct_passwd  # pylint: disable=unused-import
    from pwd import getpwnam  # pylint: disable=unused-import
    GET_PW_NAME = True
except ImportError:
    pass

if TYPE_CHECKING:
    from .command_line_tool import CommandLineTool, ExpressionTool  # pylint: disable=unused-import
    from .workflow import Workflow  # pylint: disable=unused-import

if six.PY2:
    class PermissionError(OSError):  # pylint: disable=redefined-builtin
        """Needed for Python2."""

        pass
__citation__ = "https://doi.org/10.5281/zenodo.1208477"

# NOTE: Semantic versioning of the CWLProv Research Object
# **and** the cwlprov files
#
# Rough guide (major.minor.patch):
# 1. Bump major number if removing/"breaking" resources or PROV statements
# 2. Bump minor number if adding resources or PROV statements
# 3. Bump patch number for non-breaking non-adding changes,
#    e.g. fixing broken relative paths
CWLPROV_VERSION = "https://w3id.org/cwl/prov/0.6.0"

# Research Object folders
METADATA = "metadata"
{'fraction_non_alphanumeric': 0.06690471715842887, 'fraction_numerical': 0.009772599135500847, 'mean_word_length': 4.2074363992172215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '5732976', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1533, 'n_words': 550}