1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-25 09:26:14 +01:00

Merge pull request #994 from dmach/update-sphinx-configuration

Update Sphinx configuration
This commit is contained in:
Daniel Mach 2022-06-02 10:09:38 +02:00 committed by GitHub
commit 1715163166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 188 additions and 407 deletions

20
doc/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -1,7 +1,7 @@
.. py:module:: osc.OscConfigParser
OscConfigParser
====
===============
This is the osc config parser.

View File

@ -1,7 +1,7 @@
.. py:module:: osc.build
build
====
=====
This is the osc build module to talk to the build script.

View File

@ -1,7 +1,7 @@
.. py:module:: osc.credentials
credentials
====
===========
This is the osc credentials module.

64
doc/conf.py Normal file
View File

@ -0,0 +1,64 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
# -- Project information -----------------------------------------------------
project = 'osc'
copyright = 'Contributors to the osc project'
author = 'see the AUTHORS list'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.todo',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.ifconfig',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# A string of reStructuredText that will be included at the end of every
# source file that is read. This is a possible place to add substitutions
# that should be available in every file.
rst_epilog = """
.. |obs| replace:: open build service
"""
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

View File

@ -1,298 +0,0 @@
# -*- coding: utf-8 -*-
#
# osc documentation build configuration file, created by
# sphinx-quickstart on Sun Jan 24 13:06:29 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import shlex
# top level dir (one above this file)
topdir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, topdir)
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.todo',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.ifconfig',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'osc'
copyright = u'2016, see authors list'
author = u'see authors list'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.2.3'
# The full version, including alpha/beta/rc tags.
release = '4.5.6'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'oscdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'osc.tex', u'osc Documentation',
u'see authors list', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'osc', u'osc Documentation',
[author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'osc', u'osc Documentation',
author, 'osc', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
rst_epilog = """
.. |obs| replace:: open build service
"""

View File

@ -173,11 +173,13 @@ class CommentLine(Line):
class OptionLine(Line):
"""
This class represents an option. The class' "name" attribute is used
This class represents an option. The class' ``name`` attribute is used
to store the option's name and the "value" attribute contains the option's
value. The "frmt" attribute preserves the format which was used in the configuration
value. The ``frmt`` attribute preserves the format which was used in the configuration
file.
Example:
Example::
optionx:<SPACE><SPACE>value
=> self.frmt = '%s:<SPACE><SPACE>%s'
optiony<SPACE>=<SPACE>value<SPACE>;<SPACE>some_comment

View File

@ -314,10 +314,12 @@ class Pac:
def get_preinstall_image(apiurl, arch, cache_dir, img_info, offline=False):
"""
Searches preinstall image according to build info and downloads it to cache
(unless offline is set to True (default: False)).
(unless offline is set to ``True`` (default: ``False``)).
Returns preinstall image path, source and list of image binaries, which can
be used to create rpmlist.
NOTE: preinstall image can be used only for new build roots!
.. note::
preinstall image can be used only for new build roots!
"""
imagefile = ''
imagesource = ''
@ -459,8 +461,9 @@ def get_built_files(pacdir, buildtype):
def get_repo(path):
"""Walks up path looking for any repodata directories.
@param path path to a directory
@return str path to repository directory containing repodata directory
:param path: path to a directory
:return: path to repository directory containing repodata directory
:rtype: str
"""
oldDirectory = None
currentDirectory = os.path.abspath(path)

View File

@ -448,7 +448,7 @@ def urljoin(scheme, apisrv, path=''):
def is_known_apiurl(url):
"""returns true if url is a known apiurl"""
"""returns ``True`` if url is a known apiurl"""
apiurl = urljoin(*parse_apisrv_url(None, url))
return apiurl in config['api_host_options']
@ -470,8 +470,8 @@ def extract_known_apiurl(url):
def get_apiurl_api_host_options(apiurl):
"""
Returns all apihost specific options for the given apiurl, None if
no such specific optiosn exist.
Returns all apihost specific options for the given apiurl, ``None`` if
no such specific options exist.
"""
# FIXME: in A Better World (tm) there was a config object which
# knows this instead of having to extract it from a url where it
@ -849,9 +849,9 @@ def config_set_option(section, opt, val=None, delete=False, update=True, creds_m
"""
Sets a config option. If val is not specified the current/default value is
returned. If val is specified, opt is set to val and the new value is returned.
If an option was modified get_config is called with **kwargs unless update is set
to False (override_conffile defaults to config['conffile']).
If val is not specified and delete is True then the option is removed from the
If an option was modified get_config is called with ``**kwargs`` unless update is set
to ``False`` (``override_conffile`` defaults to ``config['conffile']``).
If val is not specified and delete is ``True`` then the option is removed from the
config/reset to the default value.
"""
cp = get_configParser(config['conffile'])

View File

@ -296,7 +296,7 @@ class Serviceinfo:
self.package = None
def read(self, serviceinfo_node, append=False):
"""read in the source services <services> element passed as
"""read in the source services ``<services>`` element passed as
elementtree node.
"""
def error(msg, xml):
@ -509,7 +509,7 @@ class Serviceinfo:
return 0
class Linkinfo:
"""linkinfo metadata (which is part of the xml representing a directory
"""linkinfo metadata (which is part of the xml representing a directory)
"""
def __init__(self):
"""creates an empty linkinfo instance"""
@ -523,9 +523,9 @@ class Linkinfo:
self.baserev = None
def read(self, linkinfo_node):
"""read in the linkinfo metadata from the <linkinfo> element passed as
"""read in the linkinfo metadata from the ``<linkinfo>`` element passed as
elementtree node.
If the passed element is None, the method does nothing.
If the passed element is ``None``, the method does nothing.
"""
if linkinfo_node == None:
return
@ -539,19 +539,19 @@ class Linkinfo:
self.baserev = linkinfo_node.get('baserev')
def islink(self):
"""returns True if the linkinfo is not empty, otherwise False"""
""":return: ``True`` if the linkinfo is not empty, otherwise ``False``"""
if self.xsrcmd5 or self.lsrcmd5 or self.error is not None:
return True
return False
def isexpanded(self):
"""returns True if the package is an expanded link"""
""":return: ``True`` if the package is an expanded link"""
if self.lsrcmd5 and not self.xsrcmd5:
return True
return False
def haserror(self):
"""returns True if the link is in error state (could not be applied)"""
""":return: ``True`` if the link is in error state (could not be applied)"""
if self.error:
return True
return False
@ -1849,12 +1849,12 @@ class Package:
def islink(self):
"""tells us if the package is a link (has 'linkinfo').
A package with linkinfo is a package which links to another package.
Returns True if the package is a link, otherwise False."""
Returns ``True`` if the package is a link, otherwise ``False``."""
return self.linkinfo.islink()
def isexpanded(self):
"""tells us if the package is a link which is expanded.
Returns True if the package is expanded, otherwise False."""
Returns ``True`` if the package is expanded, otherwise ``False``."""
return self.linkinfo.isexpanded()
def islinkrepair(self):
@ -1881,21 +1881,21 @@ class Package:
def haslinkerror(self):
"""
Returns True if the link is broken otherwise False.
If the package is not a link it returns False.
Returns ``True`` if the link is broken otherwise ``False``.
If the package is not a link it returns ``False``.
"""
return self.linkinfo.haserror()
def linkerror(self):
"""
Returns an error message if the link is broken otherwise None.
If the package is not a link it returns None.
Returns an error message if the link is broken otherwise ``None``.
If the package is not a link it returns ``None``.
"""
return self.linkinfo.error
def hasserviceinfo(self):
"""
Returns True, if this package contains services.
Returns ``True``, if this package contains services.
"""
return self.serviceinfo.lsrcmd5 is not None or self.serviceinfo.xsrcmd5 is not None
@ -1933,24 +1933,22 @@ class Package:
def status(self, n):
"""
status can be:
file storefile file present STATUS
exists exists in _files
x - - 'A' and listed in _to_be_added
x x - 'R' and listed in _to_be_added
x x x ' ' if digest differs: 'M'
and if in conflicts file: 'C'
x - - '?'
- x x 'D' and listed in _to_be_deleted
x x x 'D' and listed in _to_be_deleted (e.g. if deleted file was modified)
x x x 'C' and listed in _in_conflict
x - x 'S' and listed in self.skipped
- - x 'S' and listed in self.skipped
- x x '!'
- - - NOT DEFINED
status can be::
file storefile file present STATUS
exists exists in _files
x - - 'A' and listed in _to_be_added
x x - 'R' and listed in _to_be_added
x x x ' ' if digest differs: 'M'
and if in conflicts file: 'C'
x - - '?'
- x x 'D' and listed in _to_be_deleted
x x x 'D' and listed in _to_be_deleted (e.g. if deleted file was modified)
x x x 'C' and listed in _in_conflict
x - x 'S' and listed in self.skipped
- - x 'S' and listed in self.skipped
- x x '!'
- - - NOT DEFINED
"""
known_by_meta = False
@ -2544,29 +2542,29 @@ rev: %s
class AbstractState:
"""
Base class which represents state-like objects (<review />, <state />).
Base class which represents state-like objects (``<review />``, ``<state />``).
"""
def __init__(self, tag):
self.__tag = tag
def get_node_attrs(self):
"""return attributes for the tag/element"""
""":return: attributes for the tag/element"""
raise NotImplementedError()
def get_node_name(self):
"""return tag/element name"""
""":return: tag/element name"""
return self.__tag
def get_comment(self):
"""return data from <comment /> tag"""
""":return: data from ``<comment />`` tag"""
raise NotImplementedError()
def get_description(self):
"""return data from <description /> tag"""
""":return: data from ``<description />`` tag"""
raise NotImplementedError()
def to_xml(self):
"""serialize object to XML"""
""":return: object serialized to XML"""
root = ET.Element(self.get_node_name())
for attr in self.get_node_attrs():
val = getattr(self, attr)
@ -2579,7 +2577,7 @@ class AbstractState:
return root
def to_str(self):
"""return "pretty" XML data"""
""":return: object serialized to pretty-printed XML"""
root = self.to_xml()
xmlindent(root)
return ET.tostring(root, encoding=ET_ENCODING)
@ -2686,11 +2684,15 @@ class RequestState(AbstractState):
class Action:
"""
Represents a <action /> element of a Request.
Represents an ``<action />`` element of a Request.
This class is quite common so that it can be used for all different
action types. Note: instances only provide attributes for their specific
type.
Examples:
action types.
.. note::
Instances only provide attributes for their specific type.
Examples::
r = Action('set_bugowner', tgt_project='foo', person_name='buguser')
# available attributes: r.type (== 'set_bugowner'), r.tgt_project (== 'foo'), r.tgt_package (== None)
r.to_str() ->
@ -2698,7 +2700,7 @@ class Action:
<target project="foo" />
<person name="buguser" />
</action>
##
r = Action('delete', tgt_project='foo', tgt_package='bar')
# available attributes: r.type (== 'delete'), r.tgt_project (== 'foo'), r.tgt_package (=='bar')
r.to_str() ->
@ -2743,13 +2745,18 @@ class Action:
"""
Serialize object to XML.
The xml tag names and attributes are constructed from the instance's attributes.
Example:
:return: object serialized to XML
Example::
self.group_name -> tag name is "group", attribute name is "name"
self.src_project -> tag name is "source" (translated via prefix_to_elm dict),
attribute name is "project"
Attributes prefixed with "opt_" need a special handling, the resulting xml should
look like this: opt_updatelink -> <options><updatelink>value</updatelink></options>.
Attributes which are "None" will be skipped.
Attributes prefixed with ``opt_`` need a special handling, the resulting xml should
look like this: ``opt_updatelink`` -> ``<options><updatelink>value</updatelink></options>``.
Attributes which are ``None`` will be skipped.
"""
root = ET.Element('action', type=self.type)
for i in Action.type_args[self.type]:
@ -2774,7 +2781,7 @@ class Action:
return root
def to_str(self):
"""return "pretty" XML data"""
""":return: object serialized to pretty-printed XML"""
root = self.to_xml()
xmlindent(root)
return ET.tostring(root, encoding=ET_ENCODING)
@ -2809,7 +2816,7 @@ class Action:
class Request:
"""Represents a request (<request />)"""
"""Represents a request (``<request />``)"""
def __init__(self):
self._init_attributes()
@ -2881,7 +2888,7 @@ class Request:
return self.creator
def to_xml(self):
"""serialize object to XML"""
""":return: object serialized to XML"""
root = ET.Element('request')
if self.reqid is not None:
root.set('id', self.reqid)
@ -2906,7 +2913,7 @@ class Request:
return root
def to_str(self):
"""return "pretty" XML data"""
""":return: object serialized to pretty-printed XML"""
root = self.to_xml()
xmlindent(root)
return ET.tostring(root, encoding=ET_ENCODING)
@ -4848,7 +4855,7 @@ def sha256_dgst(file):
return s.hexdigest()
def binary(s):
"""return true if a string is binary data using diff's heuristic"""
"""return ``True`` if a string is binary data using diff's heuristic"""
if s and bytes('\0', "utf-8") in s[:4096]:
return True
return False
@ -6872,7 +6879,11 @@ def checkRevision(prj, pac, revision, apiurl=None, meta=False):
def build_table(col_num, data = [], headline = [], width=1, csv = False):
"""
This method builds a simple table.
Example1: build_table(2, ['foo', 'bar', 'suse', 'osc'], ['col1', 'col2'], 2)
Example::
build_table(2, ['foo', 'bar', 'suse', 'osc'], ['col1', 'col2'], 2)
col1 col2
foo bar
suse osc
@ -7442,7 +7453,9 @@ def getPrjPacPaths(path):
returns the path for a project and a package
from path. This is needed if you try to add
or delete packages:
Examples:
Examples::
osc add pac1/: prj_dir = CWD;
pac_dir = pac1
osc add /path/to/pac1:
@ -7947,8 +7960,8 @@ def run_external(filename, *args, **kwargs):
def return_external(filename, *args, **kwargs):
"""Executes the program filename via subprocess.check_output.
*args are additional arguments which are passed to the
program filename. **kwargs specify additional arguments for
``*args`` are additional arguments which are passed to the
program filename. ``**kwargs`` specify additional arguments for
the subprocess.check_output function.
if no args are specified the plain filename is passed
to subprocess.check_output (this can be used to execute a shell
@ -7956,7 +7969,6 @@ def return_external(filename, *args, **kwargs):
to the subprocess.check_output function.
Returns the output of the command.
"""
if args:
cmd = [filename] + list(args)

View File

@ -26,7 +26,7 @@ class PackageQueries(dict):
"""Adds package query to dict if it is of the correct architecture and
is newer (has a greater version) than the currently assigned package.
@param a PackageQuery
:param query: a PackageQuery
"""
self.__setitem__(query.name(), query)

View File

@ -31,9 +31,10 @@ OPERATOR_BY_FLAGS = {
def primaryPath(directory):
"""Returns path to the primary repository data file.
@param directory repository directory that contains the repodata subdirectory
@return str path to primary repository data file
@raise IOError if repomd.xml contains no primary location
:param directory: repository directory that contains the repodata subdirectory
:return: path to primary repository data file
:rtype: str
:raise IOError: if repomd.xml contains no primary location
"""
metaDataPath = os.path.join(directory, "repodata", "repomd.xml")
elementTree = ET.parse(metaDataPath)
@ -55,10 +56,9 @@ def queries(directory):
"""Returns a list of RepoDataQueries constructed from the repodata under
the directory.
@param directory path to a repository directory (parent directory of
repodata directory)
@return list of RepoDataQueryResult instances
@raise IOError if repomd.xml contains no primary location
:param directory: path to a repository directory (parent directory of repodata directory)
:return: list of RepoDataQueryResult instances
:raise IOError: if repomd.xml contains no primary location
"""
path = primaryPath(directory)
@ -99,9 +99,8 @@ class RepoDataQueryResult(osc.util.packagequery.PackageQueryResult):
"""Creates a RepoDataQueryResult from the a package Element under a metadata
Element in a primary.xml file.
@param directory repository directory path. Used to convert relative
paths to full paths.
@param element package Element
:param directory: repository directory path. Used to convert relative paths to full paths.
:param element: package Element
"""
self.__directory = os.path.abspath(directory)
self.__element = element

View File

@ -6,6 +6,9 @@ from distutils.command import build, install_data
import gzip
import os.path
import sphinx.setup_command
import setuptools
import osc.core
@ -36,29 +39,6 @@ class build_osc(build.build, object):
self.build_man_page()
# Support for documentation (sphinx)
class build_docs(distutils.core.Command):
description = 'builds documentation using sphinx'
user_options = []
def initialize_options(self):
self.built_docs = None
def finalize_options(self):
self.set_undefined_options('build', ('build_base', 'built_docs'))
def run(self):
# metadata contains information supplied in setup()
metadata = self.distribution.metadata
# package_dir may be None, in that case use the current directory.
src_dir = (self.distribution.package_dir or {'': ''})['']
src_dir = os.path.join(os.getcwd(), src_dir)
import sphinx
sphinx.main(['runme',
'-D', 'version=%s' % metadata.get_version(),
os.path.join('docs', ), os.path.join(self.built_docs, 'docs')])
# take a potential build-base option into account (for instance, if osc is
# build and installed like this:
# python setup.py build --build-base=<dir> ... install ...)
@ -128,11 +108,10 @@ setuptools.setup(
"Topic :: System :: Archiving :: Packaging",
],
# Override certain command classes with our own ones
cmdclass={
'build': build_osc,
'build_docs': build_docs,
'build_doc': sphinx.setup_command.BuildDoc,
'install_data': install_data
},
test_suite="tests",