Uploaded image for project: 'Funtoo Linux'
  1. Funtoo Linux
  2. FL-10873

Refactor the sys-apps/hwinfo


    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Normal Normal
    • None
    • None
    • None
    • resilience of the autogen


      See https://discord.com/channels/629035601613684748/698600499280347166/1055740713414967317 too

      First of all, they offer a JSON where you can take the files names from.  I found this by looking at the HTML of the page. Here is where you can get it:
      If you use this, you won't need BeautifulSoup anymore.  You can just fetch the page using pkgtool.fetch.get_page with is_json=True, like this:
      json_data = await hub.pkgtools.fetch.get_page('https://download.opensuse.org//download/source/tumbleweed/repo/oss/src/?jsontable', is_json=True)
      If you do this, json_data will contain a Python representation of the JSON, which will be basically a list of dicts that may themselves contain lists of dicts. You can just iterate through it until you find the file you are looking for.
      Also, please don't abuse of string indexes and other string operations to filter the results or even to get a substring.  Although it is theoretically faster (inter terms of performance) to do it like that, regex is often a lot more robust, which will prevent future breakages, and your intentions are clearer than using string operations.
      For example, you commented "# Check if the link begins with m17n-contrib, ends with .tar.gz and doesn't contain RC(Release Candidate) in the name" and then added 3 lines with conditions and string operations.  The regexp ^m17n-contrib.*(?<!rc)\.tar\.gz$ means the same as your comment.  Please take some time to study regexp.  You'll be surprised with what you can accomplish.
      You seem to be working from C string mindset.  In Python, regexp are readily available and are efficient, and definetely not a bottleneck when you are already importing BeautifulSoup!
      And, for the hwinfo template, please take a look at the latest Gentoo one.  They made it a lot simpler. You could use that instead




            madman10k madman10k
            borisp borisp
            0 Vote for this issue
            4 Start watching this issue