Best Python code snippet using localstack_python
javascript_manager.py
Source:javascript_manager.py
...6 """Adds a required JS file."""7 if not path.endswith('.js'):8 path += '.js'9 self.js_files_needed.append(path)10 def _add_paths(self, base: str, paths: list):11 """Adds multiple required JS files."""12 if not base.endswith('/'):13 base += '/'14 for p in paths:15 self._add_js_file(base + p)16 def _add_linked_lists(self, paths):17 """Utility function."""18 for p in paths:19 self._add_js_file('data_structures/linked_lists/' + p + '/node_' + p)20 self._add_js_file('data_structures/linked_lists/' + p + '/linked_list_' + p)21 def _add_files_engine(self):22 """Adds the JS files needed for the overall engine."""23 # Global pre-processes.24 self._add_paths('core_global_pre_processes', ['pp_globals', 'pp_arguments', 'pp_engine', 'pp_assets', 'pp_dom_elements', 'pp_elements', 'pp_inputs', 'pp_player', 'pp_shaders', 'pp_singleton', 'pp_three_js', 'pp_time', 'pp_websockets'])25 # Main engine.26 self._add_js_file('core_engine/engine')27 # Data structures.28 self._add_paths('data_structures/bitwise_flags', ['max_size_31', 'max_size_60'])29 self._add_paths('data_structures/state_machine', ['state', 'finite_state_machine'])30 self._add_linked_lists(['base', 'interactive', 'row', 'row_element'])31 # Engine extensions.32 self._add_paths('core_engine/extensions/engine_static_data', ['colors', 'fonts'])33 self._add_paths('core_engine/extensions/time' , ['time_instance', 'time'])34 self._add_paths('core_engine/extensions/engine_features' , ['math', 'errors', 'script_loader'])35 self._add_paths('core_engine/extensions/engine_meta_data' , ['cache', 'flags', 'frames', 'state'])36 self._add_paths('core_engine/extensions/inputs' , ['inputs', 'keyboard', 'mouse'])37 self._add_paths('core_engine/extensions/web_features' , ['on_hover', 'drag_and_drop', 'window_resize', 'full_screen', 'pointer_lock'])38 self._add_js_file('core_engine/extensions/rendering/renderer')39 self._add_js_file('core_engine/heap_manager')40 # Font. (TODO: Move).41 self.js_files_needed.append('assets_json/helvetiker_regular.js')42 # Features/extensions.43 self._add_paths('inheritable_features/static/three_js_abstractions', ['feature_geometry', 'feature_material', 'feature_mesh'])44 self._add_paths('inheritable_features/static' , ['feature_text', 'feature_color', 'feature_size', 'feature_animation_sequence'])45 self._add_paths('inheritable_features/dynamic' , ['feature_animation_step'])46 self._add_paths('inheritable_features/dynamic/attachments' , ['feature_row', 'feature_title_bar'])47 self._add_paths('inheritable_features/dynamic/interactions' , ['feature_button', 'feature_interactive', 'feature_lookable', 'feature_typing', 'feature_only_moveable'])48 # ----------------------------------------------------------------------------------------------------------------49 self._add_paths('elements/base', ['element'])50 self._add_js_file('elements/base/element_extensions/meta_data')51 self._add_js_file('elements/base/floating_element')52 self._add_js_file('elements/singleton/singleton')53 self._add_paths('elements/base', ['element_singleton'])54 self._add_paths('elements/base/element_extensions', ['attachment', 'normal', 'position', 'visibility', '_three_js_internals'])55 self._add_paths('elements/base', ['floating_element_color', 'floating_element_text', 'floating_rows', 'floating_wall', 'floating_css'])56 self._add_paths('elements/environment', ['hexagon_grid', 'light_ambient', 'light_point', 'skybox', 'skybox_space'])57 # ----------------------------------------------------------------------------------------------------------------58 # DOM element abstraction.59 self._add_paths('dom_elements/dom_element' , ['base', 'text'])60 self._add_paths('dom_elements/link' , ['canvas_saver'])61 self._add_paths('dom_elements/canvas' , ['canvas', 'canvas_texture'])62 self._add_paths('dom_elements/canvas/rendering/abstraction', ['renderer_base'])63 self._add_paths('dom_elements/canvas/rendering/text' , ['canvas_text_row', 'renderer_text', 'text_line', 'text_lines'])64 #65 self._add_paths('core_engine/extensions/engine_features', ['text_2d_helper'])66 #67 #68 self._add_paths('elements/discrete/2d/text', ['text_2d', 'button_2d'])69 self._add_paths('elements/discrete/2d/icon', ['e_icon', 'e_icon_button'])70 self._add_paths('elements/discrete/2d' , ['checkbox'])71 self._add_paths('elements/discrete/3d' , ['text_3d'])72 self._add_paths('elements/discrete/wall' , ['confirmation_prompt', 'floating_picture', 'floating_todo_list'])73 #74 # HUDs.75 self._add_paths('core_engine/extensions/hud', ['hud', 'hud_abstractions', 'hud_date_time', 'hud_debug', 'hud_logs', 'hud_user_typing', 'hud_pause_menu'])76 # Player.77 self._add_paths('player' , ['player', 'player_state', 'player_cursor'])78 self._add_paths('player/controls' , ['mouse', 'movement'])79 self._add_paths('player/flashlight', ['flashlight'])80 self._add_paths('player/menu' , ['menu_abstract'])81 self._add_paths('player/menu/row' , ['action_row', 'action_create', 'action_close', 'action_fullscreen', 'action_teleport'])82 self._add_paths('player/menu' , ['menu_teleport', 'menu_create', 'menu'])83 # Worlds.84 self._add_paths('worlds/world' , ['world_base'])85 self._add_paths('worlds/world/extensions' , ['elements', 'elements_interactive', 'elements_root', 'elements_tab_target', 'elements_css', 'input', 'state'])86 self._add_paths('worlds/world_manager' , ['world_manager'])87 self._add_paths('worlds/world_manager/extensions', ['input', 'singletons', 'events'])88 self._add_paths('worlds/world/discrete' , ['settings_world'])89 self._add_paths('worlds/world/discrete/demo' , ['demo_room_tile', 'demo_room', 'demo_room_ceiling', 'demo_room_floor', 'demo_room_lights', 'demo_room_walls', 'demo_world'])90 # Shaders.91 shaders_path = 'core_engine/extensions/rendering/shaders'92 self._add_paths(shaders_path , ['shader_material_abstraction'])93 self._add_paths(shaders_path + '/background' , ['shader_material_background', 'background'])94 self._add_paths(shaders_path + '/fxaa' , ['fxaa'])95 self._add_paths(shaders_path + '/noise' , ['noise', 'shader_material_noise'])96 self._add_paths(shaders_path + '/outline_glow', ['outline_glow'])97 self._add_paths(shaders_path + '/spritesheet' , ['shader_material_spritesheet'])98 self._add_paths(shaders_path + '/transition' , ['shader_material_transition'])99 # Assets.100 self._add_paths('asset_management' , ['asset_manager', 'asset_batch', 'asset_file'])101 # Web workers.102 self._add_paths('web_workers', ['bridged-worker'])103 # Websockets....
cli.py
Source:cli.py
...10 nargs='+', action='append', required=True,11 help='Specify the URI(s) of the database(s) to access',12 )13#14def _add_paths(parser):15 parser.add_argument(16 '--paths', metavar='PATH', type=str,17 nargs=argparse.REMAINDER, action='append', required=True,18 help='Path(s) containing files or directories to be processed (default to current directory)',19 )20#21def _add_path(parser):22 parser.add_argument(23 '--path', metavar='PATH', type=str,24 nargs='?', default='.',25 help='Path containing directory to be processed (default to current directory)',26 )27#28def _add_actions(parser):29 parser.add_argument(30 '--actions', metavar='ACTION', type=str,31 nargs='*', action='append', required=False,32 help='Restrict actions to apply',33 )34#35def main():36 import sys37 import itertools38 #39 parser = argparse.ArgumentParser(40 prog='Signature Commons Controller',41 description='Simplify data ingestion, migration, and transformations for signature commons',42 )43 parser.add_argument(44 '--verbose', '-v', action='count', default=0,45 help='Increase logging level'46 )47 parser.add_argument(48 '--version', '-V', action='version', version='%(prog)s 1.0',49 help='Display application version',50 )51 subparsers = parser.add_subparsers(title='Action', dest='action')52 subparsers.required = True53 #54 extract_parser = subparsers.add_parser('extract', help='Export data to directory from database')55 _add_uris(extract_parser)56 _add_path(extract_parser)57 ingest_parser = subparsers.add_parser('ingest', help='Ingest data from directory to database')58 _add_uris(ingest_parser)59 _add_paths(ingest_parser)60 transform_parser = subparsers.add_parser('transform', help='Apply transformations to data in directory')61 _add_paths(transform_parser)62 action_parser = subparsers.add_parser('action', help='Trigger API action such as data reloading')63 _add_uris(action_parser)64 _add_actions(action_parser)65 #66 args = parser.parse_args(sys.argv[1:])67 if getattr(args, 'uri', None) is not None:68 args.uri = [ParsedUrl(u) for us in args.uri for u in us]69 if getattr(args, 'paths', None) is not None:70 args.paths = list(itertools.chain(*args.paths))71 if getattr(args, 'actions', None) is not None:72 args.actions = list(itertools.chain(*args.actions))73 logging.basicConfig(level=max(0, 40 - args.verbose*10))74 logging.info('Processing action:{action}'.format(action=args.action))75 return getattr(router, args.action)(**args.__dict__)
startup.py
Source:startup.py
...10def _remove_paths(app_path):11 _remove_from_path(app_path)12 _remove_from_path(os.path.join(app_path, 'apper'))13 _remove_from_path(os.path.join(app_path, 'lib'))14def _add_paths(app_path):15 sys.path.insert(0, app_path)16 sys.path.insert(0, os.path.join(app_path, 'apper'))17 sys.path.insert(0, os.path.join(app_path, 'lib'))18def setup_app(app_file):19 app_path = get_app_path(app_file)20 _remove_paths(app_path)21 if sys.modules.get('apper', False):22 # TODO possibly add a message to inform user that there is a potential conflict23 # Do some kind of version check?24 del sys.modules['apper']25 _add_paths(app_path)26def cleanup_app(app_file):27 app_path = get_app_path(app_file)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!