Retrieves all of the assets of a given asset_type

        Args:
            asset_type: (str) Either None, PHONE, HANDLER, or URL

        Returns:
2952
def assets(self, asset_type=None):
        
        if not self.can_update():
            self._tcex.handle_error(910, [self.type])

        if not asset_type:
            return self.tc_requests.adversary_assets(
                self.api_type, self.api_sub_type, self.unique_id
            )
        if asset_type == 'PHONE':
            return self.tc_requests.adversary_phone_assets(
                self.api_type, self.api_sub_type, self.unique_id
            )
        if asset_type == 'HANDLER':
            return self.tc_requests.adversary_handle_assets(
                self.api_type, self.api_sub_type, self.unique_id
            )
        if asset_type == 'URL':
            return self.tc_requests.adversary_url_assets(
                self.api_type, self.api_sub_type, self.unique_id
            )

        self._tcex.handle_error(
            925, ['asset_type', 'assets', 'asset_type', 'asset_type', asset_type]
        )
        return None
417230
def asset_view_prj(self, ):
        
        if not self.cur_asset:
            return

        prj = self.cur_asset.project
        self.view_prj(prj)
935330
def __get_ac_row(self, ac: model.AssetClass) -> AssetAllocationViewModel:
        
        view_model = AssetAllocationViewModel()

        view_model.depth = ac.depth
        
        # Name
        view_model.name = ac.name

        view_model.set_allocation = ac.allocation
        view_model.curr_allocation = ac.curr_alloc
        view_model.diff_allocation = ac.alloc_diff
        view_model.alloc_diff_perc = ac.alloc_diff_perc

        # value
        view_model.curr_value = ac.curr_value
        # expected value
        view_model.set_value = ac.alloc_value
        # diff
        view_model.diff_value = ac.value_diff

        return view_model
438699
def get_asset_contents(self):
        
        # Implemented from template for osid.repository.Asset.get_asset_contents_template
        return AssetContentList(
            self._my_map['assetContents'],
            runtime=self._runtime,
            proxy=self._proxy)
1156317
def retrieve_asset(self, sid, default_none=False):
        
        try:
            asset = self._asset_cache[sid]
            if asset is None and not default_none:
                raise SidsNotFound(sids=[sid])
            return asset
        except KeyError:
            raise SidsNotFound(sids=[sid])
56448
def list_assets_ddo(self):
        
        return json.loads(self.requests_session.get(self.url).content)
923260
def file_asset(class_obj: type) -> type:
    
    assert isinstance(class_obj, type), "class_obj is not a Class"
    global _file_asset_resource_type
    _file_asset_resource_type = class_obj
    return class_obj
4117
def _cache_contents(self, style_urls, asset_url_path):
        
        files = {}

        asset_urls = []
        for style_url in style_urls:
            if not self.quiet:
                print(' * Downloading style', style_url, file=sys.stderr)
            r = requests.get(style_url)
            if not 200 <= r.status_code < 300:
                print(' -> Warning: Style request responded with',
                      r.status_code, file=sys.stderr)
                files = None
                continue
            asset_content = r.text
            # Find assets and replace their base URLs with the cache directory
            for url in re.findall(STYLE_ASSET_URLS_RE, asset_content):
                asset_urls.append(urljoin(style_url, url))
            contents = re.sub(
                STYLE_ASSET_URLS_RE,
                STYLE_ASSET_URLS_SUB_FORMAT.format(asset_url_path.rstrip('/')),
                asset_content)
            # Prepare cache
            if files is not None:
                filename = self.cache_filename(style_url)
                files[filename] = contents.encode('utf-8')

        for asset_url in asset_urls:
            if not self.quiet:
                print(' * Downloading asset', asset_url, file=sys.stderr)
            # Retrieve binary file and show message
            r = requests.get(asset_url, stream=True)
            if not 200 <= r.status_code < 300:
                print(' -> Warning: Asset request responded with',
                      r.status_code, file=sys.stderr)
                files = None
                continue
            # Prepare cache
            if files is not None:
                filename = self.cache_filename(asset_url)
                files[filename] = r.raw.read(decode_content=True)

        # Skip caching if something went wrong to try again next time
        if not files:
            return False

        # Cache files if all downloads were successful
        cache = {}
        for relname in files:
            cache[safe_join(self.cache_path, relname)] = files[relname]
        if not os.path.exists(self.cache_path):
            os.makedirs(self.cache_path)
        for filename in cache:
            with open(filename, 'wb') as f:
                f.write(cache[filename])
        if not self.quiet:
            print(
                ' * Cached all downloads in', self.cache_path, file=sys.stderr)
        return True
