Nevermind, I'll submit a new v6 series tomorrow. Your comment is totally accurate and follow the PEP20 which I should follow too ("readability counts" and "explicit is better than implicit" at most ) Le jeu. 30 mars 2023, 19:10, Frederic Martinsons via lists.openembedded.org a écrit : > Pretty much indeed, except for the exception catching part (which allows a > better error message) > Do I need to submit another whole series (PATCH V6) or can I submit just > this change ? > > On Thu, 30 Mar 2023 at 18:34, Alex Kiernan wrote: > >> On Thu, Mar 30, 2023 at 4:45 PM wrote: >> > >> > From: Frederic Martinsons >> > >> > There is no need to do such things, Cargo.lock file >> > has to be at the root of CARGO_LOCK_SRC_DIR. >> > This avoid finding other possible Cargo.lock that >> > would be in subdir (for example if a patch is applied >> > on the recipe, we can have .pc subdir in S and a Cargo.lock >> > can be there) >> > >> > Signed-off-by: Frederic Martinsons >> > --- >> > .../cargo-update-recipe-crates.bbclass | 12 ++++++++---- >> > 1 file changed, 8 insertions(+), 4 deletions(-) >> > >> > diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> b/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> > index daa363b0dd..549cfe627e 100644 >> > --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> > +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> > @@ -68,10 +68,14 @@ def get_crates(f): >> > import os >> > crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n" >> > found = False >> > -for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'): >> > - for file in files: >> > - if file == 'Cargo.lock': >> > - crates += get_crates(os.path.join(root, file)) >> > +for file in os.listdir('${CARGO_LOCK_SRC_DIR}'): >> > + if file == 'Cargo.lock': >> > + try: >> > + cargo_lock_path = os.path.join('${CARGO_LOCK_SRC_DIR}', >> file) >> > + crates += get_crates(cargo_lock_path) >> > + except Exception as e: >> > + raise ValueError("Cannot parse '%s'" % cargo_lock_path) >> from e >> > + else: >> > found = True >> > if not found: >> > raise ValueError("Unable to find Cargo.lock in >> ${CARGO_LOCK_SRC_DIR}") >> >> Isn't this just a long-winded version of something like this >> (completely untested): >> >> diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> b/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> index daa363b0dd65..22ddcfa5c1e3 100644 >> --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass >> @@ -67,14 +67,7 @@ def get_crates(f): >> >> import os >> crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n" >> -found = False >> -for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'): >> - for file in files: >> - if file == 'Cargo.lock': >> - crates += get_crates(os.path.join(root, file)) >> - found = True >> -if not found: >> - raise ValueError("Unable to find Cargo.lock in >> ${CARGO_LOCK_SRC_DIR}") >> +crates += get_crates(os.path.join("${CARGO_LOCK_SRC_DIR}", "Cargo.lock")) >> open("${TARGET_FILE}", 'w').write(crates) >> EOF >> >> -- >> Alex Kiernan >> > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#179346): > https://lists.openembedded.org/g/openembedded-core/message/179346 > Mute This Topic: https://lists.openembedded.org/mt/97953740/6213388 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > frederic.martinsons@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >