diff options
author | Alec Warner <antarus@gentoo.org> | 2008-07-20 22:33:14 +0000 |
---|---|---|
committer | Alec Warner <antarus@gentoo.org> | 2008-07-20 22:33:14 +0000 |
commit | 6d6c3baad7687589d2f1d8901384df4dd838e4e2 (patch) | |
tree | 4b53dc82772ccdf62f7416275ddb9ef93a005cd5 /users | |
parent | Fix 2008.0 handbook link (diff) | |
download | gentoo-6d6c3baad7687589d2f1d8901384df4dd838e4e2.tar.gz gentoo-6d6c3baad7687589d2f1d8901384df4dd838e4e2.tar.bz2 gentoo-6d6c3baad7687589d2f1d8901384df4dd838e4e2.zip |
Initial import of a use.local.desc generator.
Diffstat (limited to 'users')
-rw-r--r-- | users/antarus/projects/infra/use_desc_gen | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/users/antarus/projects/infra/use_desc_gen b/users/antarus/projects/infra/use_desc_gen new file mode 100644 index 0000000000..9b721779f0 --- /dev/null +++ b/users/antarus/projects/infra/use_desc_gen @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# Written by Alec Warner for the Gentoo Foundation 2008 +# This code is hereby placed into the public domain. + +"""Craws an ebuild repository for local use flags and generates documentation. + +This module attempts to read metadata.xml files in an ebuild repository and +uses the <flag> xml tags to generate a set of documentation for local USE +flags. +""" + +__author__ = "Alec Warner <antarus@gentoo.org>" + +import optparse +import os + + +class RepositoryError(Exception): + """Basic Exception for repository problems.""" + pass + + +class UseFlag(object): + """A simple UseFlag wrapper.""" + + def __init__(self): + pass + + +def FindMetadataFiles(repo_path): + """Locate metadata files in repo_path. + + Args: + repo_path: path to repository. + Returns: + sequence of files. + Raises; RepositoryError. + """ + + osp = os.path.sep + profile_path = os.path.join(repo_path, osp, 'profiles') + categories = GetCategories(profile_path) + for cat in categories: + cat_path = os.path.join(profile_path, osp, cat_path) + + +def GetCategories(profile_path): + """Return a set of categories for a given repository. + + Args: + profile_path: path to profiles/ dir of a repository. + Returns: + a list of categories. + Raises: RepositoryError. + """ + + osp = os.path.sep + categories_path = os.path.join(profile_path, osp, 'categories') + try: + f = open(categories_path, 'rb') + except (IOError, OSError), e: + raise RepositoryError('Problem while opening %s: %s' % ( + categories_path, e)) + categories = [cat.strip() for cat in f.readlines()] + return categories + + +def GetOpts(): + """Simple Option Parsing.""" + + parser = optparse.OptionParser() + parser.add_option('--repo_path', '', 'path to repository from ' + 'which the documentation will be generated.') + + opts, unused_args = parser.parse_args() + + if not opts.repo_path: + parser.error('--repo_path is a required option') + + return (opts, unused_args) + +def Main(): + """Main.""" + pass + +if __name__ == '__main__': + Main() |