698985
def asset_archive(class_obj: type) -> type:
    
    assert isinstance(class_obj, type), "class_obj is not a Class"
    global _asset_archive_resource_type
    _asset_archive_resource_type = class_obj
    return class_obj
75733
def get_asset_ddos():
    
    args = []
    query = dict()
    args.append(query)
    assets_with_id = dao.get_all_listed_assets()
    assets_metadata = {a['id']: a for a in assets_with_id}
    for i in assets_metadata:
        _sanitize_record(i)
    return Response(json.dumps(assets_metadata, default=_my_converter), 200,
                    content_type='application/json')
307731
def get_assets():
    
    args = []
    query = dict()
    args.append(query)
    asset_with_id = dao.get_all_listed_assets()
    asset_ids = [a['id'] for a in asset_with_id]
    resp_body = dict({'ids': asset_ids})
    return Response(_sanitize_record(resp_body), 200, content_type='application/json')
1320006
def atype_view_asset(self, ):
        
        if not self.cur_atype:
            return

        i = self.atype_asset_treev.currentIndex()
        item = i.internalPointer()
        if item:
            asset = item.internal_data()
            if isinstance(asset, djadapter.models.Asset):
                self.view_asset(asset)
407356
def get_asset_allocation(self):
        
        # load from db
        # TODO set the base currency
        base_currency = "EUR"

        loader = AssetAllocationLoader(base_currency=base_currency)
        loader.logger = self.logger
        model = loader.load_tree_from_db()

        model.validate()

        # securities
        # read stock links
        loader.load_stock_links()
        # read stock quantities from GnuCash
        loader.load_stock_quantity()
        # Load cash balances
        loader.load_cash_balances()
        # loader.session
        # read prices from Prices database
        loader.load_stock_prices()
        # recalculate stock values into base currency
        loader.recalculate_stock_values_into_base()
        # calculate
        model.calculate_current_value()
        model.calculate_set_values()
        model.calculate_current_allocation()

        # return the model for display
        return model
1067159
def _extract_links_from_lecture_assets(self, asset_ids):
        
        links = {}

        def _add_asset(name, url, destination):
            filename, extension = os.path.splitext(clean_url(name))
            if extension is '':
                return

            extension = clean_filename(
                extension.lower().strip('.').strip(),
                self._unrestricted_filenames)
            basename = clean_filename(
                os.path.basename(filename),
                self._unrestricted_filenames)
            url = url.strip()

            if extension not in destination:
                destination[extension] = []
            destination[extension].append((url, basename))

        for asset_id in asset_ids:
            for asset in self._get_asset_urls(asset_id):
                _add_asset(asset['name'], asset['url'], links)

        return links
189205
def all(self, query=None, **kwargs):
        

        if query is None:
            query = {}

        normalize_select(query)

        return super(AssetsProxy, self).all(query, **kwargs)
70479
def no_cache(asset_url):
    
    pos = asset_url.rfind('?')
    if pos > 0:
        asset_url = asset_url[:pos]
    return asset_url
1307564
def asset(class_obj: type) -> type:
    
    assert isinstance(class_obj, type), "class_obj is not a Class"
    global _asset_resource_type
    _asset_resource_type = class_obj
    return class_obj