[rtems-lwip commit] lwip.py: Support Python earlier than 3.9

Joel Sherrill joel at rtems.org
Fri Aug 26 13:42:36 UTC 2022


Module:    rtems-lwip
Branch:    main
Commit:    edef121c0b2d1365bee14342ac22215f401011ca
Changeset: http://git.rtems.org/rtems-lwip/commit/?id=edef121c0b2d1365bee14342ac22215f401011ca

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Thu Aug 25 14:23:56 2022 -0500

lwip.py: Support Python earlier than 3.9

The removeprefix method is only available on Python 3.9 and later. This
replaces it with an equivalent function.

---

 lwip.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lwip.py b/lwip.py
index 251f11f..70c9471 100644
--- a/lwip.py
+++ b/lwip.py
@@ -29,6 +29,11 @@ from rtems_waf import rtems
 import json
 import os
 
+def removeprefix(data, prefix):
+    if data.startswith(prefix):
+        return data[len(prefix):]
+    return data
+
 xilinx_drv_incl = ''
 xilinx_drv_incl += './embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/include '
 xilinx_drv_incl += './embeddedsw/lib/bsp/standalone/src/common '
@@ -146,7 +151,7 @@ def build(bld):
                 src_root = os.path.split(root)
                 path = os.path.join(src_root[0], src_root[1])
                 if ext == '.h':
-                    subpath = path.removeprefix(root_path).removeprefix("/")
+                    subpath = removeprefix(removeprefix(path, root_path), "/")
                     bld.install_files("${PREFIX}/" + arch_lib_path + "/include/" + subpath,
                         os.path.join(path,name))
 



More information about the vc mailing list