def modpath_to_url(modpath): if modpath[0] in ("http", "https", "ftp", "s3"): if len(modpath) == 1: return modpath[0] + ":" elif len(modpath) == 2: return modpath[0] + ":" + modpath[1] else: return modpath[0] + ":" + modpath[1] + "/" + "/".join( [urllib.quote(part) for part in modpath[2:]]) path = os.path.join(*modpath) return loadimages.pathname2url(path)
def modpath_to_url(modpath): if modpath[0] in ("http", "https", "ftp", "s3"): if len(modpath) == 1: return modpath[0] + ":" elif len(modpath) == 2: return modpath[0] + ":" + modpath[1] else: return modpath[0] + ":" + modpath[1] + "/" + "/".join( [urllib.quote(part) for part in modpath[2:]]) path = os.path.join(*modpath) return loadimages.pathname2url(path)
def prepare_run(self, workspace): m = workspace.measurements assert isinstance(m, cpmeas.Measurements) root = self.get_base_directory(workspace) if m.image_set_count == 0: # Oh bad - using LoadSingleImage to load one image and process it image_numbers = [1] else: image_numbers = m.get_image_numbers() for image_number in image_numbers: dict = self.get_file_names(workspace, image_set_number=image_number) for image_name in dict.keys(): file_settings = self.get_file_settings(image_name) if file_settings.image_objects_choice == IO_IMAGES: # # Add measurements # path_name_category = C_PATH_NAME file_name_category = C_FILE_NAME url_category = C_URL else: # # Add measurements # path_name_category = C_OBJECTS_PATH_NAME file_name_category = C_OBJECTS_FILE_NAME url_category = C_OBJECTS_URL url = pathname2url(os.path.join(root, dict[image_name])) for category, value in ((path_name_category, root), (file_name_category, dict[image_name]), (url_category, url)): measurement_name = "_".join((category, image_name)) m.add_measurement(cpmeas.IMAGE, measurement_name, value, image_set_number=image_number) return True
def prepare_run(self, workspace): m = workspace.measurements assert isinstance(m, cpmeas.Measurements) root = self.get_base_directory(workspace) if m.image_set_count == 0: # Oh bad - using LoadSingleImage to load one image and process it image_numbers = [1] else: image_numbers = m.get_image_numbers() for image_number in image_numbers: dict = self.get_file_names(workspace, image_set_number=image_number) for image_name in dict.keys(): file_settings = self.get_file_settings(image_name) if file_settings.image_objects_choice == IO_IMAGES: # # Add measurements # path_name_category = C_PATH_NAME file_name_category = C_FILE_NAME url_category = C_URL else: # # Add measurements # path_name_category = C_OBJECTS_PATH_NAME file_name_category = C_OBJECTS_FILE_NAME url_category = C_OBJECTS_URL url = pathname2url(os.path.join(root, dict[image_name])) for category, value in ( (path_name_category, root), (file_name_category, dict[image_name]), (url_category, url)): measurement_name = "_".join((category, image_name)) m.add_measurement(cpmeas.IMAGE, measurement_name, value, image_set_number = image_number) return True