diff mbox series

[2/2] apibuild: Fix -refs.xml building

Message ID 1e60444afa0362390d4e61e483e874302d1e98ec.1521222704.git.crobinso@redhat.com
State New
Headers show
Series apibuild: fix with python3 | expand

Commit Message

Cole Robinson March 16, 2018, 6:05 p.m. UTC
Another usage of deprecated 'string' functions. We are just trying to
match ascii letters here, so use a simple regex. And again drop the
aggressive exception handling, it doesn't seem to trigger for anything
in libvirt code.

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 docs/apibuild.py | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Daniel P. Berrangé March 16, 2018, 6:21 p.m. UTC | #1
On Fri, Mar 16, 2018 at 02:05:12PM -0400, Cole Robinson wrote:
> Another usage of deprecated 'string' functions. We are just trying to
> match ascii letters here, so use a simple regex. And again drop the
> aggressive exception handling, it doesn't seem to trigger for anything
> in libvirt code.
> 
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  docs/apibuild.py | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
diff mbox series

Patch

diff --git a/docs/apibuild.py b/docs/apibuild.py
index e81980e3c..51abf8383 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -11,7 +11,6 @@ 
 from __future__ import print_function
 
 import os, sys
-import string
 import glob
 import re
 
@@ -2092,23 +2091,20 @@  class docBuilder:
         str = str.replace(';', ' ')
         tokens = str.split()
         for token in tokens:
-            try:
-                c = token[0]
-                if string.letters.find(c) < 0:
-                    pass
-                elif len(token) < 3:
+            c = token[0]
+            if not re.match(r"[a-zA-Z]", c):
+                pass
+            elif len(token) < 3:
+                pass
+            else:
+                lower = token.lower()
+                # TODO: generalize this a bit
+                if lower == 'and' or lower == 'the':
                     pass
+                elif token in self.xref:
+                    self.xref[token].append(id)
                 else:
-                    lower = string.lower(token)
-                    # TODO: generalize this a bit
-                    if lower == 'and' or lower == 'the':
-                        pass
-                    elif token in self.xref:
-                        self.xref[token].append(id)
-                    else:
-                        self.xref[token] = [id]
-            except:
-                pass
+                    self.xref[token] = [id]
 
     def analyze(self):
         if not quiet: