How to use library method in Robotframework

Best Python code snippet using robotframework

core.py

Source:core.py Github

copy

Full Screen

...26 "Instruction",27 "Context",28 "PassRegistry"29]30lib = get_library()31Enums = []32class LLVMEnumeration(object):33 """Represents an individual LLVM enumeration."""34 def __init__(self, name, value):35 self.name = name36 self.value = value37 def __repr__(self):38 return '%s.%s' % (self.__class__.__name__,39 self.name)40 @classmethod41 def from_value(cls, value):42 """Obtain an enumeration instance from a numeric value."""43 result = cls._value_map.get(value, None)44 if result is None:45 raise ValueError('Unknown %s: %d' % (cls.__name__,46 value))47 return result48 @classmethod49 def register(cls, name, value):50 """Registers a new enumeration.51 This is called by this module for each enumeration defined in52 enumerations. You should not need to call this outside this module.53 """54 if value in cls._value_map:55 raise ValueError('%s value already registered: %d' % (cls.__name__,56 value))57 enum = cls(name, value)58 cls._value_map[value] = enum59 setattr(cls, name, enum)60class Attribute(LLVMEnumeration):61 """Represents an individual Attribute enumeration."""62 _value_map = {}63 def __init__(self, name, value):64 super(Attribute, self).__init__(name, value)65class OpCode(LLVMEnumeration):66 """Represents an individual OpCode enumeration."""67 _value_map = {}68 def __init__(self, name, value):69 super(OpCode, self).__init__(name, value)70class TypeKind(LLVMEnumeration):71 """Represents an individual TypeKind enumeration."""72 _value_map = {}73 def __init__(self, name, value):74 super(TypeKind, self).__init__(name, value)75class Linkage(LLVMEnumeration):76 """Represents an individual Linkage enumeration."""77 _value_map = {}78 def __init__(self, name, value):79 super(Linkage, self).__init__(name, value)80class Visibility(LLVMEnumeration):81 """Represents an individual visibility enumeration."""82 _value_map = {}83 def __init__(self, name, value):84 super(Visibility, self).__init__(name, value)85class CallConv(LLVMEnumeration):86 """Represents an individual calling convention enumeration."""87 _value_map = {}88 def __init__(self, name, value):89 super(CallConv, self).__init__(name, value)90class IntPredicate(LLVMEnumeration):91 """Represents an individual IntPredicate enumeration."""92 _value_map = {}93 def __init__(self, name, value):94 super(IntPredicate, self).__init__(name, value)95class RealPredicate(LLVMEnumeration):96 """Represents an individual RealPredicate enumeration."""97 _value_map = {}98 def __init__(self, name, value):99 super(RealPredicate, self).__init__(name, value)100class LandingPadClauseTy(LLVMEnumeration):101 """Represents an individual LandingPadClauseTy enumeration."""102 _value_map = {}103 def __init__(self, name, value):104 super(LandingPadClauseTy, self).__init__(name, value)105class MemoryBuffer(LLVMObject):106 """Represents an opaque memory buffer."""107 def __init__(self, filename=None):108 """Create a new memory buffer.109 Currently, we support creating from the contents of a file at the110 specified filename.111 """112 if filename is None:113 raise Exception("filename argument must be defined")114 memory = c_object_p()115 out = c_char_p(None)116 result = lib.LLVMCreateMemoryBufferWithContentsOfFile(filename,117 byref(memory), byref(out))118 if result:119 raise Exception("Could not create memory buffer: %s" % out.value)120 LLVMObject.__init__(self, memory, disposer=lib.LLVMDisposeMemoryBuffer)121 def __len__(self):122 return lib.LLVMGetBufferSize(self)123class Value(LLVMObject):124 125 def __init__(self, value):126 LLVMObject.__init__(self, value)127 @property128 def name(self):129 return lib.LLVMGetValueName(self)130 def dump(self):131 lib.LLVMDumpValue(self)132 133 def get_operand(self, i):134 return Value(lib.LLVMGetOperand(self, i))135 136 def set_operand(self, i, v):137 return lib.LLVMSetOperand(self, i, v)138 139 def __len__(self):140 return lib.LLVMGetNumOperands(self)141class Module(LLVMObject):142 """Represents the top-level structure of an llvm program in an opaque object."""143 def __init__(self, module, name=None, context=None):144 LLVMObject.__init__(self, module, disposer=lib.LLVMDisposeModule)145 @classmethod146 def CreateWithName(cls, module_id):147 m = Module(lib.LLVMModuleCreateWithName(module_id))148 Context.GetGlobalContext().take_ownership(m)149 return m150 @property151 def datalayout(self):152 return lib.LLVMGetDataLayout(self)153 @datalayout.setter154 def datalayout(self, new_data_layout):155 """new_data_layout is a string."""156 lib.LLVMSetDataLayout(self, new_data_layout)157 @property158 def target(self):159 return lib.LLVMGetTarget(self)160 @target.setter161 def target(self, new_target):162 """new_target is a string."""163 lib.LLVMSetTarget(self, new_target)164 def dump(self):165 lib.LLVMDumpModule(self)166 class __function_iterator(object):167 def __init__(self, module, reverse=False):168 self.module = module169 self.reverse = reverse170 if self.reverse:171 self.function = self.module.last172 else:173 self.function = self.module.first174 175 def __iter__(self):176 return self177 178 def next(self):179 if not isinstance(self.function, Function):180 raise StopIteration("")181 result = self.function182 if self.reverse:183 self.function = self.function.prev184 else:185 self.function = self.function.next186 return result187 188 def __iter__(self):189 return Module.__function_iterator(self)190 def __reversed__(self):191 return Module.__function_iterator(self, reverse=True)192 @property193 def first(self):194 return Function(lib.LLVMGetFirstFunction(self))195 @property196 def last(self):197 return Function(lib.LLVMGetLastFunction(self))198 def print_module_to_file(self, filename):199 out = c_char_p(None)200 # Result is inverted so 0 means everything was ok.201 result = lib.LLVMPrintModuleToFile(self, filename, byref(out)) 202 if result:203 raise RuntimeError("LLVM Error: %s" % out.value)204class Function(Value):205 def __init__(self, value):206 Value.__init__(self, value)207 208 @property209 def next(self):210 f = lib.LLVMGetNextFunction(self)211 return f and Function(f)212 213 @property214 def prev(self):215 f = lib.LLVMGetPreviousFunction(self)216 return f and Function(f)217 218 @property219 def first(self):220 b = lib.LLVMGetFirstBasicBlock(self)221 return b and BasicBlock(b)222 @property223 def last(self):224 b = lib.LLVMGetLastBasicBlock(self)225 return b and BasicBlock(b)226 class __bb_iterator(object):227 def __init__(self, function, reverse=False):228 self.function = function229 self.reverse = reverse230 if self.reverse:231 self.bb = function.last232 else:233 self.bb = function.first234 235 def __iter__(self):236 return self237 238 def next(self):239 if not isinstance(self.bb, BasicBlock):240 raise StopIteration("")241 result = self.bb242 if self.reverse:243 self.bb = self.bb.prev244 else:245 self.bb = self.bb.next246 return result247 248 def __iter__(self):249 return Function.__bb_iterator(self)250 def __reversed__(self):251 return Function.__bb_iterator(self, reverse=True)252 253 def __len__(self):254 return lib.LLVMCountBasicBlocks(self)255class BasicBlock(LLVMObject):256 257 def __init__(self, value):258 LLVMObject.__init__(self, value)259 @property260 def next(self):261 b = lib.LLVMGetNextBasicBlock(self)262 return b and BasicBlock(b)263 @property264 def prev(self):265 b = lib.LLVMGetPreviousBasicBlock(self)266 return b and BasicBlock(b)267 268 @property269 def first(self):270 i = lib.LLVMGetFirstInstruction(self)271 return i and Instruction(i)272 @property273 def last(self):274 i = lib.LLVMGetLastInstruction(self)275 return i and Instruction(i)276 def __as_value(self):277 return Value(lib.LLVMBasicBlockAsValue(self))278 279 @property280 def name(self):281 return lib.LLVMGetValueName(self.__as_value())282 def dump(self):283 lib.LLVMDumpValue(self.__as_value())284 def get_operand(self, i):285 return Value(lib.LLVMGetOperand(self.__as_value(),286 i))287 288 def set_operand(self, i, v):289 return lib.LLVMSetOperand(self.__as_value(),290 i, v)291 292 def __len__(self):293 return lib.LLVMGetNumOperands(self.__as_value())294 class __inst_iterator(object):295 def __init__(self, bb, reverse=False): 296 self.bb = bb297 self.reverse = reverse298 if self.reverse:299 self.inst = self.bb.last300 else:301 self.inst = self.bb.first302 303 def __iter__(self):304 return self305 306 def next(self):307 if not isinstance(self.inst, Instruction):308 raise StopIteration("")309 result = self.inst310 if self.reverse:311 self.inst = self.inst.prev312 else:313 self.inst = self.inst.next314 return result315 316 def __iter__(self):317 return BasicBlock.__inst_iterator(self)318 def __reversed__(self):319 return BasicBlock.__inst_iterator(self, reverse=True)320class Instruction(Value):321 def __init__(self, value):322 Value.__init__(self, value)323 @property324 def next(self):325 i = lib.LLVMGetNextInstruction(self)326 return i and Instruction(i)327 @property328 def prev(self):329 i = lib.LLVMGetPreviousInstruction(self)330 return i and Instruction(i)331 @property332 def opcode(self):333 return OpCode.from_value(lib.LLVMGetInstructionOpcode(self))334class Context(LLVMObject):335 def __init__(self, context=None):336 if context is None:337 context = lib.LLVMContextCreate()338 LLVMObject.__init__(self, context, disposer=lib.LLVMContextDispose)339 else:340 LLVMObject.__init__(self, context)341 @classmethod342 def GetGlobalContext(cls):343 return Context(lib.LLVMGetGlobalContext())344class PassRegistry(LLVMObject):345 """Represents an opaque pass registry object."""346 def __init__(self):347 LLVMObject.__init__(self,348 lib.LLVMGetGlobalPassRegistry())349def register_library(library):350 # Initialization/Shutdown declarations.351 library.LLVMInitializeCore.argtypes = [PassRegistry]352 library.LLVMInitializeCore.restype = None353 library.LLVMInitializeTransformUtils.argtypes = [PassRegistry]354 library.LLVMInitializeTransformUtils.restype = None355 library.LLVMInitializeScalarOpts.argtypes = [PassRegistry]356 library.LLVMInitializeScalarOpts.restype = None357 library.LLVMInitializeObjCARCOpts.argtypes = [PassRegistry]358 library.LLVMInitializeObjCARCOpts.restype = None359 library.LLVMInitializeVectorization.argtypes = [PassRegistry]360 library.LLVMInitializeVectorization.restype = None361 library.LLVMInitializeInstCombine.argtypes = [PassRegistry]362 library.LLVMInitializeInstCombine.restype = None363 library.LLVMInitializeAggressiveInstCombiner.argtypes = [PassRegistry]364 library.LLVMInitializeAggressiveInstCombiner.restype = None365 library.LLVMInitializeIPO.argtypes = [PassRegistry]366 library.LLVMInitializeIPO.restype = None367 library.LLVMInitializeInstrumentation.argtypes = [PassRegistry]368 library.LLVMInitializeInstrumentation.restype = None369 library.LLVMInitializeAnalysis.argtypes = [PassRegistry]370 library.LLVMInitializeAnalysis.restype = None371 library.LLVMInitializeCodeGen.argtypes = [PassRegistry]372 library.LLVMInitializeCodeGen.restype = None373 library.LLVMInitializeTarget.argtypes = [PassRegistry]374 library.LLVMInitializeTarget.restype = None375 library.LLVMShutdown.argtypes = []376 library.LLVMShutdown.restype = None377 # Pass Registry declarations.378 library.LLVMGetGlobalPassRegistry.argtypes = []379 library.LLVMGetGlobalPassRegistry.restype = c_object_p380 # Context declarations.381 library.LLVMContextCreate.argtypes = []382 library.LLVMContextCreate.restype = c_object_p383 library.LLVMContextDispose.argtypes = [Context]384 library.LLVMContextDispose.restype = None385 library.LLVMGetGlobalContext.argtypes = []386 library.LLVMGetGlobalContext.restype = c_object_p387 # Memory buffer declarations388 library.LLVMCreateMemoryBufferWithContentsOfFile.argtypes = [c_char_p,389 POINTER(c_object_p), POINTER(c_char_p)]390 library.LLVMCreateMemoryBufferWithContentsOfFile.restype = bool391 library.LLVMGetBufferSize.argtypes = [MemoryBuffer]392 library.LLVMDisposeMemoryBuffer.argtypes = [MemoryBuffer]393 # Module declarations394 library.LLVMModuleCreateWithName.argtypes = [c_char_p]395 library.LLVMModuleCreateWithName.restype = c_object_p396 library.LLVMDisposeModule.argtypes = [Module]397 library.LLVMDisposeModule.restype = None398 library.LLVMGetDataLayout.argtypes = [Module]399 library.LLVMGetDataLayout.restype = c_char_p400 library.LLVMSetDataLayout.argtypes = [Module, c_char_p]401 library.LLVMSetDataLayout.restype = None402 library.LLVMGetTarget.argtypes = [Module]403 library.LLVMGetTarget.restype = c_char_p404 library.LLVMSetTarget.argtypes = [Module, c_char_p]405 library.LLVMSetTarget.restype = None406 library.LLVMDumpModule.argtypes = [Module]407 library.LLVMDumpModule.restype = None408 library.LLVMPrintModuleToFile.argtypes = [Module, c_char_p,409 POINTER(c_char_p)]410 library.LLVMPrintModuleToFile.restype = bool411 library.LLVMGetFirstFunction.argtypes = [Module]412 library.LLVMGetFirstFunction.restype = c_object_p413 library.LLVMGetLastFunction.argtypes = [Module]414 library.LLVMGetLastFunction.restype = c_object_p415 library.LLVMGetNextFunction.argtypes = [Function]416 library.LLVMGetNextFunction.restype = c_object_p417 library.LLVMGetPreviousFunction.argtypes = [Function]418 library.LLVMGetPreviousFunction.restype = c_object_p419 # Value declarations.420 library.LLVMGetValueName.argtypes = [Value]421 library.LLVMGetValueName.restype = c_char_p422 library.LLVMDumpValue.argtypes = [Value]423 library.LLVMDumpValue.restype = None424 library.LLVMGetOperand.argtypes = [Value, c_uint]425 library.LLVMGetOperand.restype = c_object_p426 library.LLVMSetOperand.argtypes = [Value, Value, c_uint]427 library.LLVMSetOperand.restype = None428 library.LLVMGetNumOperands.argtypes = [Value]429 library.LLVMGetNumOperands.restype = c_uint430 # Basic Block Declarations.431 library.LLVMGetFirstBasicBlock.argtypes = [Function]432 library.LLVMGetFirstBasicBlock.restype = c_object_p433 library.LLVMGetLastBasicBlock.argtypes = [Function]434 library.LLVMGetLastBasicBlock.restype = c_object_p435 library.LLVMGetNextBasicBlock.argtypes = [BasicBlock]436 library.LLVMGetNextBasicBlock.restype = c_object_p437 library.LLVMGetPreviousBasicBlock.argtypes = [BasicBlock]438 library.LLVMGetPreviousBasicBlock.restype = c_object_p439 library.LLVMGetFirstInstruction.argtypes = [BasicBlock]440 library.LLVMGetFirstInstruction.restype = c_object_p441 library.LLVMGetLastInstruction.argtypes = [BasicBlock]442 library.LLVMGetLastInstruction.restype = c_object_p443 library.LLVMBasicBlockAsValue.argtypes = [BasicBlock]444 library.LLVMBasicBlockAsValue.restype = c_object_p445 library.LLVMCountBasicBlocks.argtypes = [Function]446 library.LLVMCountBasicBlocks.restype = c_uint447 # Instruction Declarations.448 library.LLVMGetNextInstruction.argtypes = [Instruction]449 library.LLVMGetNextInstruction.restype = c_object_p450 library.LLVMGetPreviousInstruction.argtypes = [Instruction]451 library.LLVMGetPreviousInstruction.restype = c_object_p452 library.LLVMGetInstructionOpcode.argtypes = [Instruction]453 library.LLVMGetInstructionOpcode.restype = c_uint454def register_enumerations():455 if Enums:456 return None457 enums = [458 (Attribute, enumerations.Attributes),459 (OpCode, enumerations.OpCodes),460 (TypeKind, enumerations.TypeKinds),461 (Linkage, enumerations.Linkages),462 (Visibility, enumerations.Visibility),463 (CallConv, enumerations.CallConv),464 (IntPredicate, enumerations.IntPredicate),465 (RealPredicate, enumerations.RealPredicate),466 (LandingPadClauseTy, enumerations.LandingPadClauseTy),467 ]468 for enum_class, enum_spec in enums:469 for name, value in enum_spec:470 print name, value471 enum_class.register(name, value)472 return enums473def initialize_llvm():474 Context.GetGlobalContext()475 p = PassRegistry()476 lib.LLVMInitializeCore(p)477 lib.LLVMInitializeTransformUtils(p)478 lib.LLVMInitializeScalarOpts(p)479 lib.LLVMInitializeObjCARCOpts(p)480 lib.LLVMInitializeVectorization(p)481 lib.LLVMInitializeInstCombine(p)482 lib.LLVMInitializeIPO(p)483 lib.LLVMInitializeInstrumentation(p)484 lib.LLVMInitializeAnalysis(p)485 lib.LLVMInitializeCodeGen(p)486 lib.LLVMInitializeTarget(p)487register_library(lib)488Enums = register_enumerations()...

Full Screen

Full Screen

componentinfo.py

Source:componentinfo.py Github

copy

Full Screen

1"""2Descriptor objects for entities that are part of the LLVM project.3"""4from __future__ import absolute_import5try:6 import configparser7except:8 import ConfigParser as configparser9import sys10from llvmbuild.util import fatal, warning11class ParseError(Exception):12 pass13class ComponentInfo(object):14 """15 Base class for component descriptions.16 """17 type_name = None18 @staticmethod19 def parse_items(items, has_dependencies = True):20 kwargs = {}21 kwargs['name'] = items.get_string('name')22 kwargs['parent'] = items.get_optional_string('parent')23 if has_dependencies:24 kwargs['dependencies'] = items.get_list('dependencies')25 return kwargs26 def __init__(self, subpath, name, dependencies, parent):27 if not subpath.startswith('/'):28 raise ValueError("invalid subpath: %r" % subpath)29 self.subpath = subpath30 self.name = name31 self.dependencies = list(dependencies)32 # The name of the parent component to logically group this component33 # under.34 self.parent = parent35 # The parent instance, once loaded.36 self.parent_instance = None37 self.children = []38 # The original source path.39 self._source_path = None40 # A flag to mark "special" components which have some amount of magic41 # handling (generally based on command line options).42 self._is_special_group = False43 def set_parent_instance(self, parent):44 assert parent.name == self.parent, "Unexpected parent!"45 self.parent_instance = parent46 self.parent_instance.children.append(self)47 def get_component_references(self):48 """get_component_references() -> iter49 Return an iterator over the named references to other components from50 this object. Items are of the form (reference-type, component-name).51 """52 # Parent references are handled specially.53 for r in self.dependencies:54 yield ('dependency', r)55 def get_llvmbuild_fragment(self):56 abstract57 def get_parent_target_group(self):58 """get_parent_target_group() -> ComponentInfo or None59 Return the nearest parent target group (if any), or None if the60 component is not part of any target group.61 """62 # If this is a target group, return it.63 if self.type_name == 'TargetGroup':64 return self65 # Otherwise recurse on the parent, if any.66 if self.parent_instance:67 return self.parent_instance.get_parent_target_group()68class GroupComponentInfo(ComponentInfo):69 """70 Group components have no semantics as far as the build system are concerned,71 but exist to help organize other components into a logical tree structure.72 """73 type_name = 'Group'74 @staticmethod75 def parse(subpath, items):76 kwargs = ComponentInfo.parse_items(items, has_dependencies = False)77 return GroupComponentInfo(subpath, **kwargs)78 def __init__(self, subpath, name, parent):79 ComponentInfo.__init__(self, subpath, name, [], parent)80 def get_llvmbuild_fragment(self):81 return """\82type = %s83name = %s84parent = %s85""" % (self.type_name, self.name, self.parent)86class LibraryComponentInfo(ComponentInfo):87 type_name = 'Library'88 @staticmethod89 def parse_items(items):90 kwargs = ComponentInfo.parse_items(items)91 kwargs['library_name'] = items.get_optional_string('library_name')92 kwargs['required_libraries'] = items.get_list('required_libraries')93 kwargs['add_to_library_groups'] = items.get_list(94 'add_to_library_groups')95 kwargs['installed'] = items.get_optional_bool('installed', True)96 return kwargs97 @staticmethod98 def parse(subpath, items):99 kwargs = LibraryComponentInfo.parse_items(items)100 return LibraryComponentInfo(subpath, **kwargs)101 def __init__(self, subpath, name, dependencies, parent, library_name,102 required_libraries, add_to_library_groups, installed):103 ComponentInfo.__init__(self, subpath, name, dependencies, parent)104 # If given, the name to use for the library instead of deriving it from105 # the component name.106 self.library_name = library_name107 # The names of the library components which are required when linking108 # with this component.109 self.required_libraries = list(required_libraries)110 # The names of the library group components this component should be111 # considered part of.112 self.add_to_library_groups = list(add_to_library_groups)113 # Whether or not this library is installed.114 self.installed = installed115 def get_component_references(self):116 for r in ComponentInfo.get_component_references(self):117 yield r118 for r in self.required_libraries:119 yield ('required library', r)120 for r in self.add_to_library_groups:121 yield ('library group', r)122 def get_llvmbuild_fragment(self):123 result = """\124type = %s125name = %s126parent = %s127""" % (self.type_name, self.name, self.parent)128 if self.library_name is not None:129 result += 'library_name = %s\n' % self.library_name130 if self.required_libraries:131 result += 'required_libraries = %s\n' % ' '.join(132 self.required_libraries)133 if self.add_to_library_groups:134 result += 'add_to_library_groups = %s\n' % ' '.join(135 self.add_to_library_groups)136 if not self.installed:137 result += 'installed = 0\n'138 return result139 def get_library_name(self):140 return self.library_name or self.name141 def get_prefixed_library_name(self):142 """143 get_prefixed_library_name() -> str144 Return the library name prefixed by the project name. This is generally145 what the library name will be on disk.146 """147 basename = self.get_library_name()148 # FIXME: We need to get the prefix information from an explicit project149 # object, or something.150 if basename in ('gtest', 'gtest_main'):151 return basename152 return 'LLVM%s' % basename153 def get_llvmconfig_component_name(self):154 return self.get_library_name().lower()155class OptionalLibraryComponentInfo(LibraryComponentInfo):156 type_name = "OptionalLibrary"157 @staticmethod158 def parse(subpath, items):159 kwargs = LibraryComponentInfo.parse_items(items)160 return OptionalLibraryComponentInfo(subpath, **kwargs)161 def __init__(self, subpath, name, dependencies, parent, library_name,162 required_libraries, add_to_library_groups, installed):163 LibraryComponentInfo.__init__(self, subpath, name, dependencies, parent,164 library_name, required_libraries,165 add_to_library_groups, installed)166class LibraryGroupComponentInfo(ComponentInfo):167 type_name = 'LibraryGroup'168 @staticmethod169 def parse(subpath, items):170 kwargs = ComponentInfo.parse_items(items, has_dependencies = False)171 kwargs['required_libraries'] = items.get_list('required_libraries')172 kwargs['add_to_library_groups'] = items.get_list(173 'add_to_library_groups')174 return LibraryGroupComponentInfo(subpath, **kwargs)175 def __init__(self, subpath, name, parent, required_libraries = [],176 add_to_library_groups = []):177 ComponentInfo.__init__(self, subpath, name, [], parent)178 # The names of the library components which are required when linking179 # with this component.180 self.required_libraries = list(required_libraries)181 # The names of the library group components this component should be182 # considered part of.183 self.add_to_library_groups = list(add_to_library_groups)184 def get_component_references(self):185 for r in ComponentInfo.get_component_references(self):186 yield r187 for r in self.required_libraries:188 yield ('required library', r)189 for r in self.add_to_library_groups:190 yield ('library group', r)191 def get_llvmbuild_fragment(self):192 result = """\193type = %s194name = %s195parent = %s196""" % (self.type_name, self.name, self.parent)197 if self.required_libraries and not self._is_special_group:198 result += 'required_libraries = %s\n' % ' '.join(199 self.required_libraries)200 if self.add_to_library_groups:201 result += 'add_to_library_groups = %s\n' % ' '.join(202 self.add_to_library_groups)203 return result204 def get_llvmconfig_component_name(self):205 return self.name.lower()206class TargetGroupComponentInfo(ComponentInfo):207 type_name = 'TargetGroup'208 @staticmethod209 def parse(subpath, items):210 kwargs = ComponentInfo.parse_items(items, has_dependencies = False)211 kwargs['required_libraries'] = items.get_list('required_libraries')212 kwargs['add_to_library_groups'] = items.get_list(213 'add_to_library_groups')214 kwargs['has_jit'] = items.get_optional_bool('has_jit', False)215 kwargs['has_asmprinter'] = items.get_optional_bool('has_asmprinter',216 False)217 kwargs['has_asmparser'] = items.get_optional_bool('has_asmparser',218 False)219 kwargs['has_disassembler'] = items.get_optional_bool('has_disassembler',220 False)221 return TargetGroupComponentInfo(subpath, **kwargs)222 def __init__(self, subpath, name, parent, required_libraries = [],223 add_to_library_groups = [], has_jit = False,224 has_asmprinter = False, has_asmparser = False,225 has_disassembler = False):226 ComponentInfo.__init__(self, subpath, name, [], parent)227 # The names of the library components which are required when linking228 # with this component.229 self.required_libraries = list(required_libraries)230 # The names of the library group components this component should be231 # considered part of.232 self.add_to_library_groups = list(add_to_library_groups)233 # Whether or not this target supports the JIT.234 self.has_jit = bool(has_jit)235 # Whether or not this target defines an assembly printer.236 self.has_asmprinter = bool(has_asmprinter)237 # Whether or not this target defines an assembly parser.238 self.has_asmparser = bool(has_asmparser)239 # Whether or not this target defines an disassembler.240 self.has_disassembler = bool(has_disassembler)241 # Whether or not this target is enabled. This is set in response to242 # configuration parameters.243 self.enabled = False244 def get_component_references(self):245 for r in ComponentInfo.get_component_references(self):246 yield r247 for r in self.required_libraries:248 yield ('required library', r)249 for r in self.add_to_library_groups:250 yield ('library group', r)251 def get_llvmbuild_fragment(self):252 result = """\253type = %s254name = %s255parent = %s256""" % (self.type_name, self.name, self.parent)257 if self.required_libraries:258 result += 'required_libraries = %s\n' % ' '.join(259 self.required_libraries)260 if self.add_to_library_groups:261 result += 'add_to_library_groups = %s\n' % ' '.join(262 self.add_to_library_groups)263 for bool_key in ('has_asmparser', 'has_asmprinter', 'has_disassembler',264 'has_jit'):265 if getattr(self, bool_key):266 result += '%s = 1\n' % (bool_key,)267 return result268 def get_llvmconfig_component_name(self):269 return self.name.lower()270class ToolComponentInfo(ComponentInfo):271 type_name = 'Tool'272 @staticmethod273 def parse(subpath, items):274 kwargs = ComponentInfo.parse_items(items)275 kwargs['required_libraries'] = items.get_list('required_libraries')276 return ToolComponentInfo(subpath, **kwargs)277 def __init__(self, subpath, name, dependencies, parent,278 required_libraries):279 ComponentInfo.__init__(self, subpath, name, dependencies, parent)280 # The names of the library components which are required to link this281 # tool.282 self.required_libraries = list(required_libraries)283 def get_component_references(self):284 for r in ComponentInfo.get_component_references(self):285 yield r286 for r in self.required_libraries:287 yield ('required library', r)288 def get_llvmbuild_fragment(self):289 return """\290type = %s291name = %s292parent = %s293required_libraries = %s294""" % (self.type_name, self.name, self.parent,295 ' '.join(self.required_libraries))296class BuildToolComponentInfo(ToolComponentInfo):297 type_name = 'BuildTool'298 @staticmethod299 def parse(subpath, items):300 kwargs = ComponentInfo.parse_items(items)301 kwargs['required_libraries'] = items.get_list('required_libraries')302 return BuildToolComponentInfo(subpath, **kwargs)303###304class IniFormatParser(dict):305 def get_list(self, key):306 # Check if the value is defined.307 value = self.get(key)308 if value is None:309 return []310 # Lists are just whitespace separated strings.311 return value.split()312 def get_optional_string(self, key):313 value = self.get_list(key)314 if not value:315 return None316 if len(value) > 1:317 raise ParseError("multiple values for scalar key: %r" % key)318 return value[0]319 def get_string(self, key):320 value = self.get_optional_string(key)321 if not value:322 raise ParseError("missing value for required string: %r" % key)323 return value324 def get_optional_bool(self, key, default = None):325 value = self.get_optional_string(key)326 if not value:327 return default328 if value not in ('0', '1'):329 raise ParseError("invalid value(%r) for boolean property: %r" % (330 value, key))331 return bool(int(value))332 def get_bool(self, key):333 value = self.get_optional_bool(key)334 if value is None:335 raise ParseError("missing value for required boolean: %r" % key)336 return value337_component_type_map = dict(338 (t.type_name, t)339 for t in (GroupComponentInfo,340 LibraryComponentInfo, LibraryGroupComponentInfo,341 ToolComponentInfo, BuildToolComponentInfo,342 TargetGroupComponentInfo, OptionalLibraryComponentInfo))343def load_from_path(path, subpath):344 # Load the LLVMBuild.txt file as an .ini format file.345 parser = configparser.RawConfigParser()346 parser.read(path)347 # Extract the common section.348 if parser.has_section("common"):349 common = IniFormatParser(parser.items("common"))350 parser.remove_section("common")351 else:352 common = IniFormatParser({})353 return common, _read_components_from_parser(parser, path, subpath)354def _read_components_from_parser(parser, path, subpath):355 # We load each section which starts with 'component' as a distinct component356 # description (so multiple components can be described in one file).357 for section in parser.sections():358 if not section.startswith('component'):359 # We don't expect arbitrary sections currently, warn the user.360 warning("ignoring unknown section %r in %r" % (section, path))361 continue362 # Determine the type of the component to instantiate.363 if not parser.has_option(section, 'type'):364 fatal("invalid component %r in %r: %s" % (365 section, path, "no component type"))366 type_name = parser.get(section, 'type')367 type_class = _component_type_map.get(type_name)368 if type_class is None:369 fatal("invalid component %r in %r: %s" % (370 section, path, "invalid component type: %r" % type_name))371 # Instantiate the component based on the remaining values.372 try:373 info = type_class.parse(subpath,374 IniFormatParser(parser.items(section)))375 except TypeError:376 print >>sys.stderr, "error: invalid component %r in %r: %s" % (377 section, path, "unable to instantiate: %r" % type_name)378 import traceback379 traceback.print_exc()380 raise SystemExit(1)381 except ParseError:382 e = sys.exc_info()[1]383 fatal("unable to load component %r in %r: %s" % (384 section, path, e.message))385 info._source_path = path...

Full Screen

Full Screen

BUILD.bazel

Source:BUILD.bazel Github

copy

Full Screen

...3package(default_visibility = ["//visibility:public"])4##############################################################################5# Common6##############################################################################7proto_library(8 name = "annotations_proto",9 srcs = ["annotations.proto"],10 deps = [11 ":http_proto",12 "@com_google_protobuf//:descriptor_proto",13 ],14)15proto_library(16 name = "auth_proto",17 srcs = ["auth.proto"],18 deps = [":annotations_proto"],19)20proto_library(21 name = "backend_proto",22 srcs = ["backend.proto"],23 visibility = ["//visibility:public"],24)25proto_library(26 name = "billing_proto",27 srcs = ["billing.proto"],28 deps = [29 ":annotations_proto",30 ":metric_proto",31 ],32)33proto_library(34 name = "client_proto",35 srcs = ["client.proto"],36 deps = [37 "@com_google_protobuf//:descriptor_proto",38 ],39)40proto_library(41 name = "config_change_proto",42 srcs = ["config_change.proto"],43 visibility = ["//visibility:public"],44)45proto_library(46 name = "consumer_proto",47 srcs = ["consumer.proto"],48 visibility = ["//visibility:public"],49)50proto_library(51 name = "context_proto",52 srcs = ["context.proto"],53 visibility = ["//visibility:public"],54)55proto_library(56 name = "control_proto",57 srcs = ["control.proto"],58 visibility = ["//visibility:public"],59)60proto_library(61 name = "distribution_proto",62 srcs = ["distribution.proto"],63 deps = [64 ":annotations_proto",65 "@com_google_protobuf//:any_proto",66 "@com_google_protobuf//:timestamp_proto",67 ],68)69proto_library(70 name = "documentation_proto",71 srcs = ["documentation.proto"],72 visibility = ["//visibility:public"],73)74proto_library(75 name = "endpoint_proto",76 srcs = ["endpoint.proto"],77 deps = [":annotations_proto"],78)79proto_library(80 name = "field_behavior_proto",81 srcs = ["field_behavior.proto"],82 deps = [83 "@com_google_protobuf//:descriptor_proto",84 ],85)86proto_library(87 name = "http_proto",88 srcs = ["http.proto"],89 visibility = ["//visibility:public"],90)91proto_library(92 name = "httpbody_proto",93 srcs = ["httpbody.proto"],94 deps = ["@com_google_protobuf//:any_proto"],95)96proto_library(97 name = "label_proto",98 srcs = ["label.proto"],99 visibility = ["//visibility:public"],100)101proto_library(102 name = "launch_stage_proto",103 srcs = ["launch_stage.proto"],104)105proto_library(106 name = "log_proto",107 srcs = ["log.proto"],108 deps = [":label_proto"],109)110proto_library(111 name = "logging_proto",112 srcs = ["logging.proto"],113 deps = [114 ":annotations_proto",115 ":label_proto",116 ],117)118proto_library(119 name = "metric_proto",120 srcs = ["metric.proto"],121 deps = [122 ":label_proto",123 ":launch_stage_proto",124 "@com_google_protobuf//:duration_proto",125 ],126)127proto_library(128 name = "monitored_resource_proto",129 srcs = ["monitored_resource.proto"],130 deps = [131 ":label_proto",132 ":launch_stage_proto",133 "@com_google_protobuf//:struct_proto",134 ],135)136proto_library(137 name = "monitoring_proto",138 srcs = ["monitoring.proto"],139 deps = [":annotations_proto"],140)141proto_library(142 name = "quota_proto",143 srcs = ["quota.proto"],144 deps = [":annotations_proto"],145)146proto_library(147 name = "resource_proto",148 srcs = ["resource.proto"],149 deps = [150 "@com_google_protobuf//:descriptor_proto",151 ],152)153proto_library(154 name = "service_proto",155 srcs = ["service.proto"],156 deps = [157 ":annotations_proto",158 ":auth_proto",159 ":backend_proto",160 ":billing_proto",161 ":context_proto",162 ":control_proto",163 ":documentation_proto",164 ":endpoint_proto",165 ":http_proto",166 ":label_proto",167 ":log_proto",168 ":logging_proto",169 ":metric_proto",170 ":monitored_resource_proto",171 ":monitoring_proto",172 ":quota_proto",173 ":resource_proto",174 ":source_info_proto",175 ":system_parameter_proto",176 ":usage_proto",177 "@com_google_protobuf//:any_proto",178 "@com_google_protobuf//:api_proto",179 "@com_google_protobuf//:type_proto",180 "@com_google_protobuf//:wrappers_proto",181 ],182)183proto_library(184 name = "source_info_proto",185 srcs = ["source_info.proto"],186 deps = ["@com_google_protobuf//:any_proto"],187)188proto_library(189 name = "system_parameter_proto",190 srcs = ["system_parameter.proto"],191 visibility = ["//visibility:public"],192)193proto_library(194 name = "usage_proto",195 srcs = ["usage.proto"],196 deps = [":annotations_proto"],197)198##############################################################################199# Java200##############################################################################201load("@com_google_googleapis_imports//:imports.bzl", "java_proto_library")202java_proto_library(203 name = "api_java_proto",204 deps = [205 "annotations_proto",206 "auth_proto",207 "backend_proto",208 "billing_proto",209 "client_proto",210 "config_change_proto",211 "consumer_proto",212 "context_proto",213 "control_proto",214 "distribution_proto",215 "documentation_proto",216 "endpoint_proto",217 "field_behavior_proto",218 "http_proto",219 "httpbody_proto",220 "label_proto",221 "launch_stage_proto",222 "log_proto",223 "logging_proto",224 "metric_proto",225 "monitored_resource_proto",226 "monitoring_proto",227 "quota_proto",228 "resource_proto",229 "service_proto",230 "source_info_proto",231 "system_parameter_proto",232 "usage_proto",233 ],234)235##############################################################################236# Go237##############################################################################238load("@com_google_googleapis_imports//:imports.bzl", "go_proto_library")239go_proto_library(240 name = "annotations_go_proto",241 importpath = "google.golang.org/genproto/googleapis/api/annotations",242 protos = [243 ":annotations_proto",244 ":http_proto",245 ],246)247go_proto_library(248 name = "client_go_proto",249 importpath = "google.golang.org/genproto/googleapis/api/annotations;annotations",250 protos = [":client_proto"],251)252go_proto_library(253 name = "configchange_go_proto",254 importpath = "google.golang.org/genproto/googleapis/api/configchange",255 protos = [":config_change_proto"],256)257go_proto_library(258 name = "distribution_go_proto",259 importpath = "google.golang.org/genproto/googleapis/api/distribution",260 protos = [":distribution_proto"],261)262go_proto_library(263 name = "field_behavior_go_proto",264 importpath = "google.golang.org/genproto/googleapis/api/annotations;annotations",265 protos = [":field_behavior_proto"],266)267go_proto_library(268 name = "httpbody_go_proto",269 importpath = "google.golang.org/genproto/googleapis/api/httpbody",270 protos = [":httpbody_proto"],271)272go_proto_library(273 name = "label_go_proto",274 importpath = "google.golang.org/genproto/googleapis/api/label",275 protos = [":label_proto"],276)277go_proto_library(278 name = "api_go_proto",279 importpath = "google.golang.org/genproto/googleapis/api",280 protos = [281 ":launch_stage_proto",282 ],283 deps = [284 ":annotations_go_proto",285 ],286)287go_proto_library(288 name = "metric_go_proto",289 importpath = "google.golang.org/genproto/googleapis/api/metric",290 protos = [":metric_proto"],291 deps = [292 ":api_go_proto",293 ":label_go_proto",294 ],295)296go_proto_library(297 name = "monitoredres_go_proto",298 importpath = "google.golang.org/genproto/googleapis/api/monitoredres",299 protos = [":monitored_resource_proto"],300 deps = [301 ":api_go_proto",302 ":label_go_proto",303 ],304)305go_proto_library(306 name = "resource_go_proto",307 importpath = "google.golang.org/genproto/googleapis/api/annotations;annotations",308 protos = [":resource_proto"],309)310go_proto_library(311 name = "serviceconfig_go_proto",312 importpath = "google.golang.org/genproto/googleapis/api/serviceconfig",313 protos = [314 ":auth_proto",315 ":backend_proto",316 ":billing_proto",317 ":context_proto",318 ":control_proto",319 ":documentation_proto",320 ":endpoint_proto",321 ":log_proto",322 ":logging_proto",323 ":monitoring_proto",324 ":quota_proto",325 ":service_proto",326 ":source_info_proto",327 ":system_parameter_proto",328 ":usage_proto",329 ],330 deps = [331 ":annotations_go_proto",332 ":api_go_proto",333 ":label_go_proto",334 ":metric_go_proto",335 ":monitoredres_go_proto",336 ],337)338##############################################################################339# C++340##############################################################################341load("@com_google_googleapis_imports//:imports.bzl", "cc_proto_library")342cc_proto_library(343 name = "annotations_cc_proto",344 deps = [":annotations_proto"],345)346cc_proto_library(347 name = "auth_cc_proto",348 deps = [":auth_proto"],349)350cc_proto_library(351 name = "backend_cc_proto",352 deps = [":backend_proto"],353)354cc_proto_library(355 name = "billing_cc_proto",356 deps = [":billing_proto"],357)358cc_proto_library(359 name = "client_cc_proto",360 deps = [":client_proto"],361)362cc_proto_library(363 name = "config_change_cc_proto",364 deps = [":config_change_proto"],365)366cc_proto_library(367 name = "consumer_cc_proto",368 deps = [":consumer_proto"],369)370cc_proto_library(371 name = "context_cc_proto",372 deps = [":context_proto"],373)374cc_proto_library(375 name = "control_cc_proto",376 deps = [":control_proto"],377)378cc_proto_library(379 name = "distribution_cc_proto",380 deps = [":distribution_proto"],381)382cc_proto_library(383 name = "documentation_cc_proto",384 deps = [":documentation_proto"],385)386cc_proto_library(387 name = "endpoint_cc_proto",388 deps = [":endpoint_proto"],389)390cc_proto_library(391 name = "field_behavior_cc_proto",392 deps = [":field_behavior_proto"],393)394cc_proto_library(395 name = "http_cc_proto",396 deps = [":http_proto"],397)398cc_proto_library(399 name = "httpbody_cc_proto",400 deps = [":httpbody_proto"],401)402cc_proto_library(403 name = "label_cc_proto",404 deps = [":label_proto"],405)406cc_proto_library(407 name = "launch_stage_cc_proto",408 deps = [":launch_stage_proto"],409)410cc_proto_library(411 name = "log_cc_proto",412 deps = [":log_proto"],413)414cc_proto_library(415 name = "logging_cc_proto",416 deps = [":logging_proto"],417)418cc_proto_library(419 name = "metric_cc_proto",420 deps = [":metric_proto"],421)422cc_proto_library(423 name = "monitored_resource_cc_proto",424 deps = [":monitored_resource_proto"],425)426cc_proto_library(427 name = "monitoring_cc_proto",428 deps = ["monitoring_proto"],429)430cc_proto_library(431 name = "quota_cc_proto",432 deps = ["quota_proto"],433)434cc_proto_library(435 name = "resource_cc_proto",436 deps = [":resource_proto"],437)438cc_proto_library(439 name = "service_cc_proto",440 deps = [":service_proto"],441)442cc_proto_library(443 name = "source_info_cc_proto",444 deps = [":source_info_proto"],445)446cc_proto_library(447 name = "system_parameter_cc_proto",448 deps = [":system_parameter_proto"],449)450cc_proto_library(451 name = "usage_cc_proto",452 deps = [":usage_proto"],453)454##############################################################################455# Python456##############################################################################457load("@com_google_googleapis_imports//:imports.bzl", "py_proto_library")458py_proto_library(459 name = "annotations_py_proto",460 deps = [":annotations_proto"],461)462py_proto_library(463 name = "auth_py_proto",464 deps = [":auth_proto"],465)466py_proto_library(467 name = "backend_py_proto",468 deps = [":backend_proto"],469)470py_proto_library(471 name = "billing_py_proto",472 deps = [":billing_proto"],473)474py_proto_library(475 name = "client_py_proto",476 deps = [":client_proto"],477)478py_proto_library(479 name = "config_change_py_proto",480 deps = [":config_change_proto"],481)482py_proto_library(483 name = "consumer_py_proto",484 deps = [":consumer_proto"],485)486py_proto_library(487 name = "context_py_proto",488 deps = [":context_proto"],489)490py_proto_library(491 name = "control_py_proto",492 deps = [":control_proto"],493)494py_proto_library(495 name = "distribution_py_proto",496 deps = [":distribution_proto"],497)498py_proto_library(499 name = "documentation_py_proto",500 deps = [":documentation_proto"],501)502py_proto_library(503 name = "endpoint_py_proto",504 deps = [":endpoint_proto"],505)506py_proto_library(507 name = "field_behavior_py_proto",508 deps = [":field_behavior_proto"],509)510py_proto_library(511 name = "http_py_proto",512 deps = [":http_proto"],513)514py_proto_library(515 name = "httpbody_py_proto",516 deps = [":httpbody_proto"],517)518py_proto_library(519 name = "label_py_proto",520 deps = [":label_proto"],521)522py_proto_library(523 name = "launch_stage_py_proto",524 deps = [":launch_stage_proto"],525)526py_proto_library(527 name = "log_py_proto",528 deps = [":log_proto"],529)530py_proto_library(531 name = "logging_py_proto",532 deps = [":logging_proto"],533)534py_proto_library(535 name = "metric_py_proto",536 deps = [":metric_proto"],537)538py_proto_library(539 name = "monitored_resource_py_proto",540 deps = [":monitored_resource_proto"],541)542py_proto_library(543 name = "monitoring_py_proto",544 deps = ["monitoring_proto"],545)546py_proto_library(547 name = "quota_py_proto",548 deps = ["quota_proto"],549)550py_proto_library(551 name = "resource_py_proto",552 deps = [":resource_proto"],553)554py_proto_library(555 name = "service_py_proto",556 deps = [":service_proto"],557)558py_proto_library(559 name = "source_info_py_proto",560 deps = [":source_info_proto"],561)562py_proto_library(563 name = "system_parameter_py_proto",564 deps = [":system_parameter_proto"],565)566py_proto_library(567 name = "usage_py_proto",568 deps = [":usage_proto"],...

Full Screen

Full Screen

0013_change_lib_item_templates_to_forms.py

Source:0013_change_lib_item_templates_to_forms.py Github

copy

Full Screen

1"""2This migration script eliminates all of the tables that were used for the 1st version of the3library templates where template fields and contents were each stored as a separate table row4in various library item tables. All of these tables are dropped in this script, eliminating all5existing template data. A total of 14 existing tables are dropped.6We're now basing library templates on forms, so field contents are7stored as a jsonified list in the form_values table. This script introduces the following 38new association tables:91) library_info_association102) library_folder_info_association113) library_dataset_dataset_info_association12If using mysql, this script will throw an (OperationalError) exception due to a long index name on13the library_dataset_dataset_info_association table, which is OK because the script creates an index14with a shortened name.15"""16from sqlalchemy import *17from sqlalchemy.orm import *18from sqlalchemy.exc import *19from migrate import *20from migrate.changeset import *21import sys, logging22log = logging.getLogger( __name__ )23log.setLevel(logging.DEBUG)24handler = logging.StreamHandler( sys.stdout )25format = "%(name)s %(levelname)s %(asctime)s %(message)s"26formatter = logging.Formatter( format )27handler.setFormatter( formatter )28log.addHandler( handler )29metadata = MetaData( migrate_engine )30def display_migration_details():31 print "========================================"32 print "This migration script eliminates all of the tables that were used for the 1st version of the"33 print "library templates where template fields and contents were each stored as a separate table row"34 print "in various library item tables. All of these tables are dropped in this script, eliminating all"35 print "existing template data. A total of 14 existing tables are dropped."36 print ""37 print "We're now basing library templates on Galaxy forms, so field contents are stored as a jsonified"38 print "list in the form_values table. This script introduces the following 3 new association tables:"39 print "1) library_info_association"40 print "2) library_folder_info_association"41 print "3) library_dataset_dataset_info_association"42 print ""43 print "If using mysql, this script will throw an (OperationalError) exception due to a long index name"44 print "on the library_dataset_dataset_info_association table, which is OK because the script creates"45 print "an index with a shortened name."46 print "========================================"47if migrate_engine.name == 'postgres':48 # http://blog.pythonisito.com/2008/01/cascading-drop-table-with-sqlalchemy.html49 from sqlalchemy.databases import postgres50 class PGCascadeSchemaDropper(postgres.PGSchemaDropper):51 def visit_table(self, table):52 for column in table.columns:53 if column.default is not None:54 self.traverse_single(column.default)55 self.append("\nDROP TABLE " +56 self.preparer.format_table(table) +57 " CASCADE")58 self.execute()59 postgres.dialect.schemadropper = PGCascadeSchemaDropper60LibraryInfoAssociation_table = Table( 'library_info_association', metadata,61 Column( "id", Integer, primary_key=True),62 Column( "library_id", Integer, ForeignKey( "library.id" ), index=True ),63 Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),64 Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )65LibraryFolderInfoAssociation_table = Table( 'library_folder_info_association', metadata,66 Column( "id", Integer, primary_key=True),67 Column( "library_folder_id", Integer, ForeignKey( "library_folder.id" ), nullable=True, index=True ),68 Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),69 Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )70LibraryDatasetDatasetInfoAssociation_table = Table( 'library_dataset_dataset_info_association', metadata,71 Column( "id", Integer, primary_key=True),72 Column( "library_dataset_dataset_association_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), nullable=True, index=True ),73 Column( "form_definition_id", Integer, ForeignKey( "form_definition.id" ), index=True ),74 Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ) )75 76def upgrade():77 display_migration_details()78 # Load existing tables79 metadata.reflect()80 # Drop all of the original library_item_info tables81 # NOTE: all existing library item into template data is eliminated here via table drops82 try:83 LibraryItemInfoPermissions_table = Table( "library_item_info_permissions", metadata, autoload=True )84 except NoSuchTableError:85 LibraryItemInfoPermissions_table = None86 log.debug( "Failed loading table library_item_info_permissions" )87 try:88 LibraryItemInfoPermissions_table.drop()89 except Exception, e:90 log.debug( "Dropping library_item_info_permissions table failed: %s" % str( e ) )91 try:92 LibraryItemInfoTemplatePermissions_table = Table( "library_item_info_template_permissions", metadata, autoload=True )93 except NoSuchTableError:94 LibraryItemInfoTemplatePermissions_table = None95 log.debug( "Failed loading table library_item_info_template_permissions" )96 try:97 LibraryItemInfoTemplatePermissions_table.drop()98 except Exception, e:99 log.debug( "Dropping library_item_info_template_permissions table failed: %s" % str( e ) )100 try:101 LibraryItemInfoElement_table = Table( "library_item_info_element", metadata, autoload=True )102 except NoSuchTableError:103 LibraryItemInfoElement_table = None104 log.debug( "Failed loading table library_item_info_element" )105 try:106 LibraryItemInfoElement_table.drop()107 except Exception, e:108 log.debug( "Dropping library_item_info_element table failed: %s" % str( e ) )109 try:110 LibraryItemInfoTemplateElement_table = Table( "library_item_info_template_element", metadata, autoload=True )111 except NoSuchTableError:112 LibraryItemInfoTemplateElement_table = None113 log.debug( "Failed loading table library_item_info_template_element" )114 try:115 LibraryItemInfoTemplateElement_table.drop()116 except Exception, e:117 log.debug( "Dropping library_item_info_template_element table failed: %s" % str( e ) )118 try:119 LibraryInfoTemplateAssociation_table = Table( "library_info_template_association", metadata, autoload=True )120 except NoSuchTableError:121 LibraryInfoTemplateAssociation_table = None122 log.debug( "Failed loading table library_info_template_association" )123 try:124 LibraryInfoTemplateAssociation_table.drop()125 except Exception, e:126 log.debug( "Dropping library_info_template_association table failed: %s" % str( e ) )127 try:128 LibraryFolderInfoTemplateAssociation_table = Table( "library_folder_info_template_association", metadata, autoload=True )129 except NoSuchTableError:130 LibraryFolderInfoTemplateAssociation_table = None131 log.debug( "Failed loading table library_folder_info_template_association" )132 try:133 LibraryFolderInfoTemplateAssociation_table.drop()134 except Exception, e:135 log.debug( "Dropping library_folder_info_template_association table failed: %s" % str( e ) )136 try:137 LibraryDatasetInfoTemplateAssociation_table = Table( "library_dataset_info_template_association", metadata, autoload=True )138 except NoSuchTableError:139 LibraryDatasetInfoTemplateAssociation_table = None140 log.debug( "Failed loading table library_dataset_info_template_association" )141 try:142 LibraryDatasetInfoTemplateAssociation_table.drop()143 except Exception, e:144 log.debug( "Dropping library_dataset_info_template_association table failed: %s" % str( e ) )145 try:146 LibraryDatasetDatasetInfoTemplateAssociation_table = Table( "library_dataset_dataset_info_template_association", metadata, autoload=True )147 except NoSuchTableError:148 LibraryDatasetDatasetInfoTemplateAssociation_table = None149 log.debug( "Failed loading table library_dataset_dataset_info_template_association" )150 try:151 LibraryDatasetDatasetInfoTemplateAssociation_table.drop()152 except Exception, e:153 log.debug( "Dropping library_dataset_dataset_info_template_association table failed: %s" % str( e ) )154 try:155 LibraryInfoAssociation_table = Table( "library_info_association", metadata, autoload=True )156 except NoSuchTableError:157 LibraryInfoAssociation_table = None158 log.debug( "Failed loading table library_info_association" )159 try:160 LibraryInfoAssociation_table.drop()161 except Exception, e:162 log.debug( "Dropping library_info_association table failed: %s" % str( e ) )163 try:164 LibraryFolderInfoAssociation_table = Table( "library_folder_info_association", metadata, autoload=True )165 except NoSuchTableError:166 LibraryFolderInfoAssociation_table = None167 log.debug( "Failed loading table library_folder_info_association" )168 try:169 LibraryFolderInfoAssociation_table.drop()170 except Exception, e:171 log.debug( "Dropping library_folder_info_association table failed: %s" % str( e ) )172 try:173 LibraryDatasetInfoAssociation_table = Table( "library_dataset_info_association", metadata, autoload=True )174 except NoSuchTableError:175 LibraryDatasetInfoAssociation_table = None176 log.debug( "Failed loading table library_dataset_info_association" )177 try:178 LibraryDatasetInfoAssociation_table.drop()179 except Exception, e:180 log.debug( "Dropping library_dataset_info_association table failed: %s" % str( e ) )181 try:182 LibraryDatasetDatasetInfoAssociation_table = Table( "library_dataset_dataset_info_association", metadata, autoload=True )183 except NoSuchTableError:184 LibraryDatasetDatasetInfoAssociation_table = None185 log.debug( "Failed loading table library_dataset_dataset_info_association" )186 try:187 LibraryDatasetDatasetInfoAssociation_table.drop()188 except Exception, e:189 log.debug( "Dropping library_dataset_dataset_info_association table failed: %s" % str( e ) )190 try:191 LibraryItemInfo_table = Table( "library_item_info", metadata, autoload=True )192 except NoSuchTableError:193 LibraryItemInfo_table = None194 log.debug( "Failed loading table library_item_info" )195 try:196 LibraryItemInfo_table.drop()197 except Exception, e:198 log.debug( "Dropping library_item_info table failed: %s" % str( e ) )199 try:200 LibraryItemInfoTemplate_table = Table( "library_item_info_template", metadata, autoload=True )201 except NoSuchTableError:202 LibraryItemInfoTemplate_table = None203 log.debug( "Failed loading table library_item_info_template" )204 try:205 LibraryItemInfoTemplate_table.drop()206 except Exception, e:207 log.debug( "Dropping library_item_info_template table failed: %s" % str( e ) )208 # Create all new tables above209 try:210 LibraryInfoAssociation_table.create()211 except Exception, e:212 log.debug( "Creating library_info_association table failed: %s" % str( e ) )213 try:214 LibraryFolderInfoAssociation_table.create()215 except Exception, e:216 log.debug( "Creating library_folder_info_association table failed: %s" % str( e ) )217 try:218 LibraryDatasetDatasetInfoAssociation_table.create()219 except Exception, e:220 log.debug( "Creating library_dataset_dataset_info_association table failed: %s" % str( e ) )221 # Fix index on LibraryDatasetDatasetInfoAssociation_table for mysql222 if migrate_engine.name == 'mysql':223 # Load existing tables224 metadata.reflect()225 i = Index( "ix_lddaia_ldda_id", LibraryDatasetDatasetInfoAssociation_table.c.library_dataset_dataset_association_id )226 try:227 i.create()228 except Exception, e:229 log.debug( "Adding index 'ix_lddaia_ldda_id' to table 'library_dataset_dataset_info_association' table failed: %s" % str( e ) )230def downgrade():...

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 Robotframework 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