1""" 2Common utility functions for the reclass adapters 3http://reclass.pantsfullofunix.net 4""" 5 6import os 7import sys 8 9 10def prepend_reclass_source_path(opts): 11 source_path = opts.get("reclass_source_path") 12 if source_path: 13 source_path = os.path.abspath(os.path.expanduser(source_path)) 14 sys.path.insert(0, source_path) 15 16 17def filter_out_source_path_option(opts): 18 if "reclass_source_path" in opts: 19 del opts["reclass_source_path"] 20 # no return required, object was passed by reference 21 22 23def set_inventory_base_uri_default(config, opts): 24 if "inventory_base_uri" in opts: 25 return 26 27 base_roots = config.get("file_roots", {}).get("base", []) 28 if base_roots: 29 opts["inventory_base_uri"] = base_roots[0] 30