This function should be called only once, at import time. It
    traverses the passbands directory and builds a lookup table of
    passband names qualified as 'pbset:pbname' and corresponding files
    and atmosphere content within.
191718
def init_passbands(refresh=False):
    
    global _initialized

    if not _initialized or refresh:
        # load information from online passbands first so that any that are
        # available locally will override
        online_passbands = list_online_passbands(full_dict=True, refresh=refresh)
        for pb, info in online_passbands.items():
            _pbtable[pb] = {'fname': None, 'atms': info['atms'], 'pb': None}

        # load global passbands (in install directory) next and then local
        # (in .phoebe directory) second so that local passbands override
        # global passbands whenever there is a name conflict
        for path in [_pbdir_global, _pbdir_local]:
            for f in os.listdir(path):
                if f=='README':
                    continue
                init_passband(path+f)

        #Check if _pbdir_env has been set and load those passbands too
        if not _pbdir_env == None:
            for path in [_pbdir_env]:
                for f in os.listdir(path):
                    if f=='README':
                        continue
                    init_passband(path+f)


        _initialized = True
735052
def _check_samples_nodups(fnames):
    
    counts = defaultdict(int)
    for f in fnames:
        for s in get_samples(f):
            counts[s] += 1
    duplicates = [s for s, c in counts.items() if c > 1]
    if duplicates:
        raise ValueError("Duplicate samples found in inputs %s: %s" % (duplicates, fnames))
478058
def import_name(name):
    
    if isinstance(name, str):
        components = name.split('.')
        mod = __import__('.'.join(components[0:-1]), globals(), locals(), [components[-1]] )
        return getattr(mod, components[-1])
    else:
        return name
33148
def _recursive_import(package):
    

    prefix = '%s.' % (package.__name__)

    path = getattr(package, '__path__', None)

    if path:
        for submod in pkgutil.walk_packages(path, prefix=prefix):
            _import_module(submod[1], submod[0].path)
744603
def discover(package, cls_match_func):
    
    matched_classes = set()

    for _, module_name, _ in pkgutil.walk_packages(
            package.__path__,
            prefix=package.__name__ + '.',
    ):
        module = __import__(module_name, fromlist=[str('__trash')], level=0)

        # Check all the classes in that module
        for _, imported_class in inspect.getmembers(module, inspect.isclass):
            # Don't include things that are only there due to a side-effect of
            # importing
            if imported_class.__module__ != module.__name__:
                continue

            if cls_match_func(imported_class):
                matched_classes.add(imported_class)

    return matched_classes
1369280
def handle_fdid_aliases(module_or_package_name, import_alias_mapping):
    
    for key, val in import_alias_mapping.items():
        if module_or_package_name == val:
            return key
    return None
