How to use first_char_to_lower method in localstack

Best Python code snippet using localstack_python

objc_manager.py

Source:objc_manager.py Github

copy

Full Screen

...152 """153 impl = '+ (instancetype)defaultManager {\n'154 impl += _OBJC_SPACE155 impl += 'return [{1}Director defaultDirector].{0}Manager;\n'.format(156 string_utils.first_char_to_lower(self.object_name), config.objc_prefix)157 impl += '}'158 return impl159 def __convert_bys_to_string(self, by_string_list):160 """Returns "ById:(NSString *)id name:(NSString *)name" or ""161 """162 if len(by_string_list) == 0: # empty string163 return ''164 else: # "(const std::string& id, const std::string& username)"165 bys_string = 'By'166 it = 0167 for by_string in by_string_list:168 objc_var = self.__objc_var_by_name(by_string)169 if objc_var is not None:170 if it == 0:171 bys_string += string_utils.first_char_to_upper(objc_var.parameter()) + ' '172 else:173 bys_string += objc_var.parameter() + ' '174 it += 1175 else:176 print 'Unknown "{0}" in "by"'.format(by_string)177 return ''178 bys_string = bys_string[:-1]179 return bys_string180 def __objc_var_by_name(self, name_string):181 """Returns None if not found.182 """183 for objc_var in self.objc_variable_list:184 if objc_var.name == name_string:185 return objc_var186 return None187 def __fetch_implementation(self, fetch_command, config):188 """Generates Objective-C++ fetch implementation.189 Args:190 fetch_command: A <FetchCommand> object represents necessary info for generating fetch implementation.191 config: A <Config> object represents user-defined info.192 Returns:193 A string which is Objective-C++ fetch implementation.194 """195 by_list = []196 if fetch_command.where != '':197 by_list = re.split(',', fetch_command.where)198 if not fetch_command.is_plural:199 impl = '- (nullable {2}{0} *)fetch{0}FromCache{1} {{\n'\200 .format(self.object_name, self.__convert_bys_to_string(by_list), config.objc_prefix)201 impl += string_utils.indent(2)202 impl += 'std::unique_ptr<{2}::{0}> core{0} = _coreManagerHandler->{1};\n'\203 .format(self.object_name, self.__cpp_fetch_method_name(fetch_command), config.cpp_namespace)204 impl += string_utils.indent(2)205 impl += 'if (core{0}) {{\n'.format(self.object_name)206 impl += string_utils.indent(4)207 impl += 'return [{2}{0} {1}WithCore{0}:*core{0}];\n'\208 .format(self.object_name, string_utils.first_char_to_lower(self.object_name), config.objc_prefix)209 impl += string_utils.indent(2)210 impl += '}\n'211 impl += string_utils.indent(2)212 impl += 'return nil;\n'213 impl += '}'214 return impl215 else:216 impl = '- (NSArray<LCC{0} *> *)fetch{1}FromCache{2} {{\n'\217 .format(self.object_name, self.plural_object_name, self.__convert_bys_to_string(by_list))218 impl += string_utils.indent(2)219 impl += 'NSMutableArray *{0} = [NSMutableArray array];\n'.format(string_utils.first_char_to_lower(self.plural_object_name))220 impl += string_utils.indent(2)221 impl += 'std::vector<std::unique_ptr<{3}::{0}>> core{1} = _coreManagerHandler->{2};\n'\222 .format(self.object_name,223 self.plural_object_name,224 self.__cpp_fetch_method_name(fetch_command),225 config.objc_prefix)226 impl += string_utils.indent(2)227 impl += 'for (auto it = core{0}.begin(); it != core{0}.end(); ++it) {{\n'.format(self.plural_object_name)228 impl += string_utils.indent(4)229 impl += '[{0} addObject:[LCC{1} {2}WithCore{1}:(**it)]];\n'\230 .format(string_utils.first_char_to_lower(self.plural_object_name),231 self.object_name,232 string_utils.first_char_to_lower(self.object_name))233 impl += string_utils.indent(2)234 impl += '}\n'235 impl += string_utils.indent(2)236 impl += 'return [{0} copy];\n'.format(string_utils.first_char_to_lower(self.plural_object_name))237 impl += '}\n'238 self.impl = impl239 return self.impl240 def __cpp_fetch_method_name(self, fetch_command):241 by_list = []242 if fetch_command.where != '':243 by_list = re.split(',', fetch_command.where)244 if not fetch_command.is_plural:245 if len(by_list) == 0:246 skr_log_warning('Singular often comes with at least one by parameter')247 return 'Fetch{0}FromCache{1}'\248 .format(self.object_name, self.__convert_bys_to_cpp_string(by_list))249 else:250 return 'Fetch{0}FromCache{1}'\251 .format(self.plural_object_name, self.__convert_bys_to_cpp_string(by_list))252 def __convert_bys_to_cpp_string(self, by_string_list):253 """Returns "ById([id UTF8String])" or "([id UTF8String], [username UTF8String])" or "()".254 """255 if len(by_string_list) == 0: # ()256 return '()'257 elif len(by_string_list) == 1: # "ById(const std::string& id)"258 by_string = by_string_list[0]259 objc_var = self.__objc_var_by_name(by_string)260 if objc_var is not None:261 return 'By{0}({1})'.format(objc_var.to_title_style_name(), objc_var.cast_to_cpp_parameter())262 else:263 print 'Unknown "{0}" in "by"'.format(by_string)264 return ''265 else: # "([id UTF8String], [username UTF8String])"266 bys_string = '('267 for by_string in by_string_list:268 objc_var = self.__objc_var_by_name(by_string)269 if objc_var is not None:270 bys_string += objc_var.cast_to_cpp_parameter() + ', '271 else:272 print 'Unknown "{0}" in "by"'.format(by_string)273 return ''274 bys_string = bys_string[:-2] # remove last 2 chars275 bys_string += ')'276 return bys_string277 def __web_api_declaration(self, api, config):278 declaration = ''279 declaration += '- (void){0}'.format(string_utils.first_char_to_lower(api.alias))280 if len(api.input_var_list) > 0:281 if len(api.input_var_list) == 1:282 declaration += 'By'283 else:284 declaration += 'With'285 for i, input_var in enumerate(api.input_var_list):286 input_name = string_utils.to_objc_property_name(input_var.name)287 if i == 0:288 input_name = string_utils.first_char_to_upper(input_name)289 declaration += '{0}:({1}){2} '.format(input_name,290 input_var.var_type.to_objc_getter_string(config),291 string_utils.first_char_to_lower(input_name))292 declaration += 'success:(void (^)('293 else:294 declaration += 'Success:(void (^)('295 if len(api.output_var_list) > 0:296 for i, output_var in enumerate(api.output_var_list):297 declaration += output_var.var_type.to_objc_getter_string(config)298 declaration += string_utils.to_objc_property_name(output_var.name)299 if i != len(api.output_var_list) - 1:300 declaration += ', '301 declaration += '))successBlock failure:(void (^)(NSError *error))failureBlock'...

Full Screen

Full Screen

jni_class.py

Source:jni_class.py Github

copy

Full Screen

...150 def __release_impl(self):151 method_name = self.__release_method_name()152 para_name = ' (JNIEnv *env, jobject thiz, jlong handler)'153 step_1 = 'lesschat::{0}* {1} = reinterpret_cast<lesschat::{0}*>(handler);'\154 .format(self.__class_name, string_utils.first_char_to_lower(self.__class_name))155 step_2 = 'LCC_SAFE_DELETE({0});'.format(string_utils.first_char_to_lower(self.__class_name))156 return method_name + '\n' + para_name + '{{\n {0}\n {1}\n}}'.format(step_1, step_2)157 def __jni_get_jobject_by_core_object_declaration(self):158 return 'static jobject GetJ{0}ByCore{0}(const {0}& {1});'.format(159 self.__class_name, string_utils.cpp_class_name_to_cpp_file_name(self.__class_name))160 def __jni_get_jobject_by_core_object_implementation(self, config):161 impl = 'jobject JniHelper::GetJ{0}ByCore{0}(const {0}& {1}) {{\n'.format(162 self.__class_name, string_utils.cpp_class_name_to_cpp_file_name(self.__class_name))163 impl += indent(2) + 'JNIEnv* env = GetJniEnv();\n'164 impl += indent(2) + 'if (!env) {\n'165 impl += indent(4) + 'sakura::log_error("Failed to get JNIEnv");\n'166 impl += indent(4) + 'return nullptr;\n'167 impl += indent(2) + '}\n\n'168 impl += indent(2) + 'jclass {0}Jclass = JniReferenceCache::SharedCache()->{1}_jclass();\n'.format(169 string_utils.first_char_to_lower(self.__class_name),170 string_utils.cpp_class_name_to_cpp_file_name(self.__class_name))171 impl += indent(2) + 'jmethodID {0}ConstructorMethodID = env->GetMethodID({0}Jclass, "<init>", "('.format(172 string_utils.first_char_to_lower(self.__class_name))173 for jni_var in self.__jni_var_list:174 impl += jni_var.var_type.to_jni_signature()175 impl += ')V");\n\n'176 for jni_var in self.__jni_var_list:177 impl += indent(2) + jni_var.jni_var_assignment_by_cpp_variable(config) + '\n'178 impl += '\n'179 constructor_fst_line = indent(2) + 'jobject j{0}Object = env->NewObject('.format(self.__class_name)180 num_constructor_indent = len(constructor_fst_line)181 impl += constructor_fst_line182 parameters = []183 jclass_instance_name = '{0}Jclass'.format(string_utils.first_char_to_lower(self.__class_name))184 constructor_method_id = '{0}ConstructorMethodID'.format(string_utils.first_char_to_lower(self.__class_name))185 parameters.append(constructor_method_id)186 for jni_var in self.__jni_var_list:187 parameters.append('j{0}'.format(string_utils.to_title_style_name(jni_var.name)))188 impl += jclass_instance_name + ',\n'189 for parameter in parameters:190 impl += indent(num_constructor_indent) + parameter + ',\n'191 impl = impl[:-2]192 impl += ');'193 impl += '\n'194 for jni_var in self.__jni_var_list:195 delete_method = jni_var.jni_delete_local_ref()196 if delete_method != '':197 impl += indent(2) + delete_method + '\n'198 impl += '\n'199 impl += indent(2) + 'return j{0}Object;'.format(self.__class_name)200 impl += '\n'201 impl += '}\n'202 impl += '\n'203 return impl204 def __jni_get_jobjects_array_by_core_objects_declaration(self):205 return 'static jobjectArray GetJ{0}sArrayByCore{0}s(const std::vector<std::unique_ptr<{0}>>& {1}s);'.format(206 self.__class_name, string_utils.cpp_class_name_to_cpp_file_name(self.__class_name))207 def __jni_get_jobjects_array_by_core_objects_implementation(self):208 object_name = string_utils.cpp_class_name_to_cpp_file_name(self.__class_name)209 impl = 'jobjectArray JniHelper::GetJ{0}sArrayByCore{0}s(const std::vector<std::unique_ptr<{0}>>& {1}s) {{'.format(210 self.__class_name, object_name)211 impl += '\n'212 impl += indent(2) + 'jclass {0}Jclass = JniReferenceCache::SharedCache()->{1}_jclass();\n'.format(213 string_utils.first_char_to_lower(self.__class_name),214 object_name)215 impl += indent(2) + 'JNIEnv* env = GetJniEnv();\n'216 impl += indent(2) + 'if (!env) {\n'217 impl += indent(4) + 'return env->NewObjectArray(0, {0}Jclass, NULL);\n'.format(218 string_utils.first_char_to_lower(self.__class_name))219 impl += indent(2) + '}\n\n'220 impl += indent(2) + 'jobjectArray jobjs = env->NewObjectArray({0}s.size(), {1}Jclass, NULL);\n\n'.format(221 object_name,222 string_utils.first_char_to_lower(self.__class_name))223 impl += indent(2) + 'jsize i = 0;\n'224 impl += indent(2) + 'for (auto it = {0}s.begin(); it != {0}s.end(); ++it) {{\n'.format(object_name)225 impl += indent(4) + 'jobject j{0} = GetJ{0}ByCore{0}(**it);\n'.format(self.__class_name)226 impl += indent(4) + 'env->SetObjectArrayElement(jobjs, i, j{0});\n'.format(self.__class_name)227 impl += indent(4) + 'env->DeleteLocalRef(j{0});\n'.format(self.__class_name)228 impl += indent(4) + '++i;\n'229 impl += indent(2) + '}\n'230 impl += indent(2) + 'return jobjs;\n'231 impl += '}'...

Full Screen

Full Screen

objc_class.py

Source:objc_class.py Github

copy

Full Screen

...38 output_header.write('\n')39 output_header.write('}')40 output_header.write(_OBJC_BR)41 output_header.write('+ (instancetype){0}WithCore{1}:(const {2}::{1}&)core{1};'42 .format(string_utils.first_char_to_lower(self.class_name),43 self.class_name,44 config.cpp_namespace))45 output_header.write(_OBJC_BR)46 output_header.write('@end')47 def generate_header(self, config):48 """Generates Objective-C++ object header file.49 Args:50 config: A <Config> object represents user-defined configs, in this method, only apple/prefix is used.51 """52 file_name = '{1}{0}.h'.format(self.class_name, config.objc_prefix)53 file_path = _OBJC_BUILD_PATH + string_utils.cpp_group_name_to_objc_group_name(self.group_name) + '/' + file_name54 output_header = open(file_path, 'w')55 output_header.write('#import <Foundation/Foundation.h>')56 output_header.write(_OBJC_BR)57 for objc_enum in self.objc_enum_list:58 output_header.write(objc_enum.generate_objc_enum(self.class_name, config))59 output_header.write(_OBJC_BR)60 output_header.write('NS_ASSUME_NONNULL_BEGIN\n@interface {1}{0} : NSObject'.format(self.class_name,61 config.objc_prefix))62 output_header.write(_OBJC_BR)63 for objc_var in self.objc_var_list:64 output_header.write(objc_var.property(config))65 output_header.write(_OBJC_BR)66 output_header.write('@end\nNS_ASSUME_NONNULL_END')67 output_header.write(_OBJC_BR)68 def generate_implementation(self, config):69 """Generates Objective-C++ object header file.70 Args:71 config: A <Config> object represents user-defined configs, in this method, only apple/prefix is used.72 """73 file_name = '{1}{0}.mm'.format(self.class_name, config.objc_prefix)74 file_path = _OBJC_BUILD_PATH + string_utils.cpp_group_name_to_objc_group_name(self.group_name) + '/' + file_name75 output_impl = open(file_path, 'w')76 output_impl.write('#if !defined(__has_feature) || !__has_feature(objc_arc)\n#error "This file requires ARC support."\n#endif')77 output_impl.write(_OBJC_BR)78 output_impl.write('#import "{1}{0}.h"\n#import "{1}{0}_CoreAddition.h"\n\n#import "{1}ObjcAdapter.h"'.format(79 self.class_name, config.objc_prefix))80 output_impl.write(_OBJC_BR)81 output_impl.write('@implementation {1}{0}'.format(self.class_name, config.objc_prefix))82 output_impl.write(_OBJC_BR)83 output_impl.write('#pragma mark - Property')84 output_impl.write(_OBJC_BR)85 for objc_var in self.objc_var_list:86 output_impl.write(objc_var.getter_impl(config))87 output_impl.write(_OBJC_BR)88 output_impl.write(objc_var.setter_impl(config))89 output_impl.write(_OBJC_BR)90 output_impl.write('#pragma mark - Core Addition')91 output_impl.write(_OBJC_BR)92 output_impl.write('+ (instancetype){0}WithCore{1}:(const {2}::{1}&)core{1} {{\n'93 .format(string_utils.first_char_to_lower(self.class_name),94 self.class_name, config.cpp_namespace))95 output_impl.write(_OBJC_SPACE)96 output_impl.write('{2}{0} *{1} = [[{2}{0} alloc] init];\n'97 .format(self.class_name,98 string_utils.first_char_to_lower(self.class_name),99 config.objc_prefix))100 output_impl.write(_OBJC_SPACE)101 output_impl.write('{0}->_coreHandle = core{1}.Clone();\n'102 .format(string_utils.first_char_to_lower(self.class_name), self.class_name))103 output_impl.write(_OBJC_SPACE)104 output_impl.write('return {0};\n}}'.format(string_utils.first_char_to_lower(self.class_name)))105 output_impl.write(_OBJC_BR)106 output_impl.write('@end\n')107 def generate_manager_core_addition_header(self, config):108 """Generates Objective-C++ object manager private header file.109 Args:110 config: A <Config> object represents user-defined configs, in this method, only apple/prefix is used.111 """112 file_name = '{1}{0}Manager_CoreAddition.h'.format(self.class_name, config.objc_prefix)113 file_path = _OBJC_BUILD_PATH + string_utils.cpp_group_name_to_objc_group_name(self.group_name) + '/' + file_name114 output_header = open(file_path, 'w')115 output_header.write('#include "{0}_manager.h"\n#include "director.h"'.format(116 string_utils.cpp_class_name_to_cpp_file_name(self.class_name)))117 output_header.write(_OBJC_BR)118 output_header.write('@interface {1}{0}Manager () {{\n @private\n'.format(self.class_name, config.objc_prefix))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful