Get all mirrored packages.

        :param session: SQLAlchemy session
        :type session: :class:`sqlalchemy.Session`

        :return: package instances
        :rtype: generator of :class:`pyshop.models.Package`
433183
def get_mirrored(cls, session):
        
        return cls.find(session,
                        where=(cls.local == False,))
629553
def package_dataset(self):
        """"""

        return self.session.query(Dataset).filter(Dataset.vid != ROOT_CONFIG_NAME_V).one()
1308708
def package_repositories(self):
        
        if self._package_repository_manager is None:
            self._package_repository_manager = PackageRepositoryManager(session=self._session)
        return self._package_repository_manager
318169
def getAvailableClassesInPackage(package):
    
    l = list(x[1] for x in inspect.getmembers(package, inspect.isclass))

    modules = list(x[1] for x in inspect.getmembers(package, inspect.ismodule))
    for m in modules:
        l.extend(list(x[1] for x in inspect.getmembers(m, inspect.isclass)))
    l = [x for x in l if x.__name__[0] != "_"]
    n = 0
    while n < len(l):
        cls = l[n]
        if not cls.__module__.startswith(package.__name__):
            l.pop(n)
            n -= 1
        n += 1
    return l
598093
def _new_session(self):
        
        if self.labels:
            return self._database.session(labels=self.labels)
        return self._database.session()
387369
def all(cls, domain=None):
        
        Site = cls
        site = Session.query(Site)
        if domain:
            site.filter(Site.domain == domain)
        return site.all()
1088485
def get_session(db_url):
        # type: (str) -> Session
        
        engine = create_engine(db_url, poolclass=NullPool, echo=False)
        Session = sessionmaker(bind=engine)
        Base.metadata.create_all(engine)
        return Session()
230524
def __get_session(self):
        
        db_path = self.__get_config().get(ConfigKeys.asset_allocation_database_path)
        self.session = dal.get_session(db_path)
        return self.session
193056
def tables(self):
        
        from ambry.orm import Table
        from sqlalchemy.orm import lazyload

        return (self.dataset.session.query(Table)
                .filter(Table.d_vid == self.dataset.vid)
                .options(lazyload('*'))
                .all())
359688
def _instantiate_session(self, method_name, proxy=None, *args, **kwargs):
        """"""
        if 'manager' in kwargs:
            session_class = getattr(kwargs['manager'], method_name)
            del kwargs['manager']
        else:
            session_class = getattr(self._provider_manager, method_name)
        if proxy is None:
            try:
                return session_class(bank_id=self._catalog_id, *args, **kwargs)
            except AttributeError:
                return session_class(*args, **kwargs)
        else:
            try:
                return session_class(bank_id=self._catalog_id, proxy=proxy, *args, **kwargs)
            except AttributeError:
                return session_class(proxy=proxy, *args, **kwargs)
918598
def sessions(self):
        
        if self._sessions is None:
            self._sessions = SessionList(self)
        return self._sessions
551860
def list_sessions(cls):
        
        return [os.path.splitext(os.path.basename(f))[0]
                for f in os.listdir('.') if f.endswith(EXTENSION)]
1350948
def shell_sqlalchemy(session: SqlalchemySession, backend: ShellBackend):
    
    namespace = {
        'session': session
    }
    namespace.update(backend.get_namespace())
    embed(user_ns=namespace, header=backend.header)
582861
private static Set<String> getHopByHopHeaders(HttpSession session) {
        List<String> connectionHeaders = session.getReadHeaders(HEADER_CONNECTION);
        if (connectionHeaders == null) {
            connectionHeaders = Collections.emptyList();
        }
        Set<String> hopByHopHeaders = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        for (String conHeader : connectionHeaders) {
            hopByHopHeaders.add(conHeader);
        }
        hopByHopHeaders.add(HEADER_CONNECTION);
        return hopByHopHeaders;
    }
1356226
@Pure
	@Inline(value = "ReflectionUtil.getPackageClasses(($1).getName())", imported = {ReflectionUtil.class})
	public static Collection<Class<?>> getPackageClasses(Package pkg) {
		return getPackageClasses(pkg.getName());
	}
774415
def all(self):
        
        class_list = list(self.get_class_list())
        if not class_list:
            self.cache = []
            return []

        if self.cache is not None:
            return self.cache

        results = []
        for cls_path in class_list:
            module_name, class_name = cls_path.rsplit('.', 1)
            try:
                module = __import__(module_name, {}, {}, class_name)
                cls = getattr(module, class_name)
                if self.instances:
                    results.append(cls())
                else:
                    results.append(cls)
            except Exception:
                logger.exception('Unable to import {cls}'.format(cls=cls_path))
                continue
        self.cache = results

        return results
631080
def user_packages(request, user):
    
    session = DBSession()
    owned = Package.by_owner(session, user)
    maintained = Package.by_maintainer(session, user)
    owned = [('Owner', p.name) for p in owned]
    maintained = [('Maintainer', p.name) for p in maintained]
    return owned + maintained