353441
def p_instance_bodylist_noname(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
711918
def name_match(self, elt):
        '''
        '''
        return self.pname == elt.localName and \
                    self.nspname in [None, '', elt.namespaceURI]
848170
def _do_import(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name):
        
        i_codestr = None
        if '..' not in name and '://' not in name and 'url(' not in name:  # Protect against going to prohibited places...
            names = name.split(',')
            for name in names:
                name = dequote(name.strip())
                if '@import ' + name not in rule[OPTIONS]:  # If already imported in this scope, skip...
                    try:
                        raise KeyError
                        i_codestr = self._scss_files[name]
                    except KeyError:
                        filename = os.path.basename(name)
                        dirname = os.path.dirname(name)
                        load_paths = []
                        i_codestr = None
                        for path in ['./'] + LOAD_PATHS.split(','):
                            for basepath in ['./', os.path.dirname(rule[PATH])]:
                                i_codestr = None
                                full_path = os.path.realpath(
                                    os.path.join(path, basepath, dirname))
                                if full_path not in load_paths:
                                    try:
                                        full_filename = os.path.join(full_path,
                                                                     '_' + filename + '.scss')
                                        i_codestr = open(full_filename).read()
                                    except:
                                        try:
                                            full_filename = os.path.join(
                                                full_path, filename + '.scss')
                                            i_codestr = open(
                                                full_filename).read()
                                        except:
                                            try:
                                                full_filename = os.path.join(
                                                    full_path, '_' + filename)
                                                i_codestr = open(
                                                    full_filename).read()
                                            except:
                                                try:
                                                    full_filename = os.path.join(
                                                        full_path, filename)
                                                    i_codestr = open(
                                                        full_filename).read()
                                                except:
                                                    pass
                                    if i_codestr is not None:
                                        break
                                    else:
                                        load_paths.append(full_path)
                            if i_codestr is not None:
                                break
                        if i_codestr is None:
                            i_codestr = self._do_magic_import(rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name)
                        i_codestr = self._scss_files[name] = i_codestr and self.load_string(
                            i_codestr, full_filename)
                    if i_codestr is None:
                        log.warn("File to import not found or unreadable: '%s'\nLoad paths:\n\t%s",
                                 filename, "\n\t".join(load_paths))
                    else:
                        _rule = spawn_rule(rule, codestr=i_codestr,
                                           path=full_filename, lineno=c_lineno)
                        self.manage_children(_rule,
                                             p_selectors, p_parents, p_children, scope, media)
                        rule[OPTIONS]['@import ' + name] = True
        else:
            rule[PROPERTIES].append((c_lineno, c_property, None))
281257
private String getSegmentFileName(long currentId, long previousId) {
        return PbdSegmentName.createName(m_nonce, currentId, previousId, false);
    }
411677
def find_imports_and_track_names(filename, warn_about_duplicates=False,
                                 verbose=False):
    
    with open(filename) as f:
        root = ast.parse(f.read(), filename)
    visitor = ImportFinderAndNameTracker(filename)
    visitor.warn_about_duplicates = warn_about_duplicates
    visitor.verbose = verbose
    visitor.visit(root)
    visitor.leaveAllScopes()
    return visitor.imports, visitor.unused_names
127848
def prepare(bedfile):
    
    pf = bedfile.rsplit(".", 1)[0]
    abedfile = pf + ".a.bed"
    bbedfile = pf + ".b.bed"
    fwa = open(abedfile, "w")
    fwb = open(bbedfile, "w")

    bed = Bed(bedfile)
    seen = set()
    for b in bed:
        accns = b.accn.split(";")
        new_accns = []
        for accn in accns:
            if ":" in accn:
                method, a = accn.split(":", 1)
                if method in ("liftOver", "GMAP", ""):
                    accn = a
            if accn in seen:
                logging.error("Duplicate id {0} found. Ignored.".format(accn))
                continue

            new_accns.append(accn)
            b.accn = accn
            print(b, file=fwa)
            seen.add(accn)

        b.accn = ";".join(new_accns)
        print(b, file=fwb)
    fwa.close()
    fwb.close()
1219169
def qualified_name_import(cls):
    

    parts = qualified_name(cls).split('.')

    return "from {} import {}".format('.'.join(parts[:-1]), parts[-1])
623655
def import_submodules(package_name: str) -> None:
    
    importlib.invalidate_caches()

    # For some reason, python doesn't always add this by default to your path, but you pretty much
    # always want it when using `--include-package`.  And if it's already there, adding it again at
    # the end won't hurt anything.
    sys.path.append('.')

    # Import at top level
    module = importlib.import_module(package_name)
    path = getattr(module, '__path__', [])
    path_string = '' if not path else path[0]

    # walk_packages only finds immediate children, so need to recurse.
    for module_finder, name, _ in pkgutil.walk_packages(path):
        # Sometimes when you import third-party libraries that are on your path,
        # `pkgutil.walk_packages` returns those too, so we need to skip them.
        if path_string and module_finder.path != path_string:
            continue
        subpackage = f"{package_name}.{name}"
        import_submodules(subpackage)
168847
def _import_public_names(module):
    ""
    self = sys.modules[__name__]
    for name in module.__all__:
        if hasattr(self, name):
            # don't overwrite existing names
            continue
        setattr(self, name, getattr(module, name))
456431
def _to_pb(self):
        
        if self.all_:
            return KeySetPB(all=True)
        kwargs = {}

        if self.keys:
            kwargs["keys"] = _make_list_value_pbs(self.keys)

        if self.ranges:
            kwargs["ranges"] = [krange._to_pb() for krange in self.ranges]

        return KeySetPB(**kwargs)
1263525
def allowPatternsForNameChecking(self, patternsFunc, patternsClass):
        
        cfgParser = self.linter.cfgfile_parser
        nameChecker = self.getCheckerByName(NameChecker)
        if not nameChecker:
            return
        if patternsFunc:
            regexFuncAdd = "|((%s).+)$" % "|".join(patternsFunc)
        else:
            regexFuncAdd = ""
        if patternsClass:
            regexClassAdd = "|((%s).+)$" % "|".join(patternsClass)
        else:
            regexClassAdd = ""
        # Modify regex for function, method and class name.
        regexMethod = cfgParser.get("BASIC", "method-rgx") + regexFuncAdd
        regexFunction = cfgParser.get("BASIC", "function-rgx") + regexFuncAdd
        regexClass = cfgParser.get("BASIC", "class-rgx") + regexClassAdd
        # Save to config parser.
        cfgParser.set("BASIC", "method-rgx", regexMethod)
        cfgParser.set("BASIC", "function-rgx", regexFunction)
        cfgParser.set("BASIC", "class-rgx", regexClass)
        # Save to name checker.
        nameChecker.config.method_rgx = re.compile(regexMethod)
        nameChecker.config.function_rgx = re.compile(regexFunction)
        nameChecker.config.class_rgx = re.compile(regexClass)