body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def init_host(self): 'Perform any required initialization.' ctxt = context.get_admin_context() LOG.info(_LI('Starting volume driver %(driver_name)s (%(version)s)'), {'driver_name': self.driver.__class__.__name__, 'version': self.driver.get_version()}) try: self.driver.do_setup(ctxt) self...
-1,150,854,024,366,898,800
Perform any required initialization.
cinder/volume/manager.py
init_host
ISCAS-VDI/cinder-base
python
def init_host(self): ctxt = context.get_admin_context() LOG.info(_LI('Starting volume driver %(driver_name)s (%(version)s)'), {'driver_name': self.driver.__class__.__name__, 'version': self.driver.get_version()}) try: self.driver.do_setup(ctxt) self.driver.check_for_setup_error() ex...
def is_working(self): 'Return if Manager is ready to accept requests.\n\n This is to inform Service class that in case of volume driver\n initialization failure the manager is actually down and not ready to\n accept any requests.\n ' return self.driver.initialized
-7,833,758,696,326,255,000
Return if Manager is ready to accept requests. This is to inform Service class that in case of volume driver initialization failure the manager is actually down and not ready to accept any requests.
cinder/volume/manager.py
is_working
ISCAS-VDI/cinder-base
python
def is_working(self): 'Return if Manager is ready to accept requests.\n\n This is to inform Service class that in case of volume driver\n initialization failure the manager is actually down and not ready to\n accept any requests.\n ' return self.driver.initialized
def create_volume(self, context, volume_id, request_spec=None, filter_properties=None, allow_reschedule=True, volume=None): 'Creates the volume.' if (volume is None): volume = objects.Volume.get_by_id(context, volume_id) context_elevated = context.elevated() if (filter_properties is None): ...
1,890,941,168,616,453,400
Creates the volume.
cinder/volume/manager.py
create_volume
ISCAS-VDI/cinder-base
python
def create_volume(self, context, volume_id, request_spec=None, filter_properties=None, allow_reschedule=True, volume=None): if (volume is None): volume = objects.Volume.get_by_id(context, volume_id) context_elevated = context.elevated() if (filter_properties is None): filter_properties ...
@locked_volume_operation def delete_volume(self, context, volume_id, unmanage_only=False, volume=None, cascade=False): 'Deletes and unexports volume.\n\n 1. Delete a volume(normal case)\n Delete a volume and update quotas.\n\n 2. Delete a migration volume\n If deleting the volume i...
8,906,263,107,510,917,000
Deletes and unexports volume. 1. Delete a volume(normal case) Delete a volume and update quotas. 2. Delete a migration volume If deleting the volume in a migration, we want to skip quotas but we need database updates for the volume.
cinder/volume/manager.py
delete_volume
ISCAS-VDI/cinder-base
python
@locked_volume_operation def delete_volume(self, context, volume_id, unmanage_only=False, volume=None, cascade=False): 'Deletes and unexports volume.\n\n 1. Delete a volume(normal case)\n Delete a volume and update quotas.\n\n 2. Delete a migration volume\n If deleting the volume i...
def create_snapshot(self, context, volume_id, snapshot): 'Creates and exports the snapshot.' context = context.elevated() self._notify_about_snapshot_usage(context, snapshot, 'create.start') try: utils.require_driver_initialized(self.driver) snapshot.context = context model_updat...
-3,463,493,398,277,073,400
Creates and exports the snapshot.
cinder/volume/manager.py
create_snapshot
ISCAS-VDI/cinder-base
python
def create_snapshot(self, context, volume_id, snapshot): context = context.elevated() self._notify_about_snapshot_usage(context, snapshot, 'create.start') try: utils.require_driver_initialized(self.driver) snapshot.context = context model_update = self.driver.create_snapshot(sna...
@locked_snapshot_operation def delete_snapshot(self, context, snapshot, unmanage_only=False): 'Deletes and unexports snapshot.' context = context.elevated() snapshot._context = context project_id = snapshot.project_id self._notify_about_snapshot_usage(context, snapshot, 'delete.start') try: ...
-1,303,269,633,822,586,000
Deletes and unexports snapshot.
cinder/volume/manager.py
delete_snapshot
ISCAS-VDI/cinder-base
python
@locked_snapshot_operation def delete_snapshot(self, context, snapshot, unmanage_only=False): context = context.elevated() snapshot._context = context project_id = snapshot.project_id self._notify_about_snapshot_usage(context, snapshot, 'delete.start') try: utils.require_driver_initiali...
def attach_volume(self, context, volume_id, instance_uuid, host_name, mountpoint, mode): 'Updates db to show volume is attached.' @utils.synchronized(volume_id, external=True) def do_attach(): volume = self.db.volume_get(context, volume_id) volume_metadata = self.db.volume_admin_metadata_ge...
-8,125,107,459,446,559,000
Updates db to show volume is attached.
cinder/volume/manager.py
attach_volume
ISCAS-VDI/cinder-base
python
def attach_volume(self, context, volume_id, instance_uuid, host_name, mountpoint, mode): @utils.synchronized(volume_id, external=True) def do_attach(): volume = self.db.volume_get(context, volume_id) volume_metadata = self.db.volume_admin_metadata_get(context.elevated(), volume_id) ...
@locked_detach_operation def detach_volume(self, context, volume_id, attachment_id=None): 'Updates db to show volume is detached.' volume = self.db.volume_get(context, volume_id) attachment = None if attachment_id: try: attachment = self.db.volume_attachment_get(context, attachment_i...
3,415,520,564,871,494,000
Updates db to show volume is detached.
cinder/volume/manager.py
detach_volume
ISCAS-VDI/cinder-base
python
@locked_detach_operation def detach_volume(self, context, volume_id, attachment_id=None): volume = self.db.volume_get(context, volume_id) attachment = None if attachment_id: try: attachment = self.db.volume_attachment_get(context, attachment_id) except exception.VolumeAttach...
def _create_image_cache_volume_entry(self, ctx, volume_ref, image_id, image_meta): 'Create a new image-volume and cache entry for it.\n\n This assumes that the image has already been downloaded and stored\n in the volume described by the volume_ref.\n ' image_volume = None try: ...
-5,460,950,307,200,344,000
Create a new image-volume and cache entry for it. This assumes that the image has already been downloaded and stored in the volume described by the volume_ref.
cinder/volume/manager.py
_create_image_cache_volume_entry
ISCAS-VDI/cinder-base
python
def _create_image_cache_volume_entry(self, ctx, volume_ref, image_id, image_meta): 'Create a new image-volume and cache entry for it.\n\n This assumes that the image has already been downloaded and stored\n in the volume described by the volume_ref.\n ' image_volume = None try: ...
def _clone_image_volume_and_add_location(self, ctx, volume, image_service, image_meta): 'Create a cloned volume and register its location to the image.' if ((image_meta['disk_format'] != 'raw') or (image_meta['container_format'] != 'bare')): return False image_volume_context = ctx if self.driver...
1,198,232,022,801,254,700
Create a cloned volume and register its location to the image.
cinder/volume/manager.py
_clone_image_volume_and_add_location
ISCAS-VDI/cinder-base
python
def _clone_image_volume_and_add_location(self, ctx, volume, image_service, image_meta): if ((image_meta['disk_format'] != 'raw') or (image_meta['container_format'] != 'bare')): return False image_volume_context = ctx if self.driver.configuration.image_upload_use_internal_tenant: interna...
def copy_volume_to_image(self, context, volume_id, image_meta): "Uploads the specified volume to Glance.\n\n image_meta is a dictionary containing the following keys:\n 'id', 'container_format', 'disk_format'\n\n " payload = {'volume_id': volume_id, 'image_id': image_meta['id']} image_s...
-5,284,815,560,622,527,000
Uploads the specified volume to Glance. image_meta is a dictionary containing the following keys: 'id', 'container_format', 'disk_format'
cinder/volume/manager.py
copy_volume_to_image
ISCAS-VDI/cinder-base
python
def copy_volume_to_image(self, context, volume_id, image_meta): "Uploads the specified volume to Glance.\n\n image_meta is a dictionary containing the following keys:\n 'id', 'container_format', 'disk_format'\n\n " payload = {'volume_id': volume_id, 'image_id': image_meta['id']} image_s...
def _delete_image(self, context, image_id, image_service): 'Deletes an image stuck in queued or saving state.' try: image_meta = image_service.show(context, image_id) image_status = image_meta.get('status') if ((image_status == 'queued') or (image_status == 'saving')): LOG.wa...
8,074,731,748,494,501,000
Deletes an image stuck in queued or saving state.
cinder/volume/manager.py
_delete_image
ISCAS-VDI/cinder-base
python
def _delete_image(self, context, image_id, image_service): try: image_meta = image_service.show(context, image_id) image_status = image_meta.get('status') if ((image_status == 'queued') or (image_status == 'saving')): LOG.warning(_LW('Deleting image in unexpected status: %(i...
def initialize_connection(self, context, volume_id, connector): "Prepare volume for connection from host represented by connector.\n\n This method calls the driver initialize_connection and returns\n it to the caller. The connector parameter is a dictionary with\n information about the host th...
-8,752,532,811,227,430,000
Prepare volume for connection from host represented by connector. This method calls the driver initialize_connection and returns it to the caller. The connector parameter is a dictionary with information about the host that will connect to the volume in the following format:: { 'ip': ip, 'initiat...
cinder/volume/manager.py
initialize_connection
ISCAS-VDI/cinder-base
python
def initialize_connection(self, context, volume_id, connector): "Prepare volume for connection from host represented by connector.\n\n This method calls the driver initialize_connection and returns\n it to the caller. The connector parameter is a dictionary with\n information about the host th...
def terminate_connection(self, context, volume_id, connector, force=False): 'Cleanup connection from host represented by connector.\n\n The format of connector is the same as for initialize_connection.\n ' utils.require_driver_initialized(self.driver) volume_ref = self.db.volume_get(context, v...
-8,020,229,695,655,376,000
Cleanup connection from host represented by connector. The format of connector is the same as for initialize_connection.
cinder/volume/manager.py
terminate_connection
ISCAS-VDI/cinder-base
python
def terminate_connection(self, context, volume_id, connector, force=False): 'Cleanup connection from host represented by connector.\n\n The format of connector is the same as for initialize_connection.\n ' utils.require_driver_initialized(self.driver) volume_ref = self.db.volume_get(context, v...
def remove_export(self, context, volume_id): 'Removes an export for a volume.' utils.require_driver_initialized(self.driver) volume_ref = self.db.volume_get(context, volume_id) try: self.driver.remove_export(context, volume_ref) except Exception: msg = _('Remove volume export failed....
-5,397,532,297,899,845,000
Removes an export for a volume.
cinder/volume/manager.py
remove_export
ISCAS-VDI/cinder-base
python
def remove_export(self, context, volume_id): utils.require_driver_initialized(self.driver) volume_ref = self.db.volume_get(context, volume_id) try: self.driver.remove_export(context, volume_ref) except Exception: msg = _('Remove volume export failed.') LOG.exception(msg, res...
def _copy_volume_data(self, ctxt, src_vol, dest_vol, remote=None): 'Copy data from src_vol to dest_vol.' LOG.debug('copy_data_between_volumes %(src)s -> %(dest)s.', {'src': src_vol['name'], 'dest': dest_vol['name']}) properties = utils.brick_get_connector_properties() dest_remote = (remote in ['dest', '...
2,135,584,882,741,025,000
Copy data from src_vol to dest_vol.
cinder/volume/manager.py
_copy_volume_data
ISCAS-VDI/cinder-base
python
def _copy_volume_data(self, ctxt, src_vol, dest_vol, remote=None): LOG.debug('copy_data_between_volumes %(src)s -> %(dest)s.', {'src': src_vol['name'], 'dest': dest_vol['name']}) properties = utils.brick_get_connector_properties() dest_remote = (remote in ['dest', 'both']) dest_attach_info = self._...
def migrate_volume(self, ctxt, volume_id, host, force_host_copy=False, new_type_id=None, volume=None): 'Migrate the volume to the specified host (called on source host).' if (volume is None): volume = objects.Volume.get_by_id(ctxt, volume_id) try: utils.require_driver_initialized(self.driver...
-6,172,334,654,003,001,000
Migrate the volume to the specified host (called on source host).
cinder/volume/manager.py
migrate_volume
ISCAS-VDI/cinder-base
python
def migrate_volume(self, ctxt, volume_id, host, force_host_copy=False, new_type_id=None, volume=None): if (volume is None): volume = objects.Volume.get_by_id(ctxt, volume_id) try: utils.require_driver_initialized(self.driver) except exception.DriverNotInitialized: with excutils....
def _append_filter_goodness_functions(self, volume_stats): 'Returns volume_stats updated as needed.' if ('filter_function' not in volume_stats): volume_stats['filter_function'] = self.driver.get_filter_function() if ('goodness_function' not in volume_stats): volume_stats['goodness_function']...
-4,678,197,258,167,024,000
Returns volume_stats updated as needed.
cinder/volume/manager.py
_append_filter_goodness_functions
ISCAS-VDI/cinder-base
python
def _append_filter_goodness_functions(self, volume_stats): if ('filter_function' not in volume_stats): volume_stats['filter_function'] = self.driver.get_filter_function() if ('goodness_function' not in volume_stats): volume_stats['goodness_function'] = self.driver.get_goodness_function() ...
def publish_service_capabilities(self, context): 'Collect driver status and then publish.' self._report_driver_status(context) self._publish_service_capabilities(context)
3,688,470,462,004,612,000
Collect driver status and then publish.
cinder/volume/manager.py
publish_service_capabilities
ISCAS-VDI/cinder-base
python
def publish_service_capabilities(self, context): self._report_driver_status(context) self._publish_service_capabilities(context)
def promote_replica(self, ctxt, volume_id): 'Promote volume replica secondary to be the primary volume.' volume = self.db.volume_get(ctxt, volume_id) model_update = None try: utils.require_driver_initialized(self.driver) except exception.DriverNotInitialized: with excutils.save_and_r...
2,842,671,097,530,260,500
Promote volume replica secondary to be the primary volume.
cinder/volume/manager.py
promote_replica
ISCAS-VDI/cinder-base
python
def promote_replica(self, ctxt, volume_id): volume = self.db.volume_get(ctxt, volume_id) model_update = None try: utils.require_driver_initialized(self.driver) except exception.DriverNotInitialized: with excutils.save_and_reraise_exception(): LOG.exception(_LE('Promote v...
def reenable_replication(self, ctxt, volume_id): 'Re-enable replication of secondary volume with primary volumes.' volume = self.db.volume_get(ctxt, volume_id) model_update = None try: utils.require_driver_initialized(self.driver) except exception.DriverNotInitialized: with excutils....
6,959,273,489,633,431,000
Re-enable replication of secondary volume with primary volumes.
cinder/volume/manager.py
reenable_replication
ISCAS-VDI/cinder-base
python
def reenable_replication(self, ctxt, volume_id): volume = self.db.volume_get(ctxt, volume_id) model_update = None try: utils.require_driver_initialized(self.driver) except exception.DriverNotInitialized: with excutils.save_and_reraise_exception(): LOG.exception(_LE('Sync...
def create_consistencygroup(self, context, group): 'Creates the consistency group.' context = context.elevated() status = fields.ConsistencyGroupStatus.AVAILABLE model_update = None self._notify_about_consistencygroup_usage(context, group, 'create.start') try: utils.require_driver_initia...
7,328,819,059,921,083,000
Creates the consistency group.
cinder/volume/manager.py
create_consistencygroup
ISCAS-VDI/cinder-base
python
def create_consistencygroup(self, context, group): context = context.elevated() status = fields.ConsistencyGroupStatus.AVAILABLE model_update = None self._notify_about_consistencygroup_usage(context, group, 'create.start') try: utils.require_driver_initialized(self.driver) LOG.i...
def create_consistencygroup_from_src(self, context, group, cgsnapshot=None, source_cg=None): 'Creates the consistency group from source.\n\n The source can be a CG snapshot or a source CG.\n ' source_name = None snapshots = None source_vols = None try: volumes = self.db.volume_...
-3,745,478,315,313,215,000
Creates the consistency group from source. The source can be a CG snapshot or a source CG.
cinder/volume/manager.py
create_consistencygroup_from_src
ISCAS-VDI/cinder-base
python
def create_consistencygroup_from_src(self, context, group, cgsnapshot=None, source_cg=None): 'Creates the consistency group from source.\n\n The source can be a CG snapshot or a source CG.\n ' source_name = None snapshots = None source_vols = None try: volumes = self.db.volume_...
def delete_consistencygroup(self, context, group): 'Deletes consistency group and the volumes in the group.' context = context.elevated() project_id = group.project_id if (context.project_id != group.project_id): project_id = group.project_id else: project_id = context.project_id ...
932,044,870,691,766,100
Deletes consistency group and the volumes in the group.
cinder/volume/manager.py
delete_consistencygroup
ISCAS-VDI/cinder-base
python
def delete_consistencygroup(self, context, group): context = context.elevated() project_id = group.project_id if (context.project_id != group.project_id): project_id = group.project_id else: project_id = context.project_id volumes = self.db.volume_get_all_by_group(context, group...
def update_consistencygroup(self, context, group, add_volumes=None, remove_volumes=None): 'Updates consistency group.\n\n Update consistency group by adding volumes to the group,\n or removing volumes from the group.\n ' add_volumes_ref = [] remove_volumes_ref = [] add_volumes_list ...
2,105,641,434,782,602,500
Updates consistency group. Update consistency group by adding volumes to the group, or removing volumes from the group.
cinder/volume/manager.py
update_consistencygroup
ISCAS-VDI/cinder-base
python
def update_consistencygroup(self, context, group, add_volumes=None, remove_volumes=None): 'Updates consistency group.\n\n Update consistency group by adding volumes to the group,\n or removing volumes from the group.\n ' add_volumes_ref = [] remove_volumes_ref = [] add_volumes_list ...
def create_cgsnapshot(self, context, cgsnapshot): 'Creates the cgsnapshot.' caller_context = context context = context.elevated() LOG.info(_LI('Cgsnapshot %s: creating.'), cgsnapshot.id) snapshots = objects.SnapshotList.get_all_for_cgsnapshot(context, cgsnapshot.id) self._notify_about_cgsnapshot...
-1,498,914,793,036,234,000
Creates the cgsnapshot.
cinder/volume/manager.py
create_cgsnapshot
ISCAS-VDI/cinder-base
python
def create_cgsnapshot(self, context, cgsnapshot): caller_context = context context = context.elevated() LOG.info(_LI('Cgsnapshot %s: creating.'), cgsnapshot.id) snapshots = objects.SnapshotList.get_all_for_cgsnapshot(context, cgsnapshot.id) self._notify_about_cgsnapshot_usage(context, cgsnapsho...
def delete_cgsnapshot(self, context, cgsnapshot): 'Deletes cgsnapshot.' caller_context = context context = context.elevated() project_id = cgsnapshot.project_id LOG.info(_LI('cgsnapshot %s: deleting'), cgsnapshot.id) snapshots = objects.SnapshotList.get_all_for_cgsnapshot(context, cgsnapshot.id)...
-3,840,660,759,487,432,000
Deletes cgsnapshot.
cinder/volume/manager.py
delete_cgsnapshot
ISCAS-VDI/cinder-base
python
def delete_cgsnapshot(self, context, cgsnapshot): caller_context = context context = context.elevated() project_id = cgsnapshot.project_id LOG.info(_LI('cgsnapshot %s: deleting'), cgsnapshot.id) snapshots = objects.SnapshotList.get_all_for_cgsnapshot(context, cgsnapshot.id) self._notify_abo...
def update_migrated_volume(self, ctxt, volume, new_volume, volume_status): 'Finalize migration process on backend device.' model_update = None model_update_default = {'_name_id': new_volume.name_id, 'provider_location': new_volume.provider_location} try: model_update = self.driver.update_migrate...
-2,092,127,233,417,161,500
Finalize migration process on backend device.
cinder/volume/manager.py
update_migrated_volume
ISCAS-VDI/cinder-base
python
def update_migrated_volume(self, ctxt, volume, new_volume, volume_status): model_update = None model_update_default = {'_name_id': new_volume.name_id, 'provider_location': new_volume.provider_location} try: model_update = self.driver.update_migrated_volume(ctxt, volume, new_volume, volume_statu...
def failover_host(self, context, secondary_backend_id=None): "Failover a backend to a secondary replication target.\n\n Instructs a replication capable/configured backend to failover\n to one of it's secondary replication targets. host=None is\n an acceptable input, and leaves it to the driver ...
-7,785,357,875,959,712,000
Failover a backend to a secondary replication target. Instructs a replication capable/configured backend to failover to one of it's secondary replication targets. host=None is an acceptable input, and leaves it to the driver to failover to the only configured target, or to choose a target on it's own. All of the hosts...
cinder/volume/manager.py
failover_host
ISCAS-VDI/cinder-base
python
def failover_host(self, context, secondary_backend_id=None): "Failover a backend to a secondary replication target.\n\n Instructs a replication capable/configured backend to failover\n to one of it's secondary replication targets. host=None is\n an acceptable input, and leaves it to the driver ...
def freeze_host(self, context): 'Freeze management plane on this backend.\n\n Basically puts the control/management plane into a\n Read Only state. We should handle this in the scheduler,\n however this is provided to let the driver know in case it\n needs/wants to do something specific...
2,362,276,871,906,208,000
Freeze management plane on this backend. Basically puts the control/management plane into a Read Only state. We should handle this in the scheduler, however this is provided to let the driver know in case it needs/wants to do something specific on the backend. :param context: security context
cinder/volume/manager.py
freeze_host
ISCAS-VDI/cinder-base
python
def freeze_host(self, context): 'Freeze management plane on this backend.\n\n Basically puts the control/management plane into a\n Read Only state. We should handle this in the scheduler,\n however this is provided to let the driver know in case it\n needs/wants to do something specific...
def thaw_host(self, context): 'UnFreeze management plane on this backend.\n\n Basically puts the control/management plane back into\n a normal state. We should handle this in the scheduler,\n however this is provided to let the driver know in case it\n needs/wants to do something specif...
3,111,996,613,704,219,000
UnFreeze management plane on this backend. Basically puts the control/management plane back into a normal state. We should handle this in the scheduler, however this is provided to let the driver know in case it needs/wants to do something specific on the backend. :param context: security context
cinder/volume/manager.py
thaw_host
ISCAS-VDI/cinder-base
python
def thaw_host(self, context): 'UnFreeze management plane on this backend.\n\n Basically puts the control/management plane back into\n a normal state. We should handle this in the scheduler,\n however this is provided to let the driver know in case it\n needs/wants to do something specif...
def get_capabilities(self, context, discover): 'Get capabilities of backend storage.' if discover: self.driver.init_capabilities() capabilities = self.driver.capabilities LOG.debug('Obtained capabilities list: %s.', capabilities) return capabilities
5,667,258,279,005,569,000
Get capabilities of backend storage.
cinder/volume/manager.py
get_capabilities
ISCAS-VDI/cinder-base
python
def get_capabilities(self, context, discover): if discover: self.driver.init_capabilities() capabilities = self.driver.capabilities LOG.debug('Obtained capabilities list: %s.', capabilities) return capabilities
def compute_mask(argv=None): 'Function to compute a mask of non-resposive pixels from FXS images\n extracted from xtc (smd,idx,xtc format) or h5 files.\n Works for Single CPU, Multi-Processor interactive jobs and MPI batch jobs\n\n For a definition of input arguments argv and batch processing inst...
-1,029,744,097,754,570,900
Function to compute a mask of non-resposive pixels from FXS images extracted from xtc (smd,idx,xtc format) or h5 files. Works for Single CPU, Multi-Processor interactive jobs and MPI batch jobs For a definition of input arguments argv and batch processing instructions see *** mpi_fxs_launch.py *** compute_mask prod...
modules/cctbx_project/xfel/amo/pnccd_ana/mpi_fxs_mask.py
compute_mask
jorgediazjr/dials-dev20191018
python
def compute_mask(argv=None): 'Function to compute a mask of non-resposive pixels from FXS images\n extracted from xtc (smd,idx,xtc format) or h5 files.\n Works for Single CPU, Multi-Processor interactive jobs and MPI batch jobs\n\n For a definition of input arguments argv and batch processing inst...
def to_ltx(a, fmt='{:6.4f}', latexarraytype='array', imstring='i', is_row_vector=True, mathform=True, brackets='()', mark_elements=[], mark_color='pink', separate_columns=[], separate_rows=[]): '\n Return a LaTeX array given a numpy array.\n\n Parameters\n ----------\n a : numpy.ndarray\n fmt : str, ...
-1,413,996,771,371,158,000
Return a LaTeX array given a numpy array. Parameters ---------- a : numpy.ndarray fmt : str, default = '{:6.2f}' python 3 formatter, optional- https://mkaz.tech/python-string-format.html latexarraytype : str, default = 'array' Any of .. code:: python "array" "pmatrix" "bmatrix...
numpyarray_to_latex/main.py
to_ltx
psychemedia/numpyarray_to_latex
python
def to_ltx(a, fmt='{:6.4f}', latexarraytype='array', imstring='i', is_row_vector=True, mathform=True, brackets='()', mark_elements=[], mark_color='pink', separate_columns=[], separate_rows=[]): '\n Return a LaTeX array given a numpy array.\n\n Parameters\n ----------\n a : numpy.ndarray\n fmt : str, ...
def get_plugin_media_path(instance, filename): '\n Django 1.7 requires that unbound function used in fields\' definitions are defined outside the parent class\n (see https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values)\n This function is used withing field definition:\n\n fi...
450,341,442,002,724,000
Django 1.7 requires that unbound function used in fields' definitions are defined outside the parent class (see https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values) This function is used withing field definition: file = models.FileField(_("file"), upload_to=get_plugin_media_path) and it i...
cms/models/pluginmodel.py
get_plugin_media_path
stefanw/django-cms
python
def get_plugin_media_path(instance, filename): '\n Django 1.7 requires that unbound function used in fields\' definitions are defined outside the parent class\n (see https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values)\n This function is used withing field definition:\n\n fi...
def __reduce__(self): "\n Provide pickling support. Normally, this just dispatches to Python's\n standard handling. However, for models with deferred field loading, we\n need to do things manually, as they're dynamically created classes and\n only module-level classes can be pickled by t...
6,809,623,482,667,342,000
Provide pickling support. Normally, this just dispatches to Python's standard handling. However, for models with deferred field loading, we need to do things manually, as they're dynamically created classes and only module-level classes can be pickled by the default path.
cms/models/pluginmodel.py
__reduce__
stefanw/django-cms
python
def __reduce__(self): "\n Provide pickling support. Normally, this just dispatches to Python's\n standard handling. However, for models with deferred field loading, we\n need to do things manually, as they're dynamically created classes and\n only module-level classes can be pickled by t...
def get_plugin_instance(self, admin=None): "\n Given a plugin instance (usually as a CMSPluginBase), this method\n returns a tuple containing:\n\n instance - The instance AS THE APPROPRIATE SUBCLASS OF\n CMSPluginBase and not necessarily just 'self', which is\n ...
-8,788,274,808,039,571,000
Given a plugin instance (usually as a CMSPluginBase), this method returns a tuple containing: instance - The instance AS THE APPROPRIATE SUBCLASS OF CMSPluginBase and not necessarily just 'self', which is often just a CMSPluginBase, plugin - the associated plugin class instance...
cms/models/pluginmodel.py
get_plugin_instance
stefanw/django-cms
python
def get_plugin_instance(self, admin=None): "\n Given a plugin instance (usually as a CMSPluginBase), this method\n returns a tuple containing:\n\n instance - The instance AS THE APPROPRIATE SUBCLASS OF\n CMSPluginBase and not necessarily just 'self', which is\n ...
def get_instance_icon_src(self): "\n Get src URL for instance's icon\n " (instance, plugin) = self.get_plugin_instance() return (plugin.icon_src(instance) if instance else u'')
-5,296,560,135,758,746,000
Get src URL for instance's icon
cms/models/pluginmodel.py
get_instance_icon_src
stefanw/django-cms
python
def get_instance_icon_src(self): "\n \n " (instance, plugin) = self.get_plugin_instance() return (plugin.icon_src(instance) if instance else u)
def get_instance_icon_alt(self): "\n Get alt text for instance's icon\n " (instance, plugin) = self.get_plugin_instance() return (force_text(plugin.icon_alt(instance)) if instance else u'')
-2,353,452,820,428,487,700
Get alt text for instance's icon
cms/models/pluginmodel.py
get_instance_icon_alt
stefanw/django-cms
python
def get_instance_icon_alt(self): "\n \n " (instance, plugin) = self.get_plugin_instance() return (force_text(plugin.icon_alt(instance)) if instance else u)
def copy_plugin(self, target_placeholder, target_language, parent_cache, no_signals=False): "\n Copy this plugin and return the new plugin.\n\n The logic of this method is the following:\n\n # get a new generic plugin instance\n # assign the position in the plugin tree\n # save...
81,708,884,157,565,040
Copy this plugin and return the new plugin. The logic of this method is the following: # get a new generic plugin instance # assign the position in the plugin tree # save it to let mptt/treebeard calculate the tree attributes # then get a copy of the current plugin instance # assign to it the id of the generic p...
cms/models/pluginmodel.py
copy_plugin
stefanw/django-cms
python
def copy_plugin(self, target_placeholder, target_language, parent_cache, no_signals=False): "\n Copy this plugin and return the new plugin.\n\n The logic of this method is the following:\n\n # get a new generic plugin instance\n # assign the position in the plugin tree\n # save...
def post_copy(self, old_instance, new_old_ziplist): '\n Handle more advanced cases (eg Text Plugins) after the original is\n copied\n ' pass
-5,287,991,199,225,462,000
Handle more advanced cases (eg Text Plugins) after the original is copied
cms/models/pluginmodel.py
post_copy
stefanw/django-cms
python
def post_copy(self, old_instance, new_old_ziplist): '\n Handle more advanced cases (eg Text Plugins) after the original is\n copied\n ' pass
def copy_relations(self, old_instance): '\n Handle copying of any relations attached to this plugin. Custom plugins\n have to do this themselves!\n ' pass
-6,676,088,627,951,634,000
Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves!
cms/models/pluginmodel.py
copy_relations
stefanw/django-cms
python
def copy_relations(self, old_instance): '\n Handle copying of any relations attached to this plugin. Custom plugins\n have to do this themselves!\n ' pass
def get_position_in_placeholder(self): '\n 1 based position!\n ' return (self.position + 1)
-6,577,428,658,556,805,000
1 based position!
cms/models/pluginmodel.py
get_position_in_placeholder
stefanw/django-cms
python
def get_position_in_placeholder(self): '\n \n ' return (self.position + 1)
def notify_on_autoadd(self, request, conf): '\n Method called when we auto add this plugin via default_plugins in\n CMS_PLACEHOLDER_CONF.\n Some specific plugins may have some special stuff to do when they are\n auto added.\n ' pass
-8,901,765,656,126,953,000
Method called when we auto add this plugin via default_plugins in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when they are auto added.
cms/models/pluginmodel.py
notify_on_autoadd
stefanw/django-cms
python
def notify_on_autoadd(self, request, conf): '\n Method called when we auto add this plugin via default_plugins in\n CMS_PLACEHOLDER_CONF.\n Some specific plugins may have some special stuff to do when they are\n auto added.\n ' pass
def notify_on_autoadd_children(self, request, conf, children): '\n Method called when we auto add children to this plugin via\n default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF.\n Some specific plugins may have some special stuff to do when we add\n children to them. ie : TextPl...
-8,075,000,125,713,863,000
Method called when we auto add children to this plugin via default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when we add children to them. ie : TextPlugin must update its content to add HTML tags to be able to see his children in WYSIWYG.
cms/models/pluginmodel.py
notify_on_autoadd_children
stefanw/django-cms
python
def notify_on_autoadd_children(self, request, conf, children): '\n Method called when we auto add children to this plugin via\n default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF.\n Some specific plugins may have some special stuff to do when we add\n children to them. ie : TextPl...
def get_translatable_content(self): "\n Returns {field_name: field_contents} for translatable fields, where\n field_contents > ''\n " fields = (f for f in self._meta.fields if (isinstance(f, (models.CharField, models.TextField)) and f.editable and (not f.choices) and (f.name not in self.tra...
-8,645,680,237,000,977,000
Returns {field_name: field_contents} for translatable fields, where field_contents > ''
cms/models/pluginmodel.py
get_translatable_content
stefanw/django-cms
python
def get_translatable_content(self): "\n Returns {field_name: field_contents} for translatable fields, where\n field_contents > \n " fields = (f for f in self._meta.fields if (isinstance(f, (models.CharField, models.TextField)) and f.editable and (not f.choices) and (f.name not in self.trans...
@property def add_url(self): '\n Returns a custom url to add plugin instances\n ' return None
2,399,919,798,950,241,000
Returns a custom url to add plugin instances
cms/models/pluginmodel.py
add_url
stefanw/django-cms
python
@property def add_url(self): '\n \n ' return None
@property def edit_url(self): '\n Returns a custom url to edit plugin instances\n ' return None
-4,633,932,615,375,681,000
Returns a custom url to edit plugin instances
cms/models/pluginmodel.py
edit_url
stefanw/django-cms
python
@property def edit_url(self): '\n \n ' return None
@property def move_url(self): '\n Returns a custom url to move plugin instances\n ' return None
5,817,508,592,457,980,000
Returns a custom url to move plugin instances
cms/models/pluginmodel.py
move_url
stefanw/django-cms
python
@property def move_url(self): '\n \n ' return None
@property def delete_url(self): '\n Returns a custom url to delete plugin instances\n ' return None
-7,538,766,510,792,490,000
Returns a custom url to delete plugin instances
cms/models/pluginmodel.py
delete_url
stefanw/django-cms
python
@property def delete_url(self): '\n \n ' return None
@property def copy_url(self): '\n Returns a custom url to copy plugin instances\n ' return None
2,064,812,285,791,519,700
Returns a custom url to copy plugin instances
cms/models/pluginmodel.py
copy_url
stefanw/django-cms
python
@property def copy_url(self): '\n \n ' return None
def H_from_ransac(fp, tp, model, maxiter=1000, match_theshold=10): ' Robust estimation of homography H from point \n correspondences using RANSAC (ransac.py from\n http://www.scipy.org/Cookbook/RANSAC).\n \n input: fp,tp (3*n arrays) points in hom. coordinates. ' from PCV.tools impor...
-6,410,962,700,355,088,000
Robust estimation of homography H from point correspondences using RANSAC (ransac.py from http://www.scipy.org/Cookbook/RANSAC). input: fp,tp (3*n arrays) points in hom. coordinates.
PCV/geometry/homography.py
H_from_ransac
BeToMeve/PCV
python
def H_from_ransac(fp, tp, model, maxiter=1000, match_theshold=10): ' Robust estimation of homography H from point \n correspondences using RANSAC (ransac.py from\n http://www.scipy.org/Cookbook/RANSAC).\n \n input: fp,tp (3*n arrays) points in hom. coordinates. ' from PCV.tools impor...
def H_from_points(fp, tp): ' Find homography H, such that fp is mapped to tp\n using the linear DLT method. Points are conditioned\n automatically. ' if (fp.shape != tp.shape): raise RuntimeError('number of points do not match') m = mean(fp[:2], axis=1) maxstd = (max(std(fp[:2], ax...
-2,517,881,027,021,305,000
Find homography H, such that fp is mapped to tp using the linear DLT method. Points are conditioned automatically.
PCV/geometry/homography.py
H_from_points
BeToMeve/PCV
python
def H_from_points(fp, tp): ' Find homography H, such that fp is mapped to tp\n using the linear DLT method. Points are conditioned\n automatically. ' if (fp.shape != tp.shape): raise RuntimeError('number of points do not match') m = mean(fp[:2], axis=1) maxstd = (max(std(fp[:2], ax...
def Haffine_from_points(fp, tp): ' Find H, affine transformation, such that \n tp is affine transf of fp. ' if (fp.shape != tp.shape): raise RuntimeError('number of points do not match') m = mean(fp[:2], axis=1) maxstd = (max(std(fp[:2], axis=1)) + 1e-09) C1 = diag([(1 / maxstd), (1 /...
-4,405,595,007,920,864,000
Find H, affine transformation, such that tp is affine transf of fp.
PCV/geometry/homography.py
Haffine_from_points
BeToMeve/PCV
python
def Haffine_from_points(fp, tp): ' Find H, affine transformation, such that \n tp is affine transf of fp. ' if (fp.shape != tp.shape): raise RuntimeError('number of points do not match') m = mean(fp[:2], axis=1) maxstd = (max(std(fp[:2], axis=1)) + 1e-09) C1 = diag([(1 / maxstd), (1 /...
def normalize(points): ' Normalize a collection of points in \n homogeneous coordinates so that last row = 1. ' for row in points: row /= points[(- 1)] return points
948,872,030,814,935,000
Normalize a collection of points in homogeneous coordinates so that last row = 1.
PCV/geometry/homography.py
normalize
BeToMeve/PCV
python
def normalize(points): ' Normalize a collection of points in \n homogeneous coordinates so that last row = 1. ' for row in points: row /= points[(- 1)] return points
def make_homog(points): ' Convert a set of points (dim*n array) to \n homogeneous coordinates. ' return vstack((points, ones((1, points.shape[1]))))
1,080,106,401,644,308,700
Convert a set of points (dim*n array) to homogeneous coordinates.
PCV/geometry/homography.py
make_homog
BeToMeve/PCV
python
def make_homog(points): ' Convert a set of points (dim*n array) to \n homogeneous coordinates. ' return vstack((points, ones((1, points.shape[1]))))
def fit(self, data): ' Fit homography to four selected correspondences. ' data = data.T fp = data[:3, :4] tp = data[3:, :4] return H_from_points(fp, tp)
-6,976,366,703,067,128,000
Fit homography to four selected correspondences.
PCV/geometry/homography.py
fit
BeToMeve/PCV
python
def fit(self, data): ' ' data = data.T fp = data[:3, :4] tp = data[3:, :4] return H_from_points(fp, tp)
def get_error(self, data, H): ' Apply homography to all correspondences, \n return error for each transformed point. ' data = data.T fp = data[:3] tp = data[3:] fp_transformed = dot(H, fp) fp_transformed = normalize(fp_transformed) return sqrt(sum(((tp - fp_transformed) ** 2), axi...
-1,736,261,869,613,256,200
Apply homography to all correspondences, return error for each transformed point.
PCV/geometry/homography.py
get_error
BeToMeve/PCV
python
def get_error(self, data, H): ' Apply homography to all correspondences, \n return error for each transformed point. ' data = data.T fp = data[:3] tp = data[3:] fp_transformed = dot(H, fp) fp_transformed = normalize(fp_transformed) return sqrt(sum(((tp - fp_transformed) ** 2), axi...
def _get_auth_response_with_retries(response_generator, num_of_retries=NUM_OF_RETRIES_FOR_AUTHENTICATION, auth_wait_time_sec=WAIT_TIME_FOR_AUTHENTICATION_RETRIES_SEC): '\n Sends an authentication request (first time/refresh) with a retry mechanism.\n :param response_generator (lambda)\n A function ...
6,639,735,644,807,461,000
Sends an authentication request (first time/refresh) with a retry mechanism. :param response_generator (lambda) A function call that sends the wanted REST request. :return: The response received from the authentication server.
mona_sdk/authentication.py
_get_auth_response_with_retries
TalzMona/mona-sdk
python
def _get_auth_response_with_retries(response_generator, num_of_retries=NUM_OF_RETRIES_FOR_AUTHENTICATION, auth_wait_time_sec=WAIT_TIME_FOR_AUTHENTICATION_RETRIES_SEC): '\n Sends an authentication request (first time/refresh) with a retry mechanism.\n :param response_generator (lambda)\n A function ...
def _request_access_token_once(api_key, secret): '\n Sends an access token REST request and returns the response.\n ' return requests.request('POST', AUTH_API_TOKEN_URL, headers=BASIC_HEADER, json={'clientId': api_key, 'secret': secret})
896,239,106,726,657,700
Sends an access token REST request and returns the response.
mona_sdk/authentication.py
_request_access_token_once
TalzMona/mona-sdk
python
def _request_access_token_once(api_key, secret): '\n \n ' return requests.request('POST', AUTH_API_TOKEN_URL, headers=BASIC_HEADER, json={'clientId': api_key, 'secret': secret})
def _request_refresh_token_once(refresh_token_key): '\n Sends a refresh token REST request and returns the response.\n ' return requests.request('POST', REFRESH_TOKEN_URL, headers=BASIC_HEADER, json={'refreshToken': refresh_token_key})
2,580,173,910,022,958,600
Sends a refresh token REST request and returns the response.
mona_sdk/authentication.py
_request_refresh_token_once
TalzMona/mona-sdk
python
def _request_refresh_token_once(refresh_token_key): '\n \n ' return requests.request('POST', REFRESH_TOKEN_URL, headers=BASIC_HEADER, json={'refreshToken': refresh_token_key})
def _create_a_bad_response(content): '\n :param: content (str)\n The content of the response.\n :return: A functioning bad REST response instance with the given content.\n ' response = Response() response.status_code = 400 if (type(content) is str): response._content = bytes(...
8,681,903,556,756,483,000
:param: content (str) The content of the response. :return: A functioning bad REST response instance with the given content.
mona_sdk/authentication.py
_create_a_bad_response
TalzMona/mona-sdk
python
def _create_a_bad_response(content): '\n :param: content (str)\n The content of the response.\n :return: A functioning bad REST response instance with the given content.\n ' response = Response() response.status_code = 400 if (type(content) is str): response._content = bytes(...
def get_current_token_by_api_key(api_key): "\n :return: The given api_key's current access token.\n " return _get_token_info_by_api_key(api_key, ACCESS_TOKEN)
2,081,441,044,815,147,500
:return: The given api_key's current access token.
mona_sdk/authentication.py
get_current_token_by_api_key
TalzMona/mona-sdk
python
def get_current_token_by_api_key(api_key): "\n \n " return _get_token_info_by_api_key(api_key, ACCESS_TOKEN)
def _get_token_info_by_api_key(api_key, token_data_arg): '\n Returns the value of the wanted data for the given api_key.\n Returns None if the api_key or the arg does not exist.\n ' return API_KEYS_TO_TOKEN_DATA.get(api_key, {}).get(token_data_arg)
-1,166,280,672,322,913,800
Returns the value of the wanted data for the given api_key. Returns None if the api_key or the arg does not exist.
mona_sdk/authentication.py
_get_token_info_by_api_key
TalzMona/mona-sdk
python
def _get_token_info_by_api_key(api_key, token_data_arg): '\n Returns the value of the wanted data for the given api_key.\n Returns None if the api_key or the arg does not exist.\n ' return API_KEYS_TO_TOKEN_DATA.get(api_key, {}).get(token_data_arg)
def is_authenticated(api_key): "\n :return: True if Mona's client holds a valid token and can communicate with Mona's\n servers (or can refresh the token in order to), False otherwise.\n " return _get_token_info_by_api_key(api_key, IS_AUTHENTICATED)
4,448,667,322,111,320,600
:return: True if Mona's client holds a valid token and can communicate with Mona's servers (or can refresh the token in order to), False otherwise.
mona_sdk/authentication.py
is_authenticated
TalzMona/mona-sdk
python
def is_authenticated(api_key): "\n :return: True if Mona's client holds a valid token and can communicate with Mona's\n servers (or can refresh the token in order to), False otherwise.\n " return _get_token_info_by_api_key(api_key, IS_AUTHENTICATED)
def _set_api_key_authentication_status(api_key, bool_value): '\n Sets the IS_AUTHENTICATED arg in the token data dict of the given api_key, this\n setter is only needed to spare redundant calls for authentication.\n ' API_KEYS_TO_TOKEN_DATA[api_key][IS_AUTHENTICATED] = bool_value
-4,218,618,756,367,162,400
Sets the IS_AUTHENTICATED arg in the token data dict of the given api_key, this setter is only needed to spare redundant calls for authentication.
mona_sdk/authentication.py
_set_api_key_authentication_status
TalzMona/mona-sdk
python
def _set_api_key_authentication_status(api_key, bool_value): '\n Sets the IS_AUTHENTICATED arg in the token data dict of the given api_key, this\n setter is only needed to spare redundant calls for authentication.\n ' API_KEYS_TO_TOKEN_DATA[api_key][IS_AUTHENTICATED] = bool_value
def _calculate_and_set_time_to_refresh(api_key): '\n Calculates the time the access token needs to be refreshed and updates the relevant\n api_key token data.\n ' if is_authenticated(api_key): token_expires = datetime.datetime.strptime(_get_token_info_by_api_key(api_key, EXPIRES), TOKEN_EXPIRED...
-1,675,712,254,189,625,000
Calculates the time the access token needs to be refreshed and updates the relevant api_key token data.
mona_sdk/authentication.py
_calculate_and_set_time_to_refresh
TalzMona/mona-sdk
python
def _calculate_and_set_time_to_refresh(api_key): '\n Calculates the time the access token needs to be refreshed and updates the relevant\n api_key token data.\n ' if is_authenticated(api_key): token_expires = datetime.datetime.strptime(_get_token_info_by_api_key(api_key, EXPIRES), TOKEN_EXPIRED...
def _handle_authentications_error(error_message): '\n Logs an error and raises MonaAuthenticationException if\n RAISE_AUTHENTICATION_EXCEPTIONS is true, else returns false.\n ' get_logger().error(error_message) if RAISE_AUTHENTICATION_EXCEPTIONS: raise MonaAuthenticationException(error_mess...
1,139,361,633,615,693,800
Logs an error and raises MonaAuthenticationException if RAISE_AUTHENTICATION_EXCEPTIONS is true, else returns false.
mona_sdk/authentication.py
_handle_authentications_error
TalzMona/mona-sdk
python
def _handle_authentications_error(error_message): '\n Logs an error and raises MonaAuthenticationException if\n RAISE_AUTHENTICATION_EXCEPTIONS is true, else returns false.\n ' get_logger().error(error_message) if RAISE_AUTHENTICATION_EXCEPTIONS: raise MonaAuthenticationException(error_mess...
def _should_refresh_token(api_key): '\n :return: True if the token has expired, or is about to expire in\n REFRESH_TOKEN_SAFETY_MARGIN hours or less, False otherwise.\n ' return (_get_token_info_by_api_key(api_key, TIME_TO_REFRESH) < datetime.datetime.now())
-2,934,975,799,896,226,300
:return: True if the token has expired, or is about to expire in REFRESH_TOKEN_SAFETY_MARGIN hours or less, False otherwise.
mona_sdk/authentication.py
_should_refresh_token
TalzMona/mona-sdk
python
def _should_refresh_token(api_key): '\n :return: True if the token has expired, or is about to expire in\n REFRESH_TOKEN_SAFETY_MARGIN hours or less, False otherwise.\n ' return (_get_token_info_by_api_key(api_key, TIME_TO_REFRESH) < datetime.datetime.now())
def _refresh_token(api_key): '\n Gets a new token and sets the needed fields.\n ' refresh_token_key = _get_token_info_by_api_key(api_key, REFRESH_TOKEN) response = _request_refresh_token_with_retries(refresh_token_key) authentications_response_info = response.json() if (not response.ok): ...
2,829,551,205,414,393,300
Gets a new token and sets the needed fields.
mona_sdk/authentication.py
_refresh_token
TalzMona/mona-sdk
python
def _refresh_token(api_key): '\n \n ' refresh_token_key = _get_token_info_by_api_key(api_key, REFRESH_TOKEN) response = _request_refresh_token_with_retries(refresh_token_key) authentications_response_info = response.json() if (not response.ok): return _handle_authentications_error(f'Co...
@classmethod def refresh_token_if_needed(cls, decorated): "\n This decorator checks if the current client's access token is about to\n be expired/already expired, and if so, updates to a new one.\n " @wraps(decorated) def inner(*args, **kwargs): api_key = args[0]._api_key ...
-2,552,210,874,975,340,500
This decorator checks if the current client's access token is about to be expired/already expired, and if so, updates to a new one.
mona_sdk/authentication.py
refresh_token_if_needed
TalzMona/mona-sdk
python
@classmethod def refresh_token_if_needed(cls, decorated): "\n This decorator checks if the current client's access token is about to\n be expired/already expired, and if so, updates to a new one.\n " @wraps(decorated) def inner(*args, **kwargs): api_key = args[0]._api_key ...
def __init__(self, filename): 'Initialize exceptions interface.' with open(filename) as fname: self.exceptions = yaml.safe_load(fname)
-3,824,527,174,756,549,000
Initialize exceptions interface.
statick_tool/exceptions.py
__init__
axydes/statick
python
def __init__(self, filename): with open(filename) as fname: self.exceptions = yaml.safe_load(fname)
def get_ignore_packages(self): 'Get list of packages to skip when scanning a workspace.' ignore = [] if (('ignore_packages' in self.exceptions) and (self.exceptions['ignore_packages'] is not None)): ignore = self.exceptions['ignore_packages'] return ignore
-477,062,781,152,776,700
Get list of packages to skip when scanning a workspace.
statick_tool/exceptions.py
get_ignore_packages
axydes/statick
python
def get_ignore_packages(self): ignore = [] if (('ignore_packages' in self.exceptions) and (self.exceptions['ignore_packages'] is not None)): ignore = self.exceptions['ignore_packages'] return ignore
def get_exceptions(self, package): 'Get specific exceptions for given package.' exceptions = {'file': [], 'message_regex': []} if (('global' in self.exceptions) and ('exceptions' in self.exceptions['global'])): global_exceptions = self.exceptions['global']['exceptions'] if ('file' in global_...
684,870,473,872,272,800
Get specific exceptions for given package.
statick_tool/exceptions.py
get_exceptions
axydes/statick
python
def get_exceptions(self, package): exceptions = {'file': [], 'message_regex': []} if (('global' in self.exceptions) and ('exceptions' in self.exceptions['global'])): global_exceptions = self.exceptions['global']['exceptions'] if ('file' in global_exceptions): exceptions['file'] ...
def filter_file_exceptions_early(self, package, file_list): "\n Filter files based on file pattern exceptions list.\n\n Only filters files which have tools=all, intended for use after the\n discovery plugins have been run (so that Statick doesn't run the tool\n plugins against files whic...
-1,934,236,728,198,714,000
Filter files based on file pattern exceptions list. Only filters files which have tools=all, intended for use after the discovery plugins have been run (so that Statick doesn't run the tool plugins against files which will be ignored anyway).
statick_tool/exceptions.py
filter_file_exceptions_early
axydes/statick
python
def filter_file_exceptions_early(self, package, file_list): "\n Filter files based on file pattern exceptions list.\n\n Only filters files which have tools=all, intended for use after the\n discovery plugins have been run (so that Statick doesn't run the tool\n plugins against files whic...
def filter_file_exceptions(self, package, exceptions, issues): 'Filter issues based on file pattern exceptions list.' for (tool, tool_issues) in list(issues.items()): warning_printed = False to_remove = [] for issue in tool_issues: if (not os.path.isabs(issue.filename)): ...
-7,031,852,162,055,159,000
Filter issues based on file pattern exceptions list.
statick_tool/exceptions.py
filter_file_exceptions
axydes/statick
python
def filter_file_exceptions(self, package, exceptions, issues): for (tool, tool_issues) in list(issues.items()): warning_printed = False to_remove = [] for issue in tool_issues: if (not os.path.isabs(issue.filename)): if (not warning_printed): ...
@classmethod def filter_regex_exceptions(cls, exceptions, issues): 'Filter issues based on message regex exceptions list.' for exception in exceptions: exception_re = exception['regex'] exception_tools = exception['tools'] compiled_re = re.compile(exception_re) for (tool, tool_is...
-5,461,150,174,868,070,000
Filter issues based on message regex exceptions list.
statick_tool/exceptions.py
filter_regex_exceptions
axydes/statick
python
@classmethod def filter_regex_exceptions(cls, exceptions, issues): for exception in exceptions: exception_re = exception['regex'] exception_tools = exception['tools'] compiled_re = re.compile(exception_re) for (tool, tool_issues) in list(issues.items()): to_remove = ...
def filter_nolint(self, issues): "\n Filter out lines that have an explicit NOLINT on them.\n\n Sometimes the tools themselves don't properly filter these out if\n there is a complex macro or something.\n " for (tool, tool_issues) in list(issues.items()): warning_printed = Fa...
3,960,404,777,609,598,000
Filter out lines that have an explicit NOLINT on them. Sometimes the tools themselves don't properly filter these out if there is a complex macro or something.
statick_tool/exceptions.py
filter_nolint
axydes/statick
python
def filter_nolint(self, issues): "\n Filter out lines that have an explicit NOLINT on them.\n\n Sometimes the tools themselves don't properly filter these out if\n there is a complex macro or something.\n " for (tool, tool_issues) in list(issues.items()): warning_printed = Fa...
def filter_issues(self, package, issues): 'Filter issues based on exceptions list.' exceptions = self.get_exceptions(package) if exceptions['file']: issues = self.filter_file_exceptions(package, exceptions['file'], issues) if exceptions['message_regex']: issues = self.filter_regex_except...
739,342,406,282,945,700
Filter issues based on exceptions list.
statick_tool/exceptions.py
filter_issues
axydes/statick
python
def filter_issues(self, package, issues): exceptions = self.get_exceptions(package) if exceptions['file']: issues = self.filter_file_exceptions(package, exceptions['file'], issues) if exceptions['message_regex']: issues = self.filter_regex_exceptions(exceptions['message_regex'], issues)...
@classmethod def print_exception_warning(cls, tool): '\n Print warning about exception not being applied for an issue.\n\n Warning will only be printed once per tool.\n ' print('[WARNING] File exceptions not available for {} tool plugin due to lack of absolute paths for issues.'.format(tool...
6,992,496,818,379,847,000
Print warning about exception not being applied for an issue. Warning will only be printed once per tool.
statick_tool/exceptions.py
print_exception_warning
axydes/statick
python
@classmethod def print_exception_warning(cls, tool): '\n Print warning about exception not being applied for an issue.\n\n Warning will only be printed once per tool.\n ' print('[WARNING] File exceptions not available for {} tool plugin due to lack of absolute paths for issues.'.format(tool...
def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): 'IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList - a model defined in OpenAPI' if (local_vars_configuration is None): local_vars_configuration = Configuration() self.local_vars_config...
6,291,405,993,752,813,000
IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList - a model defined in OpenAPI
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
__init__
mariusgheorghies/python
python
def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): if (local_vars_configuration is None): local_vars_configuration = Configuration() self.local_vars_configuration = local_vars_configuration self._api_version = None self._items = None ...
@property def api_version(self): 'Gets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrec...
4,384,381,070,071,019,500
Gets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/co...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
api_version
mariusgheorghies/python
python
@property def api_version(self): 'Gets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrec...
@api_version.setter def api_version(self, api_version): 'Sets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may rej...
2,410,444,314,191,797,000
Sets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contri...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
api_version
mariusgheorghies/python
python
@api_version.setter def api_version(self, api_version): 'Sets the api_version of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may rej...
@property def items(self): 'Gets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501\n\n :return: The items of this IoXK8...
5,934,657,655,099,130,000
Gets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501 :return: The items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
items
mariusgheorghies/python
python
@property def items(self): 'Gets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501\n\n :return: The items of this IoXK8...
@items.setter def items(self, items): 'Sets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501\n\n :param items: The items of this IoX...
-8,176,135,908,638,800,000
Sets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501 :param items: The items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
items
mariusgheorghies/python
python
@items.setter def items(self, items): 'Sets the items of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n List of awsclustertemplates. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md # noqa: E501\n\n :param items: The items of this IoX...
@property def kind(self): 'Gets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase....
1,721,828,530,106,403,300
Gets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
kind
mariusgheorghies/python
python
@property def kind(self): 'Gets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase....
@kind.setter def kind(self, kind): 'Sets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More...
5,888,563,764,424,450,000
Sets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/d...
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
kind
mariusgheorghies/python
python
@kind.setter def kind(self, kind): 'Sets the kind of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More...
@property def metadata(self): 'Gets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n\n :return: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n :rtype: V1ListMeta\n ' return self._metadata
-686,375,580,806,189,600
Gets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 :return: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 :rtype: V1ListMeta
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
metadata
mariusgheorghies/python
python
@property def metadata(self): 'Gets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n\n\n :return: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n :rtype: V1ListMeta\n ' return self._metadata
@metadata.setter def metadata(self, metadata): 'Sets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n\n :param metadata: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n :type: V1ListMeta\n ' self._metadata = ...
8,255,552,889,854,053,000
Sets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. :param metadata: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501 :type: V1ListMeta
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
metadata
mariusgheorghies/python
python
@metadata.setter def metadata(self, metadata): 'Sets the metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList.\n\n\n :param metadata: The metadata of this IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList. # noqa: E501\n :type: V1ListMeta\n ' self._metadata = ...
def to_dict(self): 'Returns the model properties as a dict' result = {} for (attr, _) in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map((lambda x: (x.to_dict() if hasattr(x, 'to_dict') else x)), value)) e...
8,442,519,487,048,767,000
Returns the model properties as a dict
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
to_dict
mariusgheorghies/python
python
def to_dict(self): result = {} for (attr, _) in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map((lambda x: (x.to_dict() if hasattr(x, 'to_dict') else x)), value)) elif hasattr(value, 'to_dict'): ...
def to_str(self): 'Returns the string representation of the model' return pprint.pformat(self.to_dict())
5,849,158,643,760,736,000
Returns the string representation of the model
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
to_str
mariusgheorghies/python
python
def to_str(self): return pprint.pformat(self.to_dict())
def __repr__(self): 'For `print` and `pprint`' return self.to_str()
-8,960,031,694,814,905,000
For `print` and `pprint`
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
__repr__
mariusgheorghies/python
python
def __repr__(self): return self.to_str()
def __eq__(self, other): 'Returns true if both objects are equal' if (not isinstance(other, IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList)): return False return (self.to_dict() == other.to_dict())
7,353,354,793,238,505,000
Returns true if both objects are equal
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
__eq__
mariusgheorghies/python
python
def __eq__(self, other): if (not isinstance(other, IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList)): return False return (self.to_dict() == other.to_dict())
def __ne__(self, other): 'Returns true if both objects are not equal' if (not isinstance(other, IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList)): return True return (self.to_dict() != other.to_dict())
-324,507,109,502,987,460
Returns true if both objects are not equal
kubernetes/client/models/io_xk8s_cluster_infrastructure_v1alpha4_aws_cluster_template_list.py
__ne__
mariusgheorghies/python
python
def __ne__(self, other): if (not isinstance(other, IoXK8sClusterInfrastructureV1alpha4AWSClusterTemplateList)): return True return (self.to_dict() != other.to_dict())
def hashimg(self, im): ' Compute a hash for an image, useful for image comparisons ' return hashlib.md5(im.tostring()).digest()
4,447,783,696,848,638,000
Compute a hash for an image, useful for image comparisons
modules/python/test/tests_common.py
hashimg
552103917/opcv3.4
python
def hashimg(self, im): ' ' return hashlib.md5(im.tostring()).digest()
def hashimg(self, im): ' Compute a hash for an image, useful for image comparisons ' return hashlib.md5(im.tostring()).hexdigest()
8,186,755,235,098,888,000
Compute a hash for an image, useful for image comparisons
modules/python/test/tests_common.py
hashimg
552103917/opcv3.4
python
def hashimg(self, im): ' ' return hashlib.md5(im.tostring()).hexdigest()
def bbox_to_array(arr, label=0, max_bboxes=64, bbox_width=16): '\n Converts a 1-dimensional bbox array to an image-like\n 3-dimensional array CHW array\n ' arr = pad_bbox(arr, max_bboxes, bbox_width) return arr[np.newaxis, :, :]
-3,777,192,725,018,629,000
Converts a 1-dimensional bbox array to an image-like 3-dimensional array CHW array
digits/extensions/data/objectDetection/utils.py
bbox_to_array
dcmartin/digits
python
def bbox_to_array(arr, label=0, max_bboxes=64, bbox_width=16): '\n Converts a 1-dimensional bbox array to an image-like\n 3-dimensional array CHW array\n ' arr = pad_bbox(arr, max_bboxes, bbox_width) return arr[np.newaxis, :, :]
def pad_image(img, padding_image_height, padding_image_width): '\n pad a single image to the specified dimensions\n ' src_width = img.size[0] src_height = img.size[1] if (padding_image_width < src_width): raise ValueError(('Source image width %d is greater than padding width %d' % (src_wid...
120,234,168,022,130,060
pad a single image to the specified dimensions
digits/extensions/data/objectDetection/utils.py
pad_image
dcmartin/digits
python
def pad_image(img, padding_image_height, padding_image_width): '\n \n ' src_width = img.size[0] src_height = img.size[1] if (padding_image_width < src_width): raise ValueError(('Source image width %d is greater than padding width %d' % (src_width, padding_image_width))) if (padding_ima...
@classmethod def lmdb_format_length(cls): '\n width of an LMDB datafield returned by the gt_to_lmdb_format function.\n :return:\n ' return 16
2,400,491,777,051,154,000
width of an LMDB datafield returned by the gt_to_lmdb_format function. :return:
digits/extensions/data/objectDetection/utils.py
lmdb_format_length
dcmartin/digits
python
@classmethod def lmdb_format_length(cls): '\n width of an LMDB datafield returned by the gt_to_lmdb_format function.\n :return:\n ' return 16
def gt_to_lmdb_format(self): '\n For storage of a bbox ground truth object into a float32 LMDB.\n Sort-by attribute is always the last value in the array.\n ' result = [self.bbox.xl, self.bbox.yt, (self.bbox.xr - self.bbox.xl), (self.bbox.yb - self.bbox.yt), self.angle, self.object, 0, sel...
3,714,215,943,155,052,000
For storage of a bbox ground truth object into a float32 LMDB. Sort-by attribute is always the last value in the array.
digits/extensions/data/objectDetection/utils.py
gt_to_lmdb_format
dcmartin/digits
python
def gt_to_lmdb_format(self): '\n For storage of a bbox ground truth object into a float32 LMDB.\n Sort-by attribute is always the last value in the array.\n ' result = [self.bbox.xl, self.bbox.yt, (self.bbox.xr - self.bbox.xl), (self.bbox.yb - self.bbox.yt), self.angle, self.object, 0, sel...