Openembedded Bitbake Development
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 1/7] fetch2: wget latest_versionstring improve _parse_path
Date: Fri, 13 Feb 2015 15:58:08 -0600	[thread overview]
Message-ID: <1423864694-24940-2-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1423864694-24940-1-git-send-email-anibal.limon@linux.intel.com>

Add support for get group only if exist in regex, this enables to use
this function in _check_latestversion regardless if the regex is generic
or specified by REGEX_URI.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 lib/bb/fetch2/wget.py | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 9e4b443..04e2b33 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -109,16 +109,30 @@ class Wget(FetchMethod):
 
         return True
 
-
     def _parse_path(self, regex, s):
         """
         Find and group name, version and archive type in the given string s
         """
-        bb.debug(3, "parse_path(%s, %s)" % (regex.pattern, s))
+        bb.debug(3, "_parse_path(%s, %s)" % (regex.pattern, s))
+
         m = regex.search(s)
         if m:
-            bb.debug(3, "%s, %s, %s" % (m.group('name'), m.group('ver'), m.group('type')))
-            return (m.group('name'), m.group('ver'), m.group('type'))
+            pname = ''
+            pver = ''
+            ptype = ''
+
+            mdict = m.groupdict()
+            if 'name' in mdict.keys():
+                pname = mdict['name']
+            if 'pver' in mdict.keys():
+                pver = mdict['pver']
+            if 'type' in mdict.keys():
+                ptype = mdict['type']
+
+            bb.debug(3, "_parse_path: %s, %s, %s" % (pname, pver, ptype))
+
+            return (pname, pver, ptype)
+
         return None
 
     def _modelate_version(self, version):
@@ -243,25 +257,15 @@ class Wget(FetchMethod):
         pn_regex = d.getVar('REGEX', True)
         if pn_regex:
             pn_regex = re.compile(pn_regex)
+            package_regex = pn_regex
             bb.debug(3, "pn_regex = '%s'" % (pn_regex.pattern))
             
         for line in soup.find_all('a', href=True):
             newver = None
             bb.debug(3, "line = '%s'" % (line['href']))
-            if pn_regex:
-                m = pn_regex.search(line['href'])
-                if m:
-                    bb.debug(3, "Pver = '%s'" % (m.group('pver')))
-                    newver = ('', m.group('pver'), '')
-                else:
-                    m = pn_regex.search(str(line))
-                    if m:
-                        bb.debug(3, "Pver = '%s'" % (m.group('pver')))
-                        newver = ('', m.group('pver'), '')
-            else:
-                newver = self._parse_path(package_regex, line['href'])
-                if not newver:
-                    newver = self._parse_path(package_regex, str(line))
+            newver = self._parse_path(package_regex, line['href'])
+            if not newver:
+                newver = self._parse_path(package_regex, str(line))
 
             if newver:
                 bb.debug(3, "Upstream version found: %s" % newver[1])
@@ -314,7 +318,7 @@ class Wget(FetchMethod):
         psuffix_regex = "(tar\.gz|tgz|tar\.bz2|zip|xz|rpm|bz2|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)"
 
         # match name, version and archive type of a package
-        self.package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<ver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)"
+        self.package_regex_comp = re.compile("(?P<name>%s?)\.?v?(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s$)"
                                                     % (pn_regex, pver_regex, parch_regex, psuffix_regex))
         self.suffix_regex_comp = re.compile(psuffix_regex)
 
@@ -327,7 +331,7 @@ class Wget(FetchMethod):
         version = self._parse_path(self.package_regex_comp, package)
         if version:
             package_custom_regex_comp = re.compile(
-                "(?P<name>%s)(?P<ver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" %
+                "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.\-](?P<type>%s)$" %
                 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex))
 
         return package_custom_regex_comp
-- 
1.9.1



  reply	other threads:[~2015-02-13 21:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 21:58 [PATCH 0/7] fetch2: wget latest_versionstring improvments Aníbal Limón
2015-02-13 21:58 ` Aníbal Limón [this message]
2015-02-13 21:58 ` [PATCH 2/7] fetch2: wget latest_versionstring _check_latest_version improvments Aníbal Limón
2015-02-13 21:58 ` [PATCH 3/7] fetch2: wget add _check_latest_version_by_dir Aníbal Limón
2015-02-13 21:58 ` [PATCH 4/7] fetch2: wget latest_versionstring improvments in get version by dir Aníbal Limón
2015-02-13 21:58 ` [PATCH 5/7] fetch2: wget _modelate_version improvments Aníbal Limón
2015-02-13 21:58 ` [PATCH 6/7] fetch2: wget remove scape of - in regexes don't needed Aníbal Limón
2015-02-13 21:58 ` [PATCH 7/7] tests/fetch.py: latest_versionstring add set of PN Aníbal Limón

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=1423864694-24940-2-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox