def pixel_drill(task_id=None): parameters = parse_parameters_from_task(task_id=task_id) validate_parameters(parameters, task_id=task_id) task = SpectralIndicesTask.objects.get(pk=task_id) if task.status == "ERROR": return None dc = DataAccessApi(config=task.config_path) single_pixel = dc.get_dataset_by_extent(**parameters).isel(latitude=0, longitude=0) clear_mask = task.satellite.get_clean_mask_func()(single_pixel) single_pixel = single_pixel.where(single_pixel != task.satellite.no_data_value) dates = single_pixel.time.values if len(dates) < 2: task.update_status("ERROR", "There is only a single acquisition for your parameter set.") return None for spectral_index in spectral_indices_map: single_pixel[spectral_index] = spectral_indices_map[spectral_index](single_pixel) exclusion_list = task.satellite.get_measurements() plot_measurements = [band for band in single_pixel.data_vars if band not in exclusion_list] datasets = [single_pixel[band].values.transpose() for band in plot_measurements] + [clear_mask] data_labels = [stringcase.uppercase("{}".format(band)) for band in plot_measurements] + ["Clear"] titles = [stringcase.uppercase("{}".format(band)) for band in plot_measurements] + ["Clear Mask"] style = ['ro', 'go', 'bo', 'co', 'mo', 'yo', 'ko', '.'] task.plot_path = os.path.join(task.get_result_path(), "plot_path.png") create_2d_plot(task.plot_path, dates=dates, datasets=datasets, data_labels=data_labels, titles=titles, style=style) task.complete = True task.update_status("OK", "Done processing pixel drill.")
def test_uppercase(self): from stringcase import uppercase eq = self.assertEqual eq('NONE', uppercase(None)) eq('', uppercase('')) eq('FOO', uppercase('foo'))
def convertFile(file, convertType='c'): readFile = '' if len(file) > 1: readFile = file[0].strip() convertType = file[1].strip() else: readFile = file[0].strip() if readFile[-3:] == 'txt': outfile = readFile.strip('.txt') + "_out.txt" print "Output File: ", outfile o = open(outfile, "w+") f = open(readFile, "r") f1 = f.readlines() for line in f1: if convertType == 's': o.write(stringcase.snakecase(line).strip('_') + '\n') elif convertType == 'a': o.write(stringcase.uppercase(line)) elif convertType == 'l': o.write(stringcase.lowercase(line)) elif convertType == 'p': o.write(stringcase.pascalcase(line)) elif convertType == 'd': o.write(stringcase.pathcase(line).strip('/') + '\n') elif convertType == 'm': o.write(stringcase.spinalcase(line).strip('-') + '\n') else: o.write(stringcase.camelcase(stringcase.lowercase(line))) f.close() o.close() else: print 'You will need to you use a .txt'
def generate_variations(name): return [ # stringcase.snakecase(name), stringcase.camelcase(name), stringcase.uppercase(stringcase.snakecase(name)), stringcase.capitalcase(name), ]
def convertCase(self, data): txt = self.txtInput.text() result = txt if data == 'Alpha Num Case': result = stringcase.alphanumcase(txt) if data == 'Camel Case': result = stringcase.camelcase(txt) if data == 'Capital Case': result = stringcase.capitalcase(txt) if data == 'Const Case': result = stringcase.constcase(txt) if data == 'Lower Case': result = stringcase.lowercase(txt) if data == 'Pascal Case': result = stringcase.pascalcase(txt) if data == 'Path Case': result = stringcase.pathcase(txt) if data == 'Sentence Case': result = stringcase.sentencecase(txt) if data == 'Snake Case': result = stringcase.snakecase(txt) if data == 'Spinal Case': result = stringcase.spinalcase(txt) if data == 'Title Case': result = stringcase.titlecase(txt) if data == 'Trim Case': result = stringcase.trimcase(txt) if data == 'Upper Case': result = stringcase.uppercase(txt) self.lblResult.setText(result) pyperclip.copy(result)
def case_conversion(source, style: StringStyle) -> str: """Case conversion of the input (usually fully qualified vss node inlcuding the path) into a supported string style representation. Args: source: Source string to apply conversion to. style: Target string style to convert source to. Returns: Converted source string according to provided string style. """ if style == StringStyle.ALPHANUM_CASE: return stringcase.alphanumcase(source) elif style == StringStyle.CAMEL_CASE: return camel_case(source) elif style == StringStyle.CAMEL_BACK: return camel_back(source) elif style == StringStyle.CAPITAL_CASE: return stringcase.capitalcase(source) elif style == StringStyle.CONST_CASE: return stringcase.constcase(source) elif style == StringStyle.LOWER_CASE: return stringcase.lowercase(source) elif style == StringStyle.PASCAL_CASE: return stringcase.pascalcase(source) elif style == StringStyle.SENTENCE_CASE: return stringcase.sentencecase(source) elif style == StringStyle.SNAKE_CASE: return stringcase.snakecase(source) elif style == StringStyle.SPINAL_CASE: return stringcase.spinalcase(source) elif style == StringStyle.TITLE_CASE: return stringcase.titlecase(source) elif style == StringStyle.TRIM_CASE: return stringcase.trimcase(source) elif style == StringStyle.UPPER_CASE: return stringcase.uppercase(source) else: return source
def allCaps(value): for value in args.caps: if value is not None: print "All Caps: ", stringcase.uppercase(value)
def _(content): return stringcase.uppercase(content)
def _to_env_config_name(config_name: str) -> str: return uppercase(snakecase(config_name))
def generate_c_files(png_file, header_file_name, cimplementation_file_name, verbose): png_reader = png.Reader(filename=png_file) width, height, data, info = png_reader.asRGBA8() # Remove path prefix png_file = os.path.basename(png_file) # Remove path extension png_file = os.path.splitext(png_file)[0] png_name_snake_case = stringcase.snakecase(png_file) png_name_upper_snake_case = stringcase.uppercase(png_name_snake_case) png_name_camel_case = stringcase.capitalcase( stringcase.camelcase(png_file)) # Convert RGBA888 to RGB565 dataRGB565 = [] for row in data: for i in range(0, len(row), 4): r, g, b, a = row[i], row[i + 1], row[i + 2], row[i + 3] dataRGB565.extend(rgba8882rgb565(r, g, b, a).to_bytes(2, 'little')) # Compress data compressed_data = lz4.block.compress(bytes(dataRGB565), compression=12, mode='high_compression', store_size=False) compressed_data_len = len(compressed_data) # Generate header file header_file = open(header_file_name, "w") header_file.write( "// This file is auto-generated by PNG serializer. Do not edit manually.\n" ) header_file.write("#ifndef " + png_name_upper_snake_case + "_H\n") header_file.write("#define " + png_name_upper_snake_case + "_H\n\n") header_file.write("#include <stdint.h>\n\n") header_file.write("namespace Ion {\n") header_file.write("namespace " + png_name_camel_case + " {\n\n") header_file.write("constexpr uint32_t k_compressedPixelSize = " + str(compressed_data_len) + ";\n\n") header_file.write("constexpr uint32_t k_width = " + str(width) + ";\n\n") header_file.write("constexpr uint32_t k_height = " + str(height) + ";\n\n") header_file.write("extern const uint8_t compressedPixelData[];\n\n") header_file.write("}\n") header_file.write("}\n") header_file.write("#endif\n") header_file.close() # Generate cimplementation file cimplementation_file = open(cimplementation_file_name, "w") cimplementation_file.write( "// This file is auto-generated by Inliner. Do not edit manually.\n") cimplementation_file.write("#include \"" + header_file_name + "\"\n\n") cimplementation_file.write("namespace Ion {\n") cimplementation_file.write("namespace " + png_name_camel_case + " {\n\n") cimplementation_file.write("// Compressed " + str(width * height) + " pixels into " + str(compressed_data_len) + " bytes (" + str(100.0 * compressed_data_len / len(dataRGB565)) + "% compression ratio)\n\n") cimplementation_file.write("const uint8_t compressedPixelData[" + str(compressed_data_len) + "] = {") for b in compressed_data: cimplementation_file.write(hex(b) + ", ") cimplementation_file.write("\n};\n\n") cimplementation_file.write("}\n") cimplementation_file.write("}\n") cimplementation_file.close()