All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: Mark Hatle <mark.hatle@windriver.com>
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH 0/5] Add a standard module for accessing the layerindex
Date: Wed, 18 Jul 2018 09:03:10 +0200	[thread overview]
Message-ID: <9175757.rJd2U26s3Q@localhost.localdomain> (raw)
In-Reply-To: <0caa3638-b5fa-d18a-1776-2ca510f18173@windriver.com>

On Tuesday, 17 July 2018 10:56:14 PM CEST Mark Hatle wrote:
> > 2) I feel like the ;type= stuff is an unnecessary complication. Can we not 
> > just treat http URLs as being restapi and local:// (or something similarly 
> > simple) as being the local configuration? The plugins could simply have a 
> > function that returns True if it can handle the URL, as we do in bb.fetch2, 
> > and we take the first one that returns True or error out if none do.
> 
> Behind the scenes the issue is that I expect there to be different plugins that
> allow data manipulation in similar ways, but with different processing.  I was
> afraid of overriding the URI part, thus added the type field instead.
> 
> If we can come up with a proper format for this, then I think we could drop the
> typing..  but what I've come up with so far is that we need:
> 
> Cooker - data from the local cooker instance

local:// ?

> restapi-web - knowledge of how to load and parse layerindex-web data

http:// or https:// surely?

> restapi-file - a json formatted file with all of the data.. (Note: in this case,
> it can be one or more files, but everything has to be loaded together)

file:// ?

If the desire was to also allow downloading json files over http/https you could make
the decision after a quick query or simply check if the URL ends in .json.

> (the web and file stuff are co-mingled right now, maybe that is a mistake...
> they were put together since for 'offline' work, the web should be able to use a
> cached file...)
> 
> Looking at toaster, I could see the need for a 'database' way to store and load
> it... but I'm not sure that is a good longer term idea.

Toaster uses the Django ORM to access the database, so you wouldn't be
connecting to the database directly; you could make it accessible via a simple
scheme such as toaster://.

> > 5) I'd like to see the data classes (e.g. Recipe) have actual python 
> > properties on top of the getter functions, and the rest of the code should 
> > then use the properties. recipe.pn is a bit neater than recipe.get_pn() 
> > particularly as the former mirrors usage within the layer index code itself as 
> > well as tinfoil's TinfoilRecipeInfo (although TinfoilRecipeInfo doesn't 
> > actually use properties - it probably should - but the usage syntax is the key 
> > bit).
> 
> I'm not sure I understand.
> 
> You mean something like:
> 
> class Recipe(LayerIndexItem_LayerBranch):
>     ...
> 
>     self.pn = value
> 
> so you can do recipe.pn vs recipe.pn() or get_pn()?
> 
> The reason it's setup the way it is, is to preserve the data in the same format
> as the layerindex itself.  This allows someone to just dump the recipe.data
> directly, and everything stays in format.   Does python have a way to return
> processed data without it looking like a function call, i.e. with the ()?
> 
> Is this what __getattr()__ is for?

It's one way of implementing it, but the much cleaner way is to use python's 
built-in support for properties:

  https://www.programiz.com/python-programming/property

The underlying data storage doesn't have to change, your getter function can
still read the values in whatever way it wants to.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre




      reply	other threads:[~2018-07-18  7:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 20:34 [PATCH 0/5] Add a standard module for accessing the layerindex Mark Hatle
2018-07-12 20:34 ` [PATCH 1/5] bblayers/layerindex.py: Fix addition of layers Mark Hatle
2018-07-12 20:34 ` [PATCH 2/5] layerindexlib: Initial layer index processing module implementation Mark Hatle
2018-07-12 20:34 ` [PATCH 3/5] bblayers/layerindex.py: Switch to use the new layerindexlib class Mark Hatle
2018-07-12 20:34 ` [PATCH 4/5] bitbake-layers: disable parsing for layerindex commands Mark Hatle
2018-07-12 20:34 ` [PATCH 5/5] toaster/orm/management/commands/lsupdates.py: Use new layerindexlib module Mark Hatle
2018-07-12 21:07 ` [PATCH 0/5] Add a standard module for accessing the layerindex Mark Hatle
2018-07-17 20:37   ` Paul Eggleton
2018-07-17 20:56     ` Mark Hatle
2018-07-18  7:03       ` Paul Eggleton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9175757.rJd2U26s3Q@localhost.localdomain \
    --to=paul.eggleton@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=mark.hatle@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.