Check pear namespace.
This commit is contained in:
parent
b2b2244926
commit
72b9fe6f54
1 changed files with 20 additions and 7 deletions
|
@ -118,6 +118,11 @@ class Pear(BuildSystem):
|
||||||
|
|
||||||
name = "pear"
|
name = "pear"
|
||||||
|
|
||||||
|
PEAR_NAMESPACES = [
|
||||||
|
"http://pear.php.net/dtd/package-2.0",
|
||||||
|
"http://pear.php.net/dtd/package-2.1",
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
|
@ -146,10 +151,7 @@ class Pear(BuildSystem):
|
||||||
try:
|
try:
|
||||||
root = xmlparse_simplify_namespaces(
|
root = xmlparse_simplify_namespaces(
|
||||||
path,
|
path,
|
||||||
[
|
self.PEAR_NAMESPACES
|
||||||
"http://pear.php.net/dtd/package-2.0",
|
|
||||||
"http://pear.php.net/dtd/package-2.1",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
except ET.ParseError as e:
|
except ET.ParseError as e:
|
||||||
logging.warning("Unable to parse package.xml: %s", e)
|
logging.warning("Unable to parse package.xml: %s", e)
|
||||||
|
@ -173,9 +175,20 @@ class Pear(BuildSystem):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def probe(cls, path):
|
def probe(cls, path):
|
||||||
if os.path.exists(os.path.join(path, "package.xml")):
|
if not os.path.exists(os.path.join(path, "package.xml")):
|
||||||
logging.debug("Found package.xml, assuming pear package.")
|
return
|
||||||
return cls(path)
|
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
try:
|
||||||
|
tree = ET.iterparse(path)
|
||||||
|
except ET.ParseError as e:
|
||||||
|
logging.warning("Unable to parse package.xml: %s", e)
|
||||||
|
return
|
||||||
|
|
||||||
|
for ns in cls.PEAR_NAMESPACES:
|
||||||
|
if tree.root.tag == '{%s}package' % ns:
|
||||||
|
logging.debug("Found package.xml with namespace %s, assuming pear package.")
|
||||||
|
return cls(path)
|
||||||
|
|
||||||
|
|
||||||
# run_setup, but setting __name__
|
# run_setup, but setting __name__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue