Esempio n. 1
0
def main():
    if len(sys.argv) != 2:
        print("Usage: parse-package-xml PACKAGE.XML")
        return 1

    tree = ET.parse(sys.argv[1])
    doc = tree.getroot()

    dep_set = set()

    dep_types = [
        'build_depend', 'buildtool_depend', 'build_export_depend',
        'buildtool_export_depend', 'exec_depend', 'depend', 'run_depend'
    ]

    if os.getenv('TUE_INSTALL_TEST_DEPEND', 'false') == 'true':
        dep_types.append('test_depend')

    if os.getenv('TUE_INSTALL_DOC_DEPEND', 'false') == 'true':
        dep_types.append('doc_depend')

    for dep_type in dep_types:
        deps = doc.findall(dep_type)
        dep_set |= {
            dep.text
            for dep in deps if evaluate_condition(
                dep.attrib.get("condition", None), os.environ)
        }

    print('\n'.join(dep_set))
Esempio n. 2
0
    def evaluate_condition(self, context):
        """
        Evaluate the condition.

        The result is also stored in the member variable `evaluated_condition`.

        :param context: A dictionary with key value pairs to replace variables
          starting with $ in the condition.

        :returns: True if the condition evaluates to True, else False
        :raises: :exc:`ValueError` if the condition fails to parse
        """
        self.evaluated_condition = evaluate_condition(self.condition, context)
        return self.evaluated_condition
Esempio n. 3
0
    def evaluate_condition(self, context):
        """
        Evaluate the condition.

        The result is also stored in the member variable `evaluated_condition`.

        :param context: A dictionary with key value pairs to replace variables
          starting with $ in the condition.

        :returns: True if the condition evaluates to True, else False
        :raises: :exc:`ValueError` if the condition fails to parse
        """
        self.evaluated_condition = evaluate_condition(self.condition, context)
        return self.evaluated_condition