Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The crypt module is deprecated.")
def parse_pwhash(pwhash):
"Extract hash configuration from hash string."
if get_crypt_context().identify(pwhash) == 'bcrypt':
return dict(
rounds=int(pwhash.split('$')[2]),
salt=pwhash[-53:-31])
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="Use the detect_schema() function instead.")
def build_job_statepoint_index(self, exclude_const=False, index=None):
"""Build a statepoint index to identify jobs with specific parameters.
This method generates pairs of state point keys and mappings of values
to a set of all corresponding job ids. The pairs are ordered by the number
of different values.
Since state point keys may be nested, they are represented as a tuple.
For example:
.. code-block:: python
>>> for i in range(4):
... project.open_job({'a': i, 'b': {'c': i % 2}}).init()
...
>>> for key, value in project.build_job_statepoint_index():
msg = "Unable to retrieve subject from certificate '{}'."
raise RuntimeError(msg.format(fn_certificate))
else:
lines = cert_txt.split('\n')
assert lines[0].startswith('subject=')
return lines[0][len('subject='):].strip()
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The connection module is deprecated.")
def raise_unsupported_auth_mechanism(mechanism):
msg = "Auth mechanism '{}' not supported."
raise ValueError(msg.format(mechanism))
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The connection module is deprecated.")
class DBClientConnector(object):
def __init__(self, host_config, **kwargs):
self._config = host_config
self._client = None
self._kwargs = kwargs
@property
def client(self):
if self._client is None:
raise RuntimeError("Client not connected.")
else:
return self._client
@property
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The filesystems module is deprecated.")
def filesystems_from_config(fs_config):
"""Generate file system handlers from a configuration.
This function yields file system handler objects from
a file system configuration.
A configuration is a mapping where the key identifies the
type of file system, and the values represent the argument(s)
to the constructor of the specified file system handler.
Arguments can be provided as mappings, sequences or single values, e.g.:
.. code-block:: python
# The following two function calls are equivalent and both
# generate two file system handler objects:
filesystems_from_config({
def _check_schema_compatibility(self):
"""Checks whether this project's data schema is compatible with this version.
:raises RuntimeError:
If the schema version is incompatible.
"""
schema_version = version.parse(SCHEMA_VERSION)
config_schema_version = version.parse(self.config['schema_version'])
if config_schema_version > schema_version:
# Project config schema version is newer and therefore not supported.
raise IncompatibleSchemaVersion(
"The signac schema version used by this project is '{}', but signac {} "
"only supports up to schema version '{}'. Try updating signac.".format(
config_schema_version, __version__, schema_version))
elif config_schema_version < schema_version:
raise IncompatibleSchemaVersion(
"The signac schema version used by this project is '{}', but signac {} "
"requires schema version '{}'. Please use '$ signac migrate' to "
"irreversibly migrate this project's schema to the supported "
"version.".format(
config_schema_version, __version__, schema_version))
else: # identical and therefore compatible
logger.debug(
"The project's schema version {} is supported.".format(
config_schema_version))
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_client(hostcfg, **kwargs):
connector = get_connector(hostcfg, **kwargs)
connector.connect()
connector.authenticate()
return connector.client
def __setitem__(self, key, value):
if not self._mutable:
warnings.warn("Modifying the project configuration after project "
"initialization is deprecated as of version 1.3 and "
"will be removed in version 2.0.",
DeprecationWarning)
assert version.parse(__version__) < version.parse("2.0")
return super(_ProjectConfig, self).__setitem__(key, value)
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The database package is deprecated.")
def get_database(name, hostname=None, config=None):
"""Get a database handle.
The database handle is an instance of :class:`~pymongo.database.Database`,
which provides access to the document collections within one database.
.. code-block:: python
db = signac.db.get_database('MyDatabase')
docs = db.my_collection.find()
Please note, that a collection which did not exist at the point of access,
will automatically be created.
:param name: The name of the database to get.
def _collect_migrations(project):
schema_version = version.parse(SCHEMA_VERSION)
def config_schema_version():
return version.parse(project._config['schema_version'])
if config_schema_version() > schema_version:
# Project config schema version is newer and therefore not supported.
raise RuntimeError(
"The signac schema version used by this project is {}, but signac {} "
"only supports up to schema version {}. Try updating signac.".format(
config_schema_version, __version__, SCHEMA_VERSION))
while config_schema_version() < schema_version:
for (origin, destination), migration in MIGRATIONS.items():
if version.parse(origin) == config_schema_version():
yield (origin, destination), migration
break
else:
raise RuntimeError(
"The signac schema version used by this project is {}, but signac {} "
"uses schema version {} and does not know how to migrate.".format(
config_schema_version(), __version__, schema_version))
@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="Use job.id instead.")
def get_id(self):
"""The job's statepoint's unique identifier.
:return: The job id.
:rtype: str"""
return self._id