_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q244700
VolumeCutout.save_images
train
def save_images(self, directory=None, axis='z', channel=None, global_norm=True, image_format='PNG'): """See cloudvolume.lib.save_images for more information.""" if directory is None: directory = os.path.join('./saved_images', self.dataset_name,
python
{ "resource": "" }
q244701
PrecomputedSkeleton.from_path
train
def from_path(kls, vertices): """ Given an Nx3 array of vertices that constitute a single path, generate a skeleton with appropriate edges. """ if vertices.shape[0] == 0: return PrecomputedSkeleton() skel = PrecomputedSkeleton(vertices) edges = np.zeros(shape=(skel.vertices.shape[0] ...
python
{ "resource": "" }
q244702
PrecomputedSkeleton.simple_merge
train
def simple_merge(kls, skeletons): """ Simple concatenation of skeletons into one object without adding edges between them. """ if len(skeletons) == 0: return PrecomputedSkeleton() if type(skeletons[0]) is np.ndarray: skeletons = [ skeletons ] ct = 0 edges = [] for skel...
python
{ "resource": "" }
q244703
PrecomputedSkeleton.decode
train
def decode(kls, skelbuf, segid=None): """ Convert a buffer into a PrecomputedSkeleton object. Format: num vertices (Nv) (uint32) num edges (Ne) (uint32) XYZ x Nv (float32) edge x Ne (2x uint32) radii x Nv (optional, float32) vertex_type x Nv (optional, req radii, uint8) (SWC definit...
python
{ "resource": "" }
q244704
PrecomputedSkeleton.equivalent
train
def equivalent(kls, first, second): """ Tests that two skeletons are the same in form not merely that their array contents are exactly the same. This test can be made more sophisticated. """ if first.empty() and second.empty(): return True elif first.vertices.shape[0] != second.vertic...
python
{ "resource": "" }
q244705
PrecomputedSkeleton.crop
train
def crop(self, bbox): """ Crop away all vertices and edges that lie outside of the given bbox. The edge counts as inside. Returns: new PrecomputedSkeleton """ skeleton = self.clone() bbox = Bbox.create(bbox) if skeleton.empty(): return skeleton nodes_valid_mask = np.array( ...
python
{ "resource": "" }
q244706
PrecomputedSkeleton.consolidate
train
def consolidate(self): """ Remove duplicate vertices and edges from this skeleton without side effects. Returns: new consolidated PrecomputedSkeleton """ nodes = self.vertices edges = self.edges radii = self.radii vertex_types = self.vertex_types if self.empty(): return...
python
{ "resource": "" }
q244707
PrecomputedSkeleton.downsample
train
def downsample(self, factor): """ Compute a downsampled version of the skeleton by striding while preserving endpoints. factor: stride length for downsampling the saved skeleton paths. Returns: downsampled PrecomputedSkeleton """ if int(factor) != factor or factor < 1: raise ValueEr...
python
{ "resource": "" }
q244708
PrecomputedSkeleton._single_tree_paths
train
def _single_tree_paths(self, tree): """Get all traversal paths from a single tree.""" skel = tree.consolidate() tree = defaultdict(list) for edge in skel.edges: svert = edge[0] evert = edge[1] tree[svert].append(evert) tree[evert].append(svert) def dfs(path, visited): ...
python
{ "resource": "" }
q244709
PrecomputedSkeleton.paths
train
def paths(self): """ Assuming the skeleton is structured as a single tree, return a list of all traversal paths across all components. For each component, start from the first vertex, find the most distant vertex by hops and set that as the root. Then use depth first traversal to produce pat...
python
{ "resource": "" }
q244710
PrecomputedSkeleton.interjoint_paths
train
def interjoint_paths(self): """ Returns paths between the adjacent critical points in the skeleton, where a critical point is the set
python
{ "resource": "" }
q244711
PrecomputedSkeleton.components
train
def components(self): """ Extract connected components from graph. Useful for ensuring that you're working with a single tree. Returns: [ PrecomputedSkeleton, PrecomputedSkeleton, ... ] """ skel, forest = self._compute_components() if len(forest) == 0: return [] elif len(forest)...
python
{ "resource": "" }
q244712
PrecomputedSkeletonService.get
train
def get(self, segids): """ Retrieve one or more skeletons from the data layer. Example: skel = vol.skeleton.get(5) skels = vol.skeleton.get([1, 2, 3]) Raises SkeletonDecodeError on missing files or decoding errors. Required: segids: list of integers or integer Returns: ...
python
{ "resource": "" }
q244713
ThreadedQueue.put
train
def put(self, fn): """ Enqueue a task function for processing. Requires: fn: a function object that takes one argument that is the interface associated with each thread. e.g. def download(api):
python
{ "resource": "" }
q244714
ThreadedQueue.start_threads
train
def start_threads(self, n_threads): """ Terminate existing threads and create a new set if the thread number doesn't match the desired number. Required: n_threads: (int) number of threads to spawn Returns: self """ if n_threads == len(self._threads): return self ...
python
{ "resource": "" }
q244715
ThreadedQueue.kill_threads
train
def kill_threads(self): """Kill all threads.""" self._terminate.set() while self.are_threads_alive():
python
{ "resource": "" }
q244716
ThreadedQueue.wait
train
def wait(self, progress=None): """ Allow background threads to process until the task queue is empty. If there are no threads, in theory the queue should always be empty as processing happens immediately on the main thread. Optional: progress: (bool or str) show a tqdm progress bar option...
python
{ "resource": "" }
q244717
_radix_sort
train
def _radix_sort(L, i=0): """ Most significant char radix sort """ if len(L) <= 1: return L done_bucket = [] buckets = [ [] for x in range(255) ] for s in L: if i >= len(s): done_bucket.append(s) else: buckets[ ord(s[i]) ].append(s)
python
{ "resource": "" }
q244718
Storage.files_exist
train
def files_exist(self, file_paths): """ Threaded exists for all file paths. file_paths: (list) file paths to test for existence Returns: { filepath: bool } """ results = {} def exist_thunk(paths, interface):
python
{ "resource": "" }
q244719
Storage.get_files
train
def get_files(self, file_paths): """ returns a list of files faster by using threads """ results = [] def get_file_thunk(path, interface): result = error = None try: result = interface.get_file(path) except Exception as err: error = err # important to pr...
python
{ "resource": "" }
q244720
S3Interface.get_file
train
def get_file(self, file_path): """ There are many types of execptions which can get raised from this method. We want to make sure we only return None when the file doesn't exist. """ try: resp = self._conn.get_object( Bucket=self._path.bucket, Key=self.get_path_to_fi...
python
{ "resource": "" }
q244721
CloudVolume.init_submodules
train
def init_submodules(self, cache): """cache = path or bool""" self.cache = CacheService(cache,
python
{ "resource": "" }
q244722
CloudVolume.create_new_info
train
def create_new_info(cls, num_channels, layer_type, data_type, encoding, resolution, voxel_offset, volume_size, mesh=None, skeletons=None, chunk_size=(64,64,64), compressed_segmentation_block_size=(8,8,8), max_mip=0, factor=Vec(2,2,1) ): """ Used for creating new neuroglancer info files...
python
{ "resource": "" }
q244723
CloudVolume.bbox_to_mip
train
def bbox_to_mip(self, bbox, mip, to_mip): """Convert bbox or slices from one mip level to another.""" if not type(bbox) is Bbox: bbox = lib.generate_slices( bbox, self.mip_bounds(mip).minpt, self.mip_bounds(mip).maxpt, bounded=False ) bbox = Bbox.from_slices(...
python
{ "resource": "" }
q244724
CloudVolume.slices_to_global_coords
train
def slices_to_global_coords(self, slices): """ Used to convert from a higher mip
python
{ "resource": "" }
q244725
CloudVolume.slices_from_global_coords
train
def slices_from_global_coords(self, slices): """ Used for converting from mip 0 coordinates to upper mip level coordinates. This is mainly useful for debugging since the neuroglancer client displays the mip 0
python
{ "resource": "" }
q244726
CloudVolume.__realized_bbox
train
def __realized_bbox(self, requested_bbox): """ The requested bbox might not be aligned to the underlying chunk grid or even outside the bounds of the dataset. Convert the request
python
{ "resource": "" }
q244727
CloudVolume.exists
train
def exists(self, bbox_or_slices): """ Produce a summary of whether all the requested chunks exist. bbox_or_slices: accepts either a Bbox or a tuple of slices representing the requested volume. Returns: { chunk_file_name: boolean, ... } """ if type(bbox_or_slices) is Bbox: requested...
python
{ "resource": "" }
q244728
CloudVolume.delete
train
def delete(self, bbox_or_slices): """ Delete the files within the bounding box. bbox_or_slices: accepts either a Bbox or a tuple of slices representing the requested volume. """ if type(bbox_or_slices) is Bbox: requested_bbox = bbox_or_slices else: (requested_bbox, _, _) = se...
python
{ "resource": "" }
q244729
CloudVolume.transfer_to
train
def transfer_to(self, cloudpath, bbox, block_size=None, compress=True): """ Transfer files from one storage location to another, bypassing volume painting. This enables using a single CloudVolume instance to transfer big volumes. In some cases, gsutil or aws s3 cli tools may be more appropriate. Thi...
python
{ "resource": "" }
q244730
CloudVolume.download_point
train
def download_point(self, pt, size=256, mip=None): """ Download to the right of point given in mip 0 coords. Useful for quickly visualizing a neuroglancer coordinate at an arbitary mip level. pt: (x,y,z) size: int or (sx,sy,sz) Return: image
python
{ "resource": "" }
q244731
CloudVolume.download_to_shared_memory
train
def download_to_shared_memory(self, slices, location=None): """ Download images to a shared memory array. https://github.com/seung-lab/cloud-volume/wiki/Advanced-Topic:-Shared-Memory tip: If you want to use slice notation, np.s_[...] will help in a pinch. MEMORY LIFECYCLE WARNING: You are respon...
python
{ "resource": "" }
q244732
PrecomputedMeshService.get
train
def get(self, segids, remove_duplicate_vertices=True, fuse=True, chunk_size=None): """ Merge fragments derived from these segids into a single vertex and face list. Why merge multiple segids into one mesh? For example, if you have a set of segids that belong to the same neuron. segids: (...
python
{ "resource": "" }
q244733
PrecomputedMeshService._check_missing_manifests
train
def _check_missing_manifests(self, segids): """Check if there are any missing mesh manifests prior to downloading.""" manifest_paths = [ self._manifest_path(segid) for segid in segids ] with Storage(self.vol.layer_cloudpath, progress=self.vol.progress) as stor: exists = stor.files_exist(manifest_paths...
python
{ "resource": "" }
q244734
PrecomputedMeshService.save
train
def save(self, segids, filepath=None, file_format='ply'): """ Save one or more segids into a common mesh format as a single file. segids: int, string, or list thereof filepath: string or None (optional) file_format: string (optional) Supported Formats: 'obj', 'ply' """ if type(segids) ...
python
{ "resource": "" }
q244735
pad_block
train
def pad_block(block, block_size): """Pad a block to block_size with its most frequent value""" unique_vals, unique_counts = np.unique(block, return_counts=True) most_frequent_value = unique_vals[np.argmax(unique_counts)] return np.pad(block, tuple((0, desired_size - actual_size) ...
python
{ "resource": "" }
q244736
find_closest_divisor
train
def find_closest_divisor(to_divide, closest_to): """ This is used to find the right chunk size for importing a neuroglancer dataset that has a chunk import size that's not evenly divisible by 64,64,64. e.g. neuroglancer_chunk_size = find_closest_divisor(build_chunk_size, closest_to=[64,64,64]) Req...
python
{ "resource": "" }
q244737
divisors
train
def divisors(n): """Generate the divisors of n""" for i in range(1, int(math.sqrt(n)
python
{ "resource": "" }
q244738
Bbox.expand_to_chunk_size
train
def expand_to_chunk_size(self, chunk_size, offset=Vec(0,0,0, dtype=int)): """ Align a potentially non-axis aligned bbox to the grid by growing it to the nearest grid lines. Required: chunk_size: arraylike (x,y,z), the size of chunks in the dataset e.g. (64,64,64) Optional...
python
{ "resource": "" }
q244739
Bbox.round_to_chunk_size
train
def round_to_chunk_size(self, chunk_size, offset=Vec(0,0,0, dtype=int)): """ Align a potentially non-axis aligned bbox to the grid by rounding it to the nearest grid lines. Required: chunk_size: arraylike (x,y,z), the size of chunks in the dataset e.g. (64,64,64) Optional...
python
{ "resource": "" }
q244740
Bbox.contains
train
def contains(self, point): """ Tests if a point on or within a bounding box. Returns: boolean """ return ( point[0] >= self.minpt[0] and point[1] >= self.minpt[1]
python
{ "resource": "" }
q244741
Message.display
train
def display(self, display): """Sets the display of this Message. The form of display for this message # noqa: E501 :param display: The display of this Message. # noqa: E501 :type: str """ if display is None: raise ValueError("Invalid value for `display`, m...
python
{ "resource": "" }
q244742
Message.scope
train
def scope(self, scope): """Sets the scope of this Message. The audience scope that this message should reach # noqa: E501 :param scope: The scope of this Message. # noqa: E501 :type: str """ if scope is None: raise ValueError("Invalid value for `scope`, mu...
python
{ "resource": "" }
q244743
Message.severity
train
def severity(self, severity): """Sets the severity of this Message. Message severity # noqa: E501 :param severity: The severity of this Message. # noqa: E501 :type: str """ if severity is None: raise ValueError("Invalid value for `severity`, must not be `N...
python
{ "resource": "" }
q244744
FacetSearchRequestContainer.facet_query_matching_method
train
def facet_query_matching_method(self, facet_query_matching_method): """Sets the facet_query_matching_method of this FacetSearchRequestContainer. The matching method used to filter when 'facetQuery' is used. Defaults to CONTAINS. # noqa: E501 :param facet_query_matching_method: The facet_query...
python
{ "resource": "" }
q244745
MaintenanceWindow.running_state
train
def running_state(self, running_state): """Sets the running_state of this MaintenanceWindow. :param running_state: The running_state of this MaintenanceWindow. # noqa: E501 :type: str """ allowed_values = ["ONGOING", "PENDING", "ENDED"] # noqa: E501 if running_state n...
python
{ "resource": "" }
q244746
DashboardParameterValue.dynamic_field_type
train
def dynamic_field_type(self, dynamic_field_type): """Sets the dynamic_field_type of this DashboardParameterValue. :param dynamic_field_type: The dynamic_field_type of this DashboardParameterValue. # noqa: E501 :type: str """ allowed_values = ["SOURCE", "SOURCE_TAG", "METRIC_NA...
python
{ "resource": "" }
q244747
DashboardParameterValue.parameter_type
train
def parameter_type(self, parameter_type): """Sets the parameter_type of this DashboardParameterValue. :param parameter_type: The parameter_type of this DashboardParameterValue. # noqa: E501 :type: str """ allowed_values = ["SIMPLE", "LIST", "DYNAMIC"] # noqa: E501 if ...
python
{ "resource": "" }
q244748
ChartSettings.fixed_legend_filter_field
train
def fixed_legend_filter_field(self, fixed_legend_filter_field): """Sets the fixed_legend_filter_field of this ChartSettings. Statistic to use for determining whether a series is displayed on the fixed legend # noqa: E501 :param fixed_legend_filter_field: The fixed_legend_filter_field of this ...
python
{ "resource": "" }
q244749
ChartSettings.fixed_legend_filter_sort
train
def fixed_legend_filter_sort(self, fixed_legend_filter_sort): """Sets the fixed_legend_filter_sort of this ChartSettings. Whether to display \"Top\"- or \"Bottom\"-ranked series in the fixed legend # noqa: E501 :param fixed_legend_filter_sort: The fixed_legend_filter_sort of this ChartSetting...
python
{ "resource": "" }
q244750
ChartSettings.fixed_legend_position
train
def fixed_legend_position(self, fixed_legend_position): """Sets the fixed_legend_position of this ChartSettings. Where the fixed legend should be displayed with respect to the chart # noqa: E501 :param fixed_legend_position: The fixed_legend_position of this ChartSettings. # noqa: E501 ...
python
{ "resource": "" }
q244751
ChartSettings.line_type
train
def line_type(self, line_type): """Sets the line_type of this ChartSettings. Plot interpolation type. linear is default # noqa: E501 :param line_type: The line_type of this ChartSettings. # noqa: E501 :type: str """ allowed_values = ["linear", "step-before", "step-af...
python
{ "resource": "" }
q244752
ChartSettings.sparkline_display_horizontal_position
train
def sparkline_display_horizontal_position(self, sparkline_display_horizontal_position): """Sets the sparkline_display_horizontal_position of this ChartSettings. For the single stat view, the horizontal position of the displayed text # noqa: E501 :param sparkline_display_horizontal_position: T...
python
{ "resource": "" }
q244753
ChartSettings.sparkline_display_value_type
train
def sparkline_display_value_type(self, sparkline_display_value_type): """Sets the sparkline_display_value_type of this ChartSettings. For the single stat view, whether to display the name of the query or the value of query # noqa: E501 :param sparkline_display_value_type: The sparkline_displa...
python
{ "resource": "" }
q244754
ChartSettings.sparkline_size
train
def sparkline_size(self, sparkline_size): """Sets the sparkline_size of this ChartSettings. For the single stat view, a misleadingly named property. This determines whether the sparkline of the statistic is displayed in the chart BACKGROUND, BOTTOM, or NONE # noqa: E501 :param sparkline_size...
python
{ "resource": "" }
q244755
ChartSettings.sparkline_value_color_map_apply_to
train
def sparkline_value_color_map_apply_to(self, sparkline_value_color_map_apply_to): """Sets the sparkline_value_color_map_apply_to of this ChartSettings. For the single stat view, whether to apply dynamic color settings to the displayed TEXT or BACKGROUND # noqa: E501 :param sparkline_value_col...
python
{ "resource": "" }
q244756
ChartSettings.stack_type
train
def stack_type(self, stack_type): """Sets the stack_type of this ChartSettings. Type of stacked chart (applicable only if chart type is stacked). zero (default) means stacked from y=0. expand means Normalized from 0 to 1. wiggle means Minimize weighted changes. silhouette means to Center the Stream ...
python
{ "resource": "" }
q244757
ChartSettings.tag_mode
train
def tag_mode(self, tag_mode): """Sets the tag_mode of this ChartSettings. For the tabular view, which mode to use to determine which point tags to display # noqa: E501 :param tag_mode: The tag_mode of this ChartSettings. # noqa: E501
python
{ "resource": "" }
q244758
ChartSettings.windowing
train
def windowing(self, windowing): """Sets the windowing of this ChartSettings. For the tabular view, whether to use the full time window for the query or the last X minutes # noqa: E501 :param windowing: The windowing of this ChartSettings. # noqa: E501
python
{ "resource": "" }
q244759
ResponseStatus.result
train
def result(self, result): """Sets the result of this ResponseStatus. :param result: The result of this ResponseStatus. # noqa: E501 :type: str """ if result is None: raise ValueError("Invalid value for `result`, must not be `None`") # noqa: E501 allowed_va...
python
{ "resource": "" }
q244760
SearchQuery.matching_method
train
def matching_method(self, matching_method): """Sets the matching_method of this SearchQuery. The method by which search matching is performed. Default: CONTAINS # noqa: E501 :param matching_method: The matching_method of this SearchQuery. # noqa: E501
python
{ "resource": "" }
q244761
Alert.alert_type
train
def alert_type(self, alert_type): """Sets the alert_type of this Alert. Alert type. # noqa: E501 :param alert_type: The alert_type of this Alert. # noqa: E501 :type: str """ allowed_values = ["CLASSIC", "THRESHOLD"] # noqa: E501 if alert_type not in allowed_v...
python
{ "resource": "" }
q244762
Alert.severity_list
train
def severity_list(self, severity_list): """Sets the severity_list of this Alert. Alert severity list for multi-threshold type. # noqa: E501 :param severity_list: The severity_list of this Alert. # noqa: E501 :type: list[str] """ allowed_values = ["INFO", "SMOKE", "WAR...
python
{ "resource": "" }
q244763
AzureActivityLogConfiguration.category_filter
train
def category_filter(self, category_filter): """Sets the category_filter of this AzureActivityLogConfiguration. A list of Azure ActivityLog categories to pull events for.Allowable values are ADMINISTRATIVE, SERVICEHEALTH, ALERT, AUTOSCALE, SECURITY # noqa: E501 :param category_filter: The cate...
python
{ "resource": "" }
q244764
SavedSearch.entity_type
train
def entity_type(self, entity_type): """Sets the entity_type of this SavedSearch. The Wavefront entity type over which to search # noqa: E501 :param entity_type: The entity_type of this SavedSearch. # noqa: E501 :type: str """ if entity_type is None: raise ...
python
{ "resource": "" }
q244765
Chart.summarization
train
def summarization(self, summarization): """Sets the summarization of this Chart. Summarization strategy for the chart. MEAN is default # noqa: E501 :param summarization: The summarization of this Chart. # noqa: E501 :type: str """ allowed_values = ["MEAN", "MEDIAN", ...
python
{ "resource": "" }
q244766
GCPConfiguration.categories_to_fetch
train
def categories_to_fetch(self, categories_to_fetch): """Sets the categories_to_fetch of this GCPConfiguration. A list of Google Cloud Platform (GCP) services (such as ComputeEngine, PubSub, etc) from which to pull metrics. Allowable values are APPENGINE, BIGQUERY, BIGTABLE, CLOUDFUNCTIONS, CLOUDIOT, CL...
python
{ "resource": "" }
q244767
IntegrationStatus.alert_statuses
train
def alert_statuses(self, alert_statuses): """Sets the alert_statuses of this IntegrationStatus. A Map from the ids of the alerts contained in this integration to their install status. The install status can take on one of three values, `VISIBLE`, `HIDDEN`, and `NOT_LOADED` # noqa: E501 :para...
python
{ "resource": "" }
q244768
IntegrationStatus.content_status
train
def content_status(self, content_status): """Sets the content_status of this IntegrationStatus. Status of integration content, e.g. dashboards # noqa: E501 :param content_status: The content_status of this IntegrationStatus. # noqa: E501 :type: str """ if content_stat...
python
{ "resource": "" }
q244769
IntegrationStatus.install_status
train
def install_status(self, install_status): """Sets the install_status of this IntegrationStatus. Whether the customer or an automated process has installed the dashboards for this integration # noqa: E501 :param install_status: The install_status of this IntegrationStatus. # noqa: E501 ...
python
{ "resource": "" }
q244770
Dashboard.event_filter_type
train
def event_filter_type(self, event_filter_type): """Sets the event_filter_type of this Dashboard. How charts belonging to this dashboard should display events. BYCHART is default if unspecified # noqa: E501 :param event_filter_type: The event_filter_type of this Dashboard. # noqa: E501
python
{ "resource": "" }
q244771
ChartSourceQuery.scatter_plot_source
train
def scatter_plot_source(self, scatter_plot_source): """Sets the scatter_plot_source of this ChartSourceQuery. For scatter plots, does this query source the X-axis or the Y-axis # noqa: E501 :param scatter_plot_source: The scatter_plot_source of this ChartSourceQuery. # noqa: E501 :ty...
python
{ "resource": "" }
q244772
Notificant.content_type
train
def content_type(self, content_type): """Sets the content_type of this Notificant. The value of the Content-Type header of the webhook POST request. # noqa: E501 :param content_type: The content_type of this Notificant. # noqa: E501 :type: str """ allowed_values = ["a...
python
{ "resource": "" }
q244773
Notificant.method
train
def method(self, method): """Sets the method of this Notificant. The notification method used for notification target. # noqa: E501 :param method: The method of this Notificant. # noqa: E501 :type: str """ if method is None: raise ValueError("Invalid value...
python
{ "resource": "" }
q244774
Notificant.triggers
train
def triggers(self, triggers): """Sets the triggers of this Notificant. A list of occurrences on which this webhook will be fired. Valid values are ALERT_OPENED, ALERT_UPDATED, ALERT_RESOLVED, ALERT_MAINTENANCE, ALERT_SNOOZED # noqa: E501 :param triggers: The triggers of this Notificant. # n...
python
{ "resource": "" }
q244775
Event.creator_type
train
def creator_type(self, creator_type): """Sets the creator_type of this Event. :param creator_type: The creator_type of this Event. # noqa: E501 :type: list[str] """ allowed_values = ["USER", "ALERT", "SYSTEM"] # noqa: E501
python
{ "resource": "" }
q244776
_integerValue_to_int
train
def _integerValue_to_int(value_str): """ Convert a value string that conforms to DSP0004 `integerValue`, into the corresponding integer and return it. The returned value has Python type `int`, or in Python 2, type `long` if needed. Note that DSP0207 and DSP0004 only allow US-ASCII decimal digits. H...
python
{ "resource": "" }
q244777
_realValue_to_float
train
def _realValue_to_float(value_str): """ Convert a value string that conforms to DSP0004 `realValue`, into the corresponding float and return it. The special values 'INF', '-INF', and 'NAN' are supported. Note that the Python `float()` function supports a superset of input formats compared to t...
python
{ "resource": "" }
q244778
parse_cmdline
train
def parse_cmdline(argparser_): """ Parse the command line. This tests for any required args""" opts = argparser_.parse_args() if not opts.server:
python
{ "resource": "" }
q244779
_statuscode2name
train
def _statuscode2name(status_code): """Return the symbolic name for a CIM status code.""" try: s = _STATUSCODE2NAME[status_code]
python
{ "resource": "" }
q244780
_statuscode2string
train
def _statuscode2string(status_code): """Return a short message for a CIM status code.""" try: s = _STATUSCODE2STRING[status_code] except
python
{ "resource": "" }
q244781
build_mock_repository
train
def build_mock_repository(conn_, file_path_list, verbose): """ Build the mock repository from the file_path list and fake connection instance. This allows both mof files and python files to be used to build the repository. If verbose is True, it displays the respository after it is build as mo...
python
{ "resource": "" }
q244782
_remote_connection
train
def _remote_connection(server, opts, argparser_): """Initiate a remote connection, via PyWBEM. Arguments for the request are part of the command line arguments and include user name, password, namespace, etc. """ global CONN # pylint: disable=global-statement if opts.timeout is not N...
python
{ "resource": "" }
q244783
_get_connection_info
train
def _get_connection_info(): """Return a string with the connection info.""" info = 'Connection: %s,' % CONN.url if CONN.creds is not None: info += ' userid=%s,' % CONN.creds[0] else: info += ' no creds,' info += ' cacerts=%s,' % ('sys-default' if CONN.ca_certs is None ...
python
{ "resource": "" }
q244784
_get_banner
train
def _get_banner(): """Return a banner message for the interactive console.""" result = '' result += '\nPython %s' % _sys.version result += '\n\nWbemcli interactive shell' result += '\n%s' % _get_connection_info() # Give hint about exiting. Most people exit with 'quit()' which will # not re...
python
{ "resource": "" }
q244785
DMTFCIMSchema._setup_dmtf_schema
train
def _setup_dmtf_schema(self): """ Install the DMTF CIM schema from the DMTF web site if it is not already installed. This includes downloading the DMTF CIM schema zip file from the DMTF web site and expanding that file into a subdirectory defined by `schema_mof_dir`. Onc...
python
{ "resource": "" }
q244786
DMTFCIMSchema.clean
train
def clean(self): """ Remove all of the MOF files and the `schema_mof_dir` for the defined schema. This is useful because while the downloaded schema is a single compressed zip file, it creates several thousand MOF files that take up considerable space. The next time the...
python
{ "resource": "" }
q244787
DMTFCIMSchema.remove
train
def remove(self): """ The `schema_mof_dir` directory is removed if it esists and the `schema_zip_file` is removed if it exists. If the `schema_root_dir` is empty after these removals that directory is removed. """ self.clean() if os.path.isfile(self.schema_zip_fil...
python
{ "resource": "" }
q244788
print_table
train
def print_table(title, headers, rows, sort_columns=None): """ Print a table of rows with headers using tabulate. Parameters: title (:term: string): String that will be output before the Table. headers (list or tuple): List of strings that defines the header for each ...
python
{ "resource": "" }
q244789
fold_list
train
def fold_list(input_list, max_width=None): """ Fold the entries in input_list. If max_width is not None, fold only if it is longer than max_width. Otherwise fold each entry. """ if not input_list: return "" if not isinstance(input_list[0], six.string_types): input_list = [str(ite...
python
{ "resource": "" }
q244790
fold_string
train
def fold_string(input_string, max_width): """ Fold a string within a maximum width. Parameters: input_string: The string of data to go into the cell max_width: Maximum width of cell. Data is folded into multiple lines to fit into this width. Return: ...
python
{ "resource": "" }
q244791
path_wo_ns
train
def path_wo_ns(obj): """ Return path of an instance or instance path without host or namespace. Creates copy of the object so the original is not changed. """ if isinstance(obj, pywbem.CIMInstance):
python
{ "resource": "" }
q244792
connect
train
def connect(nickname, server_def, debug=None, timeout=10): """ Connect and confirm server works by testing for a known class in the default namespace or if there is no default namespace defined, in all the possible interop namespaces. returns a WBEMConnection object or None if the connection fails....
python
{ "resource": "" }
q244793
overview
train
def overview(name, server): """ Overview of the server as seen through the properties of the server class. """ print('%s OVERVIEW' % name) print(" Interop namespace: %s" % server.interop_ns) print(" Brand: %s" % server.brand) print(" Version: %s" % server.version) print(" Namespa...
python
{ "resource": "" }
q244794
get_references
train
def get_references(profile_path, role, profile_name, server): """ Get display and return the References for the path provided, ResultClass CIM_ReferencedProfile, and the role provided. """ references_for_profile = server.conn.References( ObjectName=profile_path, ResultClass="CIM_Refe...
python
{ "resource": "" }
q244795
show_profiles
train
def show_profiles(name, server, org_vm): """ Create a table of info about the profiles based on getting the references, etc. both in the dependent and antecedent direction. The resulting table is printed. """ rows = [] for profile_inst in server.profiles: pn = profile_name(org_vm, p...
python
{ "resource": "" }
q244796
fold_path
train
def fold_path(path, width=30): """ Fold a string form of a path so that each element is on separate line """ assert isinstance(path, six.string_types)
python
{ "resource": "" }
q244797
count_ref_associators
train
def count_ref_associators(nickname, server, profile_insts, org_vm): """ Get dict of counts of associator returns for ResultRole == Dependent and ResultRole == Antecedent for profiles in list. This method counts by executing repeated AssociationName calls on CIM_ReferencedProfile for each profile in...
python
{ "resource": "" }
q244798
fast_count_associators
train
def fast_count_associators(server): """ Create count of associators for CIM_ReferencedProfile using the antecedent and dependent reference properties as ResultRole for each profile defined in server.profiles and return a dictionary of the count. This code does a shortcut in executing EnumerateInstan...
python
{ "resource": "" }
q244799
show_instances
train
def show_instances(server, cim_class): """ Display the instances of the CIM_Class defined by cim_class. If the namespace is None, use the interop namespace. Search all namespaces for instances except for CIM_RegisteredProfile """ if cim_class == 'CIM_RegisteredProfile': for inst in serve...
python
{ "resource": "